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/affiche-tab.py | 10 +++--- www/html/affiche-tas.py | 12 +++---- www/html/bilan.py | 35 +++++++++++++++----- www/html/destination.py | 66 ------------------------------------- www/html/filtrage.py | 4 +-- www/html/fonctions.py | 2 +- www/html/index.py | 24 +++++++------- www/html/ip_destination.py | 78 ++++++++++++++++++++++++++++++++++++++++++++ www/html/ip_source.py | 77 +++++++++++++++++++++++++++++++++++++++++++ www/html/port_destination.py | 68 ++++++++++++++++++++++++++++++++++++++ www/html/port_source.py | 68 ++++++++++++++++++++++++++++++++++++++ www/html/style.css | 5 +-- www/html/syntaxe.py | 2 +- 13 files changed, 348 insertions(+), 103 deletions(-) delete mode 100755 www/html/destination.py create mode 100755 www/html/ip_destination.py create mode 100755 www/html/ip_source.py create mode 100755 www/html/port_destination.py create mode 100755 www/html/port_source.py diff --git a/www/html/affiche-tab.py b/www/html/affiche-tab.py index 83512dc..e36c997 100644 --- a/www/html/affiche-tab.py +++ b/www/html/affiche-tab.py @@ -18,14 +18,14 @@ def index(req): data=cur.fetchall() conn.close() - for i in data: + for i in data : content+=("""""" + """""" + str(i[1]) + """""" + """""" + str(i[2]) + """""" + -"""""" + str(i[3]) + """""" + -"""""" + lien('destination.py?ip=' + str(i[4]), str(i[4])) + """""" + -"""""" + str(i[5]) + """""" + -"""""" + str(i[6]) + """""" + +"""""" + 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])) + """""" + """""") req.write(""" diff --git a/www/html/affiche-tas.py b/www/html/affiche-tas.py index 4c63c3a..106d3a5 100644 --- a/www/html/affiche-tas.py +++ b/www/html/affiche-tas.py @@ -18,15 +18,15 @@ def index(req): data=cur.fetchall() conn.close() - - for i in data: + + for i in data : content+=("""""" + """""" + str(i[1]) + """""" + """""" + str(i[2]) + """""" + -"""""" + str(i[3]) + """""" + -"""""" + lien('destination.py?ip=' + str(i[4]), str(i[4])) + """""" + -"""""" + str(i[5]) + """""" + -"""""" + str(i[6]) + """""" + +"""""" + 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])) + """""" + """""") req.write(""" diff --git a/www/html/bilan.py b/www/html/bilan.py index a85fe98..3ebbbe7 100755 --- a/www/html/bilan.py +++ b/www/html/bilan.py @@ -48,16 +48,36 @@ def index(req): for k in suff: nom="each_"+j+"_"+k for i in globals()[nom]: - globals()[j+k]+=(""" -""" + str(i[0]) + """ + if j=="ip" and k=="dst": + globals()[j+k]+=(""" +""" +lien('ip_destination.py?ip='+str(i[0]), str(i[0]) )+ """ """ + str(i[1]) + """ - """) + """) + + elif j=="port" and k=="dst": + globals()[j+k]+=(""" +""" +lien('port_destination.py?port='+str(i[0]), str(i[0]) )+ """ +""" + str(i[1]) + """ + """) + + elif j=="ip" and k=="src": + globals()[j+k]+=(""" +""" + lien('ip_source.py?ip='+str(i[0]), str(i[0]) ) + """ +""" + str(i[1]) + """ + """) + else: + globals()[j+k]+=(""" +""" + lien('port_source.py?port='+str(i[0]), str(i[0]) ) + """ +""" + str(i[1]) + """ + """) #write the html page - req.write(baseHTML("ATS-Project",""" + req.write(baseHTML("ATS - Bilan","""

Bilan

+
+Afin de voir le reverse DNS d'une adresse IP, cliquez sur cette dernière dans le tableau
-
+
"""+str(ipdst)+""" @@ -83,8 +103,7 @@ def index(req): """+str(portsrc)+"""
IP destinationRecurrence
Port sourceReccurrence
- - - +
+ """ )) diff --git a/www/html/destination.py b/www/html/destination.py deleted file mode 100755 index 062ab2f..0000000 --- a/www/html/destination.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -import mod_python -from fonctions import baseHTML, connexionBD, lien -import socket - -def index(req): - req.content_type="text/html" - -#check si ip est bien la - try: - ip=req.form["ip"] - except KeyError: - mod_python.util.redirect(req, "index.py") - -#check si ip a le bon format - try: - socket.inet_aton(ip) - except socket.error: - mod_python.util.redirect(req, "index.py") - - content=str() - -#sql part - conn=connexionBD() - cur=conn.cursor() - - sql="SELECT * FROM paquet WHERE ip_destination=%s ORDER BY heure DESC" - sql_count="SELECT COUNT(*) FROM paquet WHERE ip_destination=%s" - - cur.execute(sql, (ip, )) - conn.commit() - data=cur.fetchall() - - cur.execute(sql_count, (ip, )) - 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]) + """""" + -"""""" + str(i[3]) + """""" + -"""""" + lien('destination.py?ip=' + str(i[4]), str(i[4])) + """""" + -"""""" + str(i[5]) + """""" + -"""""" + str(i[6]) + """""" + -"""""") - -#write the html page - req.write(baseHTML(ip,""" -

IP Destination : """ + ip + """

-

Nombre de paquets en destination de """+ ip + """ : """+ str(count[0])+ """

-
- - -""" -+ content + -""" -
HeureProtocoleIP SourceIP DestinationPort SourcePort Destination
-
-""")) diff --git a/www/html/filtrage.py b/www/html/filtrage.py index b86e264..bbc4bd2 100755 --- a/www/html/filtrage.py +++ b/www/html/filtrage.py @@ -9,10 +9,10 @@ def index(req): content=str() #write the html page - req.write(baseHTML("Filtrage",""" + req.write(baseHTML("ATS - Filtrage","""

Filtrage

-Pour voir le nombre de paquets en destination d'une adresse IP, cliquez sur cette dernière dans le tableau
+Afin de voir le reverse DNS d'une adresse IP, cliquez sur cette dernière dans le tableau Filtre
diff --git a/www/html/fonctions.py b/www/html/fonctions.py index 8fce43b..317e24e 100755 --- a/www/html/fonctions.py +++ b/www/html/fonctions.py @@ -12,7 +12,7 @@ def baseHTML(title,body):

Nombre total de paquets : """+ count +"""

Pour afficher toute la table, cliquez
diff --git a/www/html/ip_destination.py b/www/html/ip_destination.py new file mode 100755 index 0000000..f93b13d --- /dev/null +++ b/www/html/ip_destination.py @@ -0,0 +1,78 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +import mod_python +from fonctions import baseHTML, connexionBD, lien +import socket + +def index(req): + req.content_type="text/html" + +#partie socket + +#check si ip est bien la + try: + ip=req.form["ip"] + except KeyError: + mod_python.util.redirect(req, "index.py") + +#check si ip a le bon format + try: + socket.inet_aton(ip) + except socket.error: + mod_python.util.redirect(req, "index.py") + + content=str() + +#reverse dns + try: + rdns=socket.gethostbyaddr(ip)[0] + except socket.herror: + rdns="Non connu" + +#partie socket + +#sql part + conn=connexionBD() + cur=conn.cursor() + + sql="SELECT * FROM paquet WHERE ip_destination=%s ORDER BY heure DESC" + sql_count="SELECT COUNT(*) FROM paquet WHERE ip_destination=%s" + + cur.execute(sql, (ip, )) + conn.commit() + data=cur.fetchall() + + cur.execute(sql_count, (ip, )) + 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 - " + ip,""" +

IP destination : """ + ip + """

+

Nombre de paquets en destination de """+ ip + """ : """+ str(count[0])+ """

+

Reverse DNS : """+rdns+"""

+

+ + +""" ++ content + +""" +
HeureProtocoleIP SourceIP DestinationPort SourcePort Destination
+
+""")) diff --git a/www/html/ip_source.py b/www/html/ip_source.py new file mode 100755 index 0000000..861ea9a --- /dev/null +++ b/www/html/ip_source.py @@ -0,0 +1,77 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +import mod_python +from fonctions import baseHTML, connexionBD, lien +import socket + +def index(req): + req.content_type="text/html" + +#partie socket + +#check si ip est bien la + try: + ip=req.form["ip"] + except KeyError: + mod_python.util.redirect(req, "index.py") + +#check si ip a le bon format + try: + socket.inet_aton(ip) + except socket.error: + mod_python.util.redirect(req, "index.py") + + content=str() + +#reverse dns + try: + rdns=socket.gethostbyaddr(ip)[0] + except socket.herror: + rdns="Non connu" + +#partie socket + +#sql part + conn=connexionBD() + cur=conn.cursor() + + sql="SELECT * FROM paquet WHERE ip_source=%s ORDER BY heure DESC" + sql_count="SELECT COUNT(*) FROM paquet WHERE ip_source=%s" + + cur.execute(sql, (ip, )) + conn.commit() + data=cur.fetchall() + + cur.execute(sql_count, (ip, )) + 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 - " + ip,""" +

IP source : """ + ip + """

+

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

+

Reverse DNS : """+rdns+"""

+

+ + +""" ++ content + +""" +
HeureProtocoleIP SourceIP DestinationPort SourcePort Destination
+
+""")) diff --git a/www/html/port_destination.py b/www/html/port_destination.py new file mode 100755 index 0000000..cae488d --- /dev/null +++ b/www/html/port_destination.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_destination=%s ORDER BY heure DESC" + sql_count="SELECT COUNT(*) FROM paquet WHERE port_destination=%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 destination : """ + port + """

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

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

+
+ + +""" ++ content + +""" +
HeureProtocoleIP SourceIP DestinationPort SourcePort Destination
+
+ +""")) 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
+
+ +""")) diff --git a/www/html/style.css b/www/html/style.css index ae32cf5..aef1593 100755 --- a/www/html/style.css +++ b/www/html/style.css @@ -85,6 +85,7 @@ th{ display: inline-table; } -.floatTable{ - float: left; +#bilan_tab{ + width: 60%; + margin: 0 auto; } diff --git a/www/html/syntaxe.py b/www/html/syntaxe.py index 8f941b5..28c3967 100755 --- a/www/html/syntaxe.py +++ b/www/html/syntaxe.py @@ -9,7 +9,7 @@ def index(req): content=str() #write the html page - req.write(baseHTML("ATS-Project",""" + req.write(baseHTML("ATS - Syntaxe","""

Syntaxe

La """+lien('syntaxe.py','syntaxe')+""" pour utiliser les filtres disponibles sur la page """+lien('filtrage.py','filtrage')+""" est la suivante :

<colonne>='<valeur>'


-- cgit v1.2.3