Skip to content

Commit 81fa509

Browse files
committed
Only clean up handles if process started
1 parent c2d15f2 commit 81fa509

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

modules/post/windows/manage/run_as.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,8 @@ def run
102102
# execute command and get output with a poor mans pipe
103103
if priv_check
104104
print_status("Executing CreateProcessAsUserA...we are SYSTEM")
105-
begin
106-
pi = create_process_as_user(domain, user, password, nil, cmdstr)
107-
ensure
105+
pi = create_process_as_user(domain, user, password, nil, cmdstr)
106+
if pi
108107
session.railgun.kernel32.CloseHandle(pi[:process_handle])
109108
session.railgun.kernel32.CloseHandle(pi[:thread_handle])
110109
end

0 commit comments

Comments
 (0)