From 5e7d446f792a5fba71606a71f6398e249446b1c7 Mon Sep 17 00:00:00 2001 From: clyhtsuriva Date: Thu, 21 May 2020 09:18:58 +0200 Subject: Beaucoup de changements --- www/html/port_source.py | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 www/html/port_source.py (limited to 'www/html/port_source.py') diff --git a/www/html/port_source.py b/www/html/port_source.py new file mode 100755 index 0000000..e3c8ab6 --- /dev/null +++ b/www/html/port_source.py @@ -0,0 +1,68 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +import mod_python +from fonctions import baseHTML, connexionBD, lien + +def index(req): + req.content_type="text/html" + +#check si ip est bien la + try: + port=req.form["port"] + except KeyError: + mod_python.util.redirect(req, "index.py") + +#check si port a le bon format + try: + float(port) + except ValueError: + mod_python.util.redirect(req, "index.py") + + content=str() + +#sql part + conn=connexionBD() + cur=conn.cursor() + + sql="SELECT * FROM paquet WHERE port_source=%s ORDER BY heure DESC" + sql_count="SELECT COUNT(*) FROM paquet WHERE port_source=%s" + + cur.execute(sql, (port, )) + conn.commit() + data=cur.fetchall() + + cur.execute(sql_count, (port, )) + conn.commit() + count=cur.fetchone() + + conn.close() +#sql part + +#takes every lines from the select + for i in data : + content+=("""""" + +"""""" + str(i[1]) + """""" + +"""""" + str(i[2]) + """""" + +"""""" + lien('ip_source.py?ip=' + str(i[3]), str(i[3])) + """""" + +"""""" + lien('ip_destination.py?ip=' + str(i[4]), str(i[4])) + """""" + +"""""" + lien('port_source.py?port=' + str(i[5]), str(i[5]) ) + """""" + +"""""" + lien('port_destination.py?port=' + str(i[6]), str(i[6]) )+ """""" + +"""""") + +#write the html page + req.write(baseHTML("ATS - " + port,""" +

Port source : """ + port + """

+
+Afin de voir le reverse DNS d'une adresse IP, cliquez sur cette dernière dans le tableau
+

Nombre de paquets venant de """+ port + """ : """+ str(count[0])+ """

+
+ + +""" ++ content + +""" +
HeureProtocoleIP SourceIP DestinationPort SourcePort Destination
+
+ +""")) -- cgit v1.2.3