-
Notifications
You must be signed in to change notification settings - Fork 6
/
telnet-send.py
41 lines (33 loc) · 1.11 KB
/
telnet-send.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
###############################################################################
### This example script will send to the ip and port provided. ###
### Once a connection is successfully opened it will open an interactive ###
### session. ###
### Author: Conor Richard ###
###############################################################################
import socket
import telnetlib
import sys
import time
def sendShell(host, port):
print("Sending connection on ip: {ipAddress} port: {port}".format(ipAddress = host, port = port))
time.sleep(1)
# Try to configure a socket and bind to the specified host
try:
# Sending connection
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))
t = telnetlib.Telnet()
t.sock = s
t.interact()
except:
print('Connection closed or something went wrong.')
sys.exit(-1)
def main():
# Host address to listen on, use empty string to
# listen on all addresses.
host = 'localhost'
# Port to listen on.
port = 443
sendShell(host, port)
if __name__ == "__main__":
sys.exit(main())