oublis de fichiers divers et symlinks for testlibs
This commit is contained in:
parent
e2611a770a
commit
b004906464
12 changed files with 1165 additions and 135 deletions
50
surveillance/outils/virus.py
Normal file
50
surveillance/outils/virus.py
Normal file
|
@ -0,0 +1,50 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: iso-8859-15 -*-
|
||||
|
||||
###########################
|
||||
# Import des commmandes : #
|
||||
###########################
|
||||
|
||||
import commands
|
||||
import sys
|
||||
import psycopg2
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
from config import upload, virus, p2p
|
||||
import smtplib
|
||||
from ldap_crans import crans_ldap
|
||||
from time import *
|
||||
|
||||
|
||||
|
||||
# Connections :
|
||||
###############
|
||||
pgsql = psycopg2.connect(database='filtrage', user='crans')
|
||||
# Il faudra remplacer la ligne ci-dessous par pgsql.set_session(autocommit=True)
|
||||
pgsql.set_isolation_level(0)
|
||||
mail = smtplib.SMTP('localhost')
|
||||
ldap = crans_ldap()
|
||||
curseur=pgsql.cursor()
|
||||
|
||||
|
||||
requete="SELECT ip_crans FROM avertis_virus"
|
||||
curseur.execute(requete)
|
||||
virus=curseur.fetchall()
|
||||
for i in range(0,len(virus)) :
|
||||
IP=virus[i][0]
|
||||
print IP
|
||||
requete="SELECT COUNT(ip_src) from virus where ip_src='%s' and date > timestamp 'now' - interval '1 hour'"%IP
|
||||
curseur.execute(requete)
|
||||
resultv=curseur.fetchall()
|
||||
requete="SELECT COUNT(ip_src) from flood where ip_src='%s' and date > timestamp 'now' - interval '1 hour'"%IP
|
||||
curseur.execute(requete)
|
||||
resultf=curseur.fetchall()
|
||||
machine = ldap.search('ipHostNumber=%s' % IP,'w' )['machine'][0]
|
||||
hostname=machine.nom()
|
||||
proprio=machine.proprietaire()
|
||||
bl=proprio.blacklist()
|
||||
for ligne in bl:
|
||||
if '-,virus,' in ligne:
|
||||
print hostname,resultv[0][0],resultf[0][0],ligne
|
||||
break
|
||||
#else :
|
||||
# print hostname,resultv[0][0],resultf[0][0],'PAS DE BL'
|
Loading…
Add table
Add a link
Reference in a new issue