@@ -11,16 +11,16 @@ class Metasploit3 < Msf::Post
11
11
include Msf ::Post ::Windows ::Priv
12
12
include Msf ::Post ::Windows ::Runas
13
13
14
- def initialize ( info = { } )
14
+ def initialize ( info = { } )
15
15
super ( update_info ( info ,
16
16
'Name' => "Windows Manage Run Command As User" ,
17
- 'Description' => %q{
17
+ 'Description' => %q(
18
18
This module will login with the specified username/password and execute the
19
19
supplied command as a hidden process. Output is not returned by default, by setting
20
20
CMDOUT to false output will be redirected to a temp file and read back in to
21
21
display.By setting advanced option SETPASS to true, it will reset the users
22
22
password and then execute the command.
23
- } ,
23
+ ) ,
24
24
'License' => MSF_LICENSE ,
25
25
'Platform' => [ 'win' ] ,
26
26
'SessionTypes' => [ 'meterpreter' ] ,
@@ -33,7 +33,7 @@ def initialize(info={})
33
33
OptString . new ( 'USER' , [ true , 'Username to login with' ] ) ,
34
34
OptString . new ( 'PASSWORD' , [ true , 'Password to login with' ] ) ,
35
35
OptString . new ( 'CMD' , [ true , 'Command to execute' ] ) ,
36
- OptBool . new ( 'CMDOUT' , [ true , 'Retrieve command output' , false ] ) ,
36
+ OptBool . new ( 'CMDOUT' , [ true , 'Retrieve command output' , false ] )
37
37
] , self . class )
38
38
39
39
register_advanced_options (
@@ -102,7 +102,12 @@ def run
102
102
# execute command and get output with a poor mans pipe
103
103
if priv_check
104
104
print_status ( "Executing CreateProcessAsUserA...we are SYSTEM" )
105
- pi = create_process_as_user ( domain , user , password , nil , cmdstr )
105
+ begin
106
+ pi = create_process_as_user ( domain , user , password , nil , cmdstr )
107
+ ensure
108
+ session . railgun . kernel32 . CloseHandle ( pi [ :process_handle ] )
109
+ session . railgun . kernel32 . CloseHandle ( pi [ :thread_handle ] )
110
+ end
106
111
else
107
112
print_status ( "Executing CreateProcessWithLogonW..." )
108
113
pi = create_process_with_logon ( domain , user , password , nil , cmdstr )
0 commit comments