-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIoT_exploits.py
More file actions
52 lines (45 loc) · 2.4 KB
/
Copy pathIoT_exploits.py
File metadata and controls
52 lines (45 loc) · 2.4 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
# Author: Dr. X
# look for specific model exploits
# count how many exploits of a specific type
# ideally this should be done daily or for historical data
import shodan
import datetime
import Shodan_setup
# Configuration
api = Shodan_setup.get_API_key()
# read devices from file
devices_data, exploits_data, ports_data = Shodan_setup.read_input_files()
file_name = './data/exploits' + str(datetime.datetime.now()) +'.txt'
f = open(file_name, 'w')
# # change list for every run
for dev_item in devices_data:
# # Search Shodan
f.write('Searching for '+ dev_item)
for model in devices_data[dev_item]:
f.write(' and model:' + model + '\n')
for exp_item in exploits_data:
if (exp_item == 'exploits_type'):
for exp_type in exploits_data[exp_item]:
f.write('=================================================================================\n')
f.write('exploit search ' + exp_type + '\n')
f.write('=================================================================================\n')
# Wrap the request in a try/ except block to catch errors
try:
# Search Shodan
exploits = api.exploits.search(model + ' type:' + exp_type)
#windows = api.exploits.search(device + ' type:'+ type + ' platform:windows')
#linux = api.exploits.search(device + ' type:'+ type + ' platform:linux')
#hardware = api.exploits.search(device + ' type:'+ type + ' platform:hardware')
# Show the results
f.write('Exploits found: {}'.format(exploits['total']) + '\n')
#print('Windows found: {}'.format(windows['total']))
#print('Linux found: {}'.format(linux['total']))
#print('Hardware found: {}'.format(hardware['total']))
for exploit in exploits['matches']:
f.write('CVE: {}'.format(exploit['cve']) + '\n')
f.write('Description: {}'.format(exploit['description']) + '\n')
f.write('Platform: {}'.format(exploit['platform']) + '\n')
#print(exploit)
except Exception as e:
print(e)
output_file.close()