-
Notifications
You must be signed in to change notification settings - Fork 17
/
hilldust.py
executable file
·59 lines (48 loc) · 1.25 KB
/
hilldust.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
#!/usr/bin/env python3
import sys
if sys.version_info.major == 2:
exec('print "This program cannot be run in Python 2."')
exit(1)
if len(sys.argv) != 4:
print('Usage:', sys.argv[0], 'ADDRESS:PORT', 'USERNAME', 'PASSWORD')
exit(2)
import os
if os.getuid() != 0:
print('Need to be root.')
exit(3)
target = sys.argv[1]
delim_index = target.rindex(':')
host, port = target[:delim_index], target[delim_index+1:]
import impl_scapy
c = impl_scapy.Client()
c.connect(host, int(port))
print('Connected.')
c.auth(sys.argv[2], sys.argv[3], '', '')
print('Authentication completed.')
c.client_info()
c.wait_network()
print('Got network configuration.')
c.new_key()
print('Key exchanging completed.')
import platform_linux
platform_linux.set_network(c)
print('Network configured.')
def inbound_handle():
while True:
raw = c.recv()
platform_linux.write(raw)
def outbound_handle():
while True:
raw = platform_linux.read()
c.send(raw)
from threading import Thread
Thread(target=inbound_handle, daemon=True).start()
Thread(target=outbound_handle, daemon=True).start()
try:
input('Enter to exit.')
except KeyboardInterrupt:
pass
print('Logout.')
c.logout()
platform_linux.restore_network(c)
print('Network restored.')