Samuel Barthelemy
Samuel Barthelemy

Reputation: 49

Buffer overflow not working (shellcoders handbook)

I'm reading the shellcoder's handbook. I am following along and for some reason cannot get my shellcode to run. I have compiled the program with gcc -mpreferred-stack-boundary=2 -m32 -z execstack -fno-stack-protector -no-pie

I don't understand... I have control of EIP, I have looked at the stack in GDB, I am jumping to my NOP sled, but still nothing... I don't understand why it's not working. I have tried on my own, and I have even tried the verbatim code out of the book, both are not working. my dmesg is showing:

Controlling EIP: segfault at 42424242 ip 0000000042424242 sp 00000000ffffd330 error 14

After attempting to Redirect to NOP sled: segfault at 0 ip 00000000ffffd332 sp 00000000ffffd300 error 6

I'm running kali, but I've tried it on ubuntu too. I have disabled ASLR in /proc/sys/kernel. I am trying this on a Virtual Machine, so I am not sure what exactly is going on.

I would appreciate any help, as I don't want to move on until I find out what is going on.

Upvotes: 0

Views: 546

Answers (1)

Riccardo Bonafede
Riccardo Bonafede

Reputation: 606

your shellcode is compiled for a 32 bit system (the -m32 flag) on a 64bit program. So try to remove that -m32 when compiling.

Upvotes: 0

Related Questions