From 157f3642513119eb00e70d5afb9eed3127c507b2 Mon Sep 17 00:00:00 2001 From: mickael Date: Fri, 8 Feb 2019 08:26:58 +0100 Subject: [PATCH] First commit --- LogScript | 18 ++++++++++++++++++ agent.sh | 30 ++++++++++++++++++++++++++++++ analyze.sh | 17 +++++++++++++++++ config | 0 config-save | 2 ++ 5 files changed, 67 insertions(+) create mode 100755 LogScript create mode 100755 agent.sh create mode 100755 analyze.sh create mode 100644 config create mode 100644 config-save diff --git a/LogScript b/LogScript new file mode 100755 index 0000000..3dbd3cd --- /dev/null +++ b/LogScript @@ -0,0 +1,18 @@ +#!/bin/bash +# Indique au système que l'argument qui suit est le programme utilisé pour exécuter ce fichier +# En règle générale, les "#" servent à mettre en commentaire le texte qui suit comme ici +echo pwd +touch log +echo PROCESS > log +ps >> log +echo TACHE >> log +echo PERIPHERIQUE >> log +lsusb >> log +lspci >> log +echo MODELE >> log +cat /proc/version >> log +echo COPIE LOG + + + + diff --git a/agent.sh b/agent.sh new file mode 100755 index 0000000..1aade35 --- /dev/null +++ b/agent.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +PASS="agent123" + +id=$1 + +center="mickael@172.16.131.74" + +host=$USER"@"$(ip a | grep "inet " | tail -1 | cut -d " " -f 6 | cut -d "/" -f 1) + +remote=$(sed -n "1p" config) + +if [ "$remote" != "" ] + then + echo "From : "$host + echo "To : "$remote + sed -i "1d" config + sshpass -p $PASS ssh-copy-id -o StrictHostKeyChecking=no $remote 2> /dev/null + ssh $remote " +sshpass -p $PASS ssh-copy-id -o StrictHostKeyChecking=no $host 2> /dev/null; +sshpass -p $PASS ssh-copy-id -o StrictHostKeyChecking=no $center 2> /dev/null; + +scp -o StrictHostKeyChecking=no $host:config $remote:config; +scp -o StrictHostKeyChecking=no $host:agent.sh $remote:agent.sh; +scp -o StrictHostKeyChecking=no $host:analyze.sh $remote:analyze.sh; +./analyze.sh; +scp -o StrictHostKeyChecking=no log $center:log/log-$remote; +rm log; +./agent.sh $id;" +fi diff --git a/analyze.sh b/analyze.sh new file mode 100755 index 0000000..3e2ed8c --- /dev/null +++ b/analyze.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Indique au système que l'argument qui suit est le programme utilisé pour exécuter ce fichier +# En règle générale, les "#" servent à mettre en commentaire le texte qui suit comme ici +touch log +echo PROCESS > log +ps >> log +echo TACHE >> log +echo PERIPHERIQUE >> log +lsusb >> log +lspci >> log +echo MODELE >> log +cat /proc/version >> log +echo COPIE LOG + + + + diff --git a/config b/config new file mode 100644 index 0000000..e69de29 diff --git a/config-save b/config-save new file mode 100644 index 0000000..1af0972 --- /dev/null +++ b/config-save @@ -0,0 +1,2 @@ +mickael@172.16.131.33 +mickael@172.16.131.74 \ No newline at end of file