{"id":110,"date":"2021-10-06T13:10:20","date_gmt":"2021-10-06T11:10:20","guid":{"rendered":"https:\/\/areyou1or0.it\/?p=110"},"modified":"2021-10-10T21:13:12","modified_gmt":"2021-10-10T19:13:12","slug":"slae64-assignment-2-reverse-shell","status":"publish","type":"post","link":"https:\/\/areyou1or0.it\/index.php\/2021\/10\/06\/slae64-assignment-2-reverse-shell\/","title":{"rendered":"SLAE64: Assignment 2 \u2013 Reverse Shell"},"content":{"rendered":"\n<p>This blog post has been created for completing the requirements of the SecurityTube Linux Assembly Expert (SLAE64) certification:<\/p>\n\n\n\n<p><a href=\"https:\/\/www.pentesteracademy.com\/course?id=7\">https:\/\/www.pentesteracademy.com\/course?id=7<\/a><\/p>\n\n\n\n<p>Student-ID:&nbsp;<strong>PA-15847<\/strong><\/p>\n\n\n\n<p>The Objectives for the Assignment:<\/p>\n\n\n\n<p><strong><code>create a shell_reverse_tcp shellcode<\/code><\/strong>:<\/p>\n\n\n\n<ul><li><code><strong>reverse connects to configured IP and port<\/strong><\/code><\/li><li><code><strong>needs a passcode<\/strong><\/code><\/li><li><code><strong>if passcode is correct, then execs shell<\/strong><\/code><\/li><li><code><strong>remove 0x00 from bind tcp shellcode<\/strong><\/code><\/li><\/ul>\n\n\n\n<p>So I took the code written during the course as a base and developed the remaining parts as below:<\/p>\n\n\n\n<p>I use the following syscalls in the same order:<\/p>\n\n\n\n<div class=\"is-layout-flow wp-block-group\"><div class=\"wp-block-group__inner-container\">\n<p><code><strong>syscall socket <br>syscall connect<br>syscall read <br>syscall dup2<br>syscall execve<br>syscall close<\/strong><\/code><\/p>\n\n\n\n<p>First we start with opening a socket with the following syntax:<\/p>\n\n\n\n<p><code><strong>int socket(int&nbsp;<em>domain<\/em>, int&nbsp;<em>type<\/em>, int&nbsp;<em>protocol<\/em>);<\/strong><\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"924\" height=\"490\" src=\"https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.26.png\" alt=\"\" class=\"wp-image-112\" srcset=\"https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.26.png 924w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.26-300x159.png 300w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.26-768x407.png 768w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.26-600x318.png 600w\" sizes=\"(max-width: 924px) 100vw, 924px\" \/><figcaption>syscall socket<\/figcaption><\/figure>\n\n\n\n<p>Then we will make the socket connect to the server with the following syntax:<\/p>\n\n\n\n<p><code><strong>int connect(int<\/strong>&nbsp;sockfd,&nbsp;<strong>const struct<\/strong>&nbsp;sockaddr *addr,&nbsp;<strong>socklen_t<\/strong>&nbsp;addrlen<strong>);<\/strong><\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"417\" src=\"https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.33-1024x417.png\" alt=\"\" class=\"wp-image-113\" srcset=\"https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.33-1024x417.png 1024w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.33-300x122.png 300w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.33-768x313.png 768w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.33-600x244.png 600w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.33.png 1350w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>syscall connect<\/figcaption><\/figure>\n\n\n\n<p>Here we&#8217;ll read the password string and compare it with the real password for a match. If the result is wrong, it will go to end (defined at the end)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"480\" src=\"https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.38-1024x480.png\" alt=\"\" class=\"wp-image-114\" srcset=\"https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.38-1024x480.png 1024w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.38-300x141.png 300w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.38-768x360.png 768w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.38-600x281.png 600w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.38.png 1234w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>syscall read<\/figcaption><\/figure>\n\n\n\n<p>Then we have dup2 again for redirecting the socket<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"894\" height=\"482\" src=\"https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.43.png\" alt=\"\" class=\"wp-image-115\" srcset=\"https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.43.png 894w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.43-300x162.png 300w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.43-768x414.png 768w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.43-600x323.png 600w\" sizes=\"(max-width: 894px) 100vw, 894px\" \/><figcaption>syscall dup2<\/figcaption><\/figure>\n\n\n\n<p>And of course we execute \/bin\/sh with execve syscall <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"962\" height=\"684\" src=\"https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.49.png\" alt=\"\" class=\"wp-image-116\" srcset=\"https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.49.png 962w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.49-300x213.png 300w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.49-768x546.png 768w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.49-600x427.png 600w\" sizes=\"(max-width: 962px) 100vw, 962px\" \/><figcaption>syscall execve<\/figcaption><\/figure>\n\n\n\n<p>We define the end call here as it&#8217;s called in read syscall section before and exit the program<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"728\" height=\"358\" src=\"https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.53.png\" alt=\"\" class=\"wp-image-117\" srcset=\"https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.53.png 728w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.53-300x148.png 300w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-06-at-13.03.53-600x295.png 600w\" sizes=\"(max-width: 728px) 100vw, 728px\" \/><figcaption>syscall close<\/figcaption><\/figure>\n\n\n\n<p>We get a reverse shell at the end:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"835\" src=\"https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/assignment2-1024x835.png\" alt=\"\" class=\"wp-image-118\" srcset=\"https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/assignment2-1024x835.png 1024w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/assignment2-300x245.png 300w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/assignment2-768x626.png 768w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/assignment2-1536x1252.png 1536w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/assignment2-1568x1278.png 1568w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/assignment2-600x489.png 600w, https:\/\/areyou1or0.it\/wp-content\/uploads\/2021\/10\/assignment2.png 1603w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This blog post has been created for completing the requirements of the SecurityTube Linux Assembly Expert (SLAE64) certification: https:\/\/www.pentesteracademy.com\/course?id=7 Student-ID:&nbsp;PA-15847 The Objectives for the Assignment: create a shell_reverse_tcp shellcode: reverse connects to configured IP and port needs a passcode if passcode is correct, then execs shell remove 0x00 from bind tcp shellcode So I took&hellip; <a class=\"more-link\" href=\"https:\/\/areyou1or0.it\/index.php\/2021\/10\/06\/slae64-assignment-2-reverse-shell\/\">Continue reading <span class=\"screen-reader-text\">SLAE64: Assignment 2 \u2013 Reverse Shell<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[],"_links":{"self":[{"href":"https:\/\/areyou1or0.it\/index.php\/wp-json\/wp\/v2\/posts\/110"}],"collection":[{"href":"https:\/\/areyou1or0.it\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/areyou1or0.it\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/areyou1or0.it\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/areyou1or0.it\/index.php\/wp-json\/wp\/v2\/comments?post=110"}],"version-history":[{"count":3,"href":"https:\/\/areyou1or0.it\/index.php\/wp-json\/wp\/v2\/posts\/110\/revisions"}],"predecessor-version":[{"id":160,"href":"https:\/\/areyou1or0.it\/index.php\/wp-json\/wp\/v2\/posts\/110\/revisions\/160"}],"wp:attachment":[{"href":"https:\/\/areyou1or0.it\/index.php\/wp-json\/wp\/v2\/media?parent=110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/areyou1or0.it\/index.php\/wp-json\/wp\/v2\/categories?post=110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/areyou1or0.it\/index.php\/wp-json\/wp\/v2\/tags?post=110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}