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 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) def on_request_uri(cli, request)
print_status("GET #{request.uri} #{request.headers['User-Agent']}") print_status("GET #{request.uri} #{request.headers['User-Agent']}")
resp = create_response(200, "OK") resp = create_response(200, "OK")
if request.uri =~ /\.js$/ if request.uri =~ /\.js$/
path = ::File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'cookieconsent.min.js') resp.body = js_file
fd = ::File.open(path, "rb")
resp.body = fd.read(fd.stat.size)
fd.close
resp['Content-Type'] = 'text/javascript' resp['Content-Type'] = 'text/javascript'
elsif request.uri =~ /\.css$/ elsif request.uri =~ /\.css$/
path = ::File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'cookieconsent.min.css') resp.body = css_file
fd = ::File.open(path, "rb")
resp.body = fd.read(fd.stat.size)
fd.close
resp['Content-Type'] = 'text/css' resp['Content-Type'] = 'text/css'
elsif request.uri =~ /\.jpg$/ elsif request.uri =~ /\.jpg$/
path = ::File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'background.jpg') resp.body = background_file
fd = ::File.open(path, "rb")
resp.body = fd.read(fd.stat.size)
fd.close
resp['Content-Type'] = 'image/jpg' resp['Content-Type'] = 'image/jpg'
else else