tag:blogger.com,1999:blog-54596375714035791062023-06-20T22:10:01.919-07:00Linuxology, the Linux Admin's Daily blogAll things linux and probably other really cool shit too!Marzubushttp://www.blogger.com/profile/11510959381718755246noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-5459637571403579106.post-79892013003727625612012-03-23T06:14:00.002-07:002012-03-26T12:59:11.267-07:00Update: Convert that old iPhone into a GPS Tracker<span class="Apple-style-span" style="font-family: Georgia, serif; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size: 100%; ">If you have not already, take a look at the previous <a href="http://chillyupnorth.blogspot.se/2012/03/convert-that-old-iphone-into-gps.html">post</a>. This is an update on that covering my Django server side component.</span><div style="font-family: Georgia, serif; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; "><br /></div><div style="font-family: Georgia, serif; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; ">In the first part we created a simple python script which announced the GPS co-ordinates of the device to a web server. So to complete the solution we will do the following.</div><div><ul><li><span >Create a model and view to store posted tracker co-ordinates</span></li><li><span >Create a view to visualize the data with google maps API</span></li></ul><div><span class="Apple-style-span" ><span ><span style="font-size: 100%;">I won't cover setting up django itself, there are plenty of good docs on the django site for that. Once you have django up and running create a new application </span>therein<span style="font-size: 100%;"> like this:</span></span></span></div><div style="font-family: Georgia, serif; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size: 100%; "><span class="Apple-style-span" ><blockquote></blockquote><blockquote>python manage.py startapp tracker</blockquote></span></div><div style="font-family: Georgia, serif; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size: 100%; "><span class="Apple-style-span" >create tracker/models.py and tracker/views.py with the following code: <a href="http://pastebin.com/0rxDhaX5">http://pastebin.com/0rxDhaX5</a></span></div><div style="font-family: Georgia, serif; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size: 100%; "><span class="Apple-style-span" ><br /></span></div><div style="font-family: Georgia, serif; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size: 100%; "><span class="Apple-style-span" >create tracker/templates/tracker/plot.html with the following code: <a href="http://pastebin.com/T3ACVDpY">http://pastebin.com/T3ACVDpY</a></span></div><div style="font-family: Georgia, serif; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size: 100%; "><span class="Apple-style-span" ><br /></span></div><div style="font-family: Georgia, serif; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size: 100%; "><span class="Apple-style-span" >Add the following to your urls.py</span></div><div style="font-family: Georgia, serif; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size: 100%; "><span class="Apple-style-span" ><div> </div><blockquote><div>(r'^tracker/(?P<data>.*)', 'DJANGOPROJECT.tracker.views.tracker'),</data></div><div> (r'^plot/', 'DJANGOPROJECT.tracker.views.plot'),</div></blockquote><div>Now add the APP to you INSTALLED_APPS in settings.py</div></span><span class="Apple-style-span" style="font-size: medium; "> <blockquote>'DJANGOPROJECT.tracker',</blockquote></span><span class="Apple-style-span" ><div> </div><div>Now the python app on the device will be able update the location models in the django application. And you will be able to view the current position via the /plot/ url.</div><div><br /></div><div>Kegan</div></span></div><div style="font-family: Georgia, serif; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size: 100%; "><span class="Apple-style-span" ><br /></span></div></div>Marzubushttp://www.blogger.com/profile/11510959381718755246noreply@blogger.com0tag:blogger.com,1999:blog-5459637571403579106.post-36062314922565851022012-03-18T12:28:00.004-07:002012-03-18T13:14:14.568-07:00Convert that old iPhone into a GPS Tracker<div><span class="Apple-style-span" style=" ;font-size:large;"><b>Background</b></span></div>So I have been pondering for ages what to do with my old iPhone 3G, and after finding my steering lock broken on my motorcycle, I have decided to turn it into a GPS tracker to fit to my motorcycle.<div><br /></div><div>Find my phone doesn't seem to work on my jailbroken device, so I have gone for my own implementation.<br /><div><br /></div><div>My solution is this. A python script on the phone will periodically query the CoreLocation subsystem for the phone location and then post the in a RESTlike manner to a django web service running on one of my websites. I won't cover the django web service in this post, but needless to say you can adapt this script to advertise the location of the phone to you in a variety of ways.</div><div><br /></div><div>Once I have the location, just pasting the coordinates into google maps will show where the phone is located.<br /><div><br /></div><div><span class="Apple-style-span" style="font-size:130%;"><b>Requirements:</b></span></div><div>iPhone 3G running iOS 4.2.1 Jailbroken</div><div>Python ( Cydia )</div><div>pyobjc ( Cydia )</div><div>OpenSSH ( Cydia )</div><div>Some public web server you have access to. ( I host my own, if you don't have access to one, maybe use some other nifty trick / API / twitter to send yourself the location. )</div><div><br /></div><div>If you haven't already, jailbreak your phone. You can google that separately as I'm not going to cover the details of that. Just remember that if you need to network unlock your phone, pay special attention to the modem firmware you load. The default one that comes with 4.2.1 is not unlockable at this stage without breaking the GPS.</div><div><br /></div><div>Once jailbroken, use cydia to install Python, Pyobjc, VIM and OpenSSH. Now that we have all the software we need, ssh into your phone, the default username is root and password is alpine. </div><div><br /></div><div>Get the script http://pastebin.com/mHwigZXT and adapt to you needs. You need to create a web service to receive the coordinates or conjure up some other creative way. I thought about using twitter REST API via python to twit the location.</div><div><br /></div><div>I have just setup my own django app that is logging the REST calls to a specific url with location coordinates and accuracy. You can go low-tech and just use the apache logs of your server to track your phone as-well. Just pasting the coordinates into google will show you where the phone is.</div><div><br /></div><div><span class="Apple-style-span" style="font-size:130%;"><b>Implementation</b></span></div><div>Get the script http://pastebin.com/mHwigZXT</div><div><span class="Apple-style-span" style="font-size:130%;"><b><br /></b></span></div><div>Name the script without any extension, e.g. "location" ( I had troubles running it from launchctl as location.py )</div><div><br /></div><div>SCP the script up to your phone : scp location root@10.0.0.100:/var/mobile/ ( username root passwd alpine )</div><div><br /></div><div>SSH into your phone, chmod +x /var/mobile/location and then execute the script manually to check it. It takes a while to load all the objects and location, so be patient. 15 seconds or so at least.</div><div><br /></div><div>To get your application to launch at boot time and to re-run the script every 15 minutes, you need to create a application plist file and put it in the right location. I have made one for you!</div><div><br /></div><div>Get the application plist file file from http://pastebin.com/1jdb1d3d</div><div><br /></div><div><span class="Apple-style-span">scp that to </span><span class="Apple-style-span"> your phone with:</span></div><div>scp com.my.tracker.plist root@10.0.0.100:/System/Library/LaunchDaemons/</div><div><br /></div><div>reboot the phone. </div><div><br /></div><div>And thats that. You should now see some calls to your apache server with a URL containing the coordinates of you phone.</div><div><br /></div><div>Remember to leave WIFI and 3G and location services enabled! ;)</div><div><br /></div><div><span class="Apple-style-span" style="font-size:130%;"><b>Integration</b></span></div><div><span class="Apple-style-span" style="font-size:100%;">I have integrated the phone into my motorcycle and even wired to up to the bike to let it charge when the bike runs. There is also a small solar panel which charges the phone slowly to extend the life. </span></div><div><span class="Apple-style-span" style="font-size:100%;"><br /></span></div><div><span class="Apple-style-span" style="font-size:100%;">have fun!</span></div><div><span class="Apple-style-span" style="font-size:100%;"><br /></span></div><div><span class="Apple-style-span" style="font-size:100%;">Kegan</span></div><div><span class="Apple-style-span" style="font-size:100%;"><br /></span></div><div><span class="Apple-style-span" style="font-size:100%;"><br /></span></div><br /><min accuracy=""><div><br /></div></min></div></div>Marzubushttp://www.blogger.com/profile/11510959381718755246noreply@blogger.com2tag:blogger.com,1999:blog-5459637571403579106.post-73780949816553892192009-10-02T08:29:00.000-07:002009-10-02T08:34:21.432-07:00Hudson servers FAILI noticed the worst of all coding bugs! as is with many java development houses, we use hudson for all our building. And I discovered today that when hudson.dev.java.net is down, the web interface for your hudson server starts to break..<br /><br />For some fucked up reason, Hudson dev team thought it would be shit cool to make calls to their website from all hudson servers project specific configuration pages..<br /><br />see the request here I intercepted.<br />hudson.yourdomain.com:80 127.0.0.1 - - [02/Oct/2009:17:30:54 +0200] "\x16\x03\x01" 501 292 "-" "-"<br />hudson.yourdomain.com:80 127.0.0.1 - - [02/Oct/2009:17:30:54 +0200] "\x16\x03\x01" 501 292 "-" "-"<br />hudson.yourdomain.com:80 127.0.0.1 - - [02/Oct/2009:17:30:54 +0200] "\x16\x03\x01" 501 292 "-" "-"<br />hudson.yourdomain.com:80 127.0.0.1 - - [02/Oct/2009:17:30:54 +0200] "\x16\x03\x01" 501 292 "-" "-"<br /><br />WTF were you thinking!!! <br /><br />Anyway so if you have the missing batch task buttons bug or general hudson weirdness like you get a submitForm error when you try save settings,<br />add a over-ride for<br /><br />127.0.0.1 hudson.dev.java.net<br /><br />on your pc which you are trying to access your hudson with. You can direct it at any apache server anywhere!<br /><br />please goto hudson forums and WTF in there!<br /><br />KeganMarzubushttp://www.blogger.com/profile/11510959381718755246noreply@blogger.com0tag:blogger.com,1999:blog-5459637571403579106.post-9908974033701145742009-09-23T07:51:00.000-07:002009-09-23T07:56:29.813-07:00Using Jython to query JMX Objects / AttributesI was tinkering today with re-implementing some nagios and cacti checks to use jython to query jmx objects and attributes since I am getting tired of re-compiling my java code jmx query-er.<br /><br />Anyway, here is the basic code in a nut shell. You need to adapt this to your needs ofcourse.<br /><br />#START<br />import java.io.BufferedReader;<br />import java.io.IOException;<br />import java.io.InputStream;<br />import java.io.InputStreamReader;<br />import java.io.PrintStream;<br />import java.util.HashMap;<br />import java.util.Iterator;<br />import java.util.Map;<br /><br />import javax.management.MBeanServerConnection;<br />import javax.management.ObjectName;<br />import javax.management.openmbean.CompositeDataSupport;<br />import javax.management.openmbean.CompositeType;<br />import javax.management.remote.JMXConnector;<br />import javax.management.remote.JMXConnectorFactory;<br />import javax.management.remote.JMXServiceURL;<br /><br />from array import array<br /># put correct auth info in here<br />ad=array(java.lang.String,["username","password"])<br />n = java.util.HashMap()<br />n.put (javax.management.remote.JMXConnector.CREDENTIALS, ad);<br /># this is a example but you probably want the url as a URL object or similar...<br />jmxurl = javax.management.remote.JMXServiceURL("service:jmx:rmi:///jndi/rmi://10.0.0.233:12086/jmxrmi")<br />testme = javax.management.remote.JMXConnectorFactory.connect(jmxurl,n)<br />connection = testme.getMBeanServerConnection();<br /><br /># The actual query<br />object="java.lang:type=Memory"<br />attribute="HeapMemoryUsage"<br /><br /># Execute<br />attr=connection.getAttribute(javax.management.ObjectName(object),attribute)<br />print attr<br /><br /># Close the connection<br />testme.close()<br />#ENDMarzubushttp://www.blogger.com/profile/11510959381718755246noreply@blogger.com1tag:blogger.com,1999:blog-5459637571403579106.post-86071292078586597462009-07-29T07:26:00.000-07:002009-09-14T04:39:15.004-07:00Importing CVS into SVN with history<span style=";font-family:arial;font-size:100%;" >Converting old CVS repos and their history is a question that always comes up. So heres a mini-howto convert cvs to svn and preserve the history.<br /><br />Firstly install cvs2svn, on Debian based distros you can grab it with apt:<br /><blockquote><span style="font-style: italic;">sudo apt-get install cvs2svn</span><br /></blockquote><br />cvs2svn can also be downloaded from <a href="http://http//cvs2svn.tigris.org/">http://cvs2svn.tigris.org/<br /></a><br />First we need to setup a place to work and create a CVSROOT dir else cvs2svn wont be happy.<br /><blockquote><span style="font-style: italic;">mkdir -p ~/oldcvs/CVSROOT</span><br /><span style="font-style: italic;">mkdir ~/newsvn/</span><br /></blockquote><br />Now lets copy the CVS repo's data into ~/oldcvs/modulename<br /><blockquote><span style="font-style: italic;">cp -r /path/to/cvs/modulename /home/user/oldcvs/modulename</span><span style="font-style: italic;"></span><br />cvs2svn --encoding=iso8859_10 --dumpfile=/home/user/newsvn/modulename.SVN ~/oldcvs/modulename<br /></blockquote>for Encodings check <a href="http://docs.python.org/library/codecs.html#standard-encodings">http://docs.python.org/library/codecs.html#standard-encodings<br /></a>also dumpfile didnt like the ~ in the path so full path needed here!<br /><br />If all goes well you should end up with a nice report of all the revisions and their mother.<br />Now we need to import our newly create .SVN file into subversion, in my case I need to create a new project for it aswell like so:<br /><blockquote><span style="font-style: italic;">svnadmin create /path/to/svn/repos/modulename</span><br /></blockquote><br />Then just import the dump into our SVN repo we created earlier<br /><blockquote><span style="font-style: italic;">svnadmin load /path/to/svn/repos/modulename <~/newsvn/modulename.SVN</span><br /></blockquote><br />All done.<br /></span>Marzubushttp://www.blogger.com/profile/11510959381718755246noreply@blogger.com0tag:blogger.com,1999:blog-5459637571403579106.post-48062993736175080672009-07-29T05:41:00.001-07:002009-07-29T05:41:45.275-07:00Due to the unavailability of cheap iPhone 3G's in Sweden, I nabbed one in a second hand store in Switzerland for 300 CHF ( 2200 SEK ) and another two online for about 3000 SEK each.<br /><br />Each phone was locked to some or other provider. Here is my experience in jailbreaking and unlocking a Swisscom locked iPhone 3G.<br /><br />Firstly get-a-mac, I dont do windows and never will. You will need PwnageTool 3.0 for mac. Get it from one of these:<br /><ul><li><span style="font-size:78%;"><a href="http://www.revotech.org/mirror/PwnageTool_3.0.dmg" target="_blank">http://www.revotech.org/mirror/PwnageTool_3.0.dmg</a></span></li><li><span style="font-size:78%;"><a href="http://www.istation.at/pwnagetool_3.0.dmg" target="_blank">http://www.istation.at/pwnagetool_3.0.dmg</a></span></li><li><span style="font-size:78%;"><a href="http://neon.hexxeh.net/PwnageTool_3.0.dmg" target="_blank">http://neon.hexxeh.net/PwnageTool_3.0.dmg</a></span></li><li><span style="font-size:78%;"><a href="http://www.itouchmaster101.com/PwnageTool_3.0.dmg" target="_blank">http://www.itouchmaster101.com/PwnageTool_3.0.dmg</a></span></li><li><span style="font-size:78%;"><a href="http://www.zackoch.com/iphone/PwnageTool_3.0.dmg" target="_blank">http://www.zackoch.com/iphone/PwnageTool_3.0.dmg</a></span></li><li><span style="font-size:78%;"><a href="http://just.legalizecanna.biz/PwnageTool_3.0.dmg" target="_blank">http://just.legalizecanna.biz/PwnageTool_3.0.dmg</a></span></li><li><span style="font-size:78%;"><a href="http://www.neonkoala.co.uk/files/PwnageTool_3.0.dmg" target="_blank">http://www.neonkoala.co.uk/files/PwnageTool_3.0.dmg</a></span></li><li><span style="font-size:78%;"><a href="http://g.appleguru.org/PwnageTool_3.0.dmg" target="_blank">http://g.appleguru.org/PwnageTool_3.0.dmg</a></span></li><li><span style="font-size:78%;"><a href="http://o.schwarzmetall.cn/PwnageTool_3.0.dmg" target="_blank">http://o.schwarzmetall.cn/PwnageTool_3.0.dmg</a></span></li><li><span style="font-size:78%;"><a href="http://www.macdotnub.co.cc/downloads/PwnageTool_3.0.dmg" target="_blank">http://www.macdotnub.co.cc/downloads/PwnageTool_3.0.dmg</a></span></li><li><span style="font-size:78%;"><a href="http://theiphoneproject.org/mac/PwnageTool_3.0.dmg" target="_blank">http://theiphoneproject.org/mac/PwnageTool_3.0.dmg</a></span></li><li><span style="font-size:78%;"><a href="http://begolli.com/downloads/mac/PwnageTool_3.0.dmg" target="_blank">http://begolli.com/downloads/mac/PwnageTool_3.0.dmg</a></span></li><li><span style="font-size:78%;"><a href="http://d01.megashares.com/dl/b9276a6/PwnageTool_3.0.dmg" target="_blank">http://d01.megashares.com/dl/b9276a6/PwnageTool_3.0.dmg</a></span></li><li><span style="font-size:78%;"><a href="http://downloads2.touch-mania.com/jaillock/PwnageTool_3.0.dmg" target="_blank">http://downloads2.touch-mania.com/jaillock/PwnageTool_3.0.dmg</a></span></li><li><span style="font-size:78%;"><a href="http://ivwriting.com/PwnageTool_3.0.dmg" target="_blank">http://ivwriting.com/PwnageTool_3.0.dmg</a></span></li></ul><span style="font-size:78%;">Procedure<br /></span><ol><li><span style="font-size:78%;">Update the iPhone to 3.0 via iTunes.</span></li><li><span style="font-size:78%;">Launch PwnageTool and click the expert button, click the iPhone 3G.<br /></span></li><li><span style="font-size:78%;">You should see the 3.0 firmware in the main window, this is from the iTunes library actually so its trustable.</span></li><li><span style="font-size:78%;">Click the firmware for 3.0 and Next</span></li><li><span style="font-size:78%;">Click General and Next</span></li><li><span style="font-size:78%;">Check "Activate the phone", this makes the phone activate without the provider sim<br /></span></li><li><span style="font-size:78%;">Check "Enable baseband update", this makes the the phone unlock-able via Cydia<br /></span></li><li><span style="font-size:78%;">Resize the root partition to at least 700mb pref 1gb if you can spare that.<br /></span></li><li><span style="font-size:78%;">Neuter bootloader should be unchecked</span></li><li><span style="font-size:78%;">under Cydia choose "manage sources" and add <b style="font-weight: bold;">http://repo666.ultrasn0w.com</b></span></li><li><span style="font-size:78%;">Click next through Packages and Logos until you can click the Build button and then Next again</span></li><li><span style="font-size:78%;">Follow instructions in PwnageTool on how to put your phone into DFU mode</span></li><li><span style="font-size:78%;">Restore you custom image onto you iPhone via opening iTunes and hold down Option and click restore</span></li><li><span style="font-size:78%;">Choose your Custom firmware which was generated by PwnageTool</span></li><li><span style="font-size:78%;">And watch the jailbreaking process</span></li></ol>Next we need to unlock your phone to access GSM network, quite easily, all you need to do turn off your 3G and open Cydia and search for ultrasn0w (thats a numerical ZERO ) and install it, reboot the phone and voila!Marzubushttp://www.blogger.com/profile/11510959381718755246noreply@blogger.com0tag:blogger.com,1999:blog-5459637571403579106.post-41975817781932354322009-02-21T12:38:00.000-08:002009-02-21T12:41:36.933-08:00Fixing time sync messed up VOB filesI have many home video discs recorded on a Sony mini DVD cam which are giving me hell trying to import them into iMovie. Seems even playback was only running the first 20 seconds of any VOB file and then stopping. <div><br /></div><div>Resolved my issues with a nifty little mac app called <a href="http://www.squared5.com/svideo/mpeg-streamclip-mac.html">Mpeg Streamclip</a></div><div><br /></div><div>It opened up the streams and identified and corrected the time issues right away! I then could export direct to a Quicktime format h.26X format and get my movies into iMovie!</div><div><br /></div><div>I love free software...</div><div><br /></div><div>K</div>Marzubushttp://www.blogger.com/profile/11510959381718755246noreply@blogger.com0tag:blogger.com,1999:blog-5459637571403579106.post-69307327207355302792009-02-19T11:46:00.000-08:002009-02-19T12:11:42.372-08:00Still bitching at /dev/random's slownessPondering,<div><br /></div><div>So I believe I have the solution to the /dev/random being so god damn slow issue. All still totally theoretical of-course, but I reckon just thinking about it intensely for a few days will reveal the solution. </div><div><br /></div><div>The Problem (re-iterated maybe)</div><div>/dev/random = dog slow, in fact its so slow that its not usable at all, and I need a truly good randomized data source, No mathematical algorithm can create that. It has to be gathered.</div><div><br /></div><div>The Proposed Solution</div><div>Quite simply put, Im going to run a sniffer on my wireless NIC and dump all the data as is to file, maybe even use a few wireless cards and some physical nics and mux the data all together. Then write a very simple C++ program which will gather a integer block size value from /dev/urandom which is not true randomness but enough for this purpose, Then read that block-size worth of data from the wireless sniffed data and convert it to a sha1 fingerprint, The fingerprint should be very unique and after converting the sha1 to a binary string, you should be pretty good to go.</div><div><br /></div><div>This would be a very fast and good way to get very good random data. A few things spring to mind that need to be taken into account though. </div><div><br /></div><div>Firstly, tcpdump must strip all link layer and other common elements out of the data feed, so essentially only the packet payloads should be dumped. There would still be common elements in this data but I thing the sha1 would overcome any collisions.</div><div><br /></div><div>Secondly, You need a noisy wireless network to run this by, which is okay for me since I have at least 17 in my listening range. But most home networks are not going to be that busy. I guess you could essentially use any data source provided its not something common, maybe that family video which you had put on DVD, or your iPhoto library! </div><div><br /></div><div>Ill spend some time tinkering in C++ and see if I can come up with a working model and post it here.</div>Marzubushttp://www.blogger.com/profile/11510959381718755246noreply@blogger.com0tag:blogger.com,1999:blog-5459637571403579106.post-91627410264891912712009-02-18T04:41:00.000-08:002009-02-18T05:26:44.759-08:00a Thousand Monkeys (Virtual Servers)So I spent a few days pondering the issue with /dev/random under linux not being able to generate enough data to fill my hard disk in a timely fashion, to backtrack, I want to prepare a new encrypted volume, a small 100GB disk. <div><br /></div><div>As many people know, before you depend on your crypted disks, you need to fill the disk with very high quality random data, true, crypt strength data to be exact.<br /><div><br /></div><div>By my calculations on a average linux server you only get about 3 to 4 bytes per second out of /dev/random which computes to 1 Year and 1 Month to fill a 100gb disk with high quality random data. I am in more of a hurry than that.</div><div><br /></div><div>Mac OS X Leopard seems to generate almost 10MB per second but its entropy is questionable so that is also not a option. </div><div><br /></div><div>I then theorized that if I spawned many virtual hosts, and ran netcat off /dev/random to a listening netcat on one of my real servers, that I could mass cat all the dev random pipes together onto the disk. </div><div><br /></div><div>Unfortunately, as expected, it seems that /dev/random on virtual machines is pretty quiet since the machine acoustics are, well artificial in nature so there is no CPU fan noise or keyboard and mouse data to gather from. </div><div><br /></div><div>The shell script I wrote to spawn a large number of virtual hosts could come in useful though.</div><div><br /></div><div>Here is the <a href="http://www.kegans.com/scripts.php?script=aThousandMonkeys.sh&lang=bash">script.</a></div><div><br /></div><div><br /><br /><br /></div><div><br /></div><div><br /></div></div>Marzubushttp://www.blogger.com/profile/11510959381718755246noreply@blogger.com0