From c7019e5aee25f524dec9aecadb5485a65cdadbd2 Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Tue, 12 Dec 2017 14:54:49 -0600 Subject: [PATCH] Only load files once --- .../unix/http/pfsense_clickjacking.rb | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/modules/exploits/unix/http/pfsense_clickjacking.rb b/modules/exploits/unix/http/pfsense_clickjacking.rb index 746c58a294..0ae6dc4de6 100644 --- a/modules/exploits/unix/http/pfsense_clickjacking.rb +++ b/modules/exploits/unix/http/pfsense_clickjacking.rb @@ -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