#!/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) sql_count="select count(*) from paquet where ip_destination='{}';".format(ip) cur.execute(sql) conn.commit() data=cur.fetchall() cur.execute(sql_count) conn.commit() rec=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("Destination","""

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

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

""" + content + """
HeureProtocoleIP SourceIP DestinationPort SourcePort Destination
"""))