Last active
December 30, 2018 22:38
-
-
Save daktak/11236822 to your computer and use it in GitHub Desktop.
Take a photo from the webcam and email it. Requires sendmail and mplayer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#edit /etc/pam.d/system-auth | |
#change pam_unix (line 2 to below) | |
#auth [success=1 new_authtok_reqd=ok ignore=ignore default=bad] pam_unix.so try_first_pass likeauth nullok | |
#auth [default=ignore] pam_exec.so seteuid /usr/local/bin/getwebshot.sh | |
TMP_DIR=/tmp/cheese | |
HOSTNAME=localhost | |
MAILTO=me@email.com | |
MAILFROM=root@email.com.au | |
SUBJECT="Do you know this person?" | |
IP=`ifconfig | grep "inet " | column -t | awk '{print $2}'` | |
PUB_IP=`curl ifconfig.me` | |
ATTACH=$TMP_DIR/00000001.jpg | |
HOST=`hostname` | |
BODY=$TMP_DIR/body.html | |
file=$( basename "$ATTACH") | |
echo $PUB_IP >> $BODY | |
if [ ! -e $TMP_DIR ]; then | |
mkdir $TMP_DIR | |
fi | |
mplayer tv:// -vo jpeg:outdir=$TMP_DIR -frames 1 -nosound | |
#ffmpeg -f video4linux2 -s vga -i /dev/video0 -vframes 1 $ATTACH | |
cd /tmp/cheese | |
{ | |
echo "From: $MAILFROM" | |
echo "To: $MAILTO" | |
echo "MIME-Version: 1.0" | |
echo "Subject: $SUBJECT" | |
echo "Content-Type: multipart/mixed; boundary=\"FILEBOUNDARY\"" | |
echo "--FILEBOUNDARY" | |
echo "Content-Type: text/plain; charset=ISO-8859-1; format=flowed"; | |
echo "Content-Transfer-Encoding: 7bit"; | |
echo "Content-Disposition: inline"; | |
echo "" | |
echo "HOSTNAME: $HOST" | |
echo "PUBLIC IP: $PUB_IP" | |
echo "INTERNAL IP(S): " | |
echo "$IP" | |
echo "" | |
echo "" | |
echo "--FILEBOUNDARY" | |
echo "Content-Type: image/jpg" | |
echo "Content-Disposition: attachment; filename=00000001.jpg" | |
echo "Content-Transfer-Encoding: base64" | |
echo "" | |
base64 "$ATTACH" | |
echo "--FILEBOUNDARY" | |
} | /usr/sbin/sendmail -t | |
#scp the picture | |
#sudo su - userwithkey -c 'scp -P 443 $TMP_DIR/00000001.jpg user@ip.info:~/' | |
#run a command on remote server | |
#sudo su - userwithkey -c "ssh -p 443 user@ip.info 'python2 xbmcsend.py -t Urgent -m \"Failed password attempt\"'" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment