Skip to content

Commit c7019e5

Browse files
committed
Only load files once
1 parent 942e44c commit c7019e5

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

modules/exploits/unix/http/pfsense_clickjacking.rb

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,29 +52,41 @@ def initialize(info = {})
5252
)
5353
end
5454

55+
def js_file
56+
@js ||= lambda {
57+
path = File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'cookieconsent.min.js')
58+
return File.read(path)
59+
}.call
60+
end
61+
62+
def css_file
63+
@css ||= lambda {
64+
path = File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'cookieconsent.min.css')
65+
return File.read(path)
66+
}.call
67+
end
68+
69+
def background_file
70+
@background ||= lambda {
71+
path = File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'background.jpg')
72+
return File.read(path)
73+
}.call
74+
end
75+
5576
def on_request_uri(cli, request)
5677
print_status("GET #{request.uri} #{request.headers['User-Agent']}")
5778

5879
resp = create_response(200, "OK")
5980
if request.uri =~ /\.js$/
60-
path = ::File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'cookieconsent.min.js')
61-
fd = ::File.open(path, "rb")
62-
resp.body = fd.read(fd.stat.size)
63-
fd.close
81+
resp.body = js_file
6482
resp['Content-Type'] = 'text/javascript'
6583

6684
elsif request.uri =~ /\.css$/
67-
path = ::File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'cookieconsent.min.css')
68-
fd = ::File.open(path, "rb")
69-
resp.body = fd.read(fd.stat.size)
70-
fd.close
85+
resp.body = css_file
7186
resp['Content-Type'] = 'text/css'
7287

7388
elsif request.uri =~ /\.jpg$/
74-
path = ::File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'background.jpg')
75-
fd = ::File.open(path, "rb")
76-
resp.body = fd.read(fd.stat.size)
77-
fd.close
89+
resp.body = background_file
7890
resp['Content-Type'] = 'image/jpg'
7991

8092
else

0 commit comments

Comments
 (0)