Skip to content

Commit 2776047

Browse files
committed
Merge branch 'smb_cap' of github.com:Meatballs1/metasploit-framework into Meatballs1-smb_cap
2 parents fe8b9c2 + 4cadffc commit 2776047

File tree

1 file changed

+14
-14
lines changed
  • modules/auxiliary/server/capture

1 file changed

+14
-14
lines changed

modules/auxiliary/server/capture/smb.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def smb_cmd_session_setup(c, buff, esn)
334334
begin
335335
smb_get_hash(smb,arg,true)
336336
rescue ::Exception => e
337-
print_status("SMB Capture - Error processing Hash from #{smb[:name]} - #{smb[:ip]} : #{e.class} #{e} #{e.backtrace}")
337+
print_error("SMB Capture - Error processing Hash from #{smb[:name]} - #{smb[:ip]} : #{e.class} #{e} #{e.backtrace}")
338338
end
339339

340340
smb_error(CONST::SMB_COM_SESSION_SETUP_ANDX, c, CONST::SMB_STATUS_LOGON_FAILURE, true)
@@ -396,7 +396,7 @@ def smb_cmd_session_setup(c, buff, esn)
396396
smb_get_hash(smb,arg,false)
397397

398398
rescue ::Exception => e
399-
print_status("SMB Capture - Error processing Hash from #{smb[:name]} : #{e.class} #{e} #{e.backtrace}")
399+
print_error("SMB Capture - Error processing Hash from #{smb[:name]} : #{e.class} #{e} #{e.backtrace}")
400400
end
401401

402402
smb_error(CONST::SMB_COM_SESSION_SETUP_ANDX, c, CONST::SMB_STATUS_LOGON_FAILURE, true)
@@ -522,17 +522,17 @@ def smb_get_hash(smb, arg = {}, esn=true)
522522
end
523523

524524
print_status(capturelogmessage)
525+
lm_text = (lm_hash + lm_cli_challenge.to_s).empty? ? "00" * 24 : lm_hash + lm_cli_challenge.to_s
526+
nt_text = (nt_hash + nt_cli_challenge.to_s).empty? ? "00" * 24 : nt_hash + nt_cli_challenge.to_s
527+
pass = "#{smb[:domain]}:#{lm_text}:#{nt_text}:#{datastore['CHALLENGE'].to_s}"
525528

526529
# DB reporting
527530
report_auth_info(
528531
:host => smb[:ip],
529532
:port => datastore['SRVPORT'],
530533
:sname => 'smb_challenge',
531534
:user => smb[:username],
532-
:pass => smb[:domain] + ":" +
533-
( lm_hash + lm_cli_challenge.to_s ? lm_hash + lm_cli_challenge.to_s : "00" * 24 ) + ":" +
534-
( nt_hash + nt_cli_challenge.to_s ? nt_hash + nt_cli_challenge.to_s : "00" * 24 ) + ":" +
535-
datastore['CHALLENGE'].to_s,
535+
:pass => pass,
536536
:type => smb_db_type_hash,
537537
:proof => "NAME=#{smb[:nbsrc]} DOMAIN=#{smb[:domain]} OS=#{smb[:peer_os]}",
538538
:source_type => "captured",
@@ -570,8 +570,8 @@ def smb_get_hash(smb, arg = {}, esn=true)
570570
smb[:username],
571571
smb[:domain] ? smb[:domain] : "NULL",
572572
@challenge.unpack("H*")[0],
573-
lm_hash ? lm_hash : "0" * 48,
574-
nt_hash ? nt_hash : "0" * 48
573+
lm_hash.empty? ? "0" * 48 : lm_hash,
574+
nt_hash.empty? ? "0" * 48 : nt_hash
575575
].join(":").gsub(/\n/, "\\n")
576576
)
577577
fd.close
@@ -587,8 +587,8 @@ def smb_get_hash(smb, arg = {}, esn=true)
587587
[
588588
smb[:username],"",
589589
smb[:domain] ? smb[:domain] : "NULL",
590-
lm_hash ? lm_hash : "0" * 48,
591-
nt_hash ? nt_hash : "0" * 48,
590+
lm_hash.empty? ? "0" * 48 : lm_hash,
591+
nt_hash.empty? ? "0" * 48 : nt_hash,
592592
@challenge.unpack("H*")[0]
593593
].join(":").gsub(/\n/, "\\n")
594594
)
@@ -601,8 +601,8 @@ def smb_get_hash(smb, arg = {}, esn=true)
601601
smb[:username],"",
602602
smb[:domain] ? smb[:domain] : "NULL",
603603
@challenge.unpack("H*")[0],
604-
lm_hash ? lm_hash : "0" * 32,
605-
lm_cli_challenge ? lm_cli_challenge : "0" * 16
604+
lm_hash.empty? ? "0" * 32 : lm_hash,
605+
lm_cli_challenge.empty? ? "0" * 16 : lm_cli_challenge
606606
].join(":").gsub(/\n/, "\\n")
607607
)
608608
fd.close
@@ -613,8 +613,8 @@ def smb_get_hash(smb, arg = {}, esn=true)
613613
smb[:username],"",
614614
smb[:domain] ? smb[:domain] : "NULL",
615615
@challenge.unpack("H*")[0],
616-
nt_hash ? nt_hash : "0" * 32,
617-
nt_cli_challenge ? nt_cli_challenge : "0" * 160
616+
nt_hash.empty? ? "0" * 32 : nt_hash,
617+
nt_cli_challenge ? "0" * 160 : nt_cli_challenge
618618
].join(":").gsub(/\n/, "\\n")
619619
)
620620
fd.close

0 commit comments

Comments
 (0)