-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlines.py
48 lines (38 loc) · 1.68 KB
/
lines.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
import wp2
def main():
devices = wp2.api.calls.get_devices()
interfaces = {}
for device in devices:
device_ints = wp2.api.calls.get_device_ints(str(device['id']))
for interface in device_ints:
id = interface['id']
interfaces[id] = interface
interfaces[id]['deviceName'] = device['name']
interfaces[id]['clientIps'] = []
services = wp2.api.calls.get_services()
no_interface = []
for service in services:
service_devices = wp2.api.calls.get_service_devices(str(service['id']))
for service_device in service_devices:
interface_id = service_device['interfaceId']
print(str(interface_id) + '----' + str(service_device['id']))
if interfaces.get(interface_id) == None:
no_interface.append(service)
else:
for ip in service['ipRanges']:
interfaces[interface_id]['clientIps'].append(ip)
for interface, interface_info in interfaces.items():
if not interface_info['clientIps']:
continue
else:
with open(r'C:/Users/Kyle/Dropbox/Text Files/lines/' + interface_info['deviceName'] + '_' + interface_info['name'] + '.txt', 'w') as file:
for ip in interface_info['clientIps']:
file.write(ip + '\n')
with open(r'C:/Users/Kyle/Dropbox/Text Files/lines/services_without_interface.txt', 'w') as file:
for service in no_interface:
file.write(str(service['clientId']) + '\n')
for ip in service['ipRanges']:
file.write(ip + '\n')
file.write('\n')
if __name__ == "__main__":
main()