@@ -13,12 +13,15 @@ module Exploit::Remote::Psexec
13
13
include Msf ::Exploit ::Remote ::DCERPC
14
14
include Msf ::Exploit ::Remote ::SMB
15
15
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
+ #
17
21
# @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
22
25
def get_output ( smbshare , ip , file )
23
26
begin
24
27
print_status ( "Getting the command output..." )
@@ -35,12 +38,14 @@ def get_output(smbshare, ip, file)
35
38
end
36
39
37
40
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
+ #
42
47
# @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
44
49
def psexec ( command )
45
50
46
51
simple . connect ( "IPC$" )
@@ -152,14 +157,17 @@ def psexec(command)
152
157
return true
153
158
end
154
159
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
+ #
156
166
# @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
163
171
def cleanup_after ( smbshare , ip , text , bat )
164
172
begin
165
173
# Try and do cleanup command/s
@@ -183,7 +191,7 @@ def cleanup_after(smbshare, ip, text, bat)
183
191
def check_cleanup ( smbshare , ip , text )
184
192
simple . connect ( "\\ \\ #{ ip } \\ #{ smbshare } " )
185
193
begin
186
- if checktext = simple . open ( text , 'ro' )
194
+ if simple . open ( text , 'ro' )
187
195
check = false
188
196
else
189
197
check = true
0 commit comments