diff options
author | Luneji <61687883+Luneji@users.noreply.github.com> | 2020-05-12 11:22:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-12 11:22:52 +0200 |
commit | b1f7c1a9f501cd005a5fcc6556bdd3bf37bceea8 (patch) | |
tree | 28217f286a747470e33299d818f4c1b45697c6a3 | |
parent | 530e630ca8abf51dbb6351738c92c24fb647f7b6 (diff) |
Update tapdanlfon.py
-rw-r--r-- | analyse/tapdanlfon.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/analyse/tapdanlfon.py b/analyse/tapdanlfon.py index 5263af4..eb0b047 100644 --- a/analyse/tapdanlfon.py +++ b/analyse/tapdanlfon.py @@ -1,6 +1,14 @@ #!/usr/bin/python # coding: utf-8 + +import psycopg2 + + +def connexionBD(): + connexion=psycopg2.connect ("host='localhost' dbname='atsdb' user='atsuser' password='123456'") + return connexion + # read a text file as a list of lines # find the last line, change to a file you have LireHeureTCP = open ( '/tmp/heuretcp.txt',"r" ) @@ -55,7 +63,6 @@ LireIPDSTUDP.close() DerniereLignePortDSTUDP = LirePortDSTUDP.readlines() LirePortDSTUDP.close() - #print "Heure TCP:" a = DerniereLigneHeureTCP[-1] @@ -75,8 +82,6 @@ e = DerniereLigneIPDSTTCP[-1] f = DerniereLignePortDSTTCP[-1] -insert into paquet(heure,protocole,ip_source,ip_destination,port_source,port_destination) values (a,b,c,e,d,f); - #Re coucou #print "Heure UDP:" @@ -97,4 +102,19 @@ v = DerniereLigneIPDSTUDP[-1] #print "Port Destination UDP:" u = DerniereLignePortDSTUDP[-1] +print a,b,c +#sql part + +conn=connexionBD() +cur=conn.cursor() + +sql="""insert into paquet(heure,protocole,ip_source,ip_destination,port_source,port_destination) values (a,b,c,e,d,f); + insert into paquet(heure,protocole,ip_source,ip_destination,port_source,port_destination) values (z,y,x,v,w,u); +""" + +cur.execute(sql) +conn.commit() +data=cur.fetchall() + +conn.close() |