Hallo ich beschäftige mich jetzt schon etwas länger mit C/C++ und habe mich mal an das Thema "Exploiting" und sicheres Programmieren gewagt. Allerdings komme ich hier nicht weiter. Mir gehts um diese Beschreibung hier:
http://www.online-tutorials.net/security/buffer-overflow-tutorial-teil-1-grundlagen/tutorials-t-27-282.html
Ich habe die beiden Dateien main.c und exploit.c aus dem guide so übernommen und die Speicheradresse im exploit.c auch richtig ersetzt. Allerdings funktioniert das ganze bei mir nicht. Bei mir kommt statt einem: "Got it" lediglich dieses hier:
You wrote: `Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo!Hallo! '
[1] 2159 done ./exploit |
2160 segmentation fault (core dumped) ./main
die richtige Speicheradresse habe ich so ermittelt:
% gdb main
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/user/export/c/exploiting/main...done.
(gdb) disas Done
Dump of assembler code for function Done:
0x0804850c <+0>: push %ebp // Die Adresse 0x0804850c habe ich dann für die EIP in exploit.c ersetzt
0x0804850d <+1>: mov %esp,%ebp
0x0804850f <+3>: sub $0x18,%esp
0x08048512 <+6>: movl $0x80485d1,(%esp)
0x08048519 <+13>: call 0x8048380 <puts@plt>
0x0804851e <+18>: movl $0x0,(%esp)
0x08048525 <+25>: call 0x80483a0 <exit@plt>
End of assembler dump.
(gdb)
Mir ist auch nicht ganz klar wieso der Verfasser des Tutorials 128 Bytes + 4 Byte EBP rechnet. 22 * 6 "Hallo!" sind doch schon 132 Bytes.
PS: Ich würde ein eigenes Unterforum für IT-Sicherheit und allen drum und dran begrüßen