Skip to content

Commit 4613984

Browse files
committed
Move to .empty? over length
1 parent a840003 commit 4613984

File tree

1 file changed

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

1 file changed

+10
-10
lines changed

modules/auxiliary/server/capture/smb.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,8 @@ def smb_get_hash(smb, arg = {}, esn=true)
527527
end
528528

529529
print_status(capturelogmessage)
530-
lm_text = (lm_hash + lm_cli_challenge.to_s).length > 0 ? lm_hash + lm_cli_challenge.to_s : "00" * 24
531-
nt_text = (nt_hash + nt_cli_challenge.to_s).length > 0 ? nt_hash + nt_cli_challenge.to_s : "00" * 24
530+
lm_text = (lm_hash + lm_cli_challenge.to_s).empty? ? "00" * 24 : lm_hash + lm_cli_challenge.to_s
531+
nt_text = (nt_hash + nt_cli_challenge.to_s).empty? ? "00" * 24 : nt_hash + nt_cli_challenge.to_s
532532
pass = "#{smb[:domain]}:#{lm_text}:#{nt_text}:#{datastore['CHALLENGE'].to_s}"
533533

534534
# DB reporting
@@ -575,8 +575,8 @@ def smb_get_hash(smb, arg = {}, esn=true)
575575
smb[:username],
576576
smb[:domain] ? smb[:domain] : "NULL",
577577
@challenge.unpack("H*")[0],
578-
lm_hash ? lm_hash : "0" * 48,
579-
nt_hash ? nt_hash : "0" * 48
578+
lm_hash.empty? ? "0" * 48 : lm_hash,
579+
nt_hash.empty? ? "0" * 48 : nt_hash
580580
].join(":").gsub(/\n/, "\\n")
581581
)
582582
fd.close
@@ -592,8 +592,8 @@ def smb_get_hash(smb, arg = {}, esn=true)
592592
[
593593
smb[:username],"",
594594
smb[:domain] ? smb[:domain] : "NULL",
595-
lm_hash.length > 0 ? lm_hash : "0" * 48,
596-
nt_hash.length > 0 ? nt_hash : "0" * 48,
595+
lm_hash.empty? ? "0" * 48 : lm_hash,
596+
nt_hash.empty? ? "0" * 48 : nt_hash,
597597
@challenge.unpack("H*")[0]
598598
].join(":").gsub(/\n/, "\\n")
599599
)
@@ -606,8 +606,8 @@ def smb_get_hash(smb, arg = {}, esn=true)
606606
smb[:username],"",
607607
smb[:domain] ? smb[:domain] : "NULL",
608608
@challenge.unpack("H*")[0],
609-
lm_hash.length > 0 ? lm_hash : "0" * 32,
610-
lm_cli_challenge ? lm_cli_challenge : "0" * 16
609+
lm_hash.empty? ? "0" * 32 : lm_hash,
610+
lm_cli_challenge.empty? ? "0" * 16 : lm_cli_challenge
611611
].join(":").gsub(/\n/, "\\n")
612612
)
613613
fd.close
@@ -618,8 +618,8 @@ def smb_get_hash(smb, arg = {}, esn=true)
618618
smb[:username],"",
619619
smb[:domain] ? smb[:domain] : "NULL",
620620
@challenge.unpack("H*")[0],
621-
nt_hash.length > 0 ? nt_hash : "0" * 32,
622-
nt_cli_challenge ? nt_cli_challenge : "0" * 160
621+
nt_hash.empty? ? "0" * 32 : nt_hash,
622+
nt_cli_challenge ? "0" * 160 : nt_cli_challenge
623623
].join(":").gsub(/\n/, "\\n")
624624
)
625625
fd.close

0 commit comments

Comments
 (0)