So I've been working on a simple format string exploit and for the past 3 hours or so I have been bashing my head against the table wondering why my hex values weren't appearing on the stack.
If anyone can enlighten me, I would appreciate it a lot.
1.
Initially I was using python for the scripting when doing these challenges and for this example in particular:
python -c 'print "AAAAA\xcc\xd5\xff\x4f"' > a
And subsequently viewing the stack in GDB:
format string>
0xffffd550: 0xffffd584 0xf7ffdab8 0x41f95300 0x41414141
0xffffd560: 0x95c38cc3 0x0a4fbfc3 0xf7e2ec00 0xf7f8f820
Now it looks like it is not appearing after the "AAAAA" (used 5 since not aligned).
2.
However, when I use another address that I had been previously working with:
python -c 'print "AAAAA\x5c\x57\x55\x56"' > a
I get:
format string>
0xffffd550: 0xffffd584 0xf7ffdab8 0x41f95300 0x41414141
0xffffd560: 0x5655575c 0x0000000a 0xf7e2ec69 0xf7f8f820
And it seems perfectly fine?
3.
Also, when I use something like:
echo -en "AAAAA\xcc\xd5\xff\x4f" > b
I am able to properly set the value into the stack as so:
format string>
0xffffd550: 0xffffd584 0xf7ffdab8 0x41f95300 0x41414141
0xffffd560: 0x4fffd5cc 0x00000000 0xf7e2ec69 0xf7f8f820
Below are the outputs of the files a and b respectively:
AAAAA���O
AAAAAÌÕÿO
awill contain anything, since you don't have a valid Python script.