<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Can't Hack, Won't Hack</title>
	
	<link>http://canthack.org</link>
	<description />
	<lastBuildDate>Fri, 18 May 2012 14:42:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CantHackWontHack" /><feedburner:info uri="canthackwonthack" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>#WolfBot</title>
		<link>http://feedproxy.google.com/~r/CantHackWontHack/~3/MFWmQ5Xloa0/</link>
		<comments>http://canthack.org/2012/05/wolfbot/#comments</comments>
		<pubDate>Fri, 18 May 2012 09:54:25 +0000</pubDate>
		<dc:creator>Mex</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://canthack.org/?p=1193</guid>
		<description><![CDATA[I would like to introduce WolfBot, a new IRC bot that moderates a game of Werewolf. Werewolf is a social game in the ilk of Mafia and has become very popular at un-conferences such as BarCamps. There are many rule &#8230; <a href="http://canthack.org/2012/05/wolfbot/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://canthack.org/uploads/wolves.jpg" rel="fancybox-1193"><img src="http://canthack.org/uploads/wolves-227x300.jpg" alt="" title="wolves" width="227" height="300" class="alignright size-medium wp-image-1205" /></a>I would like to introduce WolfBot, a new <dfn title="Internet Relay Chat">IRC</dfn> bot that moderates a game of Werewolf. </p>
<p>Werewolf is a social game in the ilk of <a href="http://en.wikipedia.org/wiki/Mafia_(party_game)">Mafia</a> and has become very popular at un-conferences such as <a href="http://barcamp.org/">BarCamps</a>.  There are many rule variants of Werewolf, but this bot probably most closely matches the rules set out in <a href="http://boardgamegeek.com/boardgame/38159/ultimate-werewolf-ultimate-edition">ultimate werewolf</a>, with some changes to make it fit better to IRC, the voting system is slightly different for example. </p>
<p>WolfBot is based on the popular <a href="http://www.jibble.org/pircbot.php">PircBot</a> Java IRC framework. It is a collabrative project between me, <a href="http://www.twigathy.com/">Twigathy</a>, and a number of other people. The code is avaliable on github (<a href="https://github.com/tpcarlson/Werewolf/network">tpcarlson/Werewolf</a>).</p>
<p>WolfBot is currently playable in <a href="irc://irc.boredicons.com/%23wolfbot">#wolfbot</a> on the <a href="irc://irc.boredicons.com">boredicons irc network</a> and. Use the command &#8220;!join&#8221; to start playing (please note if there is a game in progress you will have to wait for it to finish before you will get voice in the channel).</p>
<p><em>This post is a quick follow up to a talk I gave at <a href="http://www.barcampcanterbury.com/">BarCamp Canterbury</a>, my <a href="https://docs.google.com/presentation/d/1pnGBkSBr3OC8jpYgqtl3JOAdY01jGSvTPI22IrSMOak/edit">original slides are available</a>.</em></p>
<img src="http://feeds.feedburner.com/~r/CantHackWontHack/~4/MFWmQ5Xloa0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://canthack.org/2012/05/wolfbot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://canthack.org/2012/05/wolfbot/</feedburner:origLink></item>
		<item>
		<title>BarCamp Canterbury recap.</title>
		<link>http://feedproxy.google.com/~r/CantHackWontHack/~3/bxsMbEsezfI/</link>
		<comments>http://canthack.org/2012/05/barcamp-canterbury-recap/#comments</comments>
		<pubDate>Tue, 08 May 2012 15:55:28 +0000</pubDate>
		<dc:creator>Mex</dc:creator>
				<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://canthack.org/?p=1169</guid>
		<description><![CDATA[Updates on the blog have been a bit thin and far between recently, but that&#8217;s because a lot of us have been busy organising BarCamp Canterbury. The event was run a couple of weekends ago (Saturday 28th and Sunday 29th &#8230; <a href="http://canthack.org/2012/05/barcamp-canterbury-recap/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div id="attachment_1180" class="wp-caption alignright" style="width: 190px"><a href="http://canthack.org/uploads/bcc2.jpg" rel="fancybox-1169"><img class="size-full wp-image-1180" title="BarCamp Canterbury 2012" src="http://canthack.org/uploads/bcc2.jpg" alt="Barcamp Canterbury Logo" width="180" height="176" /></a><p class="wp-caption-text">BarCamp Canterbury 2012</p></div>
<p>Updates on the blog have been a bit thin and far between recently, but that&#8217;s because a lot of us have been busy organising BarCamp Canterbury. The event was run a couple of weekends ago (Saturday 28th and Sunday 29th of April 2012) and thankfully all our preparation was worth it as the event went without a (noticeable) hitch.</p>
<p>I thought it would be helpful to share what we have learned, for any one else thinking of organising a BarCamp.</p>
<h3>Tickets</h3>
<ul>
<li>Use <a href="http://www.eventbrite.co.uk/">EventBrite</a>, their service is brilliant, and made keeping track of people/tickets sold a piece of cake.</li>
<li>Oversubscribe. We have a 30% no show. If your limit is 100 people you can probably issue 120+ tickets safely.</li>
</ul>
<h3>Food and Drink</h3>
<ul>
<li>Fifty people got through 140 pints of Ale and 40 pints of cider.</li>
<li><a href="http://www2.sainsburys.co.uk/food/delipartyplatter/platters/instore-party-platter-service.htm">Sainsburys do Catering!</a></li>
<li>People get grumpy without coffee.</li>
</ul>
<h3>Sponsorship</h3>
<ul>
<li>Follow up with sponsors. Some companies only replied to second email.</li>
<li>Make it clear what you expect from your sponsors, and what they should expect from you.</li>
<li>Ask for &#8220;stuff&#8221; many companies won&#8217;t give money but they will hand out freebies.</li>
</ul>
<p>I hope this helps you if your thinking of running a BarCamp or similar event yourself.  Please leave a comment if you think of anything else that would be helpful.</p>
<img src="http://feeds.feedburner.com/~r/CantHackWontHack/~4/bxsMbEsezfI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://canthack.org/2012/05/barcamp-canterbury-recap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://canthack.org/2012/05/barcamp-canterbury-recap/</feedburner:origLink></item>
		<item>
		<title>A brief history of my Zipit Z2</title>
		<link>http://feedproxy.google.com/~r/CantHackWontHack/~3/IwRtMKnn1Js/</link>
		<comments>http://canthack.org/2012/04/a-brief-history-of-my-zipit-z2/#comments</comments>
		<pubDate>Sat, 07 Apr 2012 11:50:27 +0000</pubDate>
		<dc:creator>shaun</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://canthack.org/?p=1122</guid>
		<description><![CDATA[For a while now I have been playing with the idea of building my version of the perfect alarm clock. My original ideas involved the Arduino and the Arduino Ethernet Shield. This all changed when I was introduced to the &#8230; <a href="http://canthack.org/2012/04/a-brief-history-of-my-zipit-z2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For a while now I have been playing with the idea of building my version of the perfect alarm clock. My original ideas involved the Arduino and the Arduino Ethernet Shield. This all changed when I was introduced to the Zipit Z2.</p>
<p>Unlike the Arduino, it comes with an integrated keyboard and <del>chair</del> screen. For further hardware specifications <a title="Hardware Specs" href="http://www.mozzwald.com/zipitz2" target="_blank">click here.</a></p>
<p>My investigations of the Z2 led me to Mozzwald&#8217;s site which contains most of what I wanted to know. There are Zipit guides on U-Booting, Ubuntu, etc.</p>
<p>While my Zipit was winging its way from the USA, I started work on my clock application. Using the <a href="www.lazarus.freepascal.org" target="_blank">Lazarus IDE</a> and the <a href="http://www.freepascal.org/" target="_blank">Free Pascal Compiler</a> I created the first draft. Setting up the<a href="http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM" target="_blank"> cross compile environment</a> was straight forward and I soon had a binary ready for the Zipit&#8217;s ARM v5 compatible processor.</p>
<p>After a week of anticipation, I was finally introduced to my Zipit at the Rochester Can&#8217;t Hack meet. I started by flashing the Z2 with a U-Boot image I <a title="FlashStock v0.1.2 Jan-27-2012 [with openwrt recoveryos]" href="http://www.mozzwald.com/zipit/stock/Flashstockv0.1.2_openwrt.zip" target="_blank">downloaded</a>. To get the image flashed I booted into the Z2&#8242;s stock OS and selected the reset to defaults option.</p>
<p>Using Mozzwald&#8217;s <a title="z2sid v7 RC1" href="http://zipit.markamber.co/z2sidX_v7_rc1.tar.bz2" target="_blank">z2sidX image</a> I booted into Debian Sid. Following this was a back and forth between the Can&#8217;t Hack group about keyboard layout. Needless to say I was a very happy to see X start and spent a few minutes playing Free Doom.</p>
<p>For the past few days I have been perfecting the sid image I am using, including changes that allow for better integration of my Clock application.</p>
<p>Some notes on my changes:</p>
<p>Installed avahi-daemon openssh-clients nfs-common</p>
<p>For the dbus install (avahi-deamon dependancy) I selected not to overwrite the dbus config file with the package maintainer&#8217;s version. This caused issues with dbus failing to load. To fix this I purged dbus and reinstalled avahi-daemon.</p>
<p>Something I noted was the MAC address used by Debian Sid was not the MAC address printed on a sticker found under the battery. To fix this I edited /etc/network/interfaces.</p>
<p>user@zipit:~$ cat /etc/network/interfaces<br />
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or<br />
# /usr/share/doc/ifupdown/examples for more information.<br />
auto wlan0<br />
iface wlan0 inet dhcp<br />
hwaddress ether 00:12:34:56:78:ab</p>
<p>To change the host name to &#8220;zipit&#8221; I used the hostname command and also edited /etc/hostname and the /etc/hosts file.</p>
<p>Note: I installed avahi-daemon to enable machines on the local network to find the Zipit on the network using the .local domain. i.e. ping zipit.local will resolve. This is why /etc/hosts contains the information below.</p>
<p>127.0.0.1 localhost.localdomain localhost zipit</p>
<p>I then configured samba by editing  /etc/samba/smb.conf and used pdbedit to add a samba user login.<br />
# pdbedit -a -u user</p>
<p>I have noted that the EWOC script provided on the z2sidX image has trouble configuring the wireless network when SSID&#8217;s contain spaces. I have fixed this issue and informed Mozzwald.</p>
<p>My work then shifted to my Clock application. I started adding features including a five day weather report, a week day alarm, timer and reminders. Another feature I wanted to add, was the ability to play music from a NFS share. I tested mpg123 and found that mp3&#8242;s played well when they were on the local flash drive but streaming off the NFS share was unworkable due to stuttering.</p>
<p>After adding the MP3 playback feature to Clock, I purchased a <a title="32GB Micro SDHC" href="http://www.play.com/Mobiles/Mobile/4-/14279098/-/Product.html" target="_blank">32GB Sandisk Micro SDHC</a> card to use for Zipit music storage. To my disappointment the card did not work with the Zipit Z2. The boot precess ended with I/O errors.</p>
<p>It seemed my dreams of adding music to the Zipit were in tatters, but then the word &#8220;buffers&#8221; popped into my head. When mpg123 plays back MP3&#8242;s on the Zipit it only uses about 15% of the processor&#8217;s capabilities. The stuttering had to be related to networking because local playback worked, the solution had to be buffering.</p>
<p>I changed the mpg123 command line for Clock to include a 2MB output buffer. Problem solved.</p>
<div id="attachment_1132" class="wp-caption aligncenter" style="width: 310px"><a href="http://canthack.org/2012/04/a-brief-history-of-my-zipit-z2/clock-screenshot-2/" rel="attachment wp-att-1132"><img class="size-medium wp-image-1132" src="http://canthack.org/uploads/Clock-Screenshot1-300x225.png" alt="" width="300" height="225" /></a><p class="wp-caption-text">Clock&#39;s main window showing five day weather report.</p></div>
<p>The original idea was to open-source Clock under GPL, the problem is that the site I scrape weather information from prohibits scraping. Perhaps the solution is to get information from another source. I am willing to implement this alternative and release the source and binary for Clock. Suggestions are welcome.</p>
<p>My remaining issues include a long reboot time which I believe is related to the error &#8211; libertas failed to find firmware.</p>
<p>On boot up I get the error &#8220;boot wlan0 link not ready&#8221; from addrconf<br />
and 200 second boot time.</p>
<p>Thanks go to Tristan and the Can&#8217;t Hack group, Mozzwald and all those that contributed to z2sid, Lazarus, FPC, Linux, GNU, etc &#8230;</p>
<img src="http://feeds.feedburner.com/~r/CantHackWontHack/~4/IwRtMKnn1Js" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://canthack.org/2012/04/a-brief-history-of-my-zipit-z2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://canthack.org/2012/04/a-brief-history-of-my-zipit-z2/</feedburner:origLink></item>
		<item>
		<title>Hama bead madness…</title>
		<link>http://feedproxy.google.com/~r/CantHackWontHack/~3/bf9czI4mrU4/</link>
		<comments>http://canthack.org/2012/03/hama-bead-madness/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 19:30:33 +0000</pubDate>
		<dc:creator>Han</dc:creator>
				<category><![CDATA[Crafting]]></category>
		<category><![CDATA[craft]]></category>
		<category><![CDATA[fuse beads]]></category>
		<category><![CDATA[geeky]]></category>
		<category><![CDATA[Hama bead]]></category>
		<category><![CDATA[perler]]></category>

		<guid isPermaLink="false">http://canthack.org/?p=1107</guid>
		<description><![CDATA[Well it&#8217;s been a long time since an update on hackery, and a lot has happened! So here goes, an attempt at covering the last 3 or so months&#8230; I found a new hobby! Crafty but not too difficult (unlike &#8230; <a href="http://canthack.org/2012/03/hama-bead-madness/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well it&#8217;s been a long time since an update on hackery, and a lot has happened! So here goes, an attempt at covering the last 3 or so months&#8230;</p>
<p>I found a new hobby! Crafty but not too difficult (unlike sewing/knitting/jewellery making malarkey). I&#8217;m not very patient, and I find fiddly things too&#8230;well&#8230;fiddly! So I&#8217;ve found something on my level. According to Wikipedia, <em>&#8220;plastic fusible beads are also known as Perler Beads, or called &#8220;melty beads&#8221; by young children. These small colorful beads can be placed on a solid plastic-backed peg array to form designs and then melted together with a clothes iron; alternatively, they can be strung into necklaces or bracelets, or woven into keychains. Fusible beads come in many colors and degrees of transparency/opacity, including varieties that glow in the dark or have internal glitter; peg boards come in various shapes and several geometric patterns.&#8221;</em></p>
<p>The main thing to note here is that this is usually a hobby for children. This means that it&#8217;s not fiddly (yippee!) and you don&#8217;t need to be very patient (hooray!!) so it suits me down to the ground.</p>
<p>I started off making coasters, by copying patterns I found online and filling in the space around the pattern and making it into a square. I then began going &#8220;freestyle&#8221; and making up patterns, as well as interpreting cross-stitch patterns to make other designs. Then I came across how much 8-bit art has been made with these beads. There&#8217;s an amazing amount!</p>
<div id="attachment_1109" class="wp-caption aligncenter" style="width: 310px"><a href="http://canthack.org/2012/03/hama-bead-madness/dscf2455/" rel="attachment wp-att-1109"><img class="size-medium wp-image-1109 " title="Some of my hama bead creations" src="http://canthack.org/uploads/DSCF2455-300x168.jpg" alt="Some hama bead creations" width="300" height="168" /></a><p class="wp-caption-text">Some of my hama bead creations</p></div>
<p>I then had a go at turning my creations into necklaces, brooches and magnets, which worked well. I have since sold some of them at various craft fairs, and have plans for giant 8-bit art as well as more different types of wearable geekery <img src='http://canthack.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/CantHackWontHack/~4/bf9czI4mrU4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://canthack.org/2012/03/hama-bead-madness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://canthack.org/2012/03/hama-bead-madness/</feedburner:origLink></item>
		<item>
		<title>RickRolling The Trolls</title>
		<link>http://feedproxy.google.com/~r/CantHackWontHack/~3/l1FDuNpHE6o/</link>
		<comments>http://canthack.org/2011/12/rickrolling-the-trolls/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 20:24:57 +0000</pubDate>
		<dc:creator>Mex</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://canthack.org/?p=1079</guid>
		<description><![CDATA[This post is inspired by a video a friend (Reashlin) sent to me (embedded below). In their company it is policy to lock computers when users are away from them, and if a machine is left unlocked it is customary &#8230; <a href="http://canthack.org/2011/12/rickrolling-the-trolls/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://canthack.org/uploads/rick.jpg" rel="fancybox-1079"><img src="http://canthack.org/uploads/rick-300x150.jpg" alt="" title="rickroll" width="300" height="150" class="alignright size-medium wp-image-1100" /></a>This post is inspired by a video a friend (Reashlin) sent to me (embedded below). In their company it is policy to lock computers when users are away from them, and if a machine is left unlocked it is customary to tell the supervisor in a &#8220;friendly&#8221; email from the account of the person in who left their machine unlocked.</p>
<p>Knowing this, Reashlin&#8217;s colleague wrote a C# application that leaves the computer running whatever it was before until the mouse is moved, when it switches to a full screen RickRoll video with the machine locked.</p>
<p>A whole C# application to do this seemed a bit much, so I distilled the whole thing into the following 4 line bash script. The script is quite simple. It simply waits for input from /dev/input/mice then spawns full screen mplayer in the background, and xtrlock in the foreground.  xtrlock is a handy little program that captures all keyboard/mice events until the users password is entered, a bit like a transparent xlock.  There is an issue with this script if the user is proficient in keyboard short-cuts they might never touch the mouse&#8230; but that&#8217;s something for another day.</p>
<p>If the others at canthack.org try and do <a href="http://canthack.org/uploads/aliastroll.jpg" rel="fancybox-1079">this</a> to me again they will be getting a surprise (well not that much; they do read this after all).</p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/bash
sudo cat /dev/input/mice | read -n 1
mplayer -fs rick.flv &amp;
xtrlock
</pre>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/Bps8yTw0W5c?version=3&amp;rel=1&amp;fs=1&amp;showsearch=0&amp;showinfo=1&amp;iv_load_policy=1&amp;wmode=transparent' frameborder='0'></iframe></span></p>
<img src="http://feeds.feedburner.com/~r/CantHackWontHack/~4/l1FDuNpHE6o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://canthack.org/2011/12/rickrolling-the-trolls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://canthack.org/2011/12/rickrolling-the-trolls/</feedburner:origLink></item>
		<item>
		<title>A Temperature Sensor with Arduino</title>
		<link>http://feedproxy.google.com/~r/CantHackWontHack/~3/yFbMy5ay7sw/</link>
		<comments>http://canthack.org/2011/11/a-temperature-sensor-with-arduino/#comments</comments>
		<pubDate>Sun, 13 Nov 2011 18:45:06 +0000</pubDate>
		<dc:creator>Tris</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Hardware]]></category>

		<guid isPermaLink="false">http://canthack.org/?p=429</guid>
		<description><![CDATA[After getting the Arduino Uno for Christmas last year, I set about doing what every geek does after getting bored of the usual blinky blinky pin 13 stuff, and started thinking about what I could do with it that was &#8230; <a href="http://canthack.org/2011/11/a-temperature-sensor-with-arduino/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After getting the <a title="Arduino" href="http://arduino.cc/" target="_blank">Arduino</a> Uno for Christmas last year, I set about doing what every geek does after getting bored of the usual blinky blinky pin 13 stuff, and started thinking about what I could do with it that was <em>cool</em>, and maybe even <em>useful</em>.</p>
<p>I decided to make a temperature sensor, using the cheap and easy-to-use <a title="LM35 Temperature Sensor" href="http://www.national.com/mpf/LM/LM35.html#Overview" target="_blank">LM35</a> integrated circuit, which is a compact package that looks just like a transistor.</p>
<div id="attachment_1039" class="wp-caption alignleft" style="width: 160px"><a href="http://canthack.org/2011/11/a-temperature-sensor-with-arduino/lm35/" rel="attachment wp-att-1039"><img class="size-thumbnail wp-image-1039" title="LM35" src="http://canthack.org/uploads/lm35-150x150.jpg" alt="LM35" width="150" height="150" /></a><p class="wp-caption-text">LM35</p></div>
<p>It offers a linear 10mV per degree C voltage change with temperature and so requires minimal mathematics to covert the analogue input into a temperature reading.</p>
<p>The current temperature, and a running minimum and maximum are displayed on an LCD display (using the <a title="Arduino LiquidCrystal Library" href="http://arduino.cc/en/Reference/LiquidCrystal" target="_blank">LiquidCrystal Library</a>), with the pushbutton allowing the maximum and minimum to be reset. The temperatures are calculated using a circular buffer providing a running mean value over 10 samples.</p>
<div id="attachment_1025" class="wp-caption alignright" style="width: 310px"><a href="http://canthack.org/2011/11/a-temperature-sensor-with-arduino/sd1/" rel="attachment wp-att-1025"><img class="size-medium wp-image-1025" title="SD card hack" src="http://canthack.org/uploads/sd1-300x160.jpg" alt="SD card hack" width="300" height="160" /></a><p class="wp-caption-text">SD card hack</p></div>
<p>The project also writes the temperature values to an SD card using the <a title="Arduino SD Library" href="http://arduino.cc/en/Reference/SD" target="_blank">SD Library</a>, which was attached via an awesome hack I came up with involving soldering a pin header directly to it, although in this case it&#8217;s a micro-SD adaptor to allow for changing the card more easily. The pinout is almost exactly lined up to make this hack work!</p>
<p>&nbsp;</p>
<div id="attachment_1030" class="wp-caption alignleft" style="width: 310px"><a href="http://canthack.org/2011/11/a-temperature-sensor-with-arduino/circuit/" rel="attachment wp-att-1030"><img class="size-medium wp-image-1030" title="Temperature Sensor" src="http://canthack.org/uploads/circuit-300x279.jpg" alt="Temperature Sensor" width="300" height="279" /></a><p class="wp-caption-text">Temperature Sensor</p></div>
<p>What I like about this project is that it combines all the usual cool things a beginner would want to do with their Arduino. Sensor reading, LCD screen output, SD card read/write, and button capture (which will be done with an interrupt, when I get a chance to do it).</p>
<p>The code, and Fritzing schematic, can be found on my <a title="ArduinoTemperatureSensor" href="https://github.com/tristan2468/ArduinoTemperatureSensor" target="_blank">GitHub page</a>.</p>
<img src="http://feeds.feedburner.com/~r/CantHackWontHack/~4/yFbMy5ay7sw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://canthack.org/2011/11/a-temperature-sensor-with-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://canthack.org/2011/11/a-temperature-sensor-with-arduino/</feedburner:origLink></item>
		<item>
		<title>11/11/11</title>
		<link>http://feedproxy.google.com/~r/CantHackWontHack/~3/W3QMtw33gQ4/</link>
		<comments>http://canthack.org/2011/11/11-11-11/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 23:45:53 +0000</pubDate>
		<dc:creator>Omer</dc:creator>
				<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://canthack.org/?p=973</guid>
		<description><![CDATA[Lest we forget To celebrate armistice day, the last binary day for another 88 years and 51 days, and the joy of the bodge, CantHack is at it again! We have TI hacking, watch designing, plenty of Arduinos, crafting, and &#8230; <a href="http://canthack.org/2011/11/11-11-11/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Lest we forget</h2>
<p>To celebrate armistice day, the last binary day for another 88 years and 51 days, and the joy of the bodge, CantHack is at it again!</p>
<p>We have TI hacking, watch designing, plenty of Arduinos, crafting, and software packaging. There was also beer (and Lemsip for Omer).</p>
<h2>Hack in pictures</h2>

<a href='http://canthack.org/2011/11/11-11-11/img_0521/' title='Crucial details for the night.'><img width="150" height="150" src="http://canthack.org/uploads/IMG_0521-150x150.jpg" class="attachment-thumbnail" alt="Crucial details for the night." title="Crucial details for the night." /></a>
<a href='http://canthack.org/2011/11/11-11-11/img_0523/' title='Semi-circle of hackers'><img width="150" height="150" src="http://canthack.org/uploads/IMG_0523-150x150.jpg" class="attachment-thumbnail" alt="Semi-circle of hackers" title="Semi-circle of hackers" /></a>
<a href='http://canthack.org/2011/11/11-11-11/img_0526/' title='Tris, building an Arduino temperature logger'><img width="150" height="150" src="http://canthack.org/uploads/IMG_0526-e1321045017783-150x150.jpg" class="attachment-thumbnail" alt="Tris, building an Arduino temperature logger" title="Tris, building an Arduino temperature logger" /></a>
<a href='http://canthack.org/2011/11/11-11-11/img_0535/' title='Ed, creating footprints in Designspark'><img width="150" height="150" src="http://canthack.org/uploads/IMG_0535-150x150.jpg" class="attachment-thumbnail" alt="Ed, creating footprints in Designspark" title="Ed, creating footprints in Designspark" /></a>
<a href='http://canthack.org/2011/11/11-11-11/img_0536/' title='Mitzi, observing.'><img width="150" height="150" src="http://canthack.org/uploads/IMG_0536-150x150.jpg" class="attachment-thumbnail" alt="Mitzi, observing." title="Mitzi, observing." /></a>
<a href='http://canthack.org/2011/11/11-11-11/img_0538/' title='Deb, crafting.'><img width="150" height="150" src="http://canthack.org/uploads/IMG_0538-e1321047452513-150x150.jpg" class="attachment-thumbnail" alt="Deb, crafting." title="Deb, crafting." /></a>
<a href='http://canthack.org/2011/11/11-11-11/img_0539/' title='Ladies in the craft room'><img width="150" height="150" src="http://canthack.org/uploads/IMG_0539-150x150.jpg" class="attachment-thumbnail" alt="Ladies in the craft room" title="Ladies in the craft room" /></a>
<a href='http://canthack.org/2011/11/11-11-11/img_0537/' title='Edd, playing with a TI calculator'><img width="150" height="150" src="http://canthack.org/uploads/IMG_0537-e1321045463808-150x150.jpg" class="attachment-thumbnail" alt="Edd, playing with a TI calculator" title="Edd, playing with a TI calculator" /></a>
<a href='http://canthack.org/2011/11/11-11-11/screenshot-hgdc-x-0-5-0/' title='A selection of songs played'><img width="150" height="150" src="http://canthack.org/uploads/Screenshot-hgdc-x-0.5.0-150x150.png" class="attachment-thumbnail" alt="A selection of songs played" title="A selection of songs played" /></a>
<a href='http://canthack.org/2011/11/11-11-11/img_0527/' title='HGD! (check out http://hgd.theunixzoo.co.uk/)'><img width="150" height="150" src="http://canthack.org/uploads/IMG_0527-150x150.jpg" class="attachment-thumbnail" alt="HGD! (check out http://hgd.theunixzoo.co.uk/)" title="HGD! (check out http://hgd.theunixzoo.co.uk/)" /></a>

<p><a href="http://canthack.org/uploads/aliastroll.jpg" rel="fancybox-973"><img class="aligncenter size-medium wp-image-1013" title="aliastroll" src="http://canthack.org/uploads/aliastroll-300x200.jpg" alt="" width="300" height="200" /></a></p>
<p style="text-align: center;"><strong>PROTIP:</strong> *Never* leave your laptop unattended at a hackathon <img src='http://canthack.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/CantHackWontHack/~4/W3QMtw33gQ4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://canthack.org/2011/11/11-11-11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://canthack.org/2011/11/11-11-11/</feedburner:origLink></item>
		<item>
		<title>W^X</title>
		<link>http://feedproxy.google.com/~r/CantHackWontHack/~3/n1e2yCsnpJY/</link>
		<comments>http://canthack.org/2011/11/wx/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 16:49:45 +0000</pubDate>
		<dc:creator>static-void</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://canthack.org/?p=896</guid>
		<description><![CDATA[Today I was reading about self-modifying code. I knew some things already &#8211; for example it is used sometimes as &#8216;camouflage&#8217; by malicious programs to cover their intent, by JIT compilers, and for optimising loop evaluation functions. Suppose you have &#8230; <a href="http://canthack.org/2011/11/wx/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today I was reading about self-modifying code. I knew some things already &#8211; for example it is used sometimes as &#8216;camouflage&#8217; by malicious programs to cover their intent, by JIT compilers, and for optimising loop evaluation functions. Suppose you have a number of functions that are very similar except for a couple of instructions used for some sort of comparison or evaluation. Instead of having several almost identical functions in memory, one option is to simply over-write the evaluation instructions with a slightly different piece of code every time the function is used.</p>
<p>However, in general, because of it&#8217;s usefulness in malicious programs, self modifying code is a bit of a security problem for operating systems. For this reason modern operating systems do not allow memory pages to be both writeable and executable. This is known as W^X &#8211; write XOR execute, meaning a page of memory is writable or executable, but never both.</p>
<p>The main reason for this post is an interesting work-around that Edd and I discovered today. It turns out that it is possible to map a file into memory twice. When a file is mapped into memory, the permissions are set at the same time as it is mapped. Given this, you can be a bit sneaky, and map a file as writeable, then map it again as executable. This will give you two pointers to different areas of your programs virtual address space, but both referencing the same file. You can then write some code to the file using one pointer, and execute it using the other.</p>
<p>As an example I created a little test C program with a single function in it as follows:</p>
<pre class="brush: cpp; title: ; notranslate">
int
add(int a, int b)
{
        return a+b;
}

main() {
        int a = add(12, 2);
}
</pre>
<p>I then built this with debug symbols and no compiler optimisation (since this program doesn&#8217;t do anything, with optimisations turned on the add function would disappear completely):</p>
<pre class="brush: cpp; title: ; notranslate">
gcc testcode.c -o testcode -g
</pre>
<p>This function is nothing really to do with the exploit <em>per se</em>. The plan is:</p>
<ul>
<li>Create a file</li>
<li>Map the file into memory as writeable</li>
<li>Copy the add function from the above code into this writeable memory (ending up in the file)</li>
<li>Map the file into memory as executable</li>
<li>Assign a function pointer to point to the executable memory</li>
<li>Execute the add function that we just wrote into memory using the function pointer</li>
</ul>
<p>To do this, the code below is used:</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;sys/mman.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

#define MEM_MAP_FILE &quot;/tmp/a&quot;
#define TESTCODE_FILE &quot;testcode&quot;
#define TESTCODE_SIZE 8427
#define FUNCTION_ADDR 0x394
#define FUNCTION_SIZE 0xE

int
main(void)
{
	void *p1, *p2, *p3;
	int fd, fd2;
	FILE *f, *f2;
	int (*add)(int a, int b);

	/* Create/open the file */
	f = fopen(MEM_MAP_FILE, &quot;w+&quot;);
	fd = fileno(f);

	/* Make some space in the file to copy the function in */
	lseek(fd, FUNCTION_SIZE, SEEK_SET);
	/* Have to write to actually make the space */
	write(fd, &quot;&quot;, 1);

	/* Map file as write */
	p1 = mmap(0, FUNCTION_SIZE, PROT_WRITE, MAP_SHARED, fd, 0);

	/* Open test code */
	f2 = fopen(TESTCODE_FILE, &quot;r&quot;);
	fd2 = fileno(f2);

	/* mmap the test code */
	p3 = mmap(0, TESTCODE_SIZE, PROT_READ, MAP_SHARED, fd2, 0);

	/* Copy function into writeable memory */
	memcpy(p1, p3 + FUNCTION_ADDR, FUNCTION_SIZE);

	/* Map the file as executable */
	p2 = mmap(0, FUNCTION_SIZE, PROT_EXEC, MAP_SHARED, fd, 0);

	/* Make function pointer point to the executable memory*/
	add = p2;

	/* Execute function we just wrote! */
	printf(&quot;Result = %d\n&quot;, (*add)(1, 2));
}
</pre>
<p>There are a couple of things to note. First, this code does no checks on return values of mmap, fopen etc. This is purely for readability on this blog! Second, the 3 #define pre-processor macros at the start of the program must be set up for the function that is being copied in from testcode, in our case &#8216;add&#8217;. The first is the size of the testcode executable, which can be found with &#8220;ls -l&#8221;. The second is the offset of the add function within the executable, and the third the size of the add function. The easiest way to get these last two is probably with objdump. We use &#8220;objdump -d testcode&#8221; to disassemble the file, and then scroll through until we see the add function, which will look something like:</p>
<pre class="brush: cpp; title: ; notranslate">
08048394 &lt;add&gt;:
 8048394:	55                   	push   %ebp
 8048395:	89 e5                	mov    %esp,%ebp
 8048397:	8b 45 0c             	mov    0xc(%ebp),%eax
 804839a:	8b 55 08             	mov    0x8(%ebp),%edx
 804839d:	8d 04 02             	lea    (%edx,%eax,1),%eax
 80483a0:	5d                   	pop    %ebp
 80483a1:	c3                   	ret
</pre>
<p>Unfortunately objdump relocates the file before disassembly. Therefore, we only use the last 3 digits of the address. So in this case, the add function starts at offset 394 and ends at 3a2 (the last instruction, ret, is only 1 byte long, and starts at 3a1). So the size of the function is 3a2-394 = E.</p>
<p>Running the executable afterwards will now result in:</p>
<pre class="brush: cpp; title: ; notranslate">
Result = 3
</pre>
<p>So we have managed to write to some memory and then execute what we wrote, working around the W^X feature!</p>
<p>However, this isn&#8217;t as bad as it might seem. There are actually other ways to get around W^X, for example the mprotect system call. And this doesn&#8217;t really allow you to elevate privileges very easily. You might be able to write self-modifying code, but you can&#8217;t, for example, overwrite code of a process already running as root, make the text area of an address space writable, the data area executable, or modify a file such as /bin/ls (because you still don&#8217;t have write permission to the file).</p>
<img src="http://feeds.feedburner.com/~r/CantHackWontHack/~4/n1e2yCsnpJY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://canthack.org/2011/11/wx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://canthack.org/2011/11/wx/</feedburner:origLink></item>
		<item>
		<title>CantHack..MedHack! A trip to Medway Innovation Centre</title>
		<link>http://feedproxy.google.com/~r/CantHackWontHack/~3/xHDhHJPo2I4/</link>
		<comments>http://canthack.org/2011/10/cant-hack-medhack-a-trip-to-medway-innovation-centre/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 19:51:19 +0000</pubDate>
		<dc:creator>Han</dc:creator>
				<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://canthack.org/?p=872</guid>
		<description><![CDATA[At the end of August, we were kindly invited to visit, and make use of the facilities at, the Medway Innovation Centre. We had met a member of Medway Makerspace at BarCamp Canterbury earlier in the year, and we were &#8230; <a href="http://canthack.org/2011/10/cant-hack-medhack-a-trip-to-medway-innovation-centre/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://canthack.org/2011/10/cant-hack-medhack-a-trip-to-medway-innovation-centre/dsc_0866-2/" rel="attachment wp-att-878"><img class="size-full wp-image-878 alignright" title="Coding" src="http://canthack.org/uploads/DSC_08661.jpg" alt="Coding" width="238" height="162" /></a>At the end of August, we were kindly invited to visit, and make use of the facilities at, the <a title="Medway Innovation Centre" href="http://innovationcentremedway.co.uk/" target="_blank">Medway Innovation Centre</a>. We had met a member of Medway Makerspace at <a title="BarCamp Canterbury" href="http://barcampcanterbury.blogspot.com/" target="_blank">BarCamp Canterbury</a> earlier in the year, and we were intrigued to see the venue that they use for hack meetups. We were all suitably impressed with the amazing facilities, and the guys there were so accommodating (even to those of us who were crafting rather than hacking!). We were given the use of two of their rooms and this kitchen (key for refuelling with tea &#8211; good work on the tea-making, Rob) and spent a good twelve hours making and doing.</p>
<p>The room I was in was affectionately known as &#8220;Mex&#8217;s sweatshop&#8221;.  Here, I was employed to sew Mex&#8217;s <a title="Tinkersoc" href="http://tinkersoc.org/" target="_blank">Tinkersoc</a> t-shirt, ready for him to wear at the University of Kent Freshers&#8217; Fair.  He stencilled the logo on the t-shirt, and I sewed EL wire onto it in the shape of a transistor.  I covered the parts that didn&#8217;t need to light up with black electrical tape, and soon it was complete.  Sadly there are no action shots of it!</p>
<p><img class="size-full wp-image-877 alignleft" title="Crafty goodness" src="http://canthack.org/uploads/DSCF1998.jpg" alt="Crafty goodness" width="280" height="158" /></p>
<p>I then moved on to make some things from felt under the instruction of Debora (a felting pro). Marianne copied a picture of Shaun the Sheep for me onto some paper, and I used it as a guide to cutting out pieces of felt. I went on to make a Sonic the Hedgehog (without using a template, hence a tad wonky) and a bracelet made of buttons, a necklace mainly made of buttons, and fixed an old heart-shaped necklace. Debora made the troll, Pacman and ghost, button ring and flower hairclip. Marianne made the keyhole necklace and Mex wore the hairclips! All in all it was a really fun and productive day. Just wish the place was nearer then we could join and hack away there as often as we wanted!</p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/CantHackWontHack/~4/xHDhHJPo2I4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://canthack.org/2011/10/cant-hack-medhack-a-trip-to-medway-innovation-centre/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://canthack.org/2011/10/cant-hack-medhack-a-trip-to-medway-innovation-centre/</feedburner:origLink></item>
		<item>
		<title>hgdc-x. A Cross-Platform, Native hgd Client.</title>
		<link>http://feedproxy.google.com/~r/CantHackWontHack/~3/3GSDMq34-_w/</link>
		<comments>http://canthack.org/2011/09/hgdc-x-a-cross-platform-native-hgd-client/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 15:34:56 +0000</pubDate>
		<dc:creator>Tris</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://canthack.org/?p=855</guid>
		<description><![CDATA[At Can&#8217;t Hack&#8217;s recent Medway Hack day, which took place at the Medway Hackspace, I decided to work on a new desktop /GUI client for the hgd music server. The current crop of hgd clients does not so far include &#8230; <a href="http://canthack.org/2011/09/hgdc-x-a-cross-platform-native-hgd-client/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>At Can&#8217;t Hack&#8217;s recent Medway Hack day, which took place at the Medway Hackspace, I decided to work on a new desktop /GUI client for the <a title="HGD 0.4.1 out now!" href="http://canthack.org/2011/07/hgd-0-4-1/" target="_blank">hgd </a>music server. The current crop of hgd clients does not so far include an actively maintained desktop GUI, so it was a great opportunity to provide one, and seeing as we planned to (and did) hack for 12 hours straight &#8211; there was plenty of time with which to get something reasonable implemented!</p>
<p>It is called <strong>hgdc-x</strong>. The <em><strong>X</strong></em> alludes to the cross-platform nature of the GUI code. By writing it from the ground up in <a title="Lazarus" href="http://lazarus.freepascal.org" target="_blank">Lazarus</a>/Freepascal, it can be compiled for Windows/Linux/Mac OS X/FreeBSD among others, targeting various toolkits like GTK, QT, Win32, and Carbon.</p>
<p>I have since essentially finished the client, which supports all of the usual hgd user features like user authentication, SSL encrypted connection, listing the playlist, queuing tracks and voting tracks off, but also includes added features like album artwork fetching (using the Last.fm API). Limited support is provided for hgd&#8217;s administrative features, so hgdc-x supports song pausing and skipping as long as you are logged in as a user who is an admin on the hgd server.</p>
<p>In the future I will add Last.fm scrobbling, remaining admin features and other cool stuff.</p>
<p>The development version (available right now) been tested on Windows, Linux and Mac OS X, and works fine on all three.</p>
<div id="attachment_889" class="wp-caption alignright" style="width: 264px"><a href="http://canthack.org/2011/09/hgdc-x-a-cross-platform-native-hgd-client/hgdcx-3/" rel="attachment wp-att-889"><img class="size-medium wp-image-889" title="hgdcx on Linux" src="http://canthack.org/uploads/hgdcx2-254x300.png" alt="hgdcx on Linux" width="254" height="300" /></a><p class="wp-caption-text">hgdcx on Linux</p></div>
<p>Proper tagged releases and pre-compiled binaries will follow, as soon as the hgd server makes its next release (0.5). When this happens the version numbers will be kept in sync with the server. Until then, the HEAD of hgdc-x should work correctly with the HEAD of the main hgd server repository, as I scramble to keep up with API and protocol improvements, so if you can install Lazarus 0.9.30, give it a go if you like!</p>
<p>The source is available from <a href="https://github.com/tristan2468/hgdc-x" target="_blank">GitHub</a>, where an Issue Tracker is active for any inevitable bugs or indeed feature requests you may like to add.</p>
<p>When complete, the same GitHub page will be the place to go for the pre-compiled binaries.</p>
<img src="http://feeds.feedburner.com/~r/CantHackWontHack/~4/3GSDMq34-_w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://canthack.org/2011/09/hgdc-x-a-cross-platform-native-hgd-client/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://canthack.org/2011/09/hgdc-x-a-cross-platform-native-hgd-client/</feedburner:origLink></item>
	</channel>
</rss>

