aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclyhtsuriva <clyhtsuriva@gmail.com>2020-05-21 09:18:58 +0200
committerclyhtsuriva <clyhtsuriva@gmail.com>2020-05-21 09:18:58 +0200
commit5e7d446f792a5fba71606a71f6398e249446b1c7 (patch)
tree83a1f8cd2a89982e9251d3814bb6a2c2021fa215
parentec99f84d8285a9439b726da67eb0422249b9e185 (diff)
Beaucoup de changements
-rw-r--r--www/html/affiche-tab.py10
-rw-r--r--www/html/affiche-tas.py12
-rwxr-xr-xwww/html/bilan.py35
-rwxr-xr-xwww/html/filtrage.py4
-rwxr-xr-xwww/html/fonctions.py2
-rwxr-xr-xwww/html/index.py24
-rwxr-xr-xwww/html/ip_destination.py (renamed from www/html/destination.py)28
-rwxr-xr-xwww/html/ip_source.py77
-rwxr-xr-xwww/html/port_destination.py68
-rwxr-xr-xwww/html/port_source.py68
-rwxr-xr-xwww/html/style.css5
-rwxr-xr-xwww/html/syntaxe.py2
12 files changed, 290 insertions, 45 deletions
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+=("""<tr>""" +
"""<td>""" + str(i[1]) + """</td>""" +
"""<td>""" + str(i[2]) + """</td>""" +
-"""<td>""" + str(i[3]) + """</td>""" +
-"""<td>""" + lien('destination.py?ip=' + str(i[4]), str(i[4])) + """</td>""" +
-"""<td>""" + str(i[5]) + """</td>""" +
-"""<td>""" + str(i[6]) + """</td>""" +
+"""<td>""" + lien('ip_source.py?ip=' + str(i[3]), str(i[3])) + """</td>""" +
+"""<td>""" + lien('ip_destination.py?ip=' + str(i[4]), str(i[4])) + """</td>""" +
+"""<td>""" + lien('port_source.py?port=' + str(i[5]), str(i[5])) + """</td>""" +
+"""<td>""" + lien('port_destination.py?port=' + str(i[6]), str(i[6])) + """</td>""" +
"""</tr>""")
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+=("""<tr>""" +
"""<td>""" + str(i[1]) + """</td>""" +
"""<td>""" + str(i[2]) + """</td>""" +
-"""<td>""" + str(i[3]) + """</td>""" +
-"""<td>""" + lien('destination.py?ip=' + str(i[4]), str(i[4])) + """</td>""" +
-"""<td>""" + str(i[5]) + """</td>""" +
-"""<td>""" + str(i[6]) + """</td>""" +
+"""<td>""" + lien('ip_source.py?ip=' + str(i[3]), str(i[3])) + """</td>""" +
+"""<td>""" + lien('ip_destination.py?ip=' + str(i[4]), str(i[4])) + """</td>""" +
+"""<td>""" + lien('port_source.py?port=' + str(i[5]), str(i[5])) + """</td>""" +
+"""<td>""" + lien('port_destination.py?port=' + str(i[6]), str(i[6])) + """</td>""" +
"""</tr>""")
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]+=("""<tr>
-<td>""" + str(i[0]) + """</td>
+ if j=="ip" and k=="dst":
+ globals()[j+k]+=("""<tr>
+<td>""" +lien('ip_destination.py?ip='+str(i[0]), str(i[0]) )+ """</td>
<td>""" + str(i[1]) + """</td>
- </tr>""")
+ </tr>""")
+
+ elif j=="port" and k=="dst":
+ globals()[j+k]+=("""<tr>
+<td>""" +lien('port_destination.py?port='+str(i[0]), str(i[0]) )+ """</td>
+<td>""" + str(i[1]) + """</td>
+ </tr>""")
+
+ elif j=="ip" and k=="src":
+ globals()[j+k]+=("""<tr>
+<td>""" + lien('ip_source.py?ip='+str(i[0]), str(i[0]) ) + """</td>
+<td>""" + str(i[1]) + """</td>
+ </tr>""")
+ else:
+ globals()[j+k]+=("""<tr>
+<td>""" + lien('port_source.py?port='+str(i[0]), str(i[0]) ) + """</td>
+<td>""" + str(i[1]) + """</td>
+ </tr>""")
#write the html page
- req.write(baseHTML("ATS-Project","""
+ req.write(baseHTML("ATS - Bilan","""
<h1>Bilan</h1>
+<div id="tip" style="display:block;">
+Afin de voir le reverse DNS d'une adresse IP, cliquez sur cette dernière dans le tableau <button id="ok" onclick="toggle_div(this,'tip');">OK</button></div>
<ul>
<li>Nombre total de paquets : <b>"""+total+"""</b></li>
<li>Nombre total de paquets depuis 1h : <b>"""+total_uneheure+"""</b></li>
@@ -66,7 +86,7 @@ def index(req):
<li>Nombre total de ports source differents : <b>"""+total_port_src+"""</b></li>
<li>Nombre total de ports destination differents : <b>"""+total_port_dst+"""</b></li>
</ul>
-<br/>
+<div id="bilan_tab">
<table class="inlineTable">
<tr><th>IP destination</th><th>Recurrence</th></tr>
"""+str(ipdst)+"""
@@ -83,8 +103,7 @@ def index(req):
<tr><th>Port source</th><th>Reccurrence</th></tr>
"""+str(portsrc)+"""
</table>
-<canvas id="protocole" width="20vh" height="40vw"></canvas>
-<script src="/Chart.js"></script>
-<script src="/pie.js"></script>
+</div>
+<script src="tip.js"></script>
"""
))
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","""
<h1>Filtrage</h1>
<div id="tip" style="display:block;">
-Pour voir le nombre de paquets en destination d'une adresse IP, cliquez sur cette dernière dans le tableau <button id="ok" onclick="toggle_div(this,'tip');">OK</button></div>
+Afin de voir le reverse DNS d'une adresse IP, cliquez sur cette dernière dans le tableau <button id="ok" onclick="toggle_div(this,'tip');">OK</button></div>
<b>Filtre</b>
<input type="text" id="condition" onkeyup="cherche()">
<div id="tab">
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):
</head>
<body>
<nav>
- <a href="/">Index</a>
+ <a href="/">Accueil</a>
<a href="/filtrage.py">Filtrage</a>
<a href="/syntaxe.py">Syntaxe</a>
<a href="/bilan.py">Bilan</a>
diff --git a/www/html/index.py b/www/html/index.py
index 446a90e..60bf4e5 100755
--- a/www/html/index.py
+++ b/www/html/index.py
@@ -29,20 +29,20 @@ def index(req):
#takes every lines from the select
for i in data :
- content+=("""<tr>
-<td>""" + str(i[1]) + """</td>
-<td>""" + str(i[2]) + """</td>
-<td>""" + str(i[3]) + """</td>
-<td>""" + lien('destination.py?ip=' + str(i[4]), str(i[4])) + """</td>
-<td>""" + str(i[5]) + """</td>
-<td>""" + str(i[6]) + """</td>
- </tr>""")
-
+ content+=("""<tr>""" +
+"""<td>""" + str(i[1]) + """</td>""" +
+"""<td>""" + str(i[2]) + """</td>""" +
+"""<td>""" + lien('ip_source.py?ip=' + str(i[3]), str(i[3])) + """</td>""" +
+"""<td>""" + lien('ip_destination.py?ip=' + str(i[4]), str(i[4])) + """</td>""" +
+"""<td>""" + lien('port_source.py?port=' + str(i[5]), str(i[5])) + """</td>""" +
+"""<td>""" + lien('port_destination.py?port=' + str(i[6]), str(i[6])) + """</td>""" +
+"""</tr>""")
+
#write the html page
- req.write(baseHTML("ATS-Project","""
-<h1>ATS-Project</h1>
+ req.write(baseHTML("ATS - Accueil","""
+<h1>ATS</h1>
<div id="tip" style="display:block;">
-Pour voir le nombre de paquets en destination d'une adresse IP, cliquez sur cette dernière dans le tableau <button id="ok" onclick="toggle_div(this,'tip');">OK</button></div>
+Afin de voir le reverse DNS d'une adresse IP, cliquez sur cette dernière dans le tableau <button id="ok" onclick="toggle_div(this,'tip');">OK</button></div>
<p>Nombre total de paquets : <b>"""+ count +"""</b></p>
<em>Pour afficher toute la table, cliquez</em>
<button id="afficheTas" onclick="affiche_tas()">ICI</button><br/>
diff --git a/www/html/destination.py b/www/html/ip_destination.py
index 062ab2f..f93b13d 100755
--- a/www/html/destination.py
+++ b/www/html/ip_destination.py
@@ -7,7 +7,9 @@ import socket
def index(req):
req.content_type="text/html"
-
+
+#partie socket
+
#check si ip est bien la
try:
ip=req.form["ip"]
@@ -22,6 +24,14 @@ def index(req):
content=str()
+#reverse dns
+ try:
+ rdns=socket.gethostbyaddr(ip)[0]
+ except socket.herror:
+ rdns="<em>Non connu</em>"
+
+#partie socket
+
#sql part
conn=connexionBD()
cur=conn.cursor()
@@ -45,16 +55,18 @@ def index(req):
content+=("""<tr>""" +
"""<td>""" + str(i[1]) + """</td>""" +
"""<td>""" + str(i[2]) + """</td>""" +
-"""<td>""" + str(i[3]) + """</td>""" +
-"""<td>""" + lien('destination.py?ip=' + str(i[4]), str(i[4])) + """</td>""" +
-"""<td>""" + str(i[5]) + """</td>""" +
-"""<td>""" + str(i[6]) + """</td>""" +
+"""<td>""" + lien('ip_source.py?ip=' + str(i[3]), str(i[3])) + """</td>""" +
+"""<td>""" + lien('ip_destination.py?ip=' + str(i[4]), str(i[4])) + """</td>""" +
+"""<td>""" + lien('port_source.py?port=' + str(i[5]), str(i[5])) + """</td>""" +
+"""<td>""" + lien('port_destination.py?port=' + str(i[6]), str(i[6])) + """</td>""" +
"""</tr>""")
-
+
+
#write the html page
- req.write(baseHTML(ip,"""
-<h1>IP Destination : """ + ip + """</h1>
+ req.write(baseHTML("ATS - " + ip,"""
+<h1>IP destination : """ + ip + """</h1>
<p>Nombre de paquets en destination de """+ ip + """ : <b>"""+ str(count[0])+ """</b></p>
+<p>Reverse DNS : <b>"""+rdns+"""</b><p>
<div id="tab">
<table class="data_tab">
<tr><th>Heure</th><th>Protocole</th><th>IP Source</th><th>IP Destination</th><th>Port Source</th><th>Port Destination</th></tr>
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="<em>Non connu</em>"
+
+#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+=("""<tr>""" +
+"""<td>""" + str(i[1]) + """</td>""" +
+"""<td>""" + str(i[2]) + """</td>""" +
+"""<td>""" + lien('ip_source.py?ip=' + str(i[3]), str(i[3])) + """</td>""" +
+"""<td>""" + lien('ip_destination.py?ip=' + str(i[4]), str(i[4])) + """</td>""" +
+"""<td>""" + lien('port_source.py?port=' + str(i[5]), str(i[5])) + """</td>""" +
+"""<td>""" + lien('port_destination.py?port=' + str(i[6]), str(i[6])) + """</td>""" +
+"""</tr>""")
+
+#write the html page
+ req.write(baseHTML("ATS - " + ip,"""
+<h1>IP source : """ + ip + """</h1>
+<p>Nombre de paquets venant de """+ ip + """ : <b>"""+ str(count[0])+ """</b></p>
+<p>Reverse DNS : <b>"""+rdns+"""</b><p>
+<div id="tab">
+<table class="data_tab">
+<tr><th>Heure</th><th>Protocole</th><th>IP Source</th><th>IP Destination</th><th>Port Source</th><th>Port Destination</th></tr>
+"""
++ content +
+"""
+</table>
+</div>
+"""))
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+=("""<tr>""" +
+"""<td>""" + str(i[1]) + """</td>""" +
+"""<td>""" + str(i[2]) + """</td>""" +
+"""<td>""" + lien('ip_source.py?ip=' + str(i[3]), str(i[3])) + """</td>""" +
+"""<td>""" + lien('ip_destination.py?ip=' + str(i[4]), str(i[4])) + """</td>""" +
+"""<td>""" + lien('port_source.py?port=' + str(i[5]), str(i[5])) + """</td>""" +
+"""<td>""" + lien('port_destination.py?port=' + str(i[6]), str(i[6])) + """</td>""" +
+"""</tr>""")
+
+#write the html page
+ req.write(baseHTML("ATS - " + port,"""
+<h1>Port destination : """ + port + """</h1>
+<div id="tip" style="display:block;">
+Afin de voir le reverse DNS d'une adresse IP, cliquez sur cette dernière dans le tableau <button id="ok" onclick="toggle_div(this,'tip');">OK</button></div>
+<p>Nombre de paquets en destination de """+ port + """ : <b>"""+ str(count[0])+ """</b></p>
+<div id="tab">
+<table class="data_tab">
+<tr><th>Heure</th><th>Protocole</th><th>IP Source</th><th>IP Destination</th><th>Port Source</th><th>Port Destination</th></tr>
+"""
++ content +
+"""
+</table>
+</div>
+<script src="tip.js"></script>
+"""))
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+=("""<tr>""" +
+"""<td>""" + str(i[1]) + """</td>""" +
+"""<td>""" + str(i[2]) + """</td>""" +
+"""<td>""" + lien('ip_source.py?ip=' + str(i[3]), str(i[3])) + """</td>""" +
+"""<td>""" + lien('ip_destination.py?ip=' + str(i[4]), str(i[4])) + """</td>""" +
+"""<td>""" + lien('port_source.py?port=' + str(i[5]), str(i[5]) ) + """</td>""" +
+"""<td>""" + lien('port_destination.py?port=' + str(i[6]), str(i[6]) )+ """</td>""" +
+"""</tr>""")
+
+#write the html page
+ req.write(baseHTML("ATS - " + port,"""
+<h1>Port source : """ + port + """</h1>
+<div id="tip" style="display:block;">
+Afin de voir le reverse DNS d'une adresse IP, cliquez sur cette dernière dans le tableau <button id="ok" onclick="toggle_div(this,'tip');">OK</button></div>
+<p>Nombre de paquets venant de """+ port + """ : <b>"""+ str(count[0])+ """</b></p>
+<div id="tab">
+<table class="data_tab">
+<tr><th>Heure</th><th>Protocole</th><th>IP Source</th><th>IP Destination</th><th>Port Source</th><th>Port Destination</th></tr>
+"""
++ content +
+"""
+</table>
+</div>
+<script src="tip.js"></script>
+"""))
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","""
<h1>Syntaxe</h1>
<p>La """+lien('syntaxe.py','syntaxe')+""" pour utiliser les filtres disponibles sur la page """+lien('filtrage.py','filtrage')+""" est la suivante :</p>
<p>&lt;colonne&gt;='&lt;valeur&gt;'</p><br/>