Skip to content

Commit 93ba087

Browse files
author
Brent Cook
committed
add backward compatibility for hash responses
1 parent c614f60 commit 93ba087

File tree

1 file changed

+8
-2
lines changed
  • lib/rex/post/meterpreter/extensions/stdapi/fs

1 file changed

+8
-2
lines changed

lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ def File.md5(path)
152152

153153
response = client.send_request(request)
154154

155-
return response.get_tlv_value(TLV_TYPE_FILE_HASH)
155+
# older meterpreter binaries will send FILE_NAME containing the hash
156+
hash = response.get_tlv_value(TLV_TYPE_FILE_HASH) ||
157+
response.get_tlv_value(TLV_TYPE_FILE_NAME)
158+
return hash
156159
end
157160

158161
#
@@ -165,7 +168,10 @@ def File.sha1(path)
165168

166169
response = client.send_request(request)
167170

168-
return response.get_tlv_value(TLV_TYPE_FILE_HASH)
171+
# older meterpreter binaries will send FILE_NAME containing the hash
172+
hash = response.get_tlv_value(TLV_TYPE_FILE_HASH) ||
173+
response.get_tlv_value(TLV_TYPE_FILE_NAME)
174+
return hash
169175
end
170176

171177
#

0 commit comments

Comments
 (0)