[INIT] - add client & server
This commit is contained in:
commit
ec039ce26a
11
README.md
Normal file
11
README.md
Normal file
@ -0,0 +1,11 @@
|
||||
# MoniThor
|
||||
|
||||
MoniThor is a simple monitoring tools in bash.
|
||||
|
||||
It used netcat encrypted version :
|
||||
|
||||
```
|
||||
cryptcat
|
||||
```
|
||||
|
||||
|
||||
23
client/Client.sh
Executable file
23
client/Client.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
cd $(dirname $0)/conf-client/
|
||||
|
||||
SondeFile=$(pwd)/sonde.cfg
|
||||
source service.cfg
|
||||
|
||||
|
||||
while read DATA
|
||||
do
|
||||
Cmd=$(echo $DATA| cut -d"#" -f1)
|
||||
Arg=$(echo $DATA| cut -d"#" -f2)
|
||||
Res=$(echo -e "${Cmd}#${Arg}" | timeout 0.1 cryptcat -k ${LocalPassword} ${RemoteIp} ${RemotePort} 2> /dev/null)
|
||||
if [[ -z $Res ]]
|
||||
then
|
||||
echo "5|No sonde $Cmd on serveur $RemoteIp"
|
||||
else
|
||||
echo "$Res"
|
||||
fi
|
||||
done < ${SondeFile}
|
||||
|
||||
|
||||
4
client/conf-client/service.cfg
Normal file
4
client/conf-client/service.cfg
Normal file
@ -0,0 +1,4 @@
|
||||
RemoteIp=127.0.0.1
|
||||
RemotePort=8080
|
||||
LocalPassword='Evil@MonitoR-666'
|
||||
|
||||
4
client/conf-client/sonde.cfg
Normal file
4
client/conf-client/sonde.cfg
Normal file
@ -0,0 +1,4 @@
|
||||
file#/tmp/coucou
|
||||
file#/tmp/nop
|
||||
file#
|
||||
tamere#reboot
|
||||
35
server/Daemon.sh
Executable file
35
server/Daemon.sh
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd $(dirname $0)/conf-server/
|
||||
|
||||
ScriptDir=$(pwd)/scripts/
|
||||
SondeFile=$(pwd)/sonde.cfg
|
||||
source service.cfg
|
||||
|
||||
echo "coproc cryptcat -k "${LocalPassword}" -l ${LocalIp} ${LocalPort}"
|
||||
while true
|
||||
do
|
||||
coproc cryptcat -k ${LocalPassword} -l ${LocalIp} -p ${LocalPort}
|
||||
while read -r cmd; do
|
||||
logger "Running $cmd"
|
||||
cpt=0
|
||||
while read DATA
|
||||
do
|
||||
Sonde=$(echo ${DATA}| cut -d"#" -f1)
|
||||
Exec=$(echo ${DATA}| cut -d"#" -f2)
|
||||
RealCmd=$(echo ${cmd} | cut -d"#" -f1)
|
||||
ArgCmd=$(echo ${cmd} | cut -d"#" -f2)
|
||||
if [[ "${RealCmd}" == "$Sonde" ]]
|
||||
then
|
||||
logger "Exec $Exec $Arg $cpt"
|
||||
bash ${ScriptDir}/${Exec} $ArgCmd
|
||||
cpt=$((cpt+1))
|
||||
break
|
||||
fi
|
||||
done < ${SondeFile}
|
||||
[[ "${cpt}" -eq 0 ]] && logger "You Failed $Sonde $Exec $Arg"
|
||||
|
||||
done <&"${COPROC[0]}" >&"${COPROC[1]}"
|
||||
|
||||
done
|
||||
|
||||
9
server/conf-server/scripts/FunctionOutput
Normal file
9
server/conf-server/scripts/FunctionOutput
Normal file
@ -0,0 +1,9 @@
|
||||
Exit() {
|
||||
|
||||
|
||||
Val=$(echo $1| cut -d"|" -f1)
|
||||
Txt=$(echo $1| cut -d"|" -f2)
|
||||
echo "$Val|$Txt"
|
||||
exit $Val
|
||||
|
||||
}
|
||||
12
server/conf-server/scripts/file-present.sh
Normal file
12
server/conf-server/scripts/file-present.sh
Normal file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
source $(dirname $0)/FunctionOutput
|
||||
|
||||
File="${1}"
|
||||
|
||||
[[ -z ${File} ]] && Exit "5|no argument"
|
||||
|
||||
|
||||
[[ -f ${File} ]] && Exit "0|File $File exist" || Exit "2|File $File is NOT present"
|
||||
|
||||
3
server/conf-server/service.cfg
Normal file
3
server/conf-server/service.cfg
Normal file
@ -0,0 +1,3 @@
|
||||
LocalIp=127.0.0.1
|
||||
LocalPort=8080
|
||||
LocalPassword='Evil@MonitoR-666'
|
||||
3
server/conf-server/sonde.cfg
Normal file
3
server/conf-server/sonde.cfg
Normal file
@ -0,0 +1,3 @@
|
||||
network#ip.sh
|
||||
file#file-present.sh
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user