You need to sign in or sign up before continuing.
Commit b5347e84 authored by yogesh.m's avatar yogesh.m

update

parent 176f6373
No preview for this file type
No preview for this file type
......@@ -10,6 +10,13 @@ class Packet_Analyzer():
protocols=protocols+"enip:"
if(b'0300' in hex_pkt and hex_pkt[108:112]==b'0300'):
protocols=protocols+"s7comm:"
if (b'810a' in hex_pkt and hex_pkt[84:88] == b'810a'):
protocols = protocols + "bacnet:"
if ((b'8000' in hex_pkt or b'c000' in hex_pkt) and (hex_pkt[84:88] == b'8000' or hex_pkt[84:88] == b'c000')):
print("omron found")
protocols = protocols + "omron:"
if (b'0000' in hex_pkt and hex_pkt[84:88] == b'0000'):
protocols = protocols + "modbus:"
if(hex_pkt[46:48] == b"06"):
protocols=protocols+"tcp"
if (hex_pkt[46:48] == b"11"):
......
......@@ -14,7 +14,7 @@ def discover_modbus_slaves(host,port):
insinventory='INSERT INTO modbus_devices\
(sid,sid_data,device_info,ip_address)\
VALUES\
("'+slave_key+'","'+slave_data[slave_key]["Slave ID data"]+'","'+slave_data[slave_key]["Device identification"]+'","103.94.108.252")'
("'+slave_key+'","'+slave_data[slave_key]["Slave ID data"]+'","'+slave_data[slave_key]["Device identification"]+'","'+host+'")'
query.execute(insinventory)
query.close()
mydb.commit()
\ No newline at end of file
......@@ -55,7 +55,9 @@ def convert_text(pkt):
try:
pa = Packet_Analyzer()
protocols=pa.identify_protocol(inhex)
print(protocols)
ip=pa.get_ip(inhex)
print(ip)
if(ip):
mac=pa.get_mac(inhex)
check_exist=query.execute("SELECT ip_address FROM inventory WHERE ip_address='"+ip+"'").fetchone()
......
This diff is collapsed.
# from pyroute2 import IPRoute
# ip = IPRoute()
# index = ip.link_lookup(ifname='eth0')
# print(index)
# ip.addr('add', index, address='192.168.1.0', mask=24)
# ip.close()
import json
import os
ip='192.168.2.4'.split(".")
res= True if (ip[0]+"."+ip[1]+"."+ip[2] in str(os.popen('ip addr show dev eth0|grep "net "| sed "s/\/24.*//g" | sed "s/inet //g"').read())) else os.system('sudo ip address add '+ip[0]+"."+ip[1]+"."+ip[2]+'.0/24 dev eth0')
print(res)
# print('192.168.0.0' in str(res))
print(ip[0]+"."+ip[1]+"."+ip[2])
\ No newline at end of file
with open('test.json') as f:
s = json.dumps(f.read())
print(s.__len__())
\ No newline at end of file
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