@@ -52,29 +52,41 @@ def initialize(info = {})
52
52
)
53
53
end
54
54
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
+
55
76
def on_request_uri ( cli , request )
56
77
print_status ( "GET #{ request . uri } #{ request . headers [ 'User-Agent' ] } " )
57
78
58
79
resp = create_response ( 200 , "OK" )
59
80
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
64
82
resp [ 'Content-Type' ] = 'text/javascript'
65
83
66
84
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
71
86
resp [ 'Content-Type' ] = 'text/css'
72
87
73
88
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
78
90
resp [ 'Content-Type' ] = 'image/jpg'
79
91
80
92
else
0 commit comments