-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathBACnet.py
More file actions
55 lines (35 loc) · 1.01 KB
/
BACnet.py
File metadata and controls
55 lines (35 loc) · 1.01 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
53
54
55
# -*- coding: utf-8 -*-
__author__ = 'KEYONE'
from socket import *
def OneScan(ip, port):
addr=(ip,port) #UDP发包
s = socket(AF_INET,SOCK_DGRAM) #UDP发包
s.connect(addr)
id=['79',#vendor
'78',#vendor_id
'2c',#firmware
'0c',#application
'46',#model
'4d',#object
'4b',#object_id
'1c',#description
'3a',#location
]
cmd="810a001101040005010c0c023fffff19"+id[0] #发送payload,根据需要自行取id
s.sendto(cmd.decode('hex'),addr) #UDP发包
res_list = []
cur_data, _ = s.recvfrom(1024)
for cur_chr in cur_data:
res_list.append(cur_chr)
info = ''.join(res_list[-19:-1]) #取特定字节范围 此处举例 vendor_name 信息 根据取id值改变范围
#print info
s.close()
print "IP: " , ip
print "Port: ", port
print "Vendor Name: " , info
print "Protocol: " , 'bacnet'
if __name__=="__main__":
try:
OneScan('69.70.31.138',47808)
except KeyboardInterrupt:
pass