-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathkillcast.py
382 lines (354 loc) · 11.6 KB
/
killcast.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
#!/usr/bin/env python3
import os
import sys
import json
import time
import socket
import requests
import argparse
import ipaddress
from xml.etree import ElementTree
requests.packages.urllib3.disable_warnings()
R = '\033[31m' # red
G = '\033[32m' # green
C = '\033[36m' # cyan
W = '\033[0m' # white
Y = '\033[33m' # yellow
version = '1.0.3'
parser = argparse.ArgumentParser(description="Manipulate Chromecast Devices in your Network")
parser.add_argument('-t', '--ip', help='IP Address of Chromecast', required=True)
args = parser.parse_args()
ip = args.ip
priv_ip = False
if ipaddress.ip_address(ip).is_private:
priv_ip = True
else:
pass
http_port = '8008'
https_port = '8443'
http_header = {'Content-Type' : 'application/json'}
https_header = {'Content-Type' : 'application/json', 'Authorization': 'kill.cast'}
def banner():
text = r'''
__ _ __ __ __
/ /__ (_)/ // /_____ ____ _ _____ / /_
/ //_// // // // ___// __ `// ___// __/
/ ,< / // // // /__ / /_/ /(__ )/ /_
/_/|_|/_//_//_/ \___/ \__,_//____/ \__/'''
print(G + text + W + '\n')
print(G + '[>]' + C + ' Created By : ' + W + 'thewhiteh4t')
print(G + ' |---> ' + C + 'Twitter : ' + W + 'https://twitter.com/thewhiteh4t')
print(G + ' |---> ' + C + 'Discord : ' + W + 'https://discord.com/invite/A2FUvkM')
print(G + '[>]' + C + ' Version : ' + W + version + '\n')
def ver_check():
print(G + '[+]' + C + ' Checking for Updates...', end='')
ver_url = 'https://raw.githubusercontent.com/thewhiteh4t/killcast/master/version.txt'
try:
ver_rqst = requests.get(ver_url, timeout=5)
ver_sc = ver_rqst.status_code
if ver_sc == 200:
github_ver = ver_rqst.text
github_ver = github_ver.strip()
if version == github_ver:
print(C + '[' + G + ' Up-To-Date ' + C +']' + '\n')
else:
print(C + '[' + G + ' Available : {} '.format(github_ver) + C + ']' + '\n')
else:
print(C + '[' + R + ' Status : {} '.format(ver_sc) + C + ']' + '\n')
except Exception as e:
print('\n\n' + R + '[-]' + C + ' Exception : ' + W + str(e))
def conn_test():
http_test = False
https_test = False
print('\n' + Y + '[!] Testing Connection...' + W + '\n')
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.settimeout(5)
try:
s.connect((ip, int(http_port)))
http_test = True
except OSError:
print(R + '[-]' + C + ' Exception : ' + W + 'Cannot Connect to Port 8008')
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.settimeout(5)
try:
s.connect((ip, int(https_port)))
https_test = True
except OSError:
print(R + '[-]' + C + ' Exception : ' + W + 'Cannot Connect to Port 8443')
if http_test == False or https_test == False:
print(R + '[-]' + C + ' Connection Test Failed' + W)
sys.exit()
else:
print(G + '[+]' + C + ' Connection Test Passed' + W)
def info():
print('\n' + Y + '[!] Getting Device Information...' + W + '\n')
dev_url = 'http://{}:{}/ssdp/device-desc.xml'.format(ip, http_port)
eur_url = 'http://{}:{}/setup/eureka_info'.format(ip, http_port)
try:
dev_rqst = requests.get(dev_url, headers=http_header, timeout=10)
dev_sc = dev_rqst.status_code
if dev_sc == 200:
root = ElementTree.fromstring(dev_rqst.text)
rtag = root.tag.strip('root')
rtag = rtag.strip('{}')
ns = {'ns' : '{}'.format(rtag)}
name = root.findall('.//ns:friendlyName', namespaces=ns)
manf = root.findall('.//ns:manufacturer', namespaces=ns)
model = root.findall('.//ns:modelName', namespaces=ns)
name = name[0].text
manf = manf[0].text
model = model[0].text
print (G + '[+]' + C + ' Name : ' + W + name)
print (G + '[+]' + C + ' Manufacturer : ' + W + manf)
print (G + '[+]' + C + ' Model Name : ' + W + model)
else:
print(R + '[-]' + C + ' Failed, Status : ' + W + str(dev_sc))
sys.exit()
eur_rqst = requests.get(eur_url, headers=http_header, timeout=10)
eur_sc = eur_rqst.status_code
key_list = [
'bssid', 'build_version',
'cast_build_revision', 'ethernet_connected',
'locale', 'mac_address',
'noise_level', 'signal_level',
'ssid', 'timezone',
'uptime', 'wpa_configured'
]
if eur_sc == 200:
infjson = eur_rqst.json()
for key, value in infjson.items():
if key in key_list:
key = key.replace('_', ' ').title()
if value == '':
value = 'Not Available'
else:
pass
print(G + '[+]' + C + ' {} : '.format(key) + W + str(value))
else:
pass
else:
print(R + '[-]' + C + ' Failed, Status : ' + W + str(eur_sc))
sys.exit()
except Exception as exc:
print(R + '[-]' + C + ' Exception : ' + W + str(exc))
def iprecon():
if priv_ip == True:
print('\n' + R + '[-]' + C + ' Private IP Address, Skipping...' + W)
return
else:
pass
print('\n' + Y + '[!] Getting IP Information...' + W + '\n')
key_list = ['country', 'city', 'isp', 'org', 'as']
service = 'http://ip-api.com/json/'
serv_url = service + ip
try:
r = requests.get(serv_url, timeout=5)
r_sc = r.status_code
if r_sc == 200:
r_data = r.text
json_data = json.loads(r_data)
for key, value in json_data.items():
if key in key_list:
key = key.title()
print(G + '[+]' + C + ' {} : '.format(key) + W + str(value))
else:
print(R + '[-]' + C + ' Failed, Status : ' + W + str(r_sc))
except Exception as exc:
print(R + '[-]' + C + ' Exception : ' + W + str(exc))
def saved_net():
print('\n' + Y + '[!] Sending Request...' + W)
url = 'https://{}:{}/setup/configured_networks'.format(ip, https_port)
try:
r = requests.get(url, headers=https_header, timeout=10, verify=False)
except Exception as exc:
print(R + '[-]' + C + ' Exception : ' + W + str(exc))
return
r_sc = r.status_code
if r_sc == 200:
r_data = r.text
json_data = json.loads(r_data)
for entry in json_data:
print()
for key, value in entry.items():
key = key.replace('_', ' ').title()
print(G + '[+]' + C + ' {} : '.format(key) + W + str(value))
else:
print(R + '[-]' + C + ' Failed, Status : ' + W + str(r_sc))
def wscan():
print('\n' + Y + '[!] Sending Request...' + W)
scan_url = 'https://{}:{}/setup/scan_wifi'.format(ip, https_port)
result_url = 'https://{}:{}/setup/scan_results'.format(ip, https_port)
try:
scan_r = requests.post(scan_url, headers=https_header, timeout=10, verify=False)
except Exception as exc:
print(R + '[-]' + C + ' Exception : ' + W + str(exc))
return
scan_sc = scan_r.status_code
if scan_sc == 200:
print(G + '[+]' + C + ' Action Completed!' + W)
else:
print(R + '[-]' + C + ' Failed, Status : ' + W + str(scan_sc))
print(Y + '[!] Getting Scan Results...' + W)
key_list = ['bssid', 'signal_level', 'ssid']
try:
result_r = requests.get(result_url, headers=https_header, timeout=10, verify=False)
except Exception as exc:
print(R + '[-]' + C + ' Exception : ' + W + str(exc))
return
result_sc = result_r.status_code
if result_sc == 200:
result_data = result_r.text
result_json = json.loads(result_data)
for entry in result_json:
print()
for key, value in entry.items():
if key in key_list:
key = key.replace('_', ' ').title()
print(G + '[+]' + C + ' {} : '.format(key) + W + str(value))
else:
print(R + '[-]' + C + ' Failed, Status : ' + W + str(result_sc))
def wforget():
choice = input('\n' + G + '[+]' + C + ' WPA ID : ' + W)
url = 'https://{}:{}/setup/forget_wifi'.format(ip, https_port)
data = {"wpa_id": int(choice)}
print('\n' + Y + '[!] Sending Request...' + W)
try:
r = requests.post(url, json=data, headers=https_header, timeout=10, verify=False)
except Exception as exc:
print(R + '[-]' + C + ' Exception : ' + W + str(exc))
return
r_sc = r.status_code
if r_sc == 200:
print(G + '[+]' + C + ' Action Completed!' + W)
else:
print(R + '[-]' + C + ' Failed, Status : ' + W + str(r_sc))
def rename():
newname = input('\n' + G + '[+]' + C + ' New Name : ' + W)
url = 'https://{}:{}/setup/set_eureka_info'.format(ip, https_port)
data = {'name' : '{}'.format(newname)}
print(Y + '[!] Sending Request...' + W)
try:
r = requests.post(url, json=data, headers=https_header, timeout=10, verify=False)
except Exception as exc:
print(R + '[-]' + C + ' Exception : ' + W + str(exc))
return
r_sc = r.status_code
if r_sc == 200:
print(G + '[+]' + C + ' Action Completed!' + W)
else:
print(R + '[-]' + C + ' Failed, Status : ' + W + str(r_sc))
def reboot():
print ('\n' + Y + '[!] Sending Request...' + W)
url = 'https://{}:{}/setup/reboot'.format(ip, https_port)
data = {'params' : 'now'}
try:
r = requests.post(url, json=data, headers=https_header, verify=False)
except Exception as e:
print(R + '[-]' + C + ' Exception : ' + W + str(exc))
return
r_sc = r.status_code
if r_sc == 200:
print(G + '[+]' + C + ' Action Completed!' + W)
else:
print(R + '[-]' + C + ' Failed, Status : ' + W + str(r_sc))
def reset():
print ('\n' + Y + '[!] Sending Request...' + W)
reset = 'https://{}:{}/setup/reboot'.format(ip, https_port)
data = {'params' : 'fdr'}
try:
r = requests.post(reset, json=data, headers=https_header, verify=False)
except Exception as exc:
print(R + '[-]' + C + ' Exception : ' + W + str(exc))
return
r_sc = r.status_code
if r_sc == 200:
print(G + '[+]' + C + ' Action Completed!' + W)
else:
print(R + '[-]' + C + ' Failed, Status : ' + W + str(r_sc))
def appkill():
print (G + '[1]' + C + ' YouTube' + W)
print (G + '[2]' + C + ' Netflix' + W)
#print (G + '[3]' + C + ' Google Play Music' + W)
choice = input('\n' + R + '[>] ' + W)
print ('\n' + Y + '[!] Sending Request...' + W)
if choice == '1':
url = 'http://{}:{}/apps/YouTube'.format(ip, http_port)
try:
r = requests.delete(url, headers=http_header, verify=False)
except Exception as exc:
print(R + '[-]' + C + ' Exception : ' + W + str(exc))
return
r_sc = r.status_code
if r_sc == 200:
print(G + '[+]' + C + ' Action Completed!' + W)
else:
print(R + '[-]' + C + ' Failed, Status : ' + W + str(r_sc))
elif choice == '2':
url = 'http://{}:{}/apps/Netflix'.format(ip, http_port)
try:
r = requests.delete(url, headers=http_header, verify=False)
except Exception as exc:
print(R + '[-]' + C + ' Exception : ' + W + str(exc))
return
r_sc = r.status_code
if r_sc == 200:
print(G + '[+]' + C + ' Action Completed!' + W)
else:
print(R + '[-]' + C + ' Failed, Status : ' + W + str(r_sc))
#elif choice == '3':
# print (G + '[+]' + C + ' Killing Google Play Music...')
# url = 'http://{}:{}/apps/GoogleMusic'.format(ip, http_port)
# r = requests.delete(url, headers=header, verify=False)
# r_sc = r.status_code
# if r_sc == 200:
# print(G + '[+]' + C + ' Action Completed!' + W)
# else:
# print(R + '[-]' + C + ' Failed, Status : ' + W + str(r_sc))
def menu():
while True:
print('\n' + Y + '[!] Actions : ' + W + '\n')
print(G + '[1]' + C + ' Device Information' + W)
print(G + '[2]' + C + ' IP Information' + W)
print(G + '[3]' + C + ' Saved Networks' + W)
print(G + '[4]' + C + ' Scan for Networks' + W)
print(G + '[5]' + C + ' Forget WiFi Network' + W)
print(G + '[6]' + C + ' Rename' + W)
print(G + '[7]' + C + ' Kill Apps' + W)
print(G + '[8]' + C + ' Reboot' + W)
print(G + '[9]' + C + ' Factory Reset' + W)
print(G + '[0]' + C + ' Exit' + W)
choice = input('\n' + R + '[>] ' + W)
if choice == '1':
info()
elif choice == '2':
iprecon()
elif choice == '3':
saved_net()
elif choice == '4':
wscan()
elif choice == '5':
wforget()
elif choice == '6':
rename()
elif choice == '7':
appkill()
elif choice == '8':
reboot()
elif choice == '9':
reset()
elif choice == '0':
sys.exit()
else:
print ('\n' + R + '[-]' + C + ' Invalid Choice...Try Again.' + W)
menu()
try:
banner()
ver_check()
print (G + '[+]' + C + ' Target IP : ' + W + ip)
conn_test()
info()
iprecon()
menu()
except KeyboardInterrupt:
print ('\n' + R + '[-]' + C + 'Keyboard Interrupt.' + W)
sys.exit()