Let us imagine a completely hypothetical situation where a hypothetical someone might have left their web-cam equipped laptop on a hypothetical desk while going for a hypothetical night out. In this hypothetical situation another hypothetical person comes along and hypothetically tries to log in repeatedly and then shuts down the laptop. Let us imagine the hypothetical emotions of that hypothetical laptop owner. They’d be hypothetically furious. Especially if their rsync’s had stopped, their ssh sessions been terminated, their IDE sessions closed, their documents lost. Their hypothetical furry would know no bounds. Further frustrating to their hypothetical furry would be the time taken to repair hypothetical file-systems and rescue anything that had been hypothetically broken by this sudden termination.
Imagine then our hypothetical friend’s hypothetical furry if they were slighted not once but twice.
Of course our hypothetical friend would vent their furry into coding, and as we know Python is the balm of the soul. Let us view some of this hypothetical Python.
from send_mail import send_mail
import commands
import pyinotify
import re
import time
import Skype4Py
from time import gmtime, strftime
CallStatus = 0
CallIsFinished = set ([Skype4Py.clsFailed, Skype4Py.clsFinished, Skype4Py.clsMissed,Skype4Py.clsRefused, Skype4Py.clsBusy, Skype4Py.clsCancelled])
def CallStatusText(status):
return skype.Convert.CallStatusToText(status)
def OnCall(call, status):
global CallStatus
CallStatus = status
print 'Call status: ' + CallStatusText(status)
print call.PstnNumber
try:
if (CallStatusText(status) == "Calling" and call.PstnNumber == "+<your phone number>"):
call.Answer()
print "Call accepted."
except:
print "Failed to accept."
skype = Skype4Py.Skype()
try:
skype.Attach()
skype.OnCallStatus = OnCall
except:
print "Skype attach failed, skype calling will not be possible."
class TrackModifications(pyinotify.ProcessEvent):
def process_IN_MODIFY(self, event):
f = open("/var/log/auth.log")
l = f.readlines()
f.close()
if (re.search("gnome-screensaver-dialog\: pam_unix\(gnome-screensaver\:auth\)\: authentication failure\;", l[-1]) <> None):
print "Access!"
fn = '/home/user/tmp/snap-fail-' + strftime("%d-%b-%Y_%H:%M:%S", gmtime()) + '.jpg'
commands.getoutput('uvccapture -m -x640 -y480 -o' + fn)
send_mail("<email>", "<sms email>", "", "Failed access at `" + strftime("%a, %d %b %Y %H:%M:%S", gmtime()) + "` you will receive a picture soon.", None)
send_mail("<email>", "<sms email>", "Login Failed", "Failed log-in to 'The Pandora'.\n" + l[-1], fn)
if (re.search("The-Pandora gnome-screensaver-dialog\: gkr-pam\: unlocked \'login\' keyring", l[-1]) <> None):
print "Access!"
fn = '/home/user/tmp/snap-accept-' + strftime("%d-%b-%Y_%H:%M:%S", gmtime()) + '.jpg'
commands.getoutput('uvccapture -m -x640 -y480 -o' + fn)
send_mail("<email>", "<sms email>", "", "Login accepted at `" + strftime("%a, %d %b %Y %H:%M:%S", gmtime()) + "` you will receive a picture soon.", None)
send_mail("<email>", "<sms email>", "Login Accepted", "Accepted log-in to 'The Pandora'.\n" + l[-1], fn)
pass
wm = pyinotify.WatchManager()
handler = TrackModifications()
notifier = pyinotify.Notifier(wm, default_proc_fun=handler)
wm.add_watch('/var/log/auth.log', pyinotify.IN_MODIFY)
notifier.loop()
fn = '/home/user/tmp/snap-end-' + strftime("%d-%b-%Y_%H:%M:%S", gmtime()) + '.jpg'
send_mail("<email>", "<sms email>", "", "Process ending on 'The Pandora' at`" + strftime("%a, %d %b %Y %H:%M:%S", gmtime()) + "`", None)
commands.getoutput('uvccapture -m -x640 -y480 -o' + fn)
send_mail("<email>", "<sms email>", "", "Process ending on 'The Pandora'.", fn)
The email function used for this code is very messy and actually has some pass-phrases I’d rather not show you, I suggest looking at google and various links it offers
def send_mail(send_from, send_to, subject, text, f, server="smtp.gmail.com:587"):
Where text is the message, f is the file and server is the server, I advise using Gmail as it has a Email t0 SMS gateway. The way I used it I simply had to put my phone number before `@tmomail.net` (something like 15552223344@tmomail.net). With a little googling you’ll find the appropriate suffixes for most carriers.
So, what is this? Well, basically it’s a library to allow a series of things.
- Photographic evidence of all log-ins.
- SMS and MMS (with photo) alerts when your computer is logged into or someone attempts.
- Accept calls so you can monitor audio from your computer.
- I also modified it to call out to me when there’s a log in, oh for video calling…
- It records the script being terminated.
You may have to adjust the command for ‘uvccapture’, you will want to adjust the host name (The Pandora) to yours. Remember to add your SMS Email and Email.
This script will be built off of to create something a lot more advanced and a lot better and more useful. It would be possible to rewrite this for Windows or Mac, I guess that cutting out the Skype and replacing the UVC code would be all that’d be needed.
I hope this was of use to someone. Please post comments if you find a use and/or have some success with it, I’d love to hear stories of how you caught hypothetical siblings with it.
Kind regards, Robert.
















Wall RSS Feed