Commit e6d2f399 authored by yogesh.m's avatar yogesh.m

update

parent 034b2b56
This diff is collapsed.
This diff is collapsed.
configuration:
threads: 20 #number of threads to scan at once
transfer frequency: 1 #how frequent the scan needs to be
unifytwin_server_ip_address: https://webhook.site/34c9fd4a-8924-41ab-a01f-383ef36db96b #Data will be sent back here
unifytwin_server_ip_address: https://webhook.site/eaabfef1-1764-4d97-9acb-dfb887923dd7 #Data will be sent back here
edge_device_location : Dalmia Cement
null_loopback: False
interfaces: Wi-Fi
......@@ -9,4 +9,7 @@ configuration:
blacklist_dns: ['webhook.site.']
ui_host: 127.0.0.1
ui_port: 8081
active_scan: True
active_scan_start: 192.168.1.1
active_scan_end: 192.168.1.10
transmit_assets: True
\ No newline at end of file
......@@ -5,6 +5,7 @@ from protocol_enumerators import modbus
from protocol_enumerators import omron
import sqlite3
from datetime import datetime
import json_operations
mydb=sqlite3.connect("assets.db",check_same_thread=False)
......@@ -24,45 +25,35 @@ def map_ports(ip,port):
vendor=res['Copyright']
firmware=res['Module']+" "+res['Version']
model=res['Serial Number']
updateproto='UPDATE inventory SET protocols=(select protocols from inventory where ip_address="'+ip+'")||":"||"s7comm",last_activity="'+datetime.now().strftime("%d-%m-%y %H:%M:%S")+'",type="'+dev_type+'",vendor="'+vendor+'",firmware_version="'+firmware+'",model="'+model+'" WHERE ip_address="'+ip+'"'
query.execute(updateproto)
mydb.commit()
query.close()
json_operations.update_asset(ip,"s7comm",datetime.now().strftime("%d-%m-%y %H:%M:%S"),dev_type,vendor,firmware,model)
#updateproto='UPDATE inventory SET protocols=(select protocols from inventory where ip_address="'+ip+'")||":"||"s7comm",last_activity="'+datetime.now().strftime("%d-%m-%y %H:%M:%S")+'",type="'+dev_type+'",vendor="'+vendor+'",firmware_version="'+firmware+'",model="'+model+'" WHERE ip_address="'+ip+'"'
elif(i.__name__=="protocol_enumerators.ethernetip_enum"):
dev_type=res['Type']
vendor=res['Vendor']
firmware=res['ProductName']
model=res['SerialNumber']
updateproto='UPDATE inventory SET protocols=(select protocols from inventory where ip_address="'+ip+'")||":"||"enip",last_activity="'+datetime.now().strftime("%d-%m-%y %H:%M:%S")+'",type="'+dev_type+'",vendor="'+vendor+'",firmware_version="'+firmware+'",model="'+model+'" WHERE ip_address="'+ip+'"'
query.execute(updateproto)
mydb.commit()
query.close()
json_operations.update_asset(ip, "enip", datetime.now().strftime("%d-%m-%y %H:%M:%S"), dev_type,vendor, firmware, model)
#updateproto='UPDATE inventory SET protocols=(select protocols from inventory where ip_address="'+ip+'")||":"||"enip",last_activity="'+datetime.now().strftime("%d-%m-%y %H:%M:%S")+'",type="'+dev_type+'",vendor="'+vendor+'",firmware_version="'+firmware+'",model="'+model+'" WHERE ip_address="'+ip+'"'
elif(i.__name__=="protocol_enumerators.bacnet"):
dev_type=res['desc']
vendor=res['vendorid']
firmware=res['firmware']
model=res['model']
updateproto='UPDATE inventory SET protocols=(select protocols from inventory where ip_address="'+ip+'")||":"||"bacnet",last_activity="'+datetime.now().strftime("%d-%m-%y %H:%M:%S")+'",type="'+dev_type+'",vendor="'+vendor+'",firmware_version="'+firmware+'",model="'+model+'" WHERE ip_address="'+ip+'"'
query.execute(updateproto)
mydb.commit()
query.close()
json_operations.update_asset(ip, "bacnet", datetime.now().strftime("%d-%m-%y %H:%M:%S"), dev_type, vendor,firmware, model)
#updateproto='UPDATE inventory SET protocols=(select protocols from inventory where ip_address="'+ip+'")||":"||"bacnet",last_activity="'+datetime.now().strftime("%d-%m-%y %H:%M:%S")+'",type="'+dev_type+'",vendor="'+vendor+'",firmware_version="'+firmware+'",model="'+model+'" WHERE ip_address="'+ip+'"'
elif(i.__name__=="protocol_enumerators.modbus"):
dev_type=res['Device identification']
vendor=res['Slave ID data']
model=res['sid']
updateproto='UPDATE inventory SET protocols=(select protocols from inventory where ip_address="'+ip+'")||":"||"modbus",last_activity="'+datetime.now().strftime("%d-%m-%y %H:%M:%S")+'",type="'+dev_type+'",vendor="'+vendor+'",firmware_version="'+firmware+'",model="'+model+'" WHERE ip_address="'+ip+'"'
query.execute(updateproto)
mydb.commit()
query.close()
json_operations.update_asset(ip, "modbus", datetime.now().strftime("%d-%m-%y %H:%M:%S"), dev_type, vendor,"Unknown", model)
#updateproto='UPDATE inventory SET protocols=(select protocols from inventory where ip_address="'+ip+'")||":"||"modbus",last_activity="'+datetime.now().strftime("%d-%m-%y %H:%M:%S")+'",type="'+dev_type+'",vendor="'+vendor+'",firmware_version="'+firmware+'",model="'+model+'" WHERE ip_address="'+ip+'"'
elif(i.__name__=="protocol_enumerators.omron"):
dev_type='Omron Device'
vendor='Omron Devices'
firmware=res['Controller Version']
model=res['Controller Model']
updateproto='UPDATE inventory SET protocols=(select protocols from inventory where ip_address="'+ip+'")||":"||"modbus",last_activity="'+datetime.now().strftime("%d-%m-%y %H:%M:%S")+'",type="'+dev_type+'",vendor="'+vendor+'",firmware_version="'+firmware+'",model="'+model+'" WHERE ip_address="'+ip+'"'
query.execute(updateproto)
mydb.commit()
query.close()
break
map_ports('87.59.100.251',9600)
\ No newline at end of file
json_operations.update_asset(ip, "omron", datetime.now().strftime("%d-%m-%y %H:%M:%S"), dev_type, vendor,firmware, model)
#updateproto='UPDATE inventory SET protocols=(select protocols from inventory where ip_address="'+ip+'")||":"||"modbus",last_activity="'+datetime.now().strftime("%d-%m-%y %H:%M:%S")+'",type="'+dev_type+'",vendor="'+vendor+'",firmware_version="'+firmware+'",model="'+model+'" WHERE ip_address="'+ip+'"'
break
\ No newline at end of file
......@@ -5,6 +5,7 @@ import binascii
import yaml
import sqlite3
from datetime import datetime
import active_scan
import protocol_actions
import threading
import requests
......@@ -103,8 +104,11 @@ def network_sniffing_local_storage(pkt):
ti.start()
def start_sniff(iface=interfaces):
sniff(iface=iface,prn=network_sniffing_local_storage)
act_scn=active_scan.Active_Scan()
ti = threading.Thread(target=act_scn.scan_for_assets)
ti.start()
sniff(iface=iface,prn=network_sniffing_local_storage)
if __name__=="__main__":
start_sniff()
\ No newline at end of file
start_sniff()
\ 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