Skip to content

Commit 2c0f41e

Browse files
committed
Fix session guid handling in python 3
I made the mistake of using str.decode() which isn't a thing in python3 (works fine in 2). So this commit fixes it so that the GUID string itself is generated directly as a byte string, so that the call to decode() isn't needed at all.
1 parent c4288fb commit 2c0f41e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/msf/core/payload/python/meterpreter_loader.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ def stage_meterpreter(opts={})
7575
met.sub!("PAYLOAD_UUID = \'\'", "PAYLOAD_UUID = \'#{uuid}\'")
7676

7777
if opts[:stageless] == true
78-
session_guid = "00" * 16
78+
session_guid = '\x00' * 16
7979
else
80-
session_guid = SecureRandom.uuid.gsub(/-/, '')
80+
session_guid = SecureRandom.uuid.gsub(/-/, '').gsub(/(..)/, '\\x\1')
8181
end
82-
met.sub!("SESSION_GUID = \'\'", "SESSION_GUID = \'#{session_guid}\'.decode(\'hex\')")
82+
met.sub!("SESSION_GUID = \'\'", "SESSION_GUID = \'#{session_guid}\'")
8383

8484
http_user_agent = opts[:http_user_agent] || ds['MeterpreterUserAgent']
8585
http_proxy_host = opts[:http_proxy_host] || ds['PayloadProxyHost'] || ds['PROXYHOST']

0 commit comments

Comments
 (0)