Initial revision
darcs-hash:20000521125243-92525-6092ab1d3efe6df9898549afb0aa3c7d43983e8b.gz
This commit is contained in:
commit
f1d3de9de7
26 changed files with 621 additions and 0 deletions
11
E-mail_all
Executable file
11
E-mail_all
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/zsh
|
||||||
|
./remail $1 $2 > email.tmp
|
||||||
|
chmod a+x email.tmp
|
||||||
|
echo maintenant il faut editer ./email.tmp avec pico
|
||||||
|
echo et virrer les ^M qui apparaissent.
|
||||||
|
echo apres, on lance ./email.tmp et on l'efface
|
||||||
|
#./email.tmp
|
||||||
|
#rm email.tmp
|
||||||
|
echo Done
|
||||||
|
# envoie un E-mail a tout le monde
|
||||||
|
# orthographe : E-mail_all fichier.txt "titre"
|
2
SMBMessage
Executable file
2
SMBMessage
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
cat $3 | smbclient -U $1 -M $2
|
93
arpanoid
Executable file
93
arpanoid
Executable file
|
@ -0,0 +1,93 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# Dis, emacs, c'est du -*- python -*-, ça !
|
||||||
|
#
|
||||||
|
# C.Chépélov, 19 janvier 1999. Suite à discussion avec Olivier DALOY, et
|
||||||
|
# des trucs louches dans ses logs. Merci, merci ARP !!
|
||||||
|
|
||||||
|
import config
|
||||||
|
import pickle,string,os
|
||||||
|
|
||||||
|
# Phase 1 : lire les données théoriques, les retrier pour être exploitables.
|
||||||
|
|
||||||
|
ZONEDB = pickle.load(open(config.CFG_FILE_ROOT+"Zone.db","r"))
|
||||||
|
|
||||||
|
THicn_by_mac = {} # ip, comment, name by MAC (théorique)
|
||||||
|
THncm_by_ip = {} # name, comment, MAC by IP (théorique)
|
||||||
|
|
||||||
|
for name in ZONEDB.keys():
|
||||||
|
(IP,comment,MAC) = ZONEDB[name]
|
||||||
|
THicn_by_mac[MAC] = (IP,comment,name)
|
||||||
|
THncm_by_ip[IP] = (name,comment,MAC)
|
||||||
|
|
||||||
|
# Phase 2 : Lire les données réelles, les mettres dans des dicos pour être
|
||||||
|
# exploitables.
|
||||||
|
|
||||||
|
arp = os.popen("arp -n","r")
|
||||||
|
arp.readline()
|
||||||
|
|
||||||
|
ip_by_mac = {}
|
||||||
|
mac_by_ip = {}
|
||||||
|
while 1:
|
||||||
|
s = arp.readline()
|
||||||
|
if not s: break
|
||||||
|
sl = string.split(s)
|
||||||
|
try:
|
||||||
|
ip = sl[0]
|
||||||
|
|
||||||
|
mac = ""
|
||||||
|
if (sl[1] != "ether") or (sl[2] == "(incomplete)"): raise "incomplete"
|
||||||
|
for c in string.lower(sl[2]):
|
||||||
|
if c in "0123456789abcdef":
|
||||||
|
mac = mac + c
|
||||||
|
if not ip or not mac: break
|
||||||
|
ip_by_mac[mac] = ip
|
||||||
|
mac_by_ip[ip] = mac
|
||||||
|
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Phase 3 : en fonction des gens qu'on a vus, faire une comparaison...
|
||||||
|
# d'abord, par IP vues :
|
||||||
|
|
||||||
|
try:
|
||||||
|
problems = open("/var/log/arpanoid","r").readlines()
|
||||||
|
except:
|
||||||
|
problems = []
|
||||||
|
# la liste des problèmes. Sera triée par ordre alphabétique
|
||||||
|
# et les problèmes rendus uniques.
|
||||||
|
# note: on récupère les vieux problèmes, on génèrera le même message
|
||||||
|
# plusieurs fois (pas grave, on virera les messages identiques)
|
||||||
|
|
||||||
|
def log(s):
|
||||||
|
s = s + '\n'
|
||||||
|
if not s in problems: problems.append(s)
|
||||||
|
|
||||||
|
for ip,mac in mac_by_ip.items():
|
||||||
|
|
||||||
|
if THicn_by_mac.has_key(mac):
|
||||||
|
thIP,comment,name = THicn_by_mac[mac]
|
||||||
|
if thIP == ip: pass # print name,' est clair (IP by MAC)'
|
||||||
|
else:
|
||||||
|
if THncm_by_ip.has_key(ip): victim,t1,t2 = THncm_by_ip[ip]
|
||||||
|
else: victim = "(inconnu)"
|
||||||
|
log("%s (%s) usurpe une adresse IP !!! (normal=%s,actuel=%s[%s])" % (name,comment,thIP,ip,victim))
|
||||||
|
else:
|
||||||
|
log("MACHINE INCONNUE (intruse ?) MAC=%s !" % mac)
|
||||||
|
|
||||||
|
if THncm_by_ip.has_key(ip):
|
||||||
|
name,comment,thMAC = THncm_by_ip[ip]
|
||||||
|
if thMAC == mac: pass # print name,' est clair (MAC by IP)'
|
||||||
|
else:
|
||||||
|
if THicn_by_mac.has_key(mac): t1,t2,name = THicn_by_mac[mac]
|
||||||
|
else: victim = "(inconnu)"
|
||||||
|
log("%s (%s) utilise une autre carte réseau !!! (normal=%s,actuel=%s[%s]" % (name,comment,thMAC,mac,victim))
|
||||||
|
else:
|
||||||
|
diag = "(intruse ?)"
|
||||||
|
if THicn_by_mac.has_key(mac):
|
||||||
|
THip,comment,name = THicn_by_mac[mac]
|
||||||
|
diag = "%s de %s" % (name,comment)
|
||||||
|
log("MACHINE AVEC FAUX IP=%s (%s)!" % (ip,diag))
|
||||||
|
problems.sort()
|
||||||
|
|
||||||
|
print string.join(problems,"")
|
||||||
|
|
17
arpanoid-daily
Executable file
17
arpanoid-daily
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
subject="logs ARPanoid `date` "
|
||||||
|
dest="root@crans.ens-cachan.fr"
|
||||||
|
|
||||||
|
cat <<Fini | cat - /var/log/arpanoid | mail -s "$subject" $dest
|
||||||
|
|
||||||
|
Résultats de la chasse "ARPanoid" de la journée :
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
|
Fini
|
||||||
|
|
||||||
|
mv -f /var/log/arpanoid /var/log/arpanoid.bak
|
||||||
|
touch /var/log/arpanoid
|
||||||
|
chmod 640 /var/log/arpanoid
|
||||||
|
chown root:admin /var/log/arpanoid
|
||||||
|
/etc/CRANS/code/arpanoid > /var/log/arpanoid 2>/dev/null
|
2
arpanoid-frequently
Executable file
2
arpanoid-frequently
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
/etc/CRANS/code/arpanoid > /var/log/arpanoid 2>/dev/null
|
21
auto-claque
Executable file
21
auto-claque
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# CC 2/2/1999 horrible kludge
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Pour des raisons bizarres (bug driver SMC ? matériel ?), les interfaces
|
||||||
|
# eth1 et eth2 bloquent régulièrement.
|
||||||
|
# en général, un claquage suffit à les relancer. Par ailleurs, un claquage
|
||||||
|
# ne bloque pas les communications -- on peut donc jouer à le faire
|
||||||
|
# régulièrement.
|
||||||
|
#
|
||||||
|
|
||||||
|
#a enlever les commentaires! 19.02
|
||||||
|
# 20/01/2000 jerome reactive le script
|
||||||
|
|
||||||
|
echo "Claquage des interfaces" | /usr/bin/logger -t "AutoClaque" -p user.warn
|
||||||
|
|
||||||
|
ifconfig eth0 down; ifconfig eth0 up; route add default gw 138.231.136.2
|
||||||
|
|
||||||
|
ifconfig eth1 down; ifconfig eth1 up
|
||||||
|
ifconfig eth2 down; ifconfig eth2 up 138.231.137.2 netmask 255.255.255.0 broadcast 138.231.137.255
|
||||||
|
ifconfig eth3 down; ifconfig eth3 up
|
52
cdecode
Executable file
52
cdecode
Executable file
|
@ -0,0 +1,52 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# Dis, emacs, c'est du -*- python -*-
|
||||||
|
#
|
||||||
|
"""
|
||||||
|
Programme fait pour encoder les chambres suivant le cryptage standard
|
||||||
|
pour le bâtiment G (le F peut aussi s'en servir). Inutile au B, il y a déjà un
|
||||||
|
autre mapping (les prises réseau sont numérotées différemment des chambres)
|
||||||
|
|
||||||
|
Ceci ne résistera évidemment pas à une attaque cryptographique en règle.
|
||||||
|
|
||||||
|
L'algorithme étant réellement trivial, il est raisonnable de laisser ce
|
||||||
|
script "chmod 700" et "chown root:root" !
|
||||||
|
|
||||||
|
C.Chepelov 5 novembre 1998 (présente implémentation), mise au point de
|
||||||
|
l'algorithme et première implémentation en Reverse Polish Lisp (HP48) à
|
||||||
|
l'automne 1997.
|
||||||
|
|
||||||
|
Note : l'implémentation de référence est "cencode". L'algo est symétriqe...
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print "usage : %s <numéro de code>" % sys.argv[0]
|
||||||
|
print "exemple : %s 9378 --> 126 " % sys.argv[0]
|
||||||
|
print
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
s_arg = sys.argv[1]
|
||||||
|
try:
|
||||||
|
arg = int(s_arg)
|
||||||
|
if arg >= 10000: raise "pas bon."
|
||||||
|
except:
|
||||||
|
print "L'argument doit être un nombre inférieur à 10000 !"
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
|
# C'est pas du tout optimal, mais on s'en fout !
|
||||||
|
c1 = int(arg / 100) % 10
|
||||||
|
c2 = int(arg / 10) % 10
|
||||||
|
c3 = arg % 10
|
||||||
|
s = int(arg / 1000) % 10
|
||||||
|
|
||||||
|
f3 = t1 = (10 - c1 + s) % 10
|
||||||
|
f2 = t2 = (10 - c2 + s) % 10
|
||||||
|
f1 = t3 = (10 - c3 + s) % 10
|
||||||
|
|
||||||
|
res = f1 * 100 + f2 * 10 + f3
|
||||||
|
print "Chambre = %d " % res
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
53
cencode
Executable file
53
cencode
Executable file
|
@ -0,0 +1,53 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# Dis, emacs, c'est du -*- python -*-
|
||||||
|
#
|
||||||
|
"""
|
||||||
|
Programme fait pour encoder les chambres suivant le cryptage standard
|
||||||
|
pour le bâtiment G (le F peut aussi s'en servir). Inutile au B, il y a déjà un
|
||||||
|
autre mapping (les prises réseau sont numérotées différemment des chambres)
|
||||||
|
|
||||||
|
Ceci ne résistera évidemment pas à une attaque cryptographique en règle.
|
||||||
|
|
||||||
|
L'algorithme étant réellement trivial, il est raisonnable de laisser ce
|
||||||
|
script "chmod 700" et "chown root:root" !
|
||||||
|
|
||||||
|
C.Chepelov 5 novembre 1998 (présente implémentation), mise au point de
|
||||||
|
l'algorithme et première implémentation en Reverse Polish Lisp (HP48) à
|
||||||
|
l'automne 1997.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print "usage : %s <numéro de chambre>" % sys.argv[0]
|
||||||
|
print "exemple : %s 126 --> 9378 " % sys.argv[0]
|
||||||
|
print "Ajouter G ou F selon bâtiment, W ou B selon gaine technique. "
|
||||||
|
print
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
s_arg = sys.argv[1]
|
||||||
|
try:
|
||||||
|
arg = int(s_arg)
|
||||||
|
if arg >= 1000: raise "pas bon."
|
||||||
|
except:
|
||||||
|
print "L'argument doit être un nombre inférieur à 1000 !"
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
|
# C'est pas du tout optimal, mais on s'en fout !
|
||||||
|
c1 = int(arg / 100) % 10
|
||||||
|
c2 = int(arg / 10) % 10
|
||||||
|
c3 = arg % 10
|
||||||
|
|
||||||
|
s = (c1 + c2 + c3) % 10
|
||||||
|
|
||||||
|
f3 = t1 = (10 - c1 + s) % 10
|
||||||
|
f2 = t2 = (10 - c2 + s) % 10
|
||||||
|
f1 = t3 = (10 - c3 + s) % 10
|
||||||
|
|
||||||
|
res = s * 1000 + f1 * 100 + f2 * 10 + f3
|
||||||
|
print "Code = %d " % res
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
26
claque-interfaces
Executable file
26
claque-interfaces
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# CC 2/2/1999 horrible kludge
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Pour des raisons bizarres (bug driver SMC ? matériel ?), les interfaces
|
||||||
|
# eth1 et eth2 bloquent régulièrement.
|
||||||
|
# en général, un claquage suffit à les relancer. Par ailleurs, un claquage
|
||||||
|
# ne bloque pas les communications -- on peut donc jouer à le faire
|
||||||
|
# régulièrement.
|
||||||
|
#
|
||||||
|
|
||||||
|
#a enlever les commentaires! 19.02
|
||||||
|
# 20/01/2000 jerome reactive le script
|
||||||
|
|
||||||
|
echo "Claquage des interfaces" | /usr/bin/logger -t "Claque" -p user.warn
|
||||||
|
|
||||||
|
ifconfig eth0 down; ifconfig eth0 up; route add default gw 138.231.136.2
|
||||||
|
|
||||||
|
ifconfig eth1 down; ifconfig eth1 up
|
||||||
|
ifconfig eth2 down; ifconfig eth2 up
|
||||||
|
ifconfig eth3 down; ifconfig eth3 up
|
||||||
|
|
||||||
|
#ifconfig eth2 up 138.231.138.2 netmask 255.255.255.0 broadcast 138.231.138.255
|
||||||
|
ifconfig eth2:1 up 138.231.138.2 netmask 255.255.255.0 broadcast 138.231.138.255
|
||||||
|
#ifconfig eth1:1 down 138.231.139.2 netmask 255.255.255.0 broadcast 138.231.139.255
|
||||||
|
#ifconfig eth1 up
|
5
modifetc
Normal file
5
modifetc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# utilisation : " . =modifetc "
|
||||||
|
|
||||||
|
alias cvcommit='cvs commit | grep -v "^?"'
|
||||||
|
CVSROOT="/usr/cvs-rep"
|
||||||
|
export CVSROOT
|
9
redpopup
Executable file
9
redpopup
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/sh
|
||||||
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
|
||||||
|
PYTHONPATH=/usr/lib/python-1.5/
|
||||||
|
|
||||||
|
cd /etc/CRANS
|
||||||
|
echo $1 $2 $3 $4 $5 > /tmp/last.popup.log
|
||||||
|
exec python /etc/CRANS/code/redpopup.py $1 $2 $3 $4 $5 >&2 2>/tmp/last.popup.err
|
||||||
|
|
||||||
|
|
76
redpopup.py
Executable file
76
redpopup.py
Executable file
|
@ -0,0 +1,76 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# -*- python -*-
|
||||||
|
import sys,time,os,pickle,string,popen2,random
|
||||||
|
|
||||||
|
FORKLEN = 5
|
||||||
|
TIMEOUT = 15 # une machine a 15 secondes pour recevoir un popup !
|
||||||
|
|
||||||
|
def do_bomb(Machines):
|
||||||
|
time.sleep(random.random())
|
||||||
|
if len(Machines) < FORKLEN:
|
||||||
|
for mach in Machines:
|
||||||
|
begin = time.time()
|
||||||
|
print "ré-expédition SMBpopup à ",mach
|
||||||
|
fd = popen2.Popen3("/etc/CRANS/code/SMBMessage %s %s %s" % (from_whom,mach,msgfile))
|
||||||
|
while 1:
|
||||||
|
time.sleep(1)
|
||||||
|
if fd.poll() != -1: break # fini ! (cool)
|
||||||
|
if (time.time() - begin) > TIMEOUT: break
|
||||||
|
del fd
|
||||||
|
else:
|
||||||
|
Half = len(Machines) / 2
|
||||||
|
|
||||||
|
pid = os.fork()
|
||||||
|
if pid == 0:
|
||||||
|
# child
|
||||||
|
do_bomb(Machines[:Half])
|
||||||
|
else:
|
||||||
|
# parent
|
||||||
|
do_bomb(Machines[Half:])
|
||||||
|
try:
|
||||||
|
os.waitpid(pid,0)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
# à ce stade, on a éliminé toute récursion, tant pile que process...
|
||||||
|
# croisons les doigts !!!
|
||||||
|
|
||||||
|
|
||||||
|
if len(sys.argv) < 4:
|
||||||
|
sys.stderr.write('Attend 3 arguments !\n')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
Zone = pickle.load(open(CFG_READ_DIR+"Zone.db","r"))
|
||||||
|
|
||||||
|
from_whom = sys.argv[1]
|
||||||
|
from_where = sys.argv[2]
|
||||||
|
msgfile = sys.argv[3]+"-red"
|
||||||
|
message = open(sys.argv[3],"r").readlines()
|
||||||
|
|
||||||
|
message.insert(0,("Message de %s (@%s) à ALL : \n-----\n" % (from_whom,from_where)))
|
||||||
|
open(msgfile,"w").writelines(message)
|
||||||
|
|
||||||
|
|
||||||
|
# pour gagner du temps, on n'envoie le message qu'aux machines qui sont
|
||||||
|
# (probablement) vivantes. Pour gagner encore plus de temps, on fait
|
||||||
|
# confiance au cache ARP (15 minutes)
|
||||||
|
|
||||||
|
Alive = []
|
||||||
|
arp = os.popen("arp -a","r")
|
||||||
|
while 1:
|
||||||
|
s = arp.readline()
|
||||||
|
if not s: break
|
||||||
|
mach = string.split(string.split(s)[0],'.')[0]
|
||||||
|
if mach[:5] == 'zamok': continue # évitons les boucles infininies...
|
||||||
|
if Zone.has_key(mach): Alive.append(mach)
|
||||||
|
print Alive
|
||||||
|
|
||||||
|
arp.close()
|
||||||
|
|
||||||
|
#maintenant, au boulot...
|
||||||
|
do_bomb(Alive)
|
||||||
|
unlink(msgfile)
|
||||||
|
unlink(sys.argv[3])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
BIN
remail
Normal file
BIN
remail
Normal file
Binary file not shown.
36
remail.pas
Normal file
36
remail.pas
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
program Email;
|
||||||
|
{ce programme permet de transformer /etc/CRANS/personne.cf en une liste d'Emails }
|
||||||
|
{script en pascal par jerome}
|
||||||
|
uses crt,dos;
|
||||||
|
var f: file of char;
|
||||||
|
c:char;
|
||||||
|
s:string[20];
|
||||||
|
begin
|
||||||
|
if paramcount<>2 then
|
||||||
|
begin
|
||||||
|
writeln('orthographe : E-mail_all fichier.txt "subject"');
|
||||||
|
writeln('permet au root d''envoyer un E-mail a tout le monde');
|
||||||
|
writeln('s''integre dans le script E-mail_all, ne pas toucher');
|
||||||
|
halt(0);
|
||||||
|
end;
|
||||||
|
assign (f,'personnes.cf');
|
||||||
|
reset(f);
|
||||||
|
seek(f,0);
|
||||||
|
writeln('#! /bin/zsh');
|
||||||
|
s:=' ';
|
||||||
|
repeat;
|
||||||
|
{$i-}
|
||||||
|
read(f,c);
|
||||||
|
{$i+}
|
||||||
|
if c=#58 then begin
|
||||||
|
repeat
;
|
||||||
|
read(f,c);
|
||||||
|
until c=#10;
|
||||||
|
writeln('cat ',paramstr(1),' | mail -s "', paramstr(2),'" ',s,'@crans.ens-cachan.fr');
|
||||||
|
c:=#32;
|
||||||
|
s:='';
|
||||||
|
end;
|
||||||
|
s:=s+c;
|
||||||
|
until ord(c)=35;
|
||||||
|
close(f);
|
||||||
|
end.
|
12
restart-all
Executable file
12
restart-all
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/zsh -p
|
||||||
|
# suid !!
|
||||||
|
|
||||||
|
id
|
||||||
|
|
||||||
|
echo "restarting the named (DNS) :"
|
||||||
|
kill -HUP `cat /var/run/named.pid`
|
||||||
|
|
||||||
|
echo "restarting the DHCP : "
|
||||||
|
#kill -TERM `cat /var/run/dhcpd.pid` || true
|
||||||
|
#/usr/sbin/dhcpd
|
||||||
|
/etc/init.d/dhcp reload
|
24
sendmail-vit-il
Executable file
24
sendmail-vit-il
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- Python -*-
|
||||||
|
|
||||||
|
# teste si notre sendmail fonctionne encore.
|
||||||
|
|
||||||
|
from socket import *
|
||||||
|
import sys
|
||||||
|
|
||||||
|
OK = 0
|
||||||
|
|
||||||
|
host = "localhost"
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
host = sys.argv[1]
|
||||||
|
|
||||||
|
s = socket(AF_INET,SOCK_STREAM)
|
||||||
|
try:
|
||||||
|
s.connect(host,25)
|
||||||
|
data = s.recv(3)
|
||||||
|
OK = ("220" == data)
|
||||||
|
s.close()
|
||||||
|
except:
|
||||||
|
OK = 0
|
||||||
|
|
||||||
|
sys.exit(not OK)
|
26
squid-vit-il
Executable file
26
squid-vit-il
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- Python -*-
|
||||||
|
|
||||||
|
# teste si notre squid fonctionne encore (sortof).
|
||||||
|
|
||||||
|
from socket import *
|
||||||
|
import sys
|
||||||
|
|
||||||
|
OK = 0
|
||||||
|
|
||||||
|
host = "localhost"
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
host = sys.argv[1]
|
||||||
|
|
||||||
|
s = socket(AF_INET,SOCK_STREAM)
|
||||||
|
try:
|
||||||
|
s.connect(host,3128)
|
||||||
|
s.send("GET squid-vit-il")
|
||||||
|
data = s.recv(4)
|
||||||
|
OK = ("HTTP" == data)
|
||||||
|
s.close()
|
||||||
|
except:
|
||||||
|
OK = 0
|
||||||
|
|
||||||
|
sys.exit(not OK)
|
||||||
|
|
26
surveille
Executable file
26
surveille
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/zsh
|
||||||
|
# si le process $1 est mort, le relance
|
||||||
|
|
||||||
|
unset res
|
||||||
|
|
||||||
|
arg=$1
|
||||||
|
res=`ps xeaf | grep $arg | grep -v surveille | grep -v grep`
|
||||||
|
#res=`/etc/rc.d/init.d/$arg status | grep "running"`
|
||||||
|
|
||||||
|
if [ -z $res ]; then
|
||||||
|
if [ -f /var/run/dead.$arg ]; then
|
||||||
|
# waouh, on peut rien -- on a déjà essayé de relancer ce truc
|
||||||
|
# et il est déjà mort -- y'a sûrement un problème dans les fichiers
|
||||||
|
# de config !
|
||||||
|
# faudrait faire un "ls" quotidien de /var/run/dead.* ...
|
||||||
|
true
|
||||||
|
else
|
||||||
|
/etc/rc.d/init.d/$arg stop 2>/dev/null >/dev/null
|
||||||
|
/etc/rc.d/init.d/$arg start 2>/dev/null >/dev/null
|
||||||
|
logger "surveille a du relancer $1 !" 2>/dev/null >/dev/null
|
||||||
|
touch /var/run/dead.$arg
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
rm -f /var/run/dead.$arg 2>/dev/null >/dev/null
|
||||||
|
|
||||||
|
fi
|
36
surveille-reseau
Executable file
36
surveille-reseau
Executable file
|
@ -0,0 +1,36 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
ipx=false
|
||||||
|
|
||||||
|
function teste_ou_claque() {
|
||||||
|
if ! ping -c 1 $1 2>&1 >/dev/null
|
||||||
|
then
|
||||||
|
ifconfig $2 down 2>/dev/null >/dev/null
|
||||||
|
/usr/local/bin/mii-diag -R $2 2>/dev/null >/dev/null
|
||||||
|
ifconfig $2 up 2>/dev/null >/dev/null
|
||||||
|
if [ ! -z "$3" ]
|
||||||
|
then
|
||||||
|
route add default gw $3
|
||||||
|
fi
|
||||||
|
ipx=true
|
||||||
|
logger "surveille-reseau a du claquer $2 !" 2>&1 >/dev/null
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# pour l'instant, on n'a qu'un seul réseau (eth0) où se trouve de façon sûre
|
||||||
|
# une machine partenaire, toujours présente.
|
||||||
|
# les autres réseaux peuvent être ajoutés dès que l'on aura une victime à
|
||||||
|
# pinger (par exemple, une vieille sun ou un vieux 386sx/Linux de réserve,
|
||||||
|
# ne servant à rien sauf à faire du RC5.distributed.net (pour l'ego du root)
|
||||||
|
# et répondre aux pings)
|
||||||
|
|
||||||
|
|
||||||
|
teste_ou_claque 138.231.176.65 eth0 138.231.136.2
|
||||||
|
#teste_ou_claque zagadka eth1
|
||||||
|
#teste_ou_claque gandalf eth2
|
||||||
|
#teste_ou_claque bigouden eth3
|
||||||
|
|
||||||
|
$ipx && /etc/CRANS/rc.ipx >/dev/null 2>/dev/null
|
||||||
|
|
||||||
|
|
||||||
|
|
10
surveille-sendmail
Executable file
10
surveille-sendmail
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
/etc/CRANS/sendmail-vit-il $1 && exit
|
||||||
|
|
||||||
|
killall -9 sendmail 2>/dev/null >/dev/null
|
||||||
|
echo "surveille-sendmail relance sendmail !!!" >> /var/log/messages
|
||||||
|
/usr/lib/sendmail -bd
|
||||||
|
|
||||||
|
|
||||||
|
|
10
surveille-squid
Executable file
10
surveille-squid
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
/etc/CRANS/squid-vit-il $1 && exit
|
||||||
|
|
||||||
|
echo "surveille-squid relance Squid !!!" >> /var/log/messages
|
||||||
|
squid-new >/dev/null 2>/dev/null
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
18
surveille.tout
Executable file
18
surveille.tout
Executable file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
/etc/CRANS/surveille-sendmail $HOST
|
||||||
|
/etc/CRANS/surveille-squid
|
||||||
|
/etc/CRANS/surveille httpd
|
||||||
|
/etc/CRANS/surveille smb
|
||||||
|
/etc/CRANS/surveille dhcpd
|
||||||
|
/etc/CRANS/surveille sshd2
|
||||||
|
/etc/CRANS/surveille ntpd
|
||||||
|
|
||||||
|
/etc/CRANS/surveille-reseau
|
||||||
|
# Et bientot
|
||||||
|
# /etc/CRANS/surveille-reseau.pl
|
||||||
|
|
||||||
|
|
||||||
|
killall -9 nwbind 2>/dev/null >/dev/null
|
||||||
|
#goret goret goret :-) mais on n'a pas besoin de la
|
||||||
|
#bindery[usine à gaz] NetWare
|
11
temp-avg
Executable file
11
temp-avg
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# je pipe vers calculatrice pour enlever 30 °, ça donne plus de précision. Sam. (/1 fait truncate.)
|
||||||
|
echo $(cat /proc/sys/dev/sensors/w83781d-i2c-0-2d/temp1 | tail -c 5 | head -c 2 )"/1-30"|bc
|
||||||
|
echo $(cat /proc/sys/dev/sensors/w83781d-i2c-0-2d/temp2 | tail -c 5 | head -c 2 )"/1-30"|bc
|
||||||
|
#cat /proc/sys/dev/sensors/w83781d-i2c-0-2d/temp1 | sed -e 's/.*60.0 50.0 //' | sed -e's/\0//' -e 's/\.//'
|
||||||
|
#cat /proc/sys/dev/sensors/w83781d-i2c-0-2d/temp2 | sed -e 's/.*57.0 50.0 //' | sed -e's/\0//' -e 's/\.//'
|
||||||
|
#echo 10
|
||||||
|
#echo 10
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Température-30°"
|
25
test-squid-taille-cache.pl
Executable file
25
test-squid-taille-cache.pl
Executable file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
$squidCacheDir = "/var/squid";
|
||||||
|
$squidCacheDirMaxSize = 1700000;
|
||||||
|
|
||||||
|
open(STDIN, "du -s $squidCacheDir |");
|
||||||
|
|
||||||
|
$line = <STDIN>;
|
||||||
|
chop($line);
|
||||||
|
|
||||||
|
#$line est sous la forme 12345678 $squidCacheDir
|
||||||
|
|
||||||
|
if ($line =~ /([\d]+)/){
|
||||||
|
if ($1 > $squidCacheDirMaxSize){
|
||||||
|
|
||||||
|
system("echo \"testSquid.pl relance squid \" >> /var/log/messages");
|
||||||
|
|
||||||
|
# ajoute par Aymeric pour essayer de comprendre ce qui se passe
|
||||||
|
system("df -k /var/squid >> /var/log/messages");
|
||||||
|
|
||||||
|
system("squid-new >/dev/null 2&>/dev/null &");
|
||||||
|
# J'ai rajouté un sujet pour filtrage par procmail OS :-)
|
||||||
|
system("echo \"[TEST] j'ai du relancer le squid qui
|
||||||
|
bouffait trop d'espace\"| mail -s \"testSquid\" root ");
|
||||||
|
}
|
||||||
|
}
|
7
verifie_ipforward
Executable file
7
verifie_ipforward
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# fait le 11/12/99 par Jerome KIEFFER
|
||||||
|
#retablie l'ipforwarding entre les interfaces de zamok si c'est descactive.
|
||||||
|
if [ `cat /proc/sys/net/ipv4/ip_forward` -eq `expr 0` ]
|
||||||
|
then
|
||||||
|
echo 1 >/proc/sys/net/ipv4/ip_forward
|
||||||
|
fi
|
13
watchdog
Executable file
13
watchdog
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# oui emacs c'est bien du -*- python -*-
|
||||||
|
|
||||||
|
|
||||||
|
# c'est fait pour le "software watchdog"....
|
||||||
|
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
fd = open("/dev/watchdog","w+")
|
||||||
|
while 1:
|
||||||
|
fd.write('z')
|
||||||
|
sleep(15)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue