-
Notifications
You must be signed in to change notification settings - Fork 35
/
test.py
139 lines (125 loc) · 5.78 KB
/
test.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
__version__ = '0.2'
import socket
import fcntl
import struct
from twisted.internet import reactor
from twisted.cred import portal, checkers
from twisted.conch import manhole, manhole_ssh
from twisted.conch.ssh import keys
from twisted.conch.insults import insults
app = None
#+---[RSA 3072]----+
#|E .o o=.o.=.. |
#|o...=**=o= = |
#|o.o.+*++= + . . |
#|o+ . ....+ . o +.|
#| o ..S. . . +|
#| o .. |
#| . . |
#| . . |
#| .. |
#+----[SHA256]-----+
private_rsa="""-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEArtmBetbHICKPEQAYsE74WS5m9JNnHVmkijJ+shnVW6QGLcG6meov
WcTiEq0Ti8/r7Yj5oNg7gheNjKEck5QJQJELNIiVQQ8iMDOZrwAgwpLxKnQiYW+X4EoIqk
lRPQvng3SL9uJ2Rz5Q9Ti353Ir1CBD5J9EpsIUkY0LfiAXjAdMgMzOMGnIvept+uEnSQR0
OmMYxdpRVTLVn6mBbvNCWXpJTPm5ksBgGfkLyyLdLIOIXBnIuL6FrtRCH9khW28cx8oxcs
sz5eEOEEY2WV6CRuT+hpinTBPQzzqQDbckTfNGVqULPlc40eF9Swa3n9YrKJRL32P9bK31
ZUGWWJuzy6XSZ0D/WdrZE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AAABgQCu2YF61scgIo8RABiwTvhZLmb0k2cdWaSKMn6yGdVbpAYtwbqZ6i9ZxOISrROLz+vtiPmg2DuCF42MoRyTlAlAkQs0iJVBDyIwM5mvACDCkvEqdCJhb5fgSgiqSVE9C+eDdIv24nZHPlD1OLfncivUIEPkn0SmwhSRjQt+IBeMB0yAzM4waci96m364SdJBHQ6YxjF2lFVMtWfqYFu80JZeklM+bmSwGAZ+QvLIt0sg4hcGci4voWu1EIf2SFbbxzHyjFyyzPl4Q4QRjZZXoJG5P6GmKdME9DPOpANtyRN80ZWpQs+VzjR4X1LBref1isolEvfY/1srfVlQZZYm7PLpdJnQP9Z2tkQb4NPMd7hB7yWLY5/sMrR1Fi8+PnrhAlYtG9AjOlSCMD/CRsCMmrWTILNlJ3ZZjFDPXvlQ1nNPuwdFcYeriSHs6hrnuj15tl/TESt6nXvyU6Dgwhys6UrkBmncclXweR8VDk/RQtVQA1zXnSmMKQ1fQCcbNYqTQM="
class PythonManhole(manhole.ColoredManhole):
def __init__(self):
glob = {
'__name__':'__main__',
'__doc__':None,
'__package__':None,
'__spec__':None,
'__annotations__':{},
'__builtins__':__builtins__
}
super().__init__(glob)
def makeConnection(self, cxt):
self.transport = cxt.transport
return super().makeConnection(cxt)
def lineReceived(self, *args):
# Catch exit()
try:
return super().lineReceived(*args)
except SystemExit:
self.transport.loseConnection()
def getManholeFactory(**users):
# Create a terminal
realm = manhole_ssh.TerminalRealm()
realm.chainedProtocolFactory.protocolFactory = PythonManhole
users = {key: value.encode() for key, value in users.items()}
p = portal.Portal(realm)
p.registerChecker(
checkers.InMemoryUsernamePasswordDatabaseDontUse(**users))
# Create a factory
f = manhole_ssh.ConchFactory(p)
f.publicKeys[b'ssh-rsa'] = keys.Key.fromString(public_rsa)
f.privateKeys[b'ssh-rsa'] = keys.Key.fromString(private_rsa)
return f
#class MainScreen:
#
# def __init__(self, **kwargs):
# ip = socket.gethostbyname(socket.gethostname())
# if ip.startswith('127.'):
# interfaces = ['eth0', 'eth1', 'eth2', 'wlan0', 'wlan1', 'wifi0',
# 'tiwlan0', 'tiwlan1', 'ath0', 'ath1', 'ppp0']
# for ifname in interfaces:
# try:
# ip = self.get_interface_ip(ifname)
# break
# except IOError:
# pass
# self.lan_ip = ip
#
# def get_interface_ip(self, ifname):
# s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# return socket.inet_ntoa(fcntl.ioctl(
# s.fileno(),
# 0x8915, # SIOCGIFADDR
# struct.pack('256s', ifname[:15].encode('utf-8'))
# )[20:24])
#
#
#
# def on_pause(self):
# return True
if __name__ == '__main__':
# Define the local variables
connection = reactor.listenTCP(8001, getManholeFactory(admin='kivy'))
reactor.run()