def to_raw(self, host, port):
#pylint:disable=arguments-differ
'''
:param ip: string representing the ip address or domain name to connect back to
:param port: port to connect to on the remote host
'''
l.debug("Connecting back to %s:%d", host, port)
target_ip = socket.gethostbyname(host)
raw_ip = socket.inet_aton(target_ip).encode('hex')
if port < 0 or port >= 65535:
raise ValueError("invalid port specified")
raw_port = struct.pack("!H", port).encode('hex')
return (self.hex_code % (raw_port, raw_ip)).decode('hex')
评论列表
文章目录