Send photo to email when entering wrong password
Step 1 : Prerequisites installation (Optional if available)
- ffmpeg (Photo app)
- s-nail (Mail app)
For more ways to take picture refer this article.
$ sudo apt update
$ sudo apt install ffmpeg s-nail
Step 2 : Create App password from google account
Check this to create app passwords.
Step 3 : Change the email and password(App password) in the script
Create file
sudo nano /usr/local/bin/takepic
filename=`date +%s`
ffmpeg -f video4linux2 -s vga -i /dev/video0 -vframes 1 /tmp/$filename.jpg
echo ' ALERT Usage detected:' `date` `who` | s-nail -a /tmp/$filename -S smtp-use-starttls -S ssl-verify=ignore -S smtp-auth=login -S smtp=smtp://smtp.gmail.com:587 -S from="username@gmail.com" -S smtp-auth-user=username@gmail.com -S smtp-auth-password=ashalkshalkhsbzxn -S ssl-verify=ignore -s "LOGIN ALERT" -v "tousername@gmail.com"
exit 0
Save and close.
$ sudo chmod +x /usr/local/bin/takepic
Step 4 : Change the pam.d
Backup the original file
$ sudo cp /etc/pam.d/common-auth /etc/pam.d/common-auth.orginal
$ sudo gedit /etc/pam.d/common-auth
- Update
- auth [success=1 default=ignore] pam_unix.so nullok_secure
- To
- auth [success=2 default=ignore] pam_unix.so nullok_secure
- Add the following, next to the updated line
- auth [default=ignore] pam_exec.so seteuid /usr/local/bin/takepic
Then save it. Try and have fun
Comments
Post a Comment