Compare commits

...

11 Commits

Author SHA1 Message Date
guillaume
241ee2385f remote ip delete local ip comparaison 2024-03-30 11:44:35 +01:00
guillaume
6beee1e2ba update client conf + doc 2024-03-30 11:39:58 +01:00
guillaume
5d89ac6417 check local ip deletee 2024-03-30 11:31:35 +01:00
guillaume
c4801fa8dc remote ip 2024-03-30 11:24:49 +01:00
guillaume
44e406c80f doc 2024-03-30 10:43:30 +01:00
guillaume
06caf72a34 Python => python3 2024-03-29 16:08:34 +01:00
19accb4c0e [UPDATE] - TP 05 - '#' 2022-05-02 23:16:19 +02:00
5718426164 [UPDATE] - init.d 2022-05-02 23:11:22 +02:00
86011bbacf [UPDATE] - TP 05 - '#' 2022-05-02 21:45:53 +02:00
2f2a283f7e [UPDATE] - TP 05 - '#' 2022-05-02 21:37:32 +02:00
2ff5c979b5 [UPDATE] - TP 05 2022-05-02 21:09:49 +02:00
21 changed files with 81 additions and 90 deletions

View File

@ -6,7 +6,7 @@ MoniThor is a simple monitoring tools in bash.
You can use it with netcat or cryptcat
You can see result on the client from a web page (self hosted python web server)
You can see result on the client from a web page (self hosted python3 web server)
## Server Configuration
@ -160,7 +160,7 @@ sudo /etc/init.d/monithor-c start/stop
### WEB
The client start a python sumple http server on localhost on `WebPort`
The client start a python3 sumple http server on localhost on `WebPort`
```
/usr/local/bin/monithor-client.d/MoniThorWebServer

BIN
doc/monithor-client.1.gz Normal file

Binary file not shown.

View File

@ -1,5 +1,5 @@
---
title: monithor-server
title: monithor-client
section: 1
author: Guillaume Astier Ruiz
date: 20220320
@ -7,11 +7,8 @@ date: 20220320
# SYNOPSIS
`/usr/local/bin/monithor-client [start/stop]`
`/etc/init.d/monithor-c [start/stop]`
# DESCRIPTION
monithor-client(1) permet de surveiller votre système d'information
@ -20,7 +17,7 @@ monithor-client(1) permet de surveiller votre système d'information
- il peut aussi utiliser cryptcat (chiffré)
- un serveur web en python est lancé sur votre machine de monitoring
- un serveur web en python3 est lancé sur votre machine de monitoring
# INIT.D
@ -32,7 +29,7 @@ le service peut être démarré et arrêté via system V
- Arrêt
`/etc/init.d/monithor-c start`
`/etc/init.d/monithor-c stop`
# CONFIGURATION SERVICE
@ -40,8 +37,6 @@ le service peut être démarré et arrêté via system V
`$ cat etc/monithor-client/service.cfg `
`RemoteIp=10.10.10.3:1666 `
`LocalPassword='Evil@MonitoR-666'`
`Crypted=no`
@ -52,8 +47,6 @@ le service peut être démarré et arrêté via system V
`WebPort=80`
* RemoteIp : correspond au couple adresse IP/Port de l'interface réseau utilisée
* LocalPassword : correspond au mot de passe utilisé pour chiffré la connexion si Crypted est à "yes"
* Crypted : si la valeur est à "yes" le binnaire crypcat est utilisé, si non netcat est utilisé
@ -62,7 +55,7 @@ le service peut être démarré et arrêté via system V
* TimeOut : correspond à la valeur en seconde (float) du temps maximal d'éxécution de chaque sonde
* WebPort : correpond au port utilisé pour lancer le serveur web python
* WebPort : correpond au port utilisé pour lancer le serveur web python3
# CONFIGURATION SONDE

BIN
doc/monithor-server.1.gz Normal file

Binary file not shown.

View File

@ -7,9 +7,9 @@ date: 20220320
# SYNOPSIS
`/usr/local/bin/monithor-server [start/stop]`
`/usr/local/bin/monithor-d [start/stop]`
`/etc/init.d/monithor-c [start/stop]`
`/etc/init.d/monithor-d [start/stop]`
# DESCRIPTION
@ -26,17 +26,17 @@ le service peut être démarré et arrêté via system V
- Démarrage
`/etc/init.d/monithor-c start`
`/etc/init.d/monithor-d start`
- Arrêt
`/etc/init.d/monithor-c start`
`/etc/init.d/monithor-d stop`
# CONFIGURATION SERVICE
- Le fichier responsable de la gestion IP/PORT est : service.cfg
`LocalIp=10.10.10.4`
`RemoteIp=10.10.10.4`
`LocalPort=1666`
@ -44,7 +44,7 @@ le service peut être démarré et arrêté via system V
`LocalPassword='Evil@MonitoR-666'`
* LocalIp : correspond à l'adresse IP de l'interface réseau en écoute
* RemoteIp : correspond à l'adresse IP de l'interface réseau en écoute du client de monitoring
* LocalPort : correspond au port de communication du client monithor
@ -82,9 +82,9 @@ les scripts sont tous stocké dans le répertoire :
* Configuration client :
`$ cat /etc/monithor-client/etc/monithor-client/conf/Card_10.10.10.3-1666.cfg`
`$ cat /etc/monithor-client/etc/monithor-client/conf/sample.cfg
`10.10.10.3:1666#part#/home/isen|50|80`
`#10.10.10.3:1666#part#/home/isen|50|80`
* Explication
@ -98,6 +98,8 @@ SERVEUR exécute : /usr/local/bin/monithor-server.d/part-space.sh /home/isen 50
SERVEUR renvoie les valeur récupéré à CLIENT
Les lignes commençant par '#' sont à supprimer ou à décommenter

View File

@ -30,7 +30,10 @@ GitVersion() {
}
CpArchName() {
cp -Rf monithor-${1} /tmp/monithor-${1}_${2}_all
rm -Rf /tmp/monithor-*
cp -Rf ${Wai}/monithor-${1} /tmp/monithor-${1}_${2}_all
}
@ -46,6 +49,7 @@ BuildDeb(){
[[ $Dist == "ubuntu" ]] && Compress=' -Z gzip -S fixed '
dpkg-deb ${Compress} --build --root-owner-group monithor-${1}_${2}_all &> /dev/null
[[ "$?" -eq "0" ]] && echo "OK" || echo "FAILED"
cp monithor-*deb ${Wai}/build
}
@ -57,18 +61,10 @@ CleanTemp() {
ManPage() {
if [[ $2 == "create" ]]
then
pandoc -s -t man ${Wai}/doc/monithor-${1}.md -o ${Wai}/doc/monithor-${1}.1
[[ -f ${Wai}/doc/monithor-${1}.1.gz ]] && rm -f ${Wai}/doc/monithor-${1}.1.gz
gzip ${Wai}/doc/monithor-${1}.1
cp ${Wai}/doc/monithor-${1}.1.gz ${Wai}/monithor-${1}/usr/share/man/man1/
fi
if [[ $2 == "delete" ]]
then
rm ${Wai}/monithor-${1}/usr/share/man/man1/*gz
rm ${Wai}/doc/monithor-${1}.1.gz
fi
mkdir -p /tmp/monithor-${1}_${2}_all/usr/share/man/man1/
pandoc -s -t man ${Wai}/doc/monithor-${1}.md -o /tmp/monithor-${1}_${2}_all/usr/share/man/man1/monithor-${1}.1
gzip /tmp/monithor-${1}_${2}_all/usr/share/man/man1/monithor-${1}.1
}
[[ ! -z $1 ]] && usage
@ -77,13 +73,11 @@ CheckDep
GitVersion
CpArchName server $NewTag
CpArchName client $NewTag
SedControl server $NewTag
SedControl client $NewTag
ManPage client create
ManPage server create
BuildDeb client $NewTag
ManPage server $NewTag
BuildDeb server $NewTag
ManPage client delete
ManPage server delete
CleanTemp
CpArchName client $NewTag
SedControl client $NewTag
ManPage client ${NewTag}
BuildDeb client $NewTag

View File

@ -1,6 +1,6 @@
Package: monithor-client
Version: 1.0
Architecture: all
Dependsd:netcat,cryptcat,screen,python,netcat,cryptcat,elinks
Dependsd:netcat,cryptcat,screen,python3,netcat,cryptcat,elinks
Maintainer: Guillaume Astier <guillaume@gastier.net>
Description: monithor client (with simple http server python)
Description: monithor client (with simple http server python3)

View File

@ -4,7 +4,7 @@
# Provides: monithor-c
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: MoniThor Server
# Short-Description: MoniThor client
### END INIT INFO
set -e
@ -21,15 +21,20 @@ case "$1" in
logger "monithor-client is running ..."
exit
else
logger "Starting MoniThor Server"
logger "Starting MoniThor client "
/usr/local/bin/monithor-client start
fi
;;
stop)
logger "Stoping MoniThor server" "monithor-c" || true
logger "Stoping MoniThor client " "monithor-c" || true
/usr/local/bin/monithor-client stop
;;
status)
logger "status MoniThor client " "monithor-c" || true
[ $(ps axf| grep MoniThor | grep SCREEN | wc -l) -gt 1 ] && echo "monithor-c is running" || echo "montihor-c is dead"
;;
*)
echo "Usage: /etc/init.d/monithor-c {start|stop|status}" || true
exit 1

View File

@ -1,3 +0,0 @@
10.10.10.3:1666#file#/tmp/test
10.10.10.3:1666#part#/home/isen|50|80
10.10.10.3:1666#process#sshd

View File

@ -1,3 +0,0 @@
10.10.10.4:1666#file#/tmp/test
10.10.10.4:1666#part#/home/isen|50|80
10.10.10.4:1666#process#sshd

View File

@ -0,0 +1,4 @@
#IP:PORT#SONDE#ARGUMENT
#Ex :
#10.10.10.3:1666#part#/home/isen|50|80

View File

@ -1,4 +1,3 @@
RemoteIp=10.10.10.3:1666
LocalPassword='Evil@MonitoR-666'
Crypted=no
Rotation=1

View File

@ -1,8 +0,0 @@
10.10.10.3:1666#file#/tmp/coucou
10.10.10.3:1666#file#/tmp/nop
10.10.10.3:1666#file#
10.10.10.3:1666#NotRealSondeName#reboot
10.10.10.4:1666#file#/tmp/coucou
10.10.10.4:1666#file#/tmp/nop
10.10.10.4:1666#file#
10.10.10.4:1666#NotRealSondeName#reboot

View File

@ -1,12 +1,10 @@
#!/bin/bash
source /etc/monithor-client/service.cfg
Ip=$(echo $RemoteIp| cut -d":" -f1)
Exit () {
[[ "$1" == "root" ]] && echo "You have to be root ..."
[[ "$1" == "Config" ]] && echo "Ip configuration will failed"
exit
}
@ -16,15 +14,13 @@ if [[ $(id -u) != "0" ]]
Exit root
fi
[[ ! -z $(ifconfig | grep inet | awk '{print $2}' | grep $Ip) ]] && Exit Config
if [[ "$1" == "start" ]]
then
[[ -f /tmp/endmonitor ]] && rm -f /tmp/endmonitor
rm /tmp/Monitor* /tmp/webmonithor &> /dev/null
TotalConfig=$(ls -1 /etc/monithor-client/conf/ | grep Card_.*\.cfg|wc -l)
for Conf in $(ls -1 /etc/monithor-client/conf/ | grep Card_.*\.cfg)
TotalConfig=$(ls -1 /etc/monithor-client/conf/ | grep .*\.cfg| wc -l)
for Conf in $(ls -1 /etc/monithor-client/conf/ | grep .*\.cfg)
do
screen -dmS ${Conf} bash /usr/local/bin/monithor-client.d/MoniThor ${Conf}
done
@ -33,7 +29,7 @@ fi
if [[ "$1" == "stop" ]]
then
killall python &> /dev/null
killall python3 &> /dev/null
rm /tmp/Monithor* &> /dev/null
touch /tmp/endmonitor

View File

@ -15,16 +15,19 @@ while [[ ! -f /tmp/endmonitor ]]
GenerateWebEnd /tmp/Monithor_${ConfFile}-tmp
sleep ${Rotation}
else
while read DATA
do
Remote=$(echo $DATA| cut -d"#" -f1| cut -d":" -f1)
Port=$(echo $DATA| cut -d"#" -f1| cut -d":" -f2)
Cmd=$(echo $DATA| cut -d"#" -f2)
Arg=$(echo $DATA| cut -d"#" -f3)
Res=$( echo -e "${Cmd}#${Arg}" | eval ${NcCmd} ${Remote} ${Port} 2> /dev/null)
Ret=$?
GenerateWeb "${Res:-5|No sonde $Cmd on serveur $Remote}" ${Cmd:-Nodata} ${Arg:-Noadata} ${Remote:-Nodata} /tmp/Monithor_${ConfFile}-tmp
done < /etc/monithor-client/conf/${ConfFile}
while read DATA
do
Remote=$(echo $DATA| cut -d"#" -f1| cut -d":" -f1)
Port=$(echo $DATA| cut -d"#" -f1| cut -d":" -f2)
Cmd=$(echo $DATA| cut -d"#" -f2)
Arg=$(echo $DATA| cut -d"#" -f3)
Res=$( echo -e "${Cmd}#${Arg}" | eval ${NcCmd} ${Remote} ${Port} 2> /dev/null)
Ret=$?
if [[ ! -z $(echo $DATA | grep ^"[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*:[0-9]*#.*#" ) ]]
then
GenerateWeb "${Res:-5|No sonde $Cmd on serveur $Remote}" ${Cmd:-Nodata} ${Arg:-Noadata} ${Remote:-Nodata} /tmp/Monithor_${ConfFile}-tmp
fi
done < /etc/monithor-client/conf/${ConfFile}
fi
done

View File

@ -23,7 +23,7 @@ CheckAllEnd() {
echo '
<html>
<head>
<title>MoniThor on '${RemoteIp}' </title>
<title>MoniThor on '$(hostname)' </title>
<meta http-equiv="refresh" content="1" />
</head>
<title>MONITHOR</title>

View File

@ -3,18 +3,20 @@
pushd /var/www/html/monithor
source /usr/local/bin/monithor-client.d/MoniThorFnct
python -m SimpleHTTPServer ${1} &
python3 -m http.server ${1} &
echo '<html>
<head>
<title>MoniThor on '${RemoteIp}' </title>
<title>MoniThor on '$(hostname)' </title>
<meta http-equiv="refresh" content="1" />
</head>
<title>MONITHOR</title>
!!!! Initialization !!!!
Warning : check the config /etc/monithor-client/conf/*cfg
' > index.html
while [[ ! -f /tmp/endmonitor ]]

View File

@ -1,6 +1,6 @@
Package: monithor-client
Package: monithor-server
Version: 1.0
Architecture: all
Dependsd:netcat,cryptcat,screen,python,netcat,cryptcat,elinks
Dependsd:netcat,cryptcat,screen,python3,netcat,cryptcat,elinks
Maintainer: Guillaume Astier <guillaume@gastier.net>
Description: monithor client (with simple http server python)
Description: monithor server (netcat & snort)

View File

@ -30,6 +30,13 @@ case "$1" in
/usr/local/bin/monithor-server stop
;;
status)
logger "status MoniThor server" "monithor-d" || true
[ "$(ps axf| grep '/usr/local/bin/monithor-server'|grep -v grep)" ] && echo "monithor-d is running" || echo "montihor-d is dead"
;;
*)
echo "Usage: /etc/init.d/monithor-d {start|stop|status}" || true
exit 1

View File

@ -1,4 +1,4 @@
LocalIp=10.10.10.4
RemoteIp=10.10.10.4
LocalPort=1666
########
Crypted=no

View File

@ -8,7 +8,7 @@ source /etc/monithor-server/service.cfg
Exit () {
[[ "$1" == "root" ]] && echo "You have to be root ..."
[[ "$1" == "Config" ]] && echo "Ip configuration will failed"
#[[ "$1" == "Config" ]] && echo "Ip configuration will failed"
exit
}
@ -18,17 +18,17 @@ if [[ $(id -u) != "0" ]]
Exit root
fi
[[ -z $(ifconfig | grep inet | awk '{print $2}' | grep $LocalIp) ]] && Exit Config
#[[ -z $(ifconfig | grep inet | awk '{print $2}' | grep $RemoteIp) ]] && Exit Config
[[ "${Crypted}" == "yes" ]] && NcCmd="cryptcat -k ${LocalPassword} -l ${LocalIp} -p ${LocalPort} " || NcCmd="nc -l ${LocalIp} ${LocalPort}"
[[ "${Crypted}" == "yes" ]] && NcCmd="cryptcat -k ${LocalPassword} -l ${RemoteIp} -p ${LocalPort} " || NcCmd="nc -l ${RemoteIp} -p ${LocalPort}"
if [[ "${1}" == "start" ]]
then
while true
do
#coproc cryptcat -k ${LocalPassword} -l ${LocalIp} -p ${LocalPort}
#coproc cryptcat -k ${LocalPassword} -l ${RemoteIp} -p ${LocalPort}
coproc eval ${NcCmd}
while read -r cmd; do
logger "Running $cmd"