-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathdm_rockso
71 lines (54 loc) · 1.72 KB
/
dm_rockso
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
#!/usr/bin/env python3
import asyncio
import socket
import ipaddress
import sys
async def main(targets):
loop = asyncio.get_running_loop()
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def reader():
data,addr = sock.recvfrom(4096)
if len(data) < 4:
return
#print(data)
if data[0:2] != b'\x06\x00':
return
if bytes([data[3]]) == b'\x86':
#print('ack')
return
if bytes([data[3]]) != b'\x06':
return
iana_number = int.from_bytes(data[4:8], byteorder='big')
if iana_number != 343: # intel iana number
return
if bytes([data[8]]) != b'\x40':
return
datalen = data[11]
amt_info = data[12:12+datalen]
amt_version = '{}.{}'.format(amt_info[6] >> 4, amt_info[6] & 0x0f)
if amt_info[4] == 0:
amt_provisioned = "off"
else:
amt_provisioned = "on "
#9.5
#00000157000095000020000000000000
# 9.5 provisioned
#00000157426095020020000000000000
# 11.0
#000001570000b0000020000000000000
# 11.8
#000001570000b8000020000000000000
print('[{}] {} : version {}'.format(amt_provisioned, addr[0], amt_version))
loop.add_reader(sock, reader)
probe = bytes(b'\x06\x00\x00\x06' + b'\x00\x00\x11\xbe\x80\x00\x00\x00')
if '/' in targets:
ip_generator = ipaddress.IPv4Network(targets, strict=False)
for ip in ip_generator.hosts():
sock.sendto(probe, (str(ip), 623))
else:
sock.sendto(probe, (targets, 623))
await asyncio.sleep(5)
if(len(sys.argv) != 2):
print('Usage: dm_rockso <ipaddress or cidr range>')
exit(1)
asyncio.run(main(sys.argv[1]))