Skip to content

Commit ae6dbee

Browse files
author
Charles Smith
committed
Fixed bugs with a few modules.
filezilla_server.rb would crash if there was no admin information found. In smart_hashdump.rb I replicated the changes made in hashdump.rb to handle the race condition. (It works, but is still not as reliable as regular hashdump for XP boxes) In migrate.rb the option PID is an integer, and the line "elseif datastore['PID']" was evaluating as true, even though PID was set to "". There was also a misspelling of datastore as "datstore" that I fixed.
1 parent 414fd05 commit ae6dbee

File tree

3 files changed

+45
-26
lines changed

3 files changed

+45
-26
lines changed

modules/post/windows/gather/credentials/filezilla_server.rb

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -186,26 +186,32 @@ def get_filezilla_creds(paths)
186186

187187
configuration << [config['ftp_port'], config['ftp_bindip'], config['admin_port'], config['admin_bindip'], config['admin_pass'],
188188
config['ssl'], config['ssl_certfile'], config['ssl_keypass']]
189-
if session.db_record
190-
source_id = session.db_record.id
191-
else
192-
source_id = nil
193-
end
194-
# report the goods!
195-
report_auth_info(
196-
:host => session,
197-
:port => config['admin_port'],
198-
:sname => 'filezilla-admin',
199-
:proto => 'tcp',
200-
:user => 'admin',
201-
:pass => config['admin_pass'],
202-
:type => "password",
203-
:source_id => source_id,
204-
:source_type => "exploit",
205-
:target_host => config['admin_bindip'],
206-
:target_port => config['admin_port']
207-
)
208-
189+
if session.db_record
190+
source_id = session.db_record.id
191+
else
192+
source_id = nil
193+
end
194+
# report the goods!
195+
if config['admin_port'] == "<none>"
196+
#if report_auth_info executes with admin_port equal to "<none>"
197+
#the module will crash with an error.
198+
vprint_status("(No admin information found.)")
199+
else
200+
report_auth_info(
201+
:host => session.sock.peerhost,
202+
:port => config['admin_port'],
203+
:sname => 'filezilla-admin',
204+
:proto => 'tcp',
205+
:user => 'admin',
206+
:pass => config['admin_pass'],
207+
:type => "password",
208+
:source_id => source_id,
209+
:source_type => "exploit",
210+
:target_host => config['admin_bindip'],
211+
:target_port => config['admin_port']
212+
)
213+
end
214+
209215
p = store_loot("filezilla.server.creds", "text/csv", session, credentials.to_csv,
210216
"filezilla_server_credentials.csv", "FileZilla FTP Server Credentials")
211217

modules/post/windows/gather/smart_hashdump.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ def decrypt_user_hash(rid, hbootkey, enchash, pass)
289289
def read_hashdump
290290
host,port = session.session_host, session.session_port
291291
collected_hashes = ""
292+
tries = 0
293+
292294
begin
293295

294296
print_status("\tObtaining the boot key...")
@@ -333,9 +335,20 @@ def read_hashdump
333335

334336
rescue ::Interrupt
335337
raise $!
336-
rescue ::Rex::Post::Meterpreter::RequestError => e
337-
print_error("Meterpreter Exception: #{e.class} #{e}")
338-
print_error("This module requires the use of a SYSTEM user context (hint: migrate into service process)")
338+
rescue ::Rex::Post::Meterpreter::RequestError => e
339+
# Sometimes we get this invalid handle race condition.
340+
# So let's retry a couple of times before giving up.
341+
# See bug #6815
342+
if tries < 5 and e.to_s =~ /The handle is invalid/
343+
print_status("Handle is invalid, retrying...")
344+
tries += 1
345+
retry
346+
347+
else
348+
print_error("Meterpreter Exception: #{e.class} #{e}")
349+
print_error("This script requires the use of a SYSTEM user context (hint: migrate into service process)")
350+
end
351+
339352
rescue ::Exception => e
340353
print_error("Error: #{e.class} #{e} #{e.backtrace}")
341354
end

modules/post/windows/manage/migrate.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ def run
4444
print_status("Current server process: #{server.name} (#{server.pid})")
4545

4646
target_pid = nil
47-
47+
4848
if datastore['SPAWN']
4949
print_status("Spawning notepad.exe process to migrate to")
5050
target_pid = create_temp_proc
51-
elsif datastore['PID']
51+
elsif datastore['PID'] != 0
5252
target_pid = datastore['PID']
5353
elsif datastore['NAME']
54-
target_pid = session.sys.process[datstore['NAME']]
54+
target_pid = session.sys.process[datastore['NAME']]
5555
end
5656

5757
if not target_pid

0 commit comments

Comments
 (0)