I am taking a security course that requires us to format a line attack on a unix virtual machine. Vulnerability is a format string using a command line argument.
My question is, how can I write a value to an address in a format string (for example, write the address of a shell code to a function return address)?
For example, I'm trying to write the value 987654 to the address of the return address 0xaabbccdd. I tried several lines, for example "AAAA_%10$x" , and this may lead to the printing of the program AAAA_41414141 .
Then I replace the letters with my address and try to rewrite it.
\xdd\xcc\xbb\xaa_%10$x_%54321x_%n"
But that will not work. I see that the article says that I should use a lower number in %54321x , as there are some characters that I already wrote, but I do not know how many characters I wrote before %54321x .
Note: the environment has an old version of gcc, so there is no need to worry about the value being too large. Any suggestions? Thanks.
Alex ng
source share