<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Strawp.net</title>
	<atom:link href="http://strawp.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://strawp.net</link>
	<description>*So* scripted</description>
	<lastBuildDate>Wed, 26 Oct 2011 08:02:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Quick And Dirty DVR</title>
		<link>http://strawp.net/archive/quick-and-dirty-dvr/</link>
		<comments>http://strawp.net/archive/quick-and-dirty-dvr/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 08:02:33 +0000</pubDate>
		<dc:creator>Strawp</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://strawp.net/?p=259</guid>
		<description><![CDATA[I recently dug out an old USB 1.1 Digital TV Tuner &#8211; a Hauppauge WinTV Nova-T USB, which I think I bought in about 2003 and eventually gave up on due to poor reliability under Windows, the crappy TV signal quality in Coventry and the success of excellent torrent sites like UKNova. Well, I&#8217;ve moved [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://strawp.net/wp-content/uploads/2011/10/broken_tape2.jpg"><img src="http://strawp.net/wp-content/uploads/2011/10/broken_tape2-300x198.jpg" alt="" title="Old school video recording" width="300" height="198" class="alignright size-medium wp-image-262" /></a><br />
I recently dug out an old USB 1.1 Digital TV Tuner &#8211; a Hauppauge WinTV Nova-T USB, which I think I bought in about 2003 and eventually gave up on due to poor reliability under Windows, the crappy TV signal quality in Coventry and the success of excellent torrent sites like UKNova. Well, I&#8217;ve moved house now, and with an increased TV signal strength also came the bad news that I appear to be on a limited bandwidth ADSL line. I envisaged a single evening of plugging in the tuner, installing MythTV under Ubuntu and having a neat DVR to use.</p>
<p>Sadly, this was not to be the case.</p>
<p>Getting the tuner recognised under linux wasn&#8217;t too hard. The required firmware was already present in Ubuntu&#8217;s repositories but I couldn&#8217;t get the thing to scan. MythTV couldn&#8217;t open or ID the card and &#8220;<code>scan</code>&#8221; resulted in nothing. I even tested with the intended packaged drivers under Windows and got about as far.</p>
<p>Eventually, I found &#8220;<code>w_scan</code>&#8221; which does the kind of full-frequency scan your TV would do and was able to produce a channels.conf file in the format that <code>tzap</code> uses. Success! On the<a href="http://www.mythtv.org/wiki/Tzap"> tzap page of the MythTV wiki</a> it shows how you can use <code>tzap</code> to tune the device and &#8220;<code>cat</code>&#8221; to just dump the MPEG stream to file. Excellent &#8211; time for a quick and dirty script!</p>
<p>I then <a href="http://svn.strawp.net/scripts/record">knocked up a &#8220;record&#8221; script</a>, which takes easy-to-read commands like &#8220;record Eastenders on BBC ONE for 30&#8243;, tunes the card and dumps the MPEG stream to a sensible location. Combine that with some cron and I&#8217;ve got a hacky little DVR. XBMC can do the front end stuff.</p>
<p>I now have to get used to the idea of knowing I want to watch something <em>before </em>it airs, like we used to do in the 90s.</p>
<p>Here&#8217;s my TV shows crontab as an example:</p>
<pre>
# Record soaps off the TV
29  19  * * 2,4 /home/iain/bin/record Eastenders $(date +\%F_\%A) on BBC ONE for 32
59  19  * * 1,5 /home/iain/bin/record Eastenders $(date +\%F_\%A) on BBC ONE for 32
30  18  * * 1-5 /home/iain/bin/record Hollyoaks $(date +\%F_\%A) on Channel 4 for 27

# Watchable stuff
59  20  * * 5 /home/iain/bin/record Have I Got News For You $(date +\%F) on BBC ONE for 32
59  21  * * 5 /home/iain/bin/record QI $(date +\%F) on BBC TWO for 32
0   18  * * 1-5 /home/iain/bin/record The Simpsons $(date +\%F) on Channel 4 for 30
</pre>
<p>Or for one-offs (as root, unless you change permissions on the device):</p>
<p><code>echo "record some tv on bbc one for 25" | at 16:00</code></p>
<p>(or as <a href="http://commandlinefu.com">commandlinefu.com</a> would probably prefer it:)</p>
<p><code>at 16:00 <<< 'record some tv on bbc one for 25'</code></p>
<p>Let me know in the comments if you end up using it.</p>
]]></content:encoded>
			<wfw:commentRss>http://strawp.net/archive/quick-and-dirty-dvr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DIY Hands Free Kit</title>
		<link>http://strawp.net/archive/diy-hands-free-kit/</link>
		<comments>http://strawp.net/archive/diy-hands-free-kit/#comments</comments>
		<pubDate>Tue, 10 May 2011 17:04:00 +0000</pubDate>
		<dc:creator>Strawp</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[car]]></category>
		<category><![CDATA[hands free]]></category>
		<category><![CDATA[handsfree]]></category>
		<category><![CDATA[ice]]></category>
		<category><![CDATA[in-car]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[phone]]></category>
		<category><![CDATA[satnav]]></category>

		<guid isPermaLink="false">http://strawp.net/archive/diy-hands-free-kit/</guid>
		<description><![CDATA[A few years back I came up with the CarPC as a cheapass hacky way of getting MP3 playback integrated into my unspectacular car. Since then, the world of mobile has moved on a whole lot and the laptop stashed in my boot actually pales in comparison with the features (and power) of my Desire [...]]]></description>
			<content:encoded><![CDATA[<p>A few years back I came up with the <a href="http://strawp.net/carpc/">CarPC</a> as a cheapass hacky way of getting MP3 playback integrated into my unspectacular car. Since then, the world of mobile has moved on a whole lot and the laptop stashed in my boot actually pales in comparison with the features (and power) of my Desire Z Android phone. Plus, I&#8217;m already <a href="http://strawp.net/archive/remote-wireless-music-syncing-android-and-linux/">syncing music with my phone</a>, like I used to with my car PC and with Google Navigation I have a powerful satnav solution already at hand. All I really needed at this juncture was some kind of hands free setup.</p>
<h3>Bluetooth control?</h3>
<p><a href="http://www.gromaudio.com/">Grom Audio</a>, who made the CD autochanger interface that I used for my car PC also make an <a href="http://www.gromaudio.com/usb.html">autochanger interface which extends with a bluetooth module</a>. This seemed like an unnecessary expense however &#8211; I already had the Car2PC autochanger interface which still acts as a high quality stereo input even without the USB control via the car head unit.</p>
<h3>The official HTC headset</h3>
<p><img class="alignright size-medium wp-image-247" title="HTC headset controls" src="http://strawp.net/wp-content/uploads/2011/05/wpid-IMAG0250-300x179.jpg" alt="" width="300" height="179" /></p>
<p>The headset that came with my phone has an integrated mic with three buttons: answer call/play/pause, next track and previous track. Wouldn&#8217;t it be cool if someone had worked out what the circuit inside that thing was? I googled around a while but in the end, one of my friends pointed me to <a href="http://www.george-smart.co.uk/">George Smart&#8217;s Wiki</a>, where he&#8217;d already <a href="http://www.george-smart.co.uk/wiki/HTC_Headphones">sacrificed his headset and worked out a circuit diagram</a>. This was massively useful, and given that the circuit consisted of a few cheap components, I thought I&#8217;d see</p>
<p>if I could give it a go and make a working copy.</p>
<h3>Circuit prototype</h3>
<p><a href="http://strawp.net/wp-content/uploads/2011/05/wpid-IMAG0224.jpg"><img class="size-medium wp-image-238 alignright" title="Circuit prototype" src="http://strawp.net/wp-content/uploads/2011/05/wpid-IMAG0224-300x179.jpg" alt="" width="300" height="179" /></a>If, like me you haven&#8217;t done any electronics since you were at school, it&#8217;s a good idea before you start soldering to get a prototype board. This is the Lego of electronics &#8211; you can stick components into the board without solder and switch things around if needed. I got the smallest prototype board I could find from Maplin for a couple of quid and had a circuit which gave the right resistances fairly quickly. The idea was to produce something I could plug my phone into on one end and would have stereo output and a mic connection so that any generic mic with a 3.5mm plug could be used with it. In addition to the components list on George&#8217;s wiki I needed an extra 3.5mm microphone socket, a 3.5mm stereo socket, a 3.5mm 4-pole plug (for connecting to the phone).</p>
<p><a href="http://strawp.net/wp-content/uploads/2011/05/wpid-IMAG0143.jpg"><img class="alignright size-medium wp-image-239" title="Bloody fiddly 4-pole jack" src="http://strawp.net/wp-content/uploads/2011/05/wpid-IMAG0143-300x179.jpg" alt="" width="300" height="179" /></a></p>
<p>Now, it turns out the connecting to the phone part was problematic. The audio connection on HTC phones is pretty much the same as an iPhone. It&#8217;s compatible with a standard stereo heaphone connection (3.5mm 3-pole plug) but it has a third &#8220;control&#8221; ring on the plug which is used to carry the signal for the microphone. Shorting this signal (with the play button) sends the signal to the device to play music and the next/previous buttons simply send approximate voltage signals down the wire by varying the resistance slightly. In order for the controls to work I needed a 4-pole plug. You can get 3.5mm 4-pole plugs from Maplins, but holy crap are they fiddly to solder. I spent a couple of really frustrating hours trying to get four lots of wire to stick to the really unhelpful contact surface on the plug I bought. These were not designed for people whose GCSE in Technology a distant memory.</p>
<p>In the end I gave up and managed to find a much more solder-friendly 4-pole socket on eBay and got a pre-made male-to-male 4-pole plug cable (which you can even pick up in HMV these days).</p>
<h3>Two resistances and a microphone</h3>
<p>Here&#8217;s the part where I&#8217;m glad I used a prototype board first. I selected a reasonable looking tie-clip mic online that would handle calls and voice commands for the phone and plugged it into the circuit. Suddenly, the &#8220;next track&#8221; button didn&#8217;t work. What had transpired was that by adding what was effectively a 1.4 kilo-ohm resistor to the circuit in parallel, I&#8217;d lowered the effective resistance when I pressed the next track button. This meant the phone interpreted it as &#8220;previous track&#8221;. To work around this, I needed to raise the resistance on the &#8220;next track&#8221; button. If you are trying this and get the problem, my method was to measure resistance across the mic with a multimeter, then using the <a href="http://en.wikipedia.org/wiki/Resistors_in_parallel#Parallel">resistors in parallel equation</a> plug in the target resistance on the control wire (560 ohms) and the value of the other parallel resistor on the circuit. With a little help from <a href="https://market.android.com/details?id=it.android.demi.elettronica">ElectroDroid</a>, this gave me a new resistor value to plug in (1 kilo-ohm, I think I went for) which then made all the buttons work with the mic attached.</p>
<h3>Constructing the device</h3>
<p><img class="alignright size-medium wp-image-231" title="Finished device" src="http://strawp.net/wp-content/uploads/2011/05/wpid-IMAG0240-300x179.jpg" alt="" width="300" height="179" /></p>
<p>I guessed an approximate size for the circuitry, buttons and sockets and got a small project box from Maplin. For my first attempt at this, I figured I&#8217;d make life easy for myself and just put all the connections on top so tha</p>
<p>t I could work on cutting the holes to the right shape and getting everything to fit in, then I could just pop the circuit board into the box and screw the lid down.﻿</p>
<p>The photo is what I ended up with. From the left, the interface is:</p>
<ul>
<li>Stereo audio out (to the car audio system)</li>
<li>4-pole 3.5mm stereo audio and control I/O (the phone)</li>
<li>3.5mm 2-pole mic socket (goes to tie-clip mic, which is going above the door frame in my car)</li>
<li>Previous track button</li>
<li>Play/answer button</li>
<li>Next track button</li>
</ul>
<h3>Seamless automobile integration AKA &#8220;The part with the duct tape&#8221;</h3>
<p><img class="alignright size-medium wp-image-243" title="Control unit mounted in car" src="http://strawp.net/wp-content/uploads/2011/05/wpid-IMAG0248-1-300x271.jpg" alt="" width="300" height="271" /></p>
<p>So that&#8217;s all the bits working. Now to find a space in my car that I can fit this where it&#8217;s in easy reach, won&#8217;t get in the way and can be secured easily. In the end I went for the space just in front of my gear stick, mounting it next to the 12v power socket, over the top of the ash tray. The stereo cable for the car audio actually goes through the back of the car and plugs into the Grom Audio CD autochanger emulator. The mic cable is taped around the dash up the side of the windscreen and sits near the top of the door, in clear audible range. The phone is held in a generic phone mount on the top of the dashboard and plugged in to the 12v power (converted for the phone of course).</p>
<p>I might neaten it up. I probably won&#8217;t.</p>
<h3>Extending the controls</h3>
<p>Having the standard audio controls, plus the ability to take calls is all well and good, but what about being able to do other useful stuff with those 3 buttons? I&#8217;ve <a href="http://strawp.net/archive/love-tracks-on-last-fm-with-one-click-of-a-headset-button/">previously blogged an example</a> of using <a href="https://market.android.com/details?id=net.dinglisch.android.taskerm&amp;feature=search_result">Tasker</a> with the <a href="https://market.android.com/details?id=com.kober.headsetbutton&amp;feature=search_result">Headset Button Controller</a> app, so I won&#8217;t labour the point, but suffice to say with these two little gems you can pretty much tie or automate any Android task you need to with only 3 buttons at your disposal. I keep my <a href="http://svn.strawp.net/scripts/Tasker/">Tasker profile checked into SVN</a> if you want to borrow bits of code, and I&#8217;m changing it all the time but here&#8217;s some of the things I&#8217;ve used this setup for:</p>
<ul>
<li>Press a button to activate voice commands (&#8220;navigate to cambridge&#8221;, &#8220;call home&#8221;, &#8220;listen to beastie boys&#8221; etc)</li>
<li><a href="http://strawp.net/archive/love-tracks-on-last-fm-with-one-click-of-a-headset-button/">&#8220;Love&#8221; the currently playing track</a></li>
<li> Automatically start playing music when headset and power is attached (poor man&#8217;s dock mode)</li>
<li>Automatically read out incoming texts using text-to-speech</li>
<li>Announce callers using text-to-speech</li>
<li>Re-read the last text message</li>
<li>Call a specific person using a button press</li>
<li>Launch navigation to a specific place with a button press (i.e. the &#8220;oh shit, I&#8217;m lost&#8221; button)</li>
<li>Lock onto heat signatures and engage stinger missiles</li>
</ul>
<p>So there we go. That&#8217;s the kind of car setup that you&#8217;re only just starting to see in new cars at the moment (at time of writing, ahem) and for complete pocket money.</p>
]]></content:encoded>
			<wfw:commentRss>http://strawp.net/archive/diy-hands-free-kit/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>&#8220;Love&#8221; tracks on last.fm with one click of a headset button</title>
		<link>http://strawp.net/archive/love-tracks-on-last-fm-with-one-click-of-a-headset-button/</link>
		<comments>http://strawp.net/archive/love-tracks-on-last-fm-with-one-click-of-a-headset-button/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 19:11:34 +0000</pubDate>
		<dc:creator>Strawp</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[headset button]]></category>
		<category><![CDATA[last.fm]]></category>
		<category><![CDATA[love track]]></category>
		<category><![CDATA[scrobble]]></category>
		<category><![CDATA[tasker]]></category>
		<category><![CDATA[winamp]]></category>

		<guid isPermaLink="false">http://strawp.net/?p=225</guid>
		<description><![CDATA[Here&#8217;s a handy little trick for keen last.fm users on Android that lets you mark the current track as &#8220;Loved&#8221; with a headset button combination. What you will need is: The official Last.fm client for Android Tasker Headset Button Controller A headset remote button or the headphones that probably came with your phone if it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a handy little trick for keen last.fm users on Android that lets you mark the current track as &#8220;Loved&#8221; with a headset button combination. What you will need is:</p>
<ol>
<li><a href="https://market.android.com/details?id=fm.last.android&amp;feature=search_result">The official Last.fm client for Android</a></li>
<li><a href="https://market.android.com/details?id=net.dinglisch.android.taskerm&amp;feature=search_result">Tasker</a></li>
<li><a href="https://market.android.com/details?id=com.kober.headsetbutton&amp;feature=search_result">Headset Button Controller</a></li>
<li>A headset remote button or the headphones that probably came with your phone if it&#8217;s got buttons on it</li>
</ol>
<h3>Set up last.fm</h3>
<p>Nothing much to do other than log in and make sure your media player of choice scrobbles tracks correctly. I&#8217;m using Winamp which works fine, but make sure you&#8217;ve turned on scrobbling in the settings. The last.fm widget has a &#8220;love&#8221; icon which due to the awesomeness of Android&#8217;s intents architecture we will be calling on. Add the widget somewhere on your home screen and make sure that bit works.</p>
<h3>Create a &#8220;Love Track&#8221; task in Tasker</h3>
<p>In Tasker, click &#8220;Tasks&#8221; -&gt; &#8220;New Task&#8221; (call it &#8220;Love Track&#8221;) and in the task edit window add &#8220;Misc&#8221; -&gt; &#8220;Action Intent&#8221; and in the &#8220;Action&#8221; setting, enter &#8220;fm.last.android.widget.LOVE&#8221;. Leave the other fields blank and make sure &#8220;Target&#8221; is set to &#8220;Broadcast Receiver&#8221;. You could also add an action which says &#8220;You love this track&#8221; by using &#8220;Misc&#8221; -&gt; &#8220;Say&#8221;.</p>
<p>Start a track playing and come back to the edit screen and then hit &#8220;Test&#8221;. The last.fm app should create a little toast notification (one line of text overlayed on the screen) saying the track has been marked as played. After a short while it should appear in your last.fm profile.</p>
<h3>Optional: Create a home screen shortcut</h3>
<p>Long-click on a space on your Android home screen and choose &#8220;shortcuts&#8221; -&gt; &#8220;Task&#8221; -&gt; &#8220;Love Track&#8221;. You can now click on that to mark the currently playing track.</p>
<h3>Headset button controller</h3>
<p>Headset button controller is a stupendously useful app that allows you to assign actions to headset buttons. If your headset only has one button this is great because you can do more than answer/hang up and play/pause by assigning double, triple, quadruple and long-click actions to a button.</p>
<p>Once you&#8217;ve installed this set up your usual button actions, simply set one to &#8220;Tasker Task&#8221; -&gt; &#8220;Love Track&#8221; and you&#8217;re done!</p>
]]></content:encoded>
			<wfw:commentRss>http://strawp.net/archive/love-tracks-on-last-fm-with-one-click-of-a-headset-button/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remote Wireless Music Syncing Android and Linux</title>
		<link>http://strawp.net/archive/remote-wireless-music-syncing-android-and-linux/</link>
		<comments>http://strawp.net/archive/remote-wireless-music-syncing-android-and-linux/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 19:18:19 +0000</pubDate>
		<dc:creator>Strawp</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://strawp.net/?p=210</guid>
		<description><![CDATA[Recently, an Android version of Winamp was released and included in its feature list was very useful wireless syncing with the Windows version of Winamp. Unfortunately, my file server at home doesn&#8217;t run Windows and Winamp under Wine is an unstable mess, so attempting to use that feature was out. Like a good Linux user, I [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, an Android version of <a href="http://www.winamp.com/">Winamp</a> was released and included in its feature list was very useful wireless syncing with the Windows version of Winamp. Unfortunately, my file server at home doesn&#8217;t run Windows and Winamp under Wine is an unstable mess, so attempting to use that feature was out. Like a good Linux user, I didn&#8217;t take this lying down &#8211; we don&#8217;t sit around like Windows users waiting for someone to build the solution for us, we cobble something together using tools already available! What I decided to do was to emulate the mechanism that I came up with when I built my <a href="http://strawp.net/carpc/">Car PC</a>. Basically, the core of wireless syncing in the Car PC was <a href="http://en.wikipedia.org/wiki/Rsync">rsync</a>, combined with a little bit of logic to get a list of music track locations to pull over. By offloading some of that logic onto the server, this seemed possible.</p>
<p>First, I installed <a href="https://market.android.com/details?id=eu.kowalczuk.rsync4android">an rsync app for Android</a> and tested it out. Rsync backup is just a front end for rsync, which is perfect because it lets you use all the normal rsync options, allows public key authentication (so you never need to enter a password) and displays rsync&#8217;s output to a log window. I wanted to pull files from my server so in my rsync profile I selected &#8220;rsync in reverse&#8221; and added the command line options &#8220;<code>-vHrtDL --chmod=Du+rwx,go-rwx,Fu+rw,go-rw --no-perms --progress --partial</code>&#8221; most of which is the default for a new profile, but I added:</p>
<ul>
<li><code>-L</code>, to follow <a href="http://en.wikipedia.org/wiki/Symbolic_link">symlinks</a></li>
<li><code>--progress</code>, to display file transfer progress</li>
<li><code>--partial</code>, to allow file transfer resuming</li>
</ul>
<p>Android won&#8217;t know any of the new music files have been added yet, so they won&#8217;t show up in any music players (which all look up available tracks in the built-in Android media database), so you need to install something like <a href="https://market.android.com/details?id=com.bero.sdrescan">SDrescan</a> to run after the files have copied over which will magically make them visible in the music app of your choice.</p>
<p>That&#8217;s the phone side sorted out, I just need something sensible to point it at &#8211; I don&#8217;t want rsync recursing over my entire music collection wirelessly, it would take ages.</p>
<p>On the server, I&#8217;m running the (somewhat ageing) <a href="http://www.fireflymediaserver.org/">Firefly Media Server</a>, which indexes and serves music for my Roku Soundbridge. I&#8217;d previously written a <a href="http://svn.strawp.net/lib/firefly_db.php">data abstraction class</a> in PHP for the sqlite database it runs on, so I used that to produce <a href="http://svn.strawp.net/scripts/firefly/symlink_albums.php">a script</a> (to run periodically under cron) which picks a list of albums from a playlist (created by <a href="http://svn.strawp.net/scripts/firefly/setup_recent_albums_playlist.php">another script</a>) and creates a bunch of symlinks to them in the folder that I set as the target in my rsync profile, the idea being I have a regularly changing folder which one rsync command can look at to pick up new music.</p>
<p>I now have wireless syncing that works anywhere with an internet connection, as well as on the local network (unlike Winamp) and the idea of keeping a static rsync profile and using a source folder full of symlinks provides a cunning way of pushing content onto your phone. It would be quite easy to create something like a web interface to pick files on the server and have symlinks of them created on a single rsync source folder. On top of this, Rsync backup provides hooks for Tasker to link into, so you could set this up to run automatically at some opportune moment.</p>
]]></content:encoded>
			<wfw:commentRss>http://strawp.net/archive/remote-wireless-music-syncing-android-and-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How FireShepherd could live up to its name</title>
		<link>http://strawp.net/archive/how-fireshepherd-could-live-up-to-its-name/</link>
		<comments>http://strawp.net/archive/how-fireshepherd-could-live-up-to-its-name/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 14:04:22 +0000</pubDate>
		<dc:creator>Strawp</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://strawp.net/?p=204</guid>
		<description><![CDATA[First there was FireSheep. It allows anyone to hijack HTTP session cookies for a number of sites for anyone using them on the same open access point as you. Now, a predictable counter point for that is that someone would come up with &#8220;FireShepherd&#8221; to protect this poor flock. However, FireShepherd is no where near [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://strawp.net/wp-content/uploads/2010/11/MV5BMzcwNjcxODgwOV5BMl5BanBnXkFtZTcwMzMzNTM2MQ@@._V1._SX500_SY706_.jpg"><img class="alignright size-medium wp-image-206" title="The Shepherd" src="http://strawp.net/wp-content/uploads/2010/11/MV5BMzcwNjcxODgwOV5BMl5BanBnXkFtZTcwMzMzNTM2MQ@@._V1._SX500_SY706_-212x300.jpg" alt="" width="212" height="300" /></a>First there was <a href="http://codebutler.github.com/firesheep/">FireSheep</a>. It allows anyone to hijack HTTP session cookies for a number of sites for anyone using them on the same open access point as you. Now, a predictable counter point for that is that someone would come up with &#8220;<a href="http://notendur.hi.is/~gas15/FireShepherd/">FireShepherd</a>&#8221; to protect this poor flock. However, FireShepherd is no where near as fun as FireSheep &#8211; all it does is try and crash FireSheep with fake data and hope for the best, meanwhile your session info is still being transmitted in the clear.</p>
<p>Ideas for FireShepherd to be more useful/fun:</p>
<ol>
<li>Have it force SSL connections on all the same sites that FireSheep snoops on, making session hijacking impossible. Plugins like <a href="https://addons.mozilla.org/en-US/firefox/addon/12714/">Force-TLS</a> do this.</li>
<li>Have it create bogus logins to sites where the user&#8217;s profile pic has been set as goatse, tubgirl etc. When the FireSheep user grabs that user&#8217;s session data they will have those lovely pics appear in their stolen sessions list.</li>
<li>(getting crazy here) have it perform a <a href="http://en.wikipedia.org/wiki/Man-in-the-middle_attack">man-in-the-middle attack</a> on the wireless network, replacing the network&#8217;s router as the default gateway or DNS server. You can then point people to fake versions of captured websites and feed the FireSheep user whatever you want. Oops, there&#8217;s goatse again! Oh, what&#8217;s that you just went to? A malware site? Careless FireSheep user!</li>
</ol>
<p>Anyway, there&#8217;re some ideas. As Steve Gibson pointed out in the <a href="http://www.grc.com/sn/sn-272.htm">last Security Now</a>, simply switching a network to WPA is enough to protect all the users from this attack. If you&#8217;re running a Cafe and want to provide free wifi you can make the network password as public as you want &#8211; make a poster and stick it above the till. It is unencrypted wifi, not wifi itself that allows user sessions to be hijacked like this.</p>
]]></content:encoded>
			<wfw:commentRss>http://strawp.net/archive/how-fireshepherd-could-live-up-to-its-name/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Proof of concept: Locating a remote machine using the Google API</title>
		<link>http://strawp.net/archive/proof-of-concept-locating-a-remote-machine-using-the-google-api/</link>
		<comments>http://strawp.net/archive/proof-of-concept-locating-a-remote-machine-using-the-google-api/#comments</comments>
		<pubDate>Wed, 27 Oct 2010 16:34:51 +0000</pubDate>
		<dc:creator>Strawp</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[location]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wifi]]></category>

		<guid isPermaLink="false">http://strawp.net/?p=193</guid>
		<description><![CDATA[A couple of months ago Samy Kamkar presented a cool hack at the Black Hat Conference which demonstrated that by using a cunningly constructed URL against specific internet routes, you could inject some javascript on their configuration pages and trick them into sending their own MAC address (the router&#8217;s own unique code) to a script which [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://strawp.net/wp-content/uploads/2010/10/locate.png"><img class="alignright size-medium wp-image-194" title="locate" src="http://strawp.net/wp-content/uploads/2010/10/locate-300x291.png" alt="example output of the locate script" width="300" height="291" /></a></p>
<p>A couple of months ago <a href="http://samy.pl/">Samy Kamkar</a> <a href="http://www.youtube.com/watch?v=tRJMIMBVqFI">presented a cool hack</a> at the <a href="http://www.blackhat.com/">Black Hat Conference</a> which <a href="http://samy.pl/mapxss/">demonstrated</a> that by using a cunningly constructed URL against specific internet routes, you could inject some javascript on their configuration pages and trick them into sending their own MAC address (the router&#8217;s own unique code) to a script which would use it to look up their address on Google&#8217;s API, thus telling the attacker a pretty good estimate of your physical location.</p>
<p>This was only possible because as well as photographing everything, the Google Streetview cars have been recording the locations of every wireless access point they encountered. By recording the signal strengths of certain access points by the location they were observed in it&#8217;s possible to do a simple triangulation calculation and get a pretty good estimate of where the access point is.</p>
<p>I found this pretty fascinating, so I created a little PHP script to use this trick, perhaps it could be used to help <a href="http://preyproject.com">locate a stolen laptop</a>, for example. The script works like this:</p>
<ol>
<li>Attempt to scan using the wireless network adapter for any nearby access points. Save their key details (BSSID, signal strength and most importantly, the MAC)</li>
<li>Compile all this into POST data and send it to Google using libcurl. Even without nearby MACs Google&#8217;s location API will do a better job at locating the machine than the usual GeoIP services.</li>
<li>Get a bunch of data back from Google, including longitude and latitude estimates and a street address. For ease this also gives you a Google Maps link</li>
</ol>
<p>The accuracy depends on how many neighbours your wireless card picks up and how much data Google has harvested from the wireless networks on your road, but for most people it will be accurate almost to the right house number.</p>
<p>The <a href="http://svn.strawp.net/scripts/location/locate">script is on my SVN server for download</a></p>
]]></content:encoded>
			<wfw:commentRss>http://strawp.net/archive/proof-of-concept-locating-a-remote-machine-using-the-google-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to download your Facebook photos</title>
		<link>http://strawp.net/archive/how-to-download-your-facebook-photos/</link>
		<comments>http://strawp.net/archive/how-to-download-your-facebook-photos/#comments</comments>
		<pubDate>Wed, 27 Oct 2010 14:34:44 +0000</pubDate>
		<dc:creator>Strawp</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[The Web]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[photos]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[wget]]></category>

		<guid isPermaLink="false">http://strawp.net/?p=184</guid>
		<description><![CDATA[Facebook recently released a feature that allows you to download a static version of your Facebook profile which includes all your videos, photos, your wall and a few bits of periphery information. If you&#8217;re planning on quitting Facebook, this is great because it means you don&#8217;t lose anything and it&#8217;s also a nice offline backup [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://strawp.net/wp-content/uploads/2010/10/download_info.png"><img class="alignright size-thumbnail wp-image-201" title="The new download information feature of Facebook" src="http://strawp.net/wp-content/uploads/2010/10/download_info-150x150.png" alt="" width="150" height="150" /></a>Facebook recently released a feature that allows you to download a static version of your Facebook profile which includes all your videos, photos, your wall and a few bits of periphery information. If you&#8217;re planning on quitting Facebook, this is great because it means you don&#8217;t lose anything and it&#8217;s also a nice offline backup of your Facebook info.</p>
<p>To do this, go to Account -&gt; Account Settings and pick &#8220;Download Your Information&#8221;.</p>
<p>What this doesn&#8217;t get you, however is all the photos you&#8217;re tagged in. For this you need to go through the Facebook API. Here&#8217;s how to grab all those photos in the best possible quality in a bit of a hacky way. No idea if it violates Facebook&#8217;s terms of service &#8211; who the hell knows what they are any more?</p>
<p>First of all you&#8217;ll need a system which has <strong>wget</strong>, <strong>grep</strong>, <strong>sed</strong> and <strong>awk</strong>. You can get these for Windows and this should all work, but I&#8217;m going to assume you&#8217;re logged into something with a bash prompt.</p>
<ol>
<li><strong>Find your Facebook ID</strong>. If like most people you have an alias for your homepage, click on your profile picture and you&#8217;ll see &#8220;id=xxxxxxxx&#8221;. That&#8217;s your Facebook ID</li>
<li><strong>Create a URL for calling photos.get in the API. </strong>Go to the <a href="http://developers.facebook.com/docs/reference/rest/photos.get">API documentation page for photos.get</a> and in the Test Console at the bottom, enter your Facebook ID for &#8220;subj_id&#8221;.</li>
<li><strong>Run the call.</strong> Click &#8220;Call Method&#8221; &#8211; you will then see a bunch of code on the right and you will have a URL at the top starting with <code>https://api.facebook.com/method/photos.get?subj_id=</code>. Click on it to open that page in a new window.</li>
<li><strong>Download the data.</strong> Either copy the file from the browser window (ctrl+a, ctrl+c, paste into a file) or run <code>wget -O photos.json "&lt;your URL&gt;"</code> to save your data in a file called photos.json</li>
<li><strong>Grab the images</strong>. You can now run <code>cat photos.json | sed 's/,/\n/g' | grep src_big | grep http | sed 's/\\//g' | awk -F\" '{print $4}' | wget -i -</code>. This will pluck out the URL of each photo you&#8217;re tagged in and download them to the current folder.</li>
</ol>
<p>You&#8217;ll then see wget going crazy downloading all those photos and when it&#8217;s done you&#8217;ll have a copy of every photo you&#8217;ve been tagged in. After that you&#8217;re free to stick them into an album, edit them into your existing offline Facebook profile &#8211; whatever you fancy.</p>
]]></content:encoded>
			<wfw:commentRss>http://strawp.net/archive/how-to-download-your-facebook-photos/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Recipe for a decent bash shell in Android</title>
		<link>http://strawp.net/archive/recipe-for-a-decent-bash-shell-in-android/</link>
		<comments>http://strawp.net/archive/recipe-for-a-decent-bash-shell-in-android/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 15:09:58 +0000</pubDate>
		<dc:creator>Strawp</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[connectbot]]></category>
		<category><![CDATA[cyanogenmod]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://strawp.net/?p=174</guid>
		<description><![CDATA[Root your phone if you haven&#8217;t already and install the latest stable CyanogenMod, which includes bash. If this step sounds scary, stop reading now Install ConnectBot: ConnectBot is a fantastic SSH client, but it also has a local terminal emulator. Open it up and select &#8220;local&#8221; from the drop down list and give it any [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li> Root your phone if you haven&#8217;t already and install the latest stable <a href="http://cyanogenmod.com">CyanogenMod</a>, which includes bash. If this step sounds scary, stop reading now <img src='http://strawp.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>Install ConnectBot:<br />
<img class="alignright" title="Scan with an android phone to download ConnectBot" src="http://connectbot.googlecode.com/svn/trunk/www/qr-code.png" alt="Connectbot Market QR code" width="100" height="100" /></li>
<li>ConnectBot is a fantastic SSH client, but it also has a local terminal emulator. Open it up and select &#8220;local&#8221; from the drop down list and give it any nickname.</li>
<li>Open it up to see the local shell works. It will, it&#8217;s not bash though and it won&#8217;t have tab completion. Hit the menu button and disconnect.</li>
<li>Long-press the connection and select Edit host.</li>
<li>Find the &#8220;Post-login automation&#8221; option.</li>
<li>enter:
<pre>su
bash
export PS1="\w\$ "
cd /</pre>
<p>This step automatically switches you into root mode (you will be prompted by the superuser manager the first time you do this), starts bash, sets your prompt to the working directory and then changes directory to root.</li>
<li>Hit &#8220;OK&#8221; and then the back button to return to the connections screen. Select the connection to test if it&#8217;s all working.</li>
<li>For quick access, you can add a shortcut to the home screen. Long press on the home screen, select &#8220;Shortcuts&#8221;, &#8220;ConnectBot&#8221; then the name of your connection.</li>
</ol>
<p>Tada! A one-click root terminal in bash with tab-completion (courtesy of ConnectBot&#8217;s keyboard shortcuts). Much better than the Terminal app every other blog tells you to install <img src='http://strawp.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://strawp.net/archive/recipe-for-a-decent-bash-shell-in-android/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OAuth PHP Twitter Class</title>
		<link>http://strawp.net/archive/oauth-php-twitter-class/</link>
		<comments>http://strawp.net/archive/oauth-php-twitter-class/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 14:59:56 +0000</pubDate>
		<dc:creator>Strawp</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[The Web]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://strawp.net/?p=167</guid>
		<description><![CDATA[After posting my temporary twitter unfollow script the other week I was reminded that Twitter is supposed to be dumping basic auth (sending user name and password in each request to Twitter) this month in favour of the more secure, widely adopted Open Authentication. It turned out Twitter has postponed what they have dubbed the [...]]]></description>
			<content:encoded><![CDATA[<p>After posting my <a href="http://strawp.net/archive/temporary-twitter-unfollow-script/">temporary twitter unfollow script</a> the other week I was reminded that Twitter is supposed to be dumping basic auth (sending user name and password in each request to Twitter) this month in favour of the more secure, widely adopted <a href="http://www.openauthentication.org/">Open Authentication</a>. It turned out Twitter has postponed what they have dubbed the <a href="http://mashable.com/2010/06/17/oauthcalypse-delayed/">&#8220;oauthcalypse&#8221; due to the world cup</a> but if you haven&#8217;t already, now is the time to get rid of your neat little <a href="http://www.commandlinefu.com/commands/matching/twitter/dHdpdHRlcg==/sort-by-votes">one-line curl scripts using basic auth</a> (a shame I know but it&#8217;s for the best) and find an OAuth alternative in the language of your choice.</p>
<p>I have created a simple TwitterClient class (<a href="http://svn.strawp.net/lib/twitter.class.php">available under SVN</a>) based on my <a href="http://svn.strawp.net/lib/twitter.php">previous set of basic auth and curl-using functions</a> from a couple of years back. I have left it with my app key in their on purpose, so tweets from it will appear to come from &#8220;Strawp&#8217;s PHP lib&#8221;. Register your own app if you want and use those instead, of course. On the first use of a method you will be prompted to authenticate the class against your twitter login. The secret keys will then be stored in your home folder.</p>
<p>Example usage:</p>
<pre>include( "twitter.class.php" );
$tw = new TwitterClient();
$tw-&gt;tweet( "I am using oAuth now!" );</pre>
<p>The unfollow script has also been updated to use this class.</p>
]]></content:encoded>
			<wfw:commentRss>http://strawp.net/archive/oauth-php-twitter-class/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Temporary Twitter unfollow script</title>
		<link>http://strawp.net/archive/temporary-twitter-unfollow-script/</link>
		<comments>http://strawp.net/archive/temporary-twitter-unfollow-script/#comments</comments>
		<pubDate>Thu, 27 May 2010 09:48:22 +0000</pubDate>
		<dc:creator>Strawp</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[unfollow]]></category>

		<guid isPermaLink="false">http://strawp.net/?p=161</guid>
		<description><![CDATA[Update: This now uses the oAuth Twitter class, not the basic auth function library. Do you ever get people you follow on Twitter who, for some reason have suddenly become really spammy? Normally they&#8217;re great, but maybe one evening they&#8217;ve come back drunk and are vomiting tweets all over their feed, or maybe they&#8217;re live-tweeting [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update</strong>: This now uses the <a href="http://strawp.net/archive/oauth-php-twitter-class/">oAuth Twitter class</a>, not the basic auth function library.</p>
<p>Do you ever get people you follow on Twitter who, for some reason have suddenly become really spammy? Normally they&#8217;re great, but maybe one evening they&#8217;ve come back drunk and are vomiting tweets all over their feed, or maybe they&#8217;re live-tweeting some inane reality TV show for the opening night or are taking part in an incredibly uninteresting meme hashtag.</p>
<p>Whatever the reason, you don&#8217;t want to ditch them entirely, just until they&#8217;ve stopped blabbing on about stuff you don&#8217;t care about.</p>
<p>So I made a command line script to get around this. If you want to temporarily unfollow someone, write:</p>
<pre>unfollow mrspammy for 1 week</pre>
<p>or for several users:</p>
<pre>unfollow mrspammy,mrsspammy,mrspammystennispartner for 4 days</pre>
<p>Due to the genius of of PHP&#8217;s strtodate(), the words after &#8220;for&#8221; can be pretty much any time period phrase that works with the &#8220;+&#8221; modifier from the current date. You can also specify exact dates:</p>
<pre>unfollow mrspammy until next tuesday</pre>
<p>or</p>
<pre>unfollow mrspammy until 12 july</pre>
<p>This then looks at users that were previously unfollowed, checks if you want to re-follow them by now and does so if required. Run it without specifying any unfollows to just get this behaviour. This means you can also put unfollow in cron (or whatever) to run periodically and it will automatically check if users need re-following by now.</p>
<p>This is written for Ubuntu. Any Linux will be OK, Mac too probably if you have the paths set up properly. You might even get it working under Windows.</p>
<p>To get it working, you need</p>
<ol>
<li><a href="http://svn.strawp.net/lib/twitter.php">My Twitter library under svn</a></li>
<li><a href="http://svn.strawp.net/scripts/unfollow">The unfollow script</a></li>
<li>PHP installed with libcurl</li>
</ol>
<p>Put the PHP files in the same folder. You then need to:</p>
<ol>
<li>Edit $confpath in unfollow</li>
<li>Create twitter.conf.php, containing two define() statements with TWITTER_EMAIL and TWITTER_PASSWORD in. These should contain your username and password.</li>
<li>chmod u+x unfollow</li>
<li>optional: Add unfollow to crontab to run at whatever interval you want</li>
<li>optional: make this folder part of path, symlink to unfollow or in some way make unfollow callable without defining the entire path</li>
</ol>
<p>And you&#8217;re good to go. Easy <img src='http://strawp.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Let me know if you end up using this or my twitter library at all.</p>
]]></content:encoded>
			<wfw:commentRss>http://strawp.net/archive/temporary-twitter-unfollow-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

