Code
Prey – Auto Update Stolen Status for OS X
by Jaku on Dec.03, 2011, under Code
If you haven’t heard of the Prey Project, then I suggest you check out http://preyproject.com. Prey, is an open source anti-theft solution for your mobile device. You can install their package on your laptop or phone and then if your device is stolen you can then mark it as such and track it and take screenshots and even use your camera if your device has one.
The only “bad’ thing about it, is that it is software based and relies on having an active internet connection. So if the thief wipes your device clean, or can’t login to connect to the internet then it won’t be able to check if it’s stolen and provide updates. So a majority of users will create a dummy account on their laptop with limited access and then hide their main account. I won’t get into that part to much, but if you are running OS X and want to know how you can hide your account from the login screen check out this site http://emeadeployment.blogspot.com/2011/09/how-to-configure-hidden-account-that.html.
Now not everyone is going to realize exactly when their laptop is stolen and it could be many hours or even days before the person realizes it. And every second counts when trying to recover a lost item so the sooner you’re able to start getting information the faster you’ll be able to recover your device. This is where my script comes in. Remember the dummy account with limited access? What if we could have it so that when that account logs in, it would automatically update the devices own status as stolen? Will we can, and it’s actually quite simple.
sudo defaults write com.apple.loginwindow LoginHook /var/root/prey.sh
Running the above command will create a hook so that whenever any account logs in this script will run. You can put the script anywhere you’d like but remember that it will be ran by the root user.
Now the contents of the script should look something like this.
#!/bin/bash
while true; do
sleep 10
if [ "$1" == "Apple" ]; then
if [ "`ping -c 1 google.com`" ]; then #tell prey I'm missing
curl --user $APIKEY:x "http://control.preyproject.com/devices/$DEVICEKEY.xml" -X PUT -d "device[missing]=1"
exit
fi
fi
exit
done
You can find your API key under your Account Information and the device key can be found under your Device Information, all on the Prey website. Both should be a random string. So as an example if your API key was “9g2bi3rsdsd” and your Device Key was “kjr22y”. The line above should look like.
curl --user 9g2bi3rsdsd:x "http://control.preyproject.com/devices/kjr22y.xml" -X PUT -d "device[missing]=1"
The only thing left to change is the “Apple” in the code that checks what user is logged in. If you create a dummy user named “tom” then put “tom” there instead of “Apple”. Otherwise when the account logs in it won’t update as stolen. Other than that it should be all set. Feel free to leave any comments if you have any issues or improvements!
Rick Roll Proxy…
by Jaku on Sep.24, 2009, under Code, Projects
A long time ago I decided to mess around with the redirect_program feature of squid. If you’re not familar with squid I suggest looking up the wiki on it http://en.wikipedia.org/wiki/Squid_(software).
What exactly does redirect_program do? No one knows for sure, some say that it is the very reason the internet works, while others speculate that the previous statement is nothing but rubish. The world may never know, however just because we don’t know what it does doesn’t mean we can’t use it!
Ok but seriously what does the redirect_program tag actually allow us to do. This tag is used to specify the location of the executable for the URL redirector. So you can basicaly create a program that can rewrite the requested URLs that are passing though squid. So one could play around with the data that is passing though squid pretty much on the fly. What is great about it, is that it’s very easy to program for and has many real world uses.
None of which we will talk about here. ![]()
(continue reading…)
GPS Code Update
by Jaku on Sep.22, 2009, under Code, Projects
So it seems I have to write this post again because my server crashed.. leaving everything alone but my sql databases… Oh well, could be a lot worst.
So after my post yesterday about how I update my location on my site I got a reply from @andre_vans that told me about a project called “PlayNice”. The GIThub source is at http://github.com/natfriedman/playnice and the the creator of it has a blog post about it at http://nat.org/blog/2009/08/playnice-google-apple/.
Now I mentioned in my post yesterday that I wanted to be able to use some sort of push notification on the iPhone so that my site could ask for an update and the phone would comply. This would require a custom app on the iPhone to automatically execute something when it has a push notification. Now I’m not even sure if that is possible at this stage as that would almost be like the app is running in the background, which apple does not allow yet. However, Apple has such a service built into the phone that allows anyone with a MobileMe account linked to their iPhone to get the location of the device.
So with that PlayNice will basically log in as you on your MobileMe account and launch the locate phone feature. Now the neat thing about this is that it also updates to your Google Latitude account. This make’s it pretty much perfect for what I want to do. With the source code freely available and easy to understand it was a breeze adding 3 lines of code to update my map backend whenever the PlayNice script is ran. If you wan’t to do the same with most of the code from my post yesterday then follow me past the break. Otherwise, ignore me. ![]()
(continue reading…)
How I made the locate Jaku feature
by Jaku on Sep.21, 2009, under Code, Haxs
The 2 main parts of this software have changed over the years, however this post will describe each change and will include what I currently use to get my location on the site.
The main part is the use of the Mologogo software. Which I used because I had a old boost mobile cell phone and this was the easiest and fastest way to get my location up on the web. It was also the cheapest at $1 dollar a day. After the iPhone came out I developed my own application to get my location and update the mologogo software that way. This was awesome because I could get rid of the boost mobile phone and I only had to carry a single phone then. However after almost every update to the iPhone software, I had to wait for a new jailbreak and then I had to change my code to work. This became a huge hassle and I had to deal with it after every update.
When the iPhone 2.0 software came out I assumed I wouldn’t have to do that anymore. Except for the fact that in order to actually use any application that you wrote, you needed to pay the developer fee. So instead I decided to get my location another way. On many of the twitter iPhone apps it would allow you to update your location and this would then update the GPS coordinates shown on your twitter.com page. This was an easy way to get the location of myself without the need of writing a new custom app. So I wrote some code that would look on my twitter page and find the location of me and check to see if it had updated since the last time it checked. This solution was great because it would only update as much as I wanted, and wouldn’t drain my battery since my phone would do none of the work. However, a few months after this went live twitter decided to change their design and at first the location info was no longer shown. So I had to come up with a new idea.
(continue reading…)
Posting data to Pastebin with cURL
by Jaku on Sep.20, 2009, under Code, Haxs
I needed to get a bunch of text up on pastebin and I’ve used my own cURL script to get it up there before. But then I started to think that others might want to be able to just post to pastebin directly from their bash shell. What started off as a simple one-liner then started to grow into a bit more.
With pastebin you are able to post to a sub-domain, as well as put a name along with the post and even set how long the data should stay up. So I’ve made it possible for you to edit those settings in the script so that if you want to post as “bob” and keep the data up there for a day you can do all of that.
The easiest way to install this would be the following 2 commands
sudo curl haxbyjaku.com/pastebin -o /usr/bin/pastebin
sudo chmod +x /usr/bin/pastebin
I know that you won’t run sudo on commands that download code from my server, but you can trust it since you get to see everything.
After it is installed I suggest editing the file as well so that you can set your own settings such as username or pastebin URL. Once that is all set simple run a command like "echo test | pastebin" in your terminal and you’ll get the URL that pastebin posted it to. You can even do something like "echo /etc/passwd | pastebin" and it will work exactly as you expect it to.
I’ve pasted the code after the break as well.
Dreamcast controller manipulation
by Jaku on Jun.04, 2007, under Chicago 2600, Code, Haxs, Presentations, Projects
I presented my secret project at the 2600 meeting. I was hoping for a much bigger response to it than the one I got. I felt that there was to much to go over and so that made people bored\unimpressed. Or maybe I am the only person that thinks controlling an 8 year old system with a web browser, or Wii remote is cool. Eitherway, I had fun working on it, and I learned a lot from this one project. So at least I can take the knowledge of this project and use it towards other things. I already have a few ideas but won’t be working on them until I move to my new apartment, whenever that might be.
UT-41 GPS in OS X
by Jaku on May.17, 2007, under Code, Projects
I recently got a UT-41 at http://www.geeks.com/details.asp?invtid=UT-41&cat=GPS
It didn’t support OS X out of the box so here is how I got it working.
First download the Serial to USB driver for OS X at http://www.apple.com/downloads/macosx/drivers/pl2303driver.html. After installing it, you are asked to reboot. Do so.
When you are back to OS X you can download and compile GSPd or get the GUI Binary gpsdXConfig at http://ghw.spade-men.com/gpsdx.html.
If you compiled GSPd, you can run the following command in terminal
gpsd tty.PL2303-0000103D
or if you are using the GUI you might have to refresh the serial list, and then select /dev/tty.PL2303-0000103D
To see if it is working, you can telnet to your localhost, press “r” and enter and you should see some GPS data like so.
telnet localhost 2947
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GPSD
GPSD
r
GPSD,R=1
$GPGSV,3,2,12,17,47,258,,27,33,173,,24,16,189,,29,13,287,*74
$GPGSV,3,3,12,26,13,293,,19,05,056,,20,03,125,,04,02,199,*7A
$GPRMC,224206.00,V,3818.6285,N,08552.2345,W,,,200906,,,N*59
$GPGGA,224206.00,3818.6285,N,08552.2345,W,0,00,0.0,,M,,M,,*4F
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
After that you can select GPS under Preferences, and choose GPSd in the drop down. After words you should have GPS working in OS X with the UT-41.
