@@ -334,7 +334,7 @@ def smb_cmd_session_setup(c, buff, esn)
334
334
begin
335
335
smb_get_hash ( smb , arg , true )
336
336
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 } " )
338
338
end
339
339
340
340
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)
396
396
smb_get_hash ( smb , arg , false )
397
397
398
398
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 } " )
400
400
end
401
401
402
402
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)
522
522
end
523
523
524
524
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 } "
525
528
526
529
# DB reporting
527
530
report_auth_info (
528
531
:host => smb [ :ip ] ,
529
532
:port => datastore [ 'SRVPORT' ] ,
530
533
:sname => 'smb_challenge' ,
531
534
: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 ,
536
536
:type => smb_db_type_hash ,
537
537
:proof => "NAME=#{ smb [ :nbsrc ] } DOMAIN=#{ smb [ :domain ] } OS=#{ smb [ :peer_os ] } " ,
538
538
:source_type => "captured" ,
@@ -570,8 +570,8 @@ def smb_get_hash(smb, arg = {}, esn=true)
570
570
smb [ :username ] ,
571
571
smb [ :domain ] ? smb [ :domain ] : "NULL" ,
572
572
@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
575
575
] . join ( ":" ) . gsub ( /\n / , "\\ n" )
576
576
)
577
577
fd . close
@@ -587,8 +587,8 @@ def smb_get_hash(smb, arg = {}, esn=true)
587
587
[
588
588
smb [ :username ] , "" ,
589
589
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 ,
592
592
@challenge . unpack ( "H*" ) [ 0 ]
593
593
] . join ( ":" ) . gsub ( /\n / , "\\ n" )
594
594
)
@@ -601,8 +601,8 @@ def smb_get_hash(smb, arg = {}, esn=true)
601
601
smb [ :username ] , "" ,
602
602
smb [ :domain ] ? smb [ :domain ] : "NULL" ,
603
603
@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
606
606
] . join ( ":" ) . gsub ( /\n / , "\\ n" )
607
607
)
608
608
fd . close
@@ -613,8 +613,8 @@ def smb_get_hash(smb, arg = {}, esn=true)
613
613
smb [ :username ] , "" ,
614
614
smb [ :domain ] ? smb [ :domain ] : "NULL" ,
615
615
@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
618
618
] . join ( ":" ) . gsub ( /\n / , "\\ n" )
619
619
)
620
620
fd . close
0 commit comments