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

update

parent fe3c8c37
...@@ -4,7 +4,7 @@ configuration: ...@@ -4,7 +4,7 @@ configuration:
unifytwin_server_ip_address: https://webhook.site/43393e36-6b04-4481-8485-fad2c7cd549f #Data will be sent back here unifytwin_server_ip_address: https://webhook.site/43393e36-6b04-4481-8485-fad2c7cd549f #Data will be sent back here
edge_device_location : Dalmia Cement edge_device_location : Dalmia Cement
null_loopback: False 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_ip: ['46.4.105.116','172.67.214.157','3.6.115.64','104.21.53.154']
blacklist_dns: ['webhook.site.'] blacklist_dns: ['webhook.site.']
ui_host: 0.0.0.0 ui_host: 0.0.0.0
......
...@@ -10,7 +10,7 @@ import os ...@@ -10,7 +10,7 @@ import os
from helpers.Packet_Analyzer import Packet_Analyzer from helpers.Packet_Analyzer import Packet_Analyzer
import sys import sys
def analyse_protocol(protocols,pkt): def analyse_protocol(protocols, pkt):
try: try:
dev_type = "Unknown" dev_type = "Unknown"
vendor = "Unknown" vendor = "Unknown"
...@@ -18,48 +18,44 @@ def analyse_protocol(protocols,pkt): ...@@ -18,48 +18,44 @@ def analyse_protocol(protocols,pkt):
model = "Unknown" model = "Unknown"
inhex = binascii.hexlify(bytes(pkt)) inhex = binascii.hexlify(bytes(pkt))
pa = Packet_Analyzer() pa = Packet_Analyzer()
print(protocols)
if ("enip" in protocols): if ("enip" in protocols):
print(protocols) print(protocols)
res = eip.get_info(pa.get_ip(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)))
int(pa.get_tcp_port(inhex)) if "tcp" in protocols else int(pa.get_udp_port(inhex)))
if (res): if (res):
dev_type = res['Type'] dev_type = res['Type']
vendor = res['Vendor'] vendor = res['Vendor']
firmware = res['ProductName'] firmware = res['ProductName']
model = res['SerialNumber'] model = res['SerialNumber']
elif ("s7comm" in protocols): 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( 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)))
pa.get_udp_port(inhex))))
if (res): if (res):
dev_type = res['Module Type'] + " " + res['System Name'] dev_type = res['Module Type'] + " " + res['System Name']
vendor = res['Copyright'] vendor = res['Copyright']
firmware = res['Module'] + " " + res['Version'] firmware = res['Module'] + " " + res['Version']
model = res['Serial Number'] model = res['Serial Number']
elif ("bacnet" in protocols): 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( 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)))
pa.get_udp_port(inhex))))
if (res): if (res):
dev_type = res['desc'] dev_type = res['desc'] if not res['desc'] == '' else res['object']
vendor = res['vendorid'] vendor = res['vendorid']
firmware = res['firmware'] firmware = res['firmware']
model = res['model'] model = res['model']
elif ("codesys" in protocols): 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( 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)))) pa.get_udp_port(inhex)))
if (res): if (res):
dev_type = res['OS Name'] dev_type = res['OS Name']
vendor = res['Product Type'] vendor = res['Product Type']
elif ("modbus" in protocols): 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( 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) pa.get_udp_port(inhex)), False)
if (res): if (res):
dev_type = res['Device identification'] dev_type = res['Device identification']
vendor = res['Slave ID data'] vendor = res['Slave ID data']
model = res['sid'] model = res['sid']
elif ("omron" in protocols): 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( 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) pa.get_udp_port(inhex)), False)
if (res): if (res):
dev_type = 'Omron Device' dev_type = 'Omron Device'
vendor = 'Omron Devices' vendor = 'Omron Devices'
......
def protocol_identify(hex_pkt): def protocol_identify(hex_pkt):
if (b'810a' in hex_pkt and hex_pkt[84:88] == b'810a'): if (b'810a' in hex_pkt and hex_pkt[84:88] == b'810a'):
return "bacnet:" return ":bacnet"
\ No newline at end of file
def protocol_identify(hex_pkt): def protocol_identify(hex_pkt):
print(hex_pkt) if (b'6300' in hex_pkt and hex_pkt[108:112] == b'6300'):
if (b'6300' in hex_pkt and hex_pkt[84:88] == b'6300'):
return ":enip" return ":enip"
def protocol_identify(hex_pkt): def protocol_identify(hex_pkt):
if(hex_pkt[108:112] == b'0000'): if(hex_pkt[108:112] == b'0000'):
return ":modbus" return ":modbus"
...@@ -60,7 +60,6 @@ def convert_text(pkt): ...@@ -60,7 +60,6 @@ def convert_text(pkt):
prev_protocols=jo.get_existing_protocols(ip) prev_protocols=jo.get_existing_protocols(ip)
extra_proto=set(protocols.split(':'))-set(prev_protocols.split(':')) extra_proto=set(protocols.split(':'))-set(prev_protocols.split(':'))
if(extra_proto): if(extra_proto):
print(protocols)
dev_type,vendor,firmware,model=protocol_actions.update_protocol(protocols,pkt) dev_type,vendor,firmware,model=protocol_actions.update_protocol(protocols,pkt)
prev_protocols=prev_protocols+':'+str(extra_proto).replace(", ",":").replace("{","").replace("}","").replace("'","") prev_protocols=prev_protocols+':'+str(extra_proto).replace(", ",":").replace("{","").replace("}","").replace("'","")
if(dev_type!="Unknown"): 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