Exploiting Tools
Metasploit
Shellkodovi
GDB
Instalacija
Parametri
Uputstva
Opciono možete koristiti ovu granu GEF koja sadrži interesantnije instrukcije.
Trikovi
GDB iste adrese
Prilikom debagovanja, GDB će imati nešto drugačije adrese od onih koje koristi binarni fajl prilikom izvršavanja. Možete postaviti GDB da koristi iste adrese na sledeći način:
unset env LINES
unset env COLUMNS
set env _=<putanja>
Stavite apsolutnu putanju do binarnog fajlaIskoristite binarni fajl koristeći istu apsolutnu putanju
PWD
iOLDPWD
moraju biti isti prilikom korišćenja GDB-a i prilikom iskorišćavanja binarnog fajla
Backtrace za pronalaženje pozvanih funkcija
Kada imate statički povezan binarni fajl, sve funkcije će pripadati binarnom fajlu (a ne spoljnim bibliotekama). U ovom slučaju će biti teško identifikovati tok koji binarni fajl prati kako bi na primer zatražio korisnički unos.
Možete lako identifikovati ovaj tok pokretanjem binarnog fajla sa gdb sve dok vas ne zatraže unos. Zatim ga zaustavite sa CTRL+C i koristite komandu bt
(backtrace) da vidite pozvane funkcije:
GDB server
gdbserver --multi 0.0.0.0:23947
(u IDA morate popuniti apsolutnu putanju izvršnog fajla na Linux mašini i na Windows mašini)
Ghidra
Pronalaženje offseta steka
Ghidra je veoma koristan za pronalaženje offseta za preplavljivanje bafera zahvaljujući informacijama o poziciji lokalnih promenljivih.
Na primer, u primeru ispod, preplavljivanje bafera u local_bc
ukazuje da vam je potreban offset 0xbc
. Štaviše, ako je local_10
kanarski kolačić, to ukazuje da postoji offset 0xac
za prepisivanje iz local_bc
.
Zapamtite da prva 0x08 odakle je RIP sačuvan pripada RBP.
qtool
Dobijanje svake izvršene operacije u programu.
GCC
gcc -fno-stack-protector -D_FORTIFY_SOURCE=0 -z norelro -z execstack 1.2.c -o 1.2 --> Kompajliranje bez zaštite -o --> Izlaz -g --> Sačuvaj kod (GDB će moći da ga vidi) echo 0 > /proc/sys/kernel/randomize_va_space --> Deaktiviranje ASLR u linuxu
Za kompajliranje shell koda: nasm -f elf assembly.asm --> vraća ".o" ld assembly.o -o shellcodeout --> Izvršiv
Objdump
-d --> Disasembliranje izvršnih sekcija (videti opkodove kompajliranog shell koda, pronaći ROP Gadžete, pronaći adresu funkcije...) -Mintel --> Intel sintaksa -t --> Tabela simbola -D --> Disasembliraj sve (adresa statičke promenljive) -s -j .dtors --> dtors sekcija -s -j .got --> got sekcija -D -s -j .plt --> plt sekcija dekompilirana -TR --> Relokacije ojdump -t --dynamic-relo ./exec | grep puts --> Adresa "puts" za modifikaciju u GOT objdump -D ./exec | grep "VAR_NAME" --> Adresa statičke promenljive (one se čuvaju u DATA sekciji).
Core dumps
Pokreni
ulimit -c unlimited
pre pokretanja mog programaPokreni
sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t
sudo gdb --core=<putanja/core> --quiet
Više
ldd executable | grep libc.so.6 --> Adresa (ako je ASLR, onda se menja svaki put) for i in `seq 0 20`; do ldd <Ejecutable> | grep libc; done --> Petlja za proveru da li se adresa mnogo menja readelf -s /lib/i386-linux-gnu/libc.so.6 | grep system --> Offset "system" strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep /bin/sh --> Offset "/bin/sh"
strace executable --> Funkcije pozvane od strane izvršnog fajla rabin2 -i ejecutable --> Adresa svih funkcija
Inmunity debugger
IDA
Debugiranje na udaljenom Linuxu
Unutar IDA foldera možete pronaći binarne datoteke koje se mogu koristiti za debugiranje binarnih datoteka unutar Linuxa. Da biste to učinili, premestite binarnu datoteku linux_server
ili linux_server64
unutar Linux servera i pokrenite je unutar foldera koji sadrži binarnu datoteku:
Zatim, konfigurišite debugger: Debugger (linux remote) --> Proccess options...:
Last updated