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/backup_file.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##4567class MetasploitModule < Msf::Auxiliary8include Msf::Exploit::Remote::HttpClient9include Msf::Auxiliary::WmapScanFile10include Msf::Auxiliary::Scanner11include Msf::Auxiliary::Report1213def initialize(info = {})14super(update_info(info,15'Name' => 'HTTP Backup File Scanner',16'Description' => %q{17This module identifies the existence of possible copies18of a specific file in a given path.19},20'Author' => [ 'et [at] cyberspace.org' ],21'License' => BSD_LICENSE))2223register_options(24[25OptString.new('PATH', [ true, "The path/file to identify backups", '/index.asp'])26])2728end2930def run_host(ip)31bakextensions = [32'.backup',33'.bak',34'.copy',35'.copia',36'.old',37'.orig',38'.temp',39'.txt',40'~'41]4243bakextensions.each do |ext|44file = normalize_uri(datastore['PATH'])+ext45check_for_file(file, ip)46end47if datastore['PATH'] =~ %r#(.*)(/.+$)#48file = $1 + $2.sub('/', '/.') + '.swp'49check_for_file(file, ip)50end51end52def check_for_file(file, ip)53begin54res = send_request_cgi({55'uri' => file,56'method' => 'GET',57'ctype' => 'text/plain'58}, 20)5960if (res and res.code >= 200 and res.code < 300)61print_good("Found #{wmap_base_url}#{file}")6263report_web_vuln(64:host => ip,65:port => rport,66:vhost => vhost,67:ssl => ssl,68:path => file,69:method => 'GET',70:pname => "",71:proof => "Res code: #{res.code.to_s}",72:risk => 0,73:confidence => 100,74:category => 'file',75:description => 'Backup file found.',76:name => 'backup file'77)7879else80vprint_status("NOT Found #{wmap_base_url}#{file}")81#To be removed or just displayed with verbose debugging.82end8384rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout85rescue ::Timeout::Error, ::Errno::EPIPE86end878889end90end919293