Skip to content

Commit 7361e10

Browse files
Royce DavisRoyce Davis
authored andcommitted
Merge commit '5e8f388ab8425bf2ef4c2fe33e6133b99ceb46d4' into psexec-mixin2
2 parents 6f17ed9 + 5e8f388 commit 7361e10

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

lib/msf/core/exploit/psexec.rb

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ module Exploit::Remote::Psexec
1313
include Msf::Exploit::Remote::DCERPC
1414
include Msf::Exploit::Remote::SMB
1515

16-
# Retrives output from the executed command
16+
# Retrieves output from the executed command
17+
#
18+
# @example
19+
# get_output("C$", rhost, '\WINDOWS\Temp\outputfile.txt')
20+
#
1721
# @param smbshare [String] The SMBshare to connect to. Usually C$
18-
# @param ip [IP Address] Remote Host to Connect To
19-
# @param file [File name] Path to the output file relative to the smbshare
20-
# Example: '\WINDOWS\Temp\outputfile.txt'
21-
# @return output or nil if fails
22+
# @param ip [String] Remote host to connect to
23+
# @param file [String] Path to the output file relative to the +smbshare+
24+
# @return [String,nil] output or nil if retrieval fails
2225
def get_output(smbshare, ip, file)
2326
begin
2427
print_status("Getting the command output...")
@@ -35,12 +38,14 @@ def get_output(smbshare, ip, file)
3538
end
3639

3740

38-
# This method executes a single windows command. If you want to
39-
# retrieve the output of your command you'll have to echo it
40-
# to a .txt file and then use the get_output method to retrieve it
41-
# Make sure to use the cleanup_after method when you are done.
41+
# Executes a single windows command.
42+
#
43+
# If you want to retrieve the output of your command you'll have to
44+
# redirect its output to a file and then use {#get_output} to retrieve
45+
# it. Make sure to use the {#cleanup_after} method when you are done.
46+
#
4247
# @param command [String] Should be a valid windows command
43-
# @return true if everything wen't well
48+
# @return [Boolean] true if everything wen't well
4449
def psexec(command)
4550

4651
simple.connect("IPC$")
@@ -152,14 +157,17 @@ def psexec(command)
152157
return true
153158
end
154159

155-
# This is the cleanup method, removes .txt and .bat file/s created during execution
160+
# This is the cleanup method, removes .txt and .bat file/s created
161+
# during execution
162+
#
163+
# @example
164+
# cleanup_after("C$", rhost, '\WINDOWS\Temp\output.txt', 'C:\WINDOWS\Temp\batchfile.bat')
165+
#
156166
# @param smbshare [String] The SMBshare to connect to. Usually C$
157-
# @param ip [IP Address] Remote Host to Connect To
158-
# @param text [File Path] Path to the text file relative to the smbshare
159-
# Example: '\WINDOWS\Temp\output.txt'
160-
# @param bat [File Path] Full path to the batch file created
161-
# Example: 'C:\WINDOWS\Temp\batchfile.bat'
162-
# @return only in the event of an error
167+
# @param ip [String] IP address of remote host to connect to
168+
# @param text [String] Path to the text file relative to the smbshare
169+
# @param bat [String] Full path to the batch file created
170+
# @return [StandarError] only in the event of an error
163171
def cleanup_after(smbshare, ip, text, bat)
164172
begin
165173
# Try and do cleanup command/s
@@ -183,7 +191,7 @@ def cleanup_after(smbshare, ip, text, bat)
183191
def check_cleanup(smbshare, ip, text)
184192
simple.connect("\\\\#{ip}\\#{smbshare}")
185193
begin
186-
if checktext = simple.open(text, 'ro')
194+
if simple.open(text, 'ro')
187195
check = false
188196
else
189197
check = true

0 commit comments

Comments
 (0)