From 7de837b8d1def4d3e438e9235b0b940399b3ba45 Mon Sep 17 00:00:00 2001 From: Vincent Le Gallic Date: Sat, 11 May 2013 17:56:33 +0200 Subject: [PATCH] =?UTF-8?q?[deconnexion.py]=20on=20retire=20les=20beuglant?= =?UTF-8?q?es=20sur=20les=20IPv6=20pour=20les=20mettre=20dans=20un=20autre?= =?UTF-8?q?=20cron=20moins=20fr=C3=A9quent.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- surveillance/collisions_ipv6.py | 23 +++++++++++++++++++++++ surveillance/deconnexion.py | 10 ---------- 2 files changed, 23 insertions(+), 10 deletions(-) create mode 100755 surveillance/collisions_ipv6.py diff --git a/surveillance/collisions_ipv6.py b/surveillance/collisions_ipv6.py new file mode 100755 index 00000000..58af3f3f --- /dev/null +++ b/surveillance/collisions_ipv6.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" Pour détecter et signaler les collisions d'adresses IPv6 """ + +import psycopg2 + +# Connection à la base sql via pgsql +pgsql = psycopg2.connect(database='filtrage', user='crans') +# Il faudra remplacer la ligne ci-dessous par pgsql.set_session(autocommit = True) sous wheezy +pgsql.set_isolation_level(0) +curseur = pgsql.cursor() + +# On regarde s'il y a deux ipv6 identiques avec des mac non identiques +collision_mac_ip_request = "SELECT DISTINCT a.date as date1, a.mac as mac1, a.ip as ip1, b.date as date2, b.mac as mac2, b.ip as ip2 FROM mac_ip as a, mac_ip as b where a.ip=b.ip AND a.mac != b.mac AND a.date >= b.date AND a.date - b.date < interval '3 day' ORDER BY a.date;" +curseur.execute(collision_mac_ip_request) +collision_mac_ip = curseur.fetchall() + +if collision_mac_ip != []: + print "Collision d'addresses ipv6 : " +for (date1, mac1, ip1, date2, mac2, ip2) in collision_mac_ip: + print "%s %s %s" % (date1, ipt.mac_addr(mac1), ip1) + print "%s %s %s" % (date2, ipt.mac_addr(mac2), ip2) diff --git a/surveillance/deconnexion.py b/surveillance/deconnexion.py index ffe3eb61..9b069cbc 100755 --- a/surveillance/deconnexion.py +++ b/surveillance/deconnexion.py @@ -166,16 +166,6 @@ curseur.execute(requete) uploadeurs = curseur.fetchall() -# On regarde s'il y a deux ipv6 identiques avec des mac non identiques -collision_mac_ip_request = "SELECT DISTINCT a.date as date1, a.mac as mac1, a.ip as ip1, b.date as date2, b.mac as mac2, b.ip as ip2 FROM mac_ip as a, mac_ip as b where a.ip=b.ip AND a.mac != b.mac AND a.date >= b.date AND a.date - b.date < interval '3 day' ORDER BY a.date;" -curseur.execute(collision_mac_ip_request) -collision_mac_ip = curseur.fetchall() - -if collision_mac_ip != []: - print "Collision d'addresses ipv6 : " -for (date1, mac1, ip1, date2, mac2, ip2) in collision_mac_ip: - print "%s %s %s" % (date1, ipt.mac_addr(mac1), ip1) - print "%s %s %s" % (date2, ipt.mac_addr(mac2), ip2) # Table des avertis ###################