forked from hazcod/ISIS-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_assignments.py
executable file
·185 lines (171 loc) · 4.46 KB
/
check_assignments.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/usr/bin/python
import socket
import subprocess
import git
import os.path
import check_networks
import shutil
from database import *
from wifi import *
from take_image import *
from kick_from_ap import *
from crack_network import *
from rogue_ap import *
from find_devices import *
# File created when assignment is still running
file_busy = '/tmp/busy'
def opdrachtvolbracht():
try:
os.remove(file_busy)
except:
pass
query = 'update assignments SET status = "executed" where assignments_id ="'
query+= str(cmd_id)
query+= '";'
executequery(query)
def opdrachterror(errormsg):
try:
os.remove(file_busy)
except:
pass
query = 'update assignments SET status = "error", parameter="'
query+= errormsg
query+= '" where assignments_id="'
query+= str(cmd_id)
query+= '";'
print(query)
executequery(query)
def opdrachtexecute():
open(file_busy, 'a').close()
query= 'update assignments SET status = "busy" where assignments_id="'
query+= str(cmd_id)
query+= '";'
executequery(query)
def lastseen():
# # Update last seen
query='update units set last_seen = now() where caption="'
query+=socket.gethostname()
query+='";'
executequery(query)
# Check into our hotel ..erm..website
lastseen()
# All your command are belong to us
query = "select assignment,assignments_id,parameter from assignments where caption='"
query+= socket.gethostname()
query+= "' and status='new' order by assignments_id ASC limit 1;"
tmp = executequery(query)
if tmp:
command = tmp[0][0]
cmd_id = tmp[0][1]
parameter = tmp[0][2]
else:
print('No commands atm.')
quit()
# Safe check for wipe, executed even when busy
if command == "wipe":
try:
#remove files gracefully
print('ZOMG DELETE EVERYTHING')
except:
#force remove files
print('WOW SUCH DELETE FORCE')
elif command == "stoprogue":
try:
opdrachtexecute()
stop_rogue_ap()
opdrachtvolbracht()
opdrachtvolbracht()
quit()
except Exception, e:
opdrachterror('Could not stop the rogue ' + str(e))
# Quit when there is an assignment still running
if os.path.isfile(file_busy):
print('Still busy or no command !')
quit()
print('- Assignment check')
# Check for assignments
if command == "gitCheckout":
try:
opdrachtexecute()
repo = git.Repo('/home/isis/ISIS-frontend')
o = repo.remotes.origin
o.pull()
opdrachtvolbracht()
except AssertionError:
opdrachtvolbracht()
except:
opdrachterror("Merge conflicts")
elif command == "scan":
try:
opdrachtexecute()
check_networks.scan()
opdrachtvolbracht()
except subprocess.CalledProcessError:
opdrachterror("Geen wifi-stick verbonden.")
except Exception, e:
opdrachterror('Scan error: ' + str (e))
elif command == "snap":
try:
opdrachtexecute()
take_picture()
opdrachtvolbracht()
except:
opdrachterror("Geen camera verbonden.")
elif command == "deauth":
try:
opdrachtexecute()
ap = parameter.split('|')[0]
target = parameter.split('|')[1]
channel = parameter.split('|')[2]
kick_ap(ap,channel,target)
opdrachtvolbracht()
except Exception, e:
opdrachterror('Deauth failed: ' + str(e))
elif command == "crackWifiUnit":
try:
opdrachtexecute()
crack_network(parameter)
opdrachtvolbracht()
except Exception, e:
opdrachterror('Crack failed: ' + str(e))
elif command == "rogue":
try:
opdrachtexecute()
start_rogue_ap()
except Exception, e:
opdrachterror('Could not go rogue ' + str(e))
elif command == "finddevices":
try:
try:
opdrachtexecute()
find_devices()
opdrachtvolbracht()
finally:
shutil.rmtree("/home/isis/dump")
except Exception, e:
opdrachterror('Could not find devices ' + str(e))
elif command == "nmap":
try:
try:
opdrachtexecute()
temp = subprocess.check_output(['ifconfig','-a'])
if ('wlan0' not in temp):
raise Exception("Wifi stick not found")
quit()
find_devices()
if "open" in parameter.split('|')[1]:
connectWifiWEP(parameter.split('|')[0])
elif "wpa" in parameter.split('|')[1]:
connectWifiWPA(parameter.split('|')[0],parameter.split('|')[2])
else:
connectWifiWEP(parameter.split('|')[0],parameter.split('|')[2])
map()
finally:
cleanupInterfaces()
#cleanupInterfaces_bckp() #just to be sure
os.system('sudo echo "nameserver 8.8.8.8" > /etc/resolv.conf')
os.system("sudo rm -rf /home/isis/dump")
except Exception, e:
opdrachterror('NMAP PROBLEEM: ' + str(e))
else:
opdrachterror('Unknown command ' + command)