[UPDATED 12-10-08] Should all work So here is the updated script - we will see how well it works soon enough
First install everything you need
sudo apt-get install postfix mutt cheese streamer libsasl2-2 libsasl2-modules
Now configure postfix, after installing do
sudo dpkg-reconfigure postfix
select ok; internet site; server1.example.com; leave this one blank; server1.example.com, localhost; NO; 127.0.0.1/8; 0; +; ALL
Now from http://ubuntu-tutorials.com/2008/11/11/relaying-postfix-smtp-via-smtpgmailcom/ do the following (assuming you use Gmail)
Now do ``` sudo nano /etc/postfix/main.cf
and add this to the end of the file
relayhost = [smtp.gmail.com]:587 smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_tls_CAfile = /etc/postfix/cacert.pem smtp_use_tls = yes
now exit and save
next do
sudo nano /etc/postfix/sasl_passwd
and put this in it
[smtp.gmail.com]:587 user.name@gmail.com:password
replace the username and password
then run this
sudo chmod 400 /etc/postfix/sasl_passwd sudo postmap /etc/postfix/sasl_passwd
Now we are going to create the script
sudo nano /etc/init.d/securetwit
and populate it with
#!/bin/bash
Script by L|nuxPS2 with help from
http://ubuntuforums.org/archive/index.php/t-129304.html : http://ubuntuforums.org/archive/index.php/t-526176.html
and leftyfb from #ubuntu on EFnet
BEGIN INIT INFO
Provides: securetwit
Required-Start: $remote_fs $syslog
Required-Stop: $remote_fs $syslog
Default-Start: 2 3 4 5
Default-Stop: 0 1 6
Short-Description: A just-for fun security measure that uses twitter
Description: Securetwit sends the picture and external IP address of whomever turns on a computer with a webcam
END INIT INFO
IP=$(wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
streamer -c /dev/video0 -b 32 -o /etc/securetwit/pic.jpeg
echo | mutt -a '/etc/securetwit/pic.jpeg' -s "Someone is on your Laptop from $IP " USERNAME@twitpic.com
mv /etc/securetwit/pic.jpeg /etc/securetwit/pic.jpeg.old
exit 0
save and close it. now add it to the startup
update-rc.d securetwit defaults 99
and make it executable
chmod +x /etc/init.d/securetwit
and make a folder for it to use to save everything in
sudo mkdir /etc/securetwit
restart and the script should work - the only problem I can see is that it will just fail to ping the websites and then not run - I just need to find a way to make it keep trying and upon success stop... all while running in the background... hrm... it might do that now, i'll see
[ORIGINAL POST]
> So i don't know if this has been done before or if it falls under security but if not i'm sure a mod will put it where it should be...
This is my first script so don't get all pissy about how i did something wrong - I know I most likely did, think constructive and point me to some stuff that could help
Anyways, I just wrote a quick script that should be of some use if you have a laptop with a built in webcam (or a pc with a well situated webcam)
This uses Twitter and Twitpic to send a picture of whoever is on your computer whenever the script is run - that way you get an update sent to your phone with who is using it.
First its good if you make a new twitter account just for this - that way you can follow it and get the update to your phone - make sure its not on the public timeline and you should be good
some preliminary stuff
sudo apt-get install cheese streamer mutt sendmail
cheese just to see if your webcam is working, streamer to capture the frame from the webcam and output the file mutt to send it to twitpic and sendmail so you can actually use mutt...
right off the bat i have no eartly idea how the hell postfix manages to work but here is the guide I followed - sorry I am of no help in that department (and I mean NONE :P )
[http://www.howtoforge.com/perfect_setup_ubuntu_6.10_p5](http://www.howtoforge.com/perfect_setup_ubuntu_6.10_p5)
Once you have that done were on to making the script
first: in your home directory
mkdir '.securetwit' cd ~/.securetwit/ nano securetwit.sh
Now for making the shell script
#!/bin/bash
streamer -c /dev/video0 -b 32 -o ~/.securetwit/pic.jpeg
wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//' | mutt -a '/home/[COLOR="RoyalBlue"]USER[/COLOR]/.securetwit/pic.jpeg' -s "" '[COLOR="RoyalBlue"]USER.NUMBER@twitpic.com[/COLOR]'
mv ~/.securetwit/pic.jpeg ~/.securetwit/pic.jpeg.old
exit 0
Make sure to replace the bold and blue text with your username (I had trouble getting mutt to read the attachment from '~/.securetwit/pic.jpeg') and the link that twitpic will give you to send pictures to - also make sure your pics arent sent to the public timeline within twitpic
now just
chmod +x securetwit.sh
Now add it to the startup programs or whenever you log in make it run automatically
Currently it outputs the external IP in the body of the email which is useless so if anyone knows how to make mutt let me put it as the subject please let me know...
Obviously you could just make it email the picture to you but i'm sure there are plenty of better programs and whatnot that could do this - i just thought it would be fun for my first script to integrate twitter into things that way it can all be done via cell phone
None the less, Hope you enjoy it
-LinuxPS2