Commit 32d7bbfd authored by yogesh.m's avatar yogesh.m

update

parent fe3c8c37
......@@ -4,7 +4,7 @@ configuration:
unifytwin_server_ip_address: https://webhook.site/43393e36-6b04-4481-8485-fad2c7cd549f #Data will be sent back here
edge_device_location : Dalmia Cement
null_loopback: False
interfaces: Intel(R) Ethernet Connection (4) I219-LM
interfaces: Wi-Fi
blacklist_ip: ['46.4.105.116','172.67.214.157','3.6.115.64','104.21.53.154']
blacklist_dns: ['webhook.site.']
ui_host: 0.0.0.0
......
......@@ -10,7 +10,7 @@ import os
from helpers.Packet_Analyzer import Packet_Analyzer
import sys
def analyse_protocol(protocols,pkt):
def analyse_protocol(protocols, pkt):
try:
dev_type = "Unknown"
vendor = "Unknown"
......@@ -18,48 +18,44 @@ def analyse_protocol(protocols,pkt):
model = "Unknown"
inhex = binascii.hexlify(bytes(pkt))
pa = Packet_Analyzer()
print(protocols)
if ("enip" in protocols):
print(protocols)
res = eip.get_info(pa.get_ip(inhex),
int(pa.get_tcp_port(inhex)) if "tcp" in protocols else int(pa.get_udp_port(inhex)))
res = eip.get_info(pa.get_ip(inhex),int(pa.get_tcp_port(inhex)) if "tcp" in protocols else int(pa.get_udp_port(inhex)))
if (res):
dev_type = res['Type']
vendor = res['Vendor']
firmware = res['ProductName']
model = res['SerialNumber']
elif ("s7comm" in protocols):
res = s7.get_info(eip.get_info(pa.get_ip(inhex), int(pa.get_tcp_port(inhex)) if "tcp" in protocols else int(
pa.get_udp_port(inhex))))
res = s7.get_info(pa.get_ip(inhex), int(pa.get_tcp_port(inhex)) if "tcp" in protocols else int(pa.get_udp_port(inhex)))
if (res):
dev_type = res['Module Type'] + " " + res['System Name']
vendor = res['Copyright']
firmware = res['Module'] + " " + res['Version']
model = res['Serial Number']
elif ("bacnet" in protocols):
res = bac.get_info(eip.get_info(pa.get_ip(inhex), int(pa.get_tcp_port(inhex)) if "tcp" in protocols else int(
pa.get_udp_port(inhex))))
res = bac.get_info(pa.get_ip(inhex), int(pa.get_tcp_port(inhex)) if "tcp" in protocols else int(pa.get_udp_port(inhex)))
if (res):
dev_type = res['desc']
dev_type = res['desc'] if not res['desc'] == '' else res['object']
vendor = res['vendorid']
firmware = res['firmware']
model = res['model']
elif ("codesys" in protocols):
res = codesys.get_info(eip.get_info(pa.get_ip(inhex), int(pa.get_tcp_port(inhex)) if "tcp" in protocols else int(
pa.get_udp_port(inhex))))
res = codesys.get_info(pa.get_ip(inhex), int(pa.get_tcp_port(inhex)) if "tcp" in protocols else int(
pa.get_udp_port(inhex)))
if (res):
dev_type = res['OS Name']
vendor = res['Product Type']
elif ("modbus" in protocols):
res = modbus.get_info(eip.get_info(pa.get_ip(inhex), int(pa.get_tcp_port(inhex)) if "tcp" in protocols else int(
pa.get_udp_port(inhex))), False)
res = modbus.get_info(pa.get_ip(inhex), int(pa.get_tcp_port(inhex)) if "tcp" in protocols else int(
pa.get_udp_port(inhex)), False)
if (res):
dev_type = res['Device identification']
vendor = res['Slave ID data']
model = res['sid']
elif ("omron" in protocols):
res = omron.get_info(eip.get_info(pa.get_ip(inhex), int(pa.get_tcp_port(inhex)) if "tcp" in protocols else int(
pa.get_udp_port(inhex))), False)
res = omron.get_info(pa.get_ip(inhex), int(pa.get_tcp_port(inhex)) if "tcp" in protocols else int(
pa.get_udp_port(inhex)), False)
if (res):
dev_type = 'Omron Device'
vendor = 'Omron Devices'
......
def protocol_identify(hex_pkt):
if (b'810a' in hex_pkt and hex_pkt[84:88] == b'810a'):
return "bacnet:"
\ No newline at end of file
return ":bacnet"
def protocol_identify(hex_pkt):
print(hex_pkt)
if (b'6300' in hex_pkt and hex_pkt[84:88] == b'6300'):
if (b'6300' in hex_pkt and hex_pkt[108:112] == b'6300'):
return ":enip"
def protocol_identify(hex_pkt):
if(hex_pkt[108:112] == b'0000'):
return ":modbus"
......@@ -60,7 +60,6 @@ def convert_text(pkt):
prev_protocols=jo.get_existing_protocols(ip)
extra_proto=set(protocols.split(':'))-set(prev_protocols.split(':'))
if(extra_proto):
print(protocols)
dev_type,vendor,firmware,model=protocol_actions.update_protocol(protocols,pkt)
prev_protocols=prev_protocols+':'+str(extra_proto).replace(", ",":").replace("{","").replace("}","").replace("'","")
if(dev_type!="Unknown"):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment