Skip to content

Commit 8b050fc

Browse files
author
Brent Cook
committed
simplify cleanup code, remove duplicate logic
1 parent 9d13df3 commit 8b050fc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,16 @@ def get_sql_hash(instance_name)
112112

113113
print_status("Attempting to get password hashes...")
114114

115-
get_hash_result = run_sql(query, instance_name)
115+
res = run_sql(query, instance_name)
116116

117-
if get_hash_result.include?('0x')
117+
if res.include?('0x')
118118
# Parse Data
119119
if hash_type == "mssql12"
120-
crlfRepair = get_hash_result.unpack('H*')[0].gsub("200d0a","PLACEHOLDER").gsub("0d0a","").gsub("PLACEHOLDER","0d0a").gsub(/../) { |pair| pair.hex.chr }
121-
hash_array = crlfRepair.split("\r\n").grep(/0x/)
122-
else
123-
hash_array = get_hash_result.split("\r\n").grep(/0x/)
120+
res = res.unpack('H*')[0].gsub("200d0a", "_CRLF_").gsub("0d0a", "").gsub("_CRLF_", "0d0a").gsub(/../) {
121+
|pair| pair.hex.chr
122+
}
124123
end
124+
hash_array = res.split("\r\n").grep(/0x/)
125125

126126
store_hashes(hash_array, hash_type)
127127
else

0 commit comments

Comments
 (0)