-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest1.py
More file actions
32 lines (26 loc) · 730 Bytes
/
test1.py
File metadata and controls
32 lines (26 loc) · 730 Bytes
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
import sys
import requests
import base64
try:
requests.packages.urllib3.disable_warnings()
except:
pass
D42_USER = 'admin'
D42_PWD = 'adm!nd42'
D42_URL = 'http://localhost:8000'
headers = {
'Authorization': 'Basic ' + base64.b64encode(D42_USER + ':' + D42_PWD),
'Content-Type': 'application/x-www-form-urlencoded'
}
f = '/api/1.0/devices/'
url = D42_URL+f
response = requests.get(url,headers=headers, verify=False)
raw = response.json()
devices = [x['device_id'] for x in raw['Devices']]
total = len(devices)
i = 1
for device in devices:
print '\t[-] Device ID: %s [%d of %d]' % (device, i, total)
f = '/api/1.0/devices/%s/' % device
url = D42_URL + f
i+=1