Commit 09b19ede authored by yogesh.m's avatar yogesh.m

update

parent 98078998
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (security-management (offline))" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
<component name="PyCharmProfessionalAdvertiser"> <component name="PyCharmProfessionalAdvertiser">
<option name="shown" value="true" /> <option name="shown" value="true" />
</component> </component>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" /> <excludeFolder url="file://$MODULE_DIR$/venv" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
<component name="PyDocumentationSettings"> <component name="PyDocumentationSettings">
......
No preview for this file type
No preview for this file type
scapy==2.4.5 scapy==2.4.5
mac-vendor-lookup==0.1.12
PyYAML==6.0 PyYAML==6.0
flask==2.2.2 flask==2.2.2
requests==2.28.2 requests==2.28.2
\ No newline at end of file
...@@ -44,7 +44,7 @@ def start_sniff(): ...@@ -44,7 +44,7 @@ def start_sniff():
process.start() process.start()
else: else:
process.start() process.start()
status="listening on "+interface+"" status = "listening on "+interface+""
return hello_world() return hello_world()
@app.route('/stop_sniff',methods = ['POST', 'GET']) @app.route('/stop_sniff',methods = ['POST', 'GET'])
......
...@@ -64,7 +64,6 @@ def convert_text(pkt): ...@@ -64,7 +64,6 @@ def convert_text(pkt):
mac=pa.get_mac(inhex) mac=pa.get_mac(inhex)
check_exist=query.execute("SELECT ip_address FROM inventory WHERE ip_address='"+ip+"'").fetchone() check_exist=query.execute("SELECT ip_address FROM inventory WHERE ip_address='"+ip+"'").fetchone()
if(not check_exist): if(not check_exist):
# add_subnet= True if (ip in str(os.popen('ip addr |grep inet| grep -v "::"| sed "s/inet //g"| sed -e "s/\/.*//g"').read())) else os.system("echo "+ip+" | grep -qa '^10.\|^192\.168\|^172\.16\|^2.2.' && sudo ip address add "+ip+".100/24 dev "+interfaces)
dev_type,vendor,firmware,model=protocol_actions.analyse_protocol(protocols,pkt) dev_type,vendor,firmware,model=protocol_actions.analyse_protocol(protocols,pkt)
insinventory='INSERT INTO inventory\ insinventory='INSERT INTO inventory\
(ip_address,name,last_activity,type,protocols,mac_address,vendor,firmware_version,model,operating_system,plant)\ (ip_address,name,last_activity,type,protocols,mac_address,vendor,firmware_version,model,operating_system,plant)\
...@@ -77,7 +76,6 @@ def convert_text(pkt): ...@@ -77,7 +76,6 @@ def convert_text(pkt):
prev_protocols=query.execute("SELECT protocols FROM inventory WHERE ip_address='"+ip+"'").fetchone()[0] prev_protocols=query.execute("SELECT protocols FROM inventory WHERE ip_address='"+ip+"'").fetchone()[0]
extra_proto=set(protocols.split(':'))-set(prev_protocols.split(':')) extra_proto=set(protocols.split(':'))-set(prev_protocols.split(':'))
if(extra_proto): if(extra_proto):
# add_subnet= True if (ip in str(os.popen('ip addr |grep inet| grep -v "::"| sed "s/inet //g"| sed -e "s/\/.*//g"').read())) else os.system("echo "+ip+" | grep -qa '^10.\|^192\.168\|^172\.16\|^2.2.' && sudo ip address add "+ip+".100/24 dev "+interfaces)
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"):
...@@ -102,9 +100,6 @@ def convert_text(pkt): ...@@ -102,9 +100,6 @@ def convert_text(pkt):
mydb.commit() mydb.commit()
pass pass
except Exception as e: except Exception as e:
# exc_type, exc_obj, exc_tb = sys.exc_info()
# fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
# print(exc_type, fname, exc_tb.tb_lineno)
pass pass
def gasmi_api(pkt): def gasmi_api(pkt):
......
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