Videos
So I'm going through the SEED Labs and I'm having a bit of a problem with format strings. The goal of the lab is to use format strings on a program to be able to view a certain value and to edit it. The source code of the program is here.
The program is nice enough to give you the memory locations of the values you are supposed to be reading and overwriting since ASLR is turned on. An example program output is:
[03/18/2016 18:56] seed@ubuntu:~/Desktop/SoftwareLabs/FormatStrLab$ ./vul_prog The variable secret's address is 0xbfde43f0 (on stack) The variable secret's value is 0x 991a008 (on heap) secret[0]'s address is 0x 991a008 (on heap) secret[1]'s address is 0x 991a00c (on heap) Please enter a decimal integer 1 Please enter a string \x09\x91\xa0\x08%8$s \x09\x91\xa0\x08D The original secrets: 0x44 -- 0x55 The new secrets: 0x44 -- 0x55
Basically the goal is to view and then overwrite the 2nd secret value, 0x55. The problem I'm having is when I try to view/overwrite the 2nd secret value, I end up doing the action on the 1st secret value. I'm very confused with this since I thought that you can see/write to any memory location with the format string exploit. An example of my attempts are below:
Attempt to read 2nd secret value:
The variable secret's address is 0xbfd681f0 (on stack) The variable secret's value is 0x 9137008 (on heap) secret[0]'s address is 0x 9137008 (on heap) secret[1]'s address is 0x 913700c (on heap) Please enter a decimal integer 1 Please enter a string \x09\x13\x70\x0c%8$s \x09\x13\x70\x0cD<---(I should get U, not D) The original secrets: 0x44 -- 0x55 The new secrets: 0x44 -- 0x55
Attempt to overwrite 2nd secret value:
The variable secret's address is 0xbfe28010 (on stack) The variable secret's value is 0x 9b47008 (on heap) secret[0]'s address is 0x 9b47008 (on heap) secret[1]'s address is 0x 9b4700c (on heap) Please enter a decimal integer 1 Please enter a string \x09\xb4\x70\x0c%8$n \x09\xb4\x70\x0c The original secrets: 0x44 -- 0x55 The new secrets: 0x10 -- 0x55<-- should turn to 0x10
If you guys can tell me what's going on I'd very much appreciate it!