![]() |
SMS-based stolen phone locator
1 Attachment(s)
This script was born out of my rage of having my N900 stolen earlier this year. I wanted a simple SMS-based solution for retrieving my new N900 if it were ever stolen again. I used some python code for SMS send/recv and GPS tracking from the wiki and put it together for this.
Here's how it works: At phone startup, the script reads the SIM card number and compares it to your own valid number. If invalid, it'll send an SMS every x seconds to a pre-defined phone number that includes IMSI and GPS coordinates. It also makes a phone call to the same number after a user-defined number of seconds (to lower chance of thief closing out the phone app). Whether the SIM card is valid or not, the script listens for a user-defined SMS alert-code. When alert mode is activated, it returns texts to the incoming number with the same info as above (IMSI and GPS). Installation: 1. Send thief-be-caught.tar.gz to n900 2. Extract: tar cvf thief-be-found.tar.gz -C / 3. Fill out variables at the top of /etc/event.d/banana 3. Reboot 4. Check if script is running with: ps | grep sms Prereqs: python libraries (incl. python-location) To close the daemon: sh /usr/sbin/sms-quit.sh Notes: * Some alert code strings seem to be interpreted incorrectly by the SMS receiving procedure, so try changing the alert code if nothing happens. * Every time the GPS coordinates are read, the internal GPS and network positioning are enabled in case they were ever disabled. The location server will also be set to supl.google.com. I hope this helps someone get their phone back if anything unfortunate happens. I am new to sh and python scripting, so please test and improve or offer feedback. |
Re: SMS-based stolen phone locator
Thanks for that!
Do I have to activate it by sending SMS only? |
Re: SMS-based stolen phone locator
You may also be interested in http://www.whereismydevice.com, (see http://talk.maemo.org/showthread.php?t=51027) - you could integrate your script with this, which will then keep you updated even if the stolen n900 has no capability to send SMS, by updating the details on the website for you to monitor.
Cheers, Ben |
Re: SMS-based stolen phone locator
@Reeby
Yes, just send the ALERT_CODE you define. @benh Thanks. I'm setting up your scripts right now in case this falls through. |
Re: SMS-based stolen phone locator
Quote:
I now do it: cp /home/user/MyDocs/newfolder/* /usr/sbin and: cp /home/user/MyDocs/newfolder* /home/user/MyDocs/chmod 775 but that doesn't work :P do i have to follow the banana documents steps? don't really understand them |
Re: SMS-based stolen phone locator
AlexV12:
It requires either SSH or using XTerm. But please, don't do anything you don't know what is. EDIT: You updated right before me. Remember to do it as root. sudo gainroot |
Re: SMS-based stolen phone locator
Can somebody upload it to devel repository?
Thanks! |
Re: SMS-based stolen phone locator
Quote:
well it doesn't give an error but what do i do after i've copied the files to sbin and chmod? |
Re: SMS-based stolen phone locator
@alex
You must copy sms.py and sms_gps.py to the /usr/sbin folder. There is no chmod folder. chmod is a unix command that lets you change file permissions. In this case, we need these files to execute, so type in: Code:
cd /usr/sbin Make sure you edit the parameters at the top of this file. VALID_IMSI=XXXXXXXXXXX # this is your own IMSI SEND_TEXT_INTERVAL=120.0 # how often (sec) to send SMS HOME_PHONE=XXXXXXXXXX # designated phone number to send SMS and phone calls TIME_WAIT_TO_CALL=60 # time to wait (sec) after invalid SIM card detected before making phone call ALERT_CODE="XXXXXXXXX" # SMS code used to activate alert mode To fill out the VALID_IMSI field, you can find your own IMSI by entering this into the terminal: Code:
dbus-send --system --type=method_call --print-reply --dest=com.nokia.phone.SIM /com/nokia/phone/SIM Phone.Sim.get_imsi |
Re: SMS-based stolen phone locator
allright, i've done all that. how do you know when itms working?
like always xterm just goes to the next line (which normally means it worked what you typed) but how do you shut it off? i'm not going to try it before i can turn it off. |
Re: SMS-based stolen phone locator
good point.. need to have a way to shut it off. I've added a new file to the ZIP archive, sms-quit.sh.
Use this to shut the script down: Code:
sh /usr/sbin/sms-quit.sh Code:
ps | grep "sms.py" |
Re: SMS-based stolen phone locator
allright, i'll see if ican get it to work.
is there a possibility that when you sms the code or when the sim is changed, it will take photo's from front and rear camera so we might be able to get a headshot of the guy who's stolen your phone and sent it email or mms. and if you slide open the keyboard? i know there is aprogram called "i am here" which already does this, but unfortunatly it doesn't work anymore.. anyway, just to make sure i did everything right. this is what i have done so far: (i filled in the XXXXXX in banana) http://img529.imageshack.us/img529/7...0081811405.png now i rebooted and restarted xterminal http://a.yfrog.com/img59/840/screens...0081811480.png is this correct? |
Re: SMS-based stolen phone locator
yea, that's correct so far. Also, do chmod on sms-quit.sh so that you can run that later.
After a reboot, run: ps | grep "sms.py" If you see python /usr/sbin/sms.py --listen..., then it's working. This is when you can send yourself a text message with your alert code and the script will text back with info. You should see the GPS icon up in the status bar if it's working. I'll look into the front cam taking pics when the keyboard slides open. Not sure about it though, because the image quality is so bad. |
Re: SMS-based stolen phone locator
when i run: ps | grep "sms.py" i get:
1577 root [allot of spaces] 2088 S [allot of spaces] grep sms.py |
Re: SMS-based stolen phone locator
What happens when you run:
python /usr/sbin/sms.py --sendinfo phone_number 120 000 "alert" (replace phone_number with your #) |
Re: SMS-based stolen phone locator
This looks great, exactly the sort of thing I was looking for! Haven't delved too deeply into it but it would be great if it had the following:
The ability to change the 'home' phone number via the alert message, as it may be that your 'home' phone number may change when you no longer have access to the N900. So an SMS like: "$ALERT_CODE 0123456789" will send the info to 0123456789. If you don't supply a trailing number, it should use the stored 'home' phone number. With regard to taking a picture via the front camera, the best way would probably be to automatically take a picture if the IMEI isn't the valid one and a call has just finished. Hopefully the thief will be in the process of moving the phone away from their head so it'll catch a half decent picture of them. Also, I find that it takes a ridiculous amount of time (like 5-15 minutes) for my GPS to get a lock, does the script take this into account? The only issue I see is if the thief decides to wipe the OS, but I don't think the average crim is going to be bothered enough to do that, probably too busy looking through all your photo's and music! But good work! Even if it saves just one N900 from the crack heads then it has to be worth it. |
Re: SMS-based stolen phone locator
Nice work;
btw, i would replace VALID_IMSI=XXXXXXXXXXX by VALID_IMSI=`dbus-send --system --type=method_call --print-reply --dest=com.nokia.phone.SIM /com/nokia/phone/SIM Phone.Sim.get_imsi | head -2 | tail -1 | tr -s '"' ' ' | cut -d ' ' -f 3` |
Re: SMS-based stolen phone locator
Erm, wouldn't that mean that the IMSI is always valid?
|
Re: SMS-based stolen phone locator
Quote:
The 'home' number is irrelevant when alert mode is activated via text. The information will be replied back to the number that sent the alert. The GPS lock should be faster because I only require 3+ satellites to be locked on. Anyway, you'll be fine since the script waits for the GPS to provide a coordinate before sending a text. Finally, I don't think most phone thieves are advanced enough to flash rootfs. I have a good story about that. The guy who stole my phone took a full picture of himself in the mirror and had the bright idea to share it to my pixelpipe account lol. I had a good laugh when it popped up on my facebook page. I got his comcast IP address from pixelpipe, but my detective wasn't too advanced either, and never did get subscriber information from comcast. |
Re: SMS-based stolen phone locator
Quote:
|
Re: SMS-based stolen phone locator
I'm having trouble with the banana script, it seems to never launch on boot?
I've not chmod'd, just put it into /etc/event.d, is there anything else I need to do apart from edit the top? Is there anyway to see debug upstart? EDIT: Also, how about sending the cell tower info as well? |
Re: SMS-based stolen phone locator
Try commenting out these lines:
start on started hildon-desktop stop on starting shutdown script end script Then run it from terminal. What output do you get? |
Re: SMS-based stolen phone locator
Nokia-N900:/etc/event.d# sh banana
: not founde 2: : not founde 5: : not founde 6: : not founde 9: : not founde 17: : not founde 22: banana: line 26: syntax error: "done" unexpected (expecting "do") I didn't do anything apart from download it from the 1st post, put it into event.d and edit the top of the file EDIT: I think it needs bash? |
Re: SMS-based stolen phone locator
did you copy over the sms files? also, maybe you're missing python runtime?
|
Re: SMS-based stolen phone locator
Nope, I can run the files just fine manually, it's just the upstart script. The one thing I did do was edit banana using vim for windows, so maybe it's screwing up the line endings or something. I'll try with a 'vanilla' banana and not edit it before copying it across.
EDIT: Nope, still not working. I hate to ask this but have you tried using the files from your zipfile? Are you sure that the zip program isn't doing something strange to the line endings? |
Re: SMS-based stolen phone locator
fyi i wrote it using winscp's built-in text editor
EDIT: I tried downloading the zip file, copying banana using winscp, and editing it using winscp's editor and the python program still runs as it should. |
Re: SMS-based stolen phone locator
I ended up having to format it like this to get it to work without errors:
export VALID_IMSI= export SEND_TEXT_INTERVAL=120.0 export HOME_PHONE= export TIME_WAIT_TO_CALL=60 export ALERT_CODE="XXXXXX" touch /tmp/imsi export imsiFile=/tmp/imsi dbus-send --system --type=method_call --print-reply --dest=com.nokia.phone.SIM /com/nokia/phone/SIM Phone.Sim.get_imsi | grep string | cut -f 2 -d '"' > $imsiFile while read line do imsiNum=$line done < $imsiFile if [ $imsiNum -ne $VALID_IMSI ]; then python /usr/sbin/sms.py --sendinfo $HOME_PHONE $SEND_TEXT_INTERVAL $imsiNum $ALERT_CODE python /usr/sbin/sms.py --listen 0 $SEND_TEXT_INTERVAL $imsiNum $ALERT_CODE & sleep $TIME_WAIT_TO_CALL run-standalone.sh dbus-send --system --type=method_call --print-reply --dest=com.nokia.csd.Call /com/nokia/csd/call com.nokia.csd.Call.CreateWith string:"$HOME_PHONE" uint32:0 else python /usr/sbin/sms.py --listen 0 $SEND_TEXT_INTERVAL $imsiNum $ALERT_CODE & |
Re: SMS-based stolen phone locator
What does 'export' do? Also, is it working with upstart now? If so, could you attach your file to the post so I can test it and update the zip. Thx.
|
Re: SMS-based stolen phone locator
You are asking me what 'export' does? Sheesh.
Ok, I'll sit down and have a go at doing it properly and then get back to you. |
Re: SMS-based stolen phone locator
hah yeah.. as i mentioned, I'm new to sh scripting. I see that it makes the variables global, but I don't see how that fixes the script on your end.
|
Re: SMS-based stolen phone locator
Quote:
My GPS icon appears. it's flashing, but no solid connection after 1 minute |
Re: SMS-based stolen phone locator
Quote:
|
Re: SMS-based stolen phone locator
They have something like this in Firefox https://addons.mozilla.org/en-US/firefox/addon/51329/ Who wants to try and report back if its any good. I will try it in Minefield or Fennec mobile if they have for it.
|
Re: SMS-based stolen phone locator
Quote:
Control app: Code:
Nokia-N900:~# smscon Code:
Nokia-N900:~# smscon -log The current functions are: reboot, shutdown, show remaining battery charge, send current gps coordinates, send frontcam picture to my own server, set up ssh connection with available connection (WLAN/GPRS) to my own server) |
Re: SMS-based stolen phone locator
Quote:
Quote:
tar cvjf thief-be-found.tar.gz /etc/event.d/banana /usr/sbin/sms* Which would package them all up in a friendly manner so a user can unpack with this: tar xvjf thief-be-found.tar.gz -C / No need for changing directories or chmod. @digitalvoid: Yeah, well I drive a ferrari and shag a supermodel, fancy sharing your code or what? |
Re: SMS-based stolen phone locator
Quote:
Most people can't use it. Especially if they're looking for the user friendliness of an iPhone or Android device. I keep forgetting how to reflash my device myself once in a while. Heck install openssh, create a reverse tunnel and you'll be able to mess with the thief's head by using command line commands to make the device do what you want. =P |
Re: SMS-based stolen phone locator
Quote:
|
Re: SMS-based stolen phone locator
You are far, far more likely to have a cell connection than a wifi connection if the phone is stolen, so it's best to use the GSM side rather than relying on the thief to connect to the internet.
|
Re: SMS-based stolen phone locator
Quote:
|
Re: SMS-based stolen phone locator
There's other issues as well, like you don't need the tmp file. Here is what I have at the moment:
#!/bin/sh VALID_IMSI= SEND_TEXT_INTERVAL=120.0 HOME_PHONE= TIME_WAIT_TO_CALL=60 ALERT_CODE="" imsiNum=`dbus-send --system --type=method_call --print-reply --dest=com.nokia.phone.SIM /com/nokia/phone/SIM Phone.Sim.get_imsi | grep string | cut -f 2 -d '"'` echo $imsiNum if [ $imsiNum -ne $VALID_IMSI ]; then python /usr/sbin/sms.py --sendinfo $HOME_PHONE $SEND_TEXT_INTERVAL $imsiNum $ALERT_CODE python /usr/sbin/sms.py --listen 0 $SEND_TEXT_INTERVAL $imsiNum $ALERT_CODE & sleep $TIME_WAIT_TO_CALL run-standalone.sh dbus-send --system --type=method_call --print-reply --dest=com.nokia.csd.Call /com/nokia/csd/call com.nokia.csd.Call.CreateWith string:"$HOME_PHONE" uint32:0 else python /usr/sbin/sms.py --listen 0 $SEND_TEXT_INTERVAL $imsiNum $ALERT_CODE & fi Notice that you don't need to write/read a tmpfile, you can just use a backtick. But for some really annoying reason it still isn't working, p.s You didn't just copy and paste my tar command? I think you might have picked up sms-manager with the wildcard if you did. |
All times are GMT. The time now is 13:18. |
vBulletin® Version 3.8.8