From 986552eb0db366f1dfd13c00b01f66c30e9f9c0b Mon Sep 17 00:00:00 2001 From: clyhtsuriva Date: Sun, 19 Apr 2020 23:46:05 +0200 Subject: ajout destination.py --- www/html/destination.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 www/html/destination.py diff --git a/www/html/destination.py b/www/html/destination.py new file mode 100755 index 0000000..cc8713a --- /dev/null +++ b/www/html/destination.py @@ -0,0 +1,55 @@ +#!/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='{}';".format(ip) + cur.execute(sql) + conn.commit() + data=cur.fetchall() + 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("Destination",""" +

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

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