Salut!
Suite à ce fil : retrouver-son-precieux-ordi-ou-tel-t43072.html
j’ai voulu faire ma propre version, qui ne nécessite pas d’ouverture de session X, comme ça, même si le voleur n’a pas mon mot de passe, le programme est quand même lancé.
C’est un simple script shell, qui est éxécuté par root via une tache cron.
EDIT1 : Si la connexion internet n’est pas disponible, l’envoi est retenté tous les $RETRY secondes.
Plus d’infos ici : yeuxdelibad.net/Programmation/Charmou.html
J’aimerais avoir vos commentaires, et surtout vos idées d’informations supplémentaires à inclure.
Le script :
[code]#!/bin/sh
Some variables, edit to fit your needs
Where the program will work
RPDIR=/tmp/charmou
SSH config. Don’t touch if not needed
You might want to use key authentification instead of clear passwd
YOURSERVER=“superserver.net”
LOGIN=“superman”
PORT=“22”
Replace here with your favorite command line
How to get public ip, example "wget -qO- ifconfig.me/ip
PUBLICIP=“wget -qO- yeuxdelibad.net/ip.php”
Name of the webcam capture
CAPTUREIMAGE=“webcamshot-$(date +%Y-%m-%d-%H-%M-%S).jpg”
How to take a shot with webcam
WEBCAMSHOT=“fswebcam -q --no-banner $CAPTUREIMAGE”
How to reduce png size. (jpegoptim, optipng, pngnq -e “.png” -f ,…)
OPTIMAGE=“jpegoptim”
How to compress data
ARCHIVE="$(hostname)_$(date +%Y%m%d-%H%M).tgz"
COMPRESS=“tar -czf $ARCHIVE *”
How to get network informations
NTKINFO="/sbin/ifconfig -a && /sbin/iwconfig"
Traceroute to a public server
TRACEROUTE=“traceroute -q1 -n www.google.com”
How to get wifi access points
WIFIAP="/sbin/iwlist scanning"
How to know network connections
NTKCNT=“netstat -putn”
Command to upload or send the report
example by email :
UP=“echo “charmou report” | mail -s “Rapport charmou” -a $RPDIR/$ARCHIVE superman@krypton.org”
UP=“scp -P $PORT $RPDIR/$ARCHIVE $LOGIN@$YOURSERVER:/home/superman/charmou/”
Time to wait if upload failed (no connexion) in seconds
RETRY=5
LOGFILE=$RPDIR/infos.log
getinfos() {
echo "Date/time: $(date +%Y/%m/%d-%X) "
echo “Computer name: $(hostname)”
echo -n "Public IP: "
eval $PUBLICIP || echo “Public Ip unavailable”
echo “”
echo "Network configuration: "
eval $NTKINFO
echo "Nearby wireless access points: "
eval $WIFIAP
echo "Network routes: "
eval $TRACEROUTE
echo "Current network connections: "
eval $NTKCNT
Add here anything else
}
echo “* Let’s go in $RPDIR…”
mkdir -p $RPDIR || exit 1
cd $RPDIR
echo “* It’s $(date) and we begin the record on $(hostname)”
echo “-----”
echo -n “* Taking shot with webcam…”
eval $WEBCAMSHOT && echo “[done]” || echo “[failed]”
echo -n “* Optimize picture size…”
eval $OPTIMAGE $CAPTUREIMAGE >/dev/null 2>&1 && echo “[done]” || echo “[failed]”
echo -n “* Getting some informations…”
getinfos > $LOGFILE 2>&1 && echo “[done]” || echo “[failed]”
echo -n “* Compressing data…”
eval $COMPRESS && echo “[done]” || echo “[failed]”
echo -n “* Sending report…”
eval $UP
while [ $? -ne 0 ]; do
echo “[failed] -> Trying again in $RETRY sec”
sleep $RETRY
eval $UP
done
echo “[done]”
echo -n “* Cleaning…”
rm -r “$RPDIR” || echo “[done]” || echo “[failed]”
echo “-----”
echo “Bye bye o/”
exit 0
[/code]