View Single Post
Posts: 7 | Thanked: 23 times | Joined on Sep 2012
#1
Updated to Prey 0.5.9

I've updated Prey to 0.5.9 on my N900 after seeing it was released and finding the geo module was no longer working on 0.5.3 due to Google changing their API. I've also gotten the rest of prey working, including the gateway IP address and the webcam (using gst-launch). The webcam on the N900 takes rather dim pictures, so you'll just have to hope that any would-be thief uses it in a well lit area.

I've changed this post quite a bit, so I've uploaded the old one here if anyone still wants to take a look at 0.5.3:
http://sprunge.us/RMFF

I've also made quite a few more changes this time around to get everything working, so to make it easier, I've just made a .tar.gz file of my working version to download. I'll go ahead and list out the changes at the bottom of this for those who are curious.

Installation

First, download my tar file (attached to this post). A note here: I've remove the GPL license file and the pixmaps image folder from the archive to get it under the 488KB upload limit on this forum. I've attached the license in a separate file so as to not break the terms of the GPL.

Once you download it, you will need to place it on your phone with whatever method you what (I used sftp). Then, untar the file to /home/opt/prey:

Code:
cd /home/opt
mkdir prey/
cd prey/
mv /directory/tar/file/is/in/prey-maemo-0.5.9.tar.gz ./
tar xvzpf prey-maemo-0.5.9.tar.gz

Next we'll need to get curl working. Install curl from extras-devel. Note that curl will not work right away. Maemo holds back the update to libcurl3 for some reason (no idea why here, but I haven't found any negative effects from updating it).

Code:
apt-get install curl
apt-get install libcurl3

Next we will need bash4 (the regular bash package will not work correctly), wireless-tools, gstreamer-tools and imagemagick.

Code:
apt-get install bash4 wireless-tools gstreamer-tools imagemagick

Last we need to set up cron. You may be able to use fcron here, but I used cron since the prey script tries to call `crontab` several times.

Code:
apt-get install cron
Add a startup script for cron, so it will start after a reboot.

/etc/event.d/cron:
Code:
start on started hildon-desktop
stop on starting shutdown
console none
service
script
/etc/init.d/cron start
end script
Then you want to add prey to your crontab (replace nano with whatever editor you use):

Code:
EDITOR=nano crontab -e
Add the line:

Code:
*/10 * * * * bash4 /home/opt/prey/prey.sh > /var/log/prey.log 2>&1
After that, we should be ready to set up prey. Create an account on http://preyproject.com/. Once you create the account, log in and click on the "Account" tab. Once there, find your API key on the left side. You'll need to copy this into the config file:

Code:
nano -w /home/opt/prey/config
Find the api_key='' line and add your API key there. Then run the prey.sh script (you may need to make it executable first):

Code:
cd /home/opt/prey
chmod +x prey.sh
bash4 prey.sh
This should create a device in your control panel. Check and see. Also make sure it added the device key into your config file below the API key. If not, add this in (device key is found in the control panel on the left side when viewing a device).

Once that is done, it should be ready to test. Mark the device as missing in the control panel and set the frequency to whatever you want (I use 10). Note that it will update your crontab entry based on this. I also set it to recieve every bit of data that it can. Everything should be working at this point, but note that I've hardcoded the modified files time to 1 hour and the path to /home/user/MyDocs. If you would like to change this, look at the manual changes section below to see where to edit it.

After that, wait and make sure you recieve a report after 10 minutes, or you can run prey.sh manually to check as well. I'd also reboot and test it as well just to make sure cron was set up correctly.

If you've gotten several reports and everything looks good, then congrats, you're done!

Manual Changes

This section is for anyone who is interested in the changes I made to the stock Linux Prey version (Download here: http://preyproject.com/download) to get everything working. I've you've downloaded my version and followed the directions above, you do not need to make these changes.

Applied this bug fix affecting Prey 0.5.9. Geolocation results came back incorrect, based on IP address only instead of nearby WIFI points, without this fix:
https://github.com/TAWood/prey-bash-...ae7e0a2b90e57a

config:
Prey switched to using SSL to submit reports and curl on Maemo fails when trying to verify the certificate, so the --insecure option needs to be added (if anyone can figure out a better way, let me know).
Code:
curl_options='--insecure --compress --connect-timeout 60'
core/functions:
Update the crontab line to use bash4.
Code:
update_execution_delay(){
        local full_path=$(full_path "$base_path")
        (crontab -l 2> /dev/null | grep -v prey; echo "${1}" "bash4 ${full_path}/prey.sh > /var/log/prey.log 2>&1") | crontab -
}
platform/linux/functions:
Change the whoami line to check for root instead of $logged_user:
Code:
if [ "`whoami`" != "root" ]; then
Prey was grabbing the IP address from the loopback device (127.0.0.1) instead of wlan0, so we just need to alter the get_ip_address() function slightly to grab the correct address:
Code:
get_ip_address(){
        ifconfig $1 2> /dev/null | grep "inet " | awk '{print $2}' | sed "s/127.0.0.1//" | sed "s/addr://" | awk '{ printf "%s", $0 }'
}
Maemo doesn't come with iproute2 (might be in busybox-power). Either way, I've just change the function to grab the gateway address to use `route` instead of `ip r`.
Code:
get_gateway_ip(){
        route | grep default | awk '{print $2}'
}
modules/network/platform/linux/functions:
Remove -p option and redirect errors to /dev/null.
Code:
get_active_connections() {
	active_connections=$(netstat -tun 2>/dev/null | grep -v "127.0.0.1")
}
modules/session/core/functions:
Busybox find doesn't support -mmin, so I've changed this to -mtime. Also used /home/user/MyDocs as the directory to search and removed the regex hiding hidden files since most of Maemo's files in MyDocs are in hidden directories (.images, .sounds, .documents, etc).
Code:
get_modified_files() {
	modified_files=`find /home/user/MyDocs -type f -mtime -1 2> /dev/null`
}
modules/webcam/platform/linux/functions:
Changed streamer to gst-launch here. Also just emptied the capture_video() function since it was using streamer doesn't seem to be needed.
Code:
take_picture() {

        # do we have streamer installed ?
        local streamer=`which gst-launch`
        if [ -n "$streamer" ]; then
                $streamer v4l2camsrc device=/dev/video1 num-buffers=1 ! dspjpegenc ! filesink location="$tmpdir/streamer3.jpeg" 2>&1 > /dev/null
                mv "$tmpdir/streamer3.jpeg" "$webcam__picture" > /dev/null
        fi

}

capture_video() {

        # we should already know if we do have streamer
        if [ -n "$streamer" ]; then
                echo -n ''
        fi

}
A small note on the above: You can change /dev/video1 to /dev/video0 if you would rather have it take a picture with the main camera than the front cam. Keep in mind though that the lens cover would need to be open, or all you would get would be a blank image.
Attached Files
File Type: gz prey-maemo-0.5.9.tar.gz (485.8 KB, 110 views)
File Type: gz LICENSE.tar.gz (12.0 KB, 88 views)

Last edited by Presence; 2013-02-04 at 16:26.
 

The Following 18 Users Say Thank You to Presence For This Useful Post: