<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Alice, Bob, and Mallory: Category Security</title>
    <link>http://www.alicebobandmallory.com/articles/category/security</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>metasyntactics</description>
    <item>
      <title>To hack a Superpower</title>
      <description>&lt;p&gt;I was interviewed in a swedish documentary called &lt;a href="http://svt.se/2.122744/1.2172403/att-hacka-en-stormakt?lid=20101014&amp;amp;lpos=SVT2_0000_sitelink&amp;amp;from=tabla"&gt;Att hacka en stormakt&lt;/a&gt; (To hack a Superpower). It's mostly in swedish but &lt;a href="http://alicebobandmallory.com/articles/2007/02/04/hello-this-is-special-agent-brian"&gt;Brian Koref&lt;/a&gt; (US AF) and Tom Talleur (NASA) are interviewed in english. It can be &lt;a href="http://svtplay.se/v/2175727/dokumentarfilm/att_hacka_en_stormakt"&gt;streamed from SVTPlay&lt;/a&gt; (at least if you live in Sweden) until 2010-11-09.&lt;/p&gt;

&lt;p&gt;It covers the cracking frenzy of a couple Swedish youths back in 1996. They happened to break into a server I was responsible for and from that server they logged in to a machine with a .mil-address. That's how we got involved.&lt;/p&gt;

&lt;p&gt;The event has been covered before in a &lt;a href="http://sverigesradio.se/sida/artikel.aspx?ProgramID=2519&amp;amp;Artikel=2447808"&gt;radio documentary&lt;/a&gt; called &lt;i&gt;Svenska hackers&lt;/i&gt; (Swedish hackers).&lt;/p&gt;</description>
      <pubDate>Thu, 14 Oct 2010 21:57:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:3638307e-12fd-4e27-899f-8c612277b1f1</guid>
      <author>Jonas Elfström</author>
      <link>http://www.alicebobandmallory.com/articles/2010/10/14/to-hack-a-superpower</link>
      <category>Security</category>
    </item>
    <item>
      <title>Did Little Bobby Tables migrate to Sweden?</title>
      <description>&lt;p&gt;As you may have heard, we've had a &lt;a href="http://www.thelocal.se/29172/20100922/"&gt;very close election&lt;/a&gt; here in Sweden. Today the Swedish Election Authority published the &lt;a href="http://www.val.se/val/val2010/handskrivna/handskrivna.skv"&gt;hand written votes&lt;/a&gt;. While scanning through them I happened to notice &lt;/p&gt;

&lt;p&gt;&lt;code&gt;R;13;Hallands län;80;Halmstad;01;Halmstads västra valkrets;0904;Söndrum 4;&lt;/code&gt;&lt;font style="background-color:#ffffaa"&gt;pwn DROP TABLE VALJ&lt;/font&gt;&lt;code&gt;;1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The second to last field&lt;sup&gt;1&lt;/sup&gt; is the actual text on the ballot&lt;sup&gt;2&lt;/sup&gt;. Could it be that &lt;a href="http://xkcd.com/327/"&gt;Little Bobby Tables&lt;/a&gt; is all grown up and has migrated to Sweden? Well, it's probably just a joke but even so it brings questions since an &lt;a href="http://en.wikipedia.org/wiki/SQL_injection"&gt;SQL-injection&lt;/a&gt; on election data would be very serious.&lt;/p&gt;

&lt;p&gt;Someone even tried to get some JavaScript in there:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;R;14;Västra Götalands län;80;Göteborg;03;Göteborg, Centrum;0722;Centrum, Övre Johanneberg;&lt;/code&gt;&lt;font style="background-color:#ffffaa"&gt;(Script src=http://hittepa.webs.com/x.txt)&lt;/font&gt;&lt;code&gt;;1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I'm pleased to see that they published the list as text and not HTML. This hacker/joker voter &lt;a href="http://hittepa.webs.com/"&gt;seems to think&lt;/a&gt;&lt;sup&gt;3&lt;/sup&gt; they "censored" his vote/script. I'm not so sure about that, a more reasonable explanation is that they couldn't enter  &lt;a href="http://en.wikipedia.org/wiki/Bracket#Uses_of_.22.3C.22_and_.22.3E.22"&gt;brackets&lt;/a&gt;, quotation marks, and so on.&lt;/p&gt;

&lt;p&gt;There are also a couple of URL:s to online retailers and three votes on a conspiracy friendly site. I chose not to link to any of those.&lt;/p&gt;

&lt;p&gt;This time the &lt;a href="http://news.ycombinator.com/item?id=1722043"&gt;pen and paper scripting attack&lt;/a&gt; failed. Let's hope it stays that way.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
PS. Someone noticed that there are no votes from Stockholm in &lt;a href="http://www.val.se/val/val2010/handskrivna/handskrivna.skv"&gt;there&lt;/a&gt; right now (&lt;a href="http://en.wikipedia.org/wiki/ISO_8601"&gt;2010-09-24&lt;/a&gt;). I asked the Swedish Election Authority about this and it turns out that The County Administrative Board (Länsstyrelsen) gets two months to register all the handwritten votes. There's a good chance that those will bring more attempts like the ones above. DS.
&lt;br&gt;&lt;br&gt;
&lt;font color="red"&gt;EDIT 2010-09-24&lt;/font&gt;&lt;br&gt;
Links:&lt;br&gt;
&lt;a href="http://www.aftonbladet.se/nyheter/valet2010/article7844634.ab"&gt;Aftonbladet&lt;/a&gt; &lt;a href="http://www.dn.se/nyheter/valet2010/forsokte-hacka-valet-med-rostsedlar-1.1176677"&gt;DN&lt;/a&gt; &lt;a href="http://www.svd.se/nyheter/politik/valet2010/forsokte-hacka-valet-med-rostsedlar_5394833.svd"&gt;SvD&lt;/a&gt; &lt;a href="http://www.expressen.se/nyheter/val2010/1.2149620/forsokte-hacka-valet-med-rostsedlar"&gt;Expressen&lt;/a&gt;  &lt;a href="http://svt.se/2.128339/1.2162040/forsokte_hacka_valet_med_rostsedlar"&gt;SVT&lt;/a&gt; - all in Swedish.&lt;br/&gt;
&lt;a href="http://politics.slashdot.org/story/10/09/24/0221217/Swedes-Cast-Write-In-Votes-for-SQL-Injection-Donald-Duck"&gt;Slashdot&lt;/a&gt; &lt;a href="http://www.bbc.co.uk/blogs/seealso/2010/09/tech_brief_95.html"&gt;BBC&lt;/a&gt; &lt;a href="http://www.wired.co.uk/news/archive/2010-09/24/sweden-election-hack"&gt;Wired&lt;/a&gt;
&lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt;The name of the party, not a name of a person.&lt;br/&gt;
&lt;sup&gt;2&lt;/sup&gt;Almost all Swedish voters use the preprinted ballots but you are allowed to write your own by hand.&lt;br/&gt;
&lt;sup&gt;3&lt;/sup&gt;The site disappeared after this post was published.&lt;/p&gt;</description>
      <pubDate>Thu, 23 Sep 2010 22:36:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:74c5afa7-34a0-4f5e-93ef-30af7231ee15</guid>
      <author>Jonas Elfström</author>
      <link>http://www.alicebobandmallory.com/articles/2010/09/23/did-little-bobby-tables-migrate-to-sweden</link>
      <category>Security</category>
    </item>
    <item>
      <title>A case for using only three different digits in keypad codes</title>
      <description>&lt;p&gt;Keypads have obvious security problems and keypads accepting a stream of digits with no # or enter in between, while checking for the four digit long code, are even worse.&lt;/p&gt;

&lt;p&gt;The important part is to not leak the digits in the code &lt;a href="http://www.schneier.com/blog/archives/2009/07/information_lea_1.html"&gt;by wear&lt;/a&gt; or intentional markings because if they leak it's suddenly very far from 10000 combinations.&lt;/p&gt;

&lt;p&gt;If the "lock picker" only knows that the code contains four digits there are 10000 combinations. Keypads accepting a stream of digits can then be opened in a maximum of 10003 keystrokes using the &lt;a href="http://en.wikipedia.org/wiki/De_Bruijn_sequence#Uses"&gt;De
Bruijn sequence&lt;/a&gt;. That is still quite a lot.&lt;/p&gt;

&lt;p&gt;Below is a Ruby implementation of the &lt;a href="http://www.hakank.org/comb/debruijn.cgi"&gt;De
Bruijn sequence&lt;/a&gt;.&lt;/p&gt;

&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;15&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;25&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;&lt;span style="color:#666"&gt;# De Bruijn sequence&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#666"&gt;# Original implementation by Frank Ruskey (1994)&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#666"&gt;# translated to C by Joe Sawada&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#666"&gt;# translated to Ruby by Jonas Elfström (2009)&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#33B"&gt;@n&lt;/span&gt;=&lt;span style="color:#00D;font-weight:bold"&gt;4&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#33B"&gt;@k&lt;/span&gt;=&lt;span style="color:#00D;font-weight:bold"&gt;10&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#33B"&gt;@a&lt;/span&gt;=[&lt;span style="color:#00D;font-weight:bold"&gt;0&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#33B"&gt;@sequence&lt;/span&gt;=[]&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;def&lt;/span&gt; &lt;span style="color:#06B;font-weight:bold"&gt;debruijn&lt;/span&gt;(t, p)&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#080;font-weight:bold"&gt;if&lt;/span&gt; t&amp;gt;&lt;span style="color:#33B"&gt;@n&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span style="color:#080;font-weight:bold"&gt;if&lt;/span&gt; &lt;span style="color:#33B"&gt;@n&lt;/span&gt;%p==&lt;span style="color:#00D;font-weight:bold"&gt;0&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span style="color:#00D;font-weight:bold"&gt;1&lt;/span&gt;.upto(p) {|j| &lt;span style="color:#33B"&gt;@sequence&lt;/span&gt;&amp;lt;&amp;lt;&lt;span style="color:#33B"&gt;@a&lt;/span&gt;[j]}&lt;tt&gt;
&lt;/tt&gt;    &lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#080;font-weight:bold"&gt;else&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span style="color:#33B"&gt;@a&lt;/span&gt;[t]=&lt;span style="color:#33B"&gt;@a&lt;/span&gt;[t-p]&lt;tt&gt;
&lt;/tt&gt;    debruijn(t+&lt;span style="color:#00D;font-weight:bold"&gt;1&lt;/span&gt;,p)&lt;tt&gt;
&lt;/tt&gt;    (&lt;span style="color:#33B"&gt;@a&lt;/span&gt;[t-p]+&lt;span style="color:#00D;font-weight:bold"&gt;1&lt;/span&gt;).upto(&lt;span style="color:#33B"&gt;@k&lt;/span&gt;-&lt;span style="color:#00D;font-weight:bold"&gt;1&lt;/span&gt;) {|j|&lt;tt&gt;
&lt;/tt&gt;      &lt;span style="color:#33B"&gt;@a&lt;/span&gt;[t]=j&lt;tt&gt;
&lt;/tt&gt;      debruijn(t+&lt;span style="color:#00D;font-weight:bold"&gt;1&lt;/span&gt;,t)&lt;tt&gt;
&lt;/tt&gt;    }&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;debruijn(&lt;span style="color:#00D;font-weight:bold"&gt;1&lt;/span&gt;,&lt;span style="color:#00D;font-weight:bold"&gt;1&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;print &lt;span style="color:#33B"&gt;@sequence&lt;/span&gt;.join&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;&lt;br&gt;
It's not uncommon to find keypads with 4 of the 10 keys worn down and if you do you can be pretty sure that the code contains those four different digits. The number of possible combinations are 4! = 4x3x2x1 = 24. I got curious to see if there's a kind of &lt;a href="http://mathworld.wolfram.com/deBruijnSequence.html"&gt;De Bruijn sequence&lt;/a&gt; for this that brings down the 4*24=96 keystrokes. By scribbling in a &lt;a href="http://www.scintilla.org/SciTE.html"&gt;text editor&lt;/a&gt; I quickly realized there's not a clean sequence. Not clean in the way that a sequence following the rules can be created. Also it's probably even quite daunting to present it as mathematically dense and beautiful as the &lt;a href="http://www.stefangeens.com/2004/10/the-de-bruijn-c.html"&gt;De Bruijn&lt;/a&gt; but that could be my less than great &lt;a href="http://en.wikipedia.org/wiki/Combinatorics"&gt;combinatorics&lt;/a&gt; speaking.&lt;/p&gt;

&lt;p&gt;I made a quick and dirty brute force hack to try to find a shorter sequence.&lt;/p&gt;

&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;15&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;25&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;seq=[]&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#00D;font-weight:bold"&gt;1&lt;/span&gt;.upto(&lt;span style="color:#00D;font-weight:bold"&gt;4&lt;/span&gt;) {|a| &lt;span style="color:#00D;font-weight:bold"&gt;1&lt;/span&gt;.upto(&lt;span style="color:#00D;font-weight:bold"&gt;4&lt;/span&gt;) {|b| &lt;span style="color:#00D;font-weight:bold"&gt;1&lt;/span&gt;.upto(&lt;span style="color:#00D;font-weight:bold"&gt;4&lt;/span&gt;) {|c| &lt;span style="color:#00D;font-weight:bold"&gt;1&lt;/span&gt;.upto(&lt;span style="color:#00D;font-weight:bold"&gt;4&lt;/span&gt;) {|d|&lt;tt&gt;
&lt;/tt&gt;  seq &amp;lt;&amp;lt; &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;%d%d%d%d&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; % [a,b,c,d] &lt;span style="color:#080;font-weight:bold"&gt;if&lt;/span&gt; !(a==b || a==c || a==d || b==c || b==d || c==d)&lt;tt&gt;
&lt;/tt&gt;}}}}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;s=seq[&lt;span style="color:#00D;font-weight:bold"&gt;0&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;seq.delete_at(&lt;span style="color:#00D;font-weight:bold"&gt;0&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;while&lt;/span&gt; (seq.length&amp;gt;&lt;span style="color:#00D;font-weight:bold"&gt;0&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  next_code=(seq.select {|c| c[&lt;span style="color:#00D;font-weight:bold"&gt;0&lt;/span&gt;..&lt;span style="color:#00D;font-weight:bold"&gt;2&lt;/span&gt;]==s[&lt;span style="color:#00D;font-weight:bold"&gt;-3&lt;/span&gt;..&lt;span style="color:#00D;font-weight:bold"&gt;-1&lt;/span&gt;]})&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#080;font-weight:bold"&gt;if&lt;/span&gt; next_code.empty?&lt;tt&gt;
&lt;/tt&gt;    next_code=(seq.select {|c| c[&lt;span style="color:#00D;font-weight:bold"&gt;0&lt;/span&gt;..&lt;span style="color:#00D;font-weight:bold"&gt;1&lt;/span&gt;]==s[&lt;span style="color:#00D;font-weight:bold"&gt;-2&lt;/span&gt;..&lt;span style="color:#00D;font-weight:bold"&gt;-1&lt;/span&gt;]})&lt;tt&gt;
&lt;/tt&gt;    &lt;span style="color:#080;font-weight:bold"&gt;if&lt;/span&gt; next_code.empty? &lt;tt&gt;
&lt;/tt&gt;      next_code=(seq.select {|c| c[&lt;span style="color:#00D;font-weight:bold"&gt;0&lt;/span&gt;]==s[&lt;span style="color:#00D;font-weight:bold"&gt;-1&lt;/span&gt;]})&lt;tt&gt;
&lt;/tt&gt;      s+=next_code[&lt;span style="color:#00D;font-weight:bold"&gt;0&lt;/span&gt;][&lt;span style="color:#00D;font-weight:bold"&gt;1&lt;/span&gt;..&lt;span style="color:#00D;font-weight:bold"&gt;3&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;      seq.delete_at(seq.index(next_code[&lt;span style="color:#00D;font-weight:bold"&gt;0&lt;/span&gt;]))&lt;tt&gt;
&lt;/tt&gt;    &lt;span style="color:#080;font-weight:bold"&gt;else&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      s+=next_code[&lt;span style="color:#00D;font-weight:bold"&gt;0&lt;/span&gt;][&lt;span style="color:#00D;font-weight:bold"&gt;2&lt;/span&gt;..&lt;span style="color:#00D;font-weight:bold"&gt;3&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;      seq.delete_at(seq.index(next_code[&lt;span style="color:#00D;font-weight:bold"&gt;0&lt;/span&gt;]))&lt;tt&gt;
&lt;/tt&gt;    &lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#080;font-weight:bold"&gt;else&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    next_code=(seq.select {|c| c[&lt;span style="color:#00D;font-weight:bold"&gt;0&lt;/span&gt;..&lt;span style="color:#00D;font-weight:bold"&gt;2&lt;/span&gt;]==s[&lt;span style="color:#00D;font-weight:bold"&gt;-3&lt;/span&gt;..&lt;span style="color:#00D;font-weight:bold"&gt;-1&lt;/span&gt;]})&lt;tt&gt;
&lt;/tt&gt;    s+=next_code[&lt;span style="color:#00D;font-weight:bold"&gt;0&lt;/span&gt;][&lt;span style="color:#00D;font-weight:bold"&gt;3&lt;/span&gt;].chr&lt;tt&gt;
&lt;/tt&gt;    seq.delete_at(seq.index(next_code[&lt;span style="color:#00D;font-weight:bold"&gt;0&lt;/span&gt;]))&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;&lt;br&gt;
The above code takes the first code "1234" of the 24 and then searches the rest of the array for a code beginning with "234". It finds "2341" and adds "1" to the end of &lt;em&gt;s&lt;/em&gt; and continues to look for "341" and so on. Relatively soon there is no three digit match and then it tries two digits and eventually even that fails and then it gets the first one digit match. The resulting sequence is: &lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;123412314231243121342132413214321&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;From 96 to 33 keystrokes. Not as effective as De Bruijn but still significant. Unlike De Bruijn I have absolutely no proof that this is the shortest one possible but it seems likely. Also notice that in the middle of the sequence we find "3121" and "1213". Those break the criteria of four different digits but they seem to be necessary to be able to enter the reversed mode. Try reading the sequence forward and backwards to see what I mean.&lt;/p&gt;

&lt;p&gt;If the code only contains two digits it's gets even more trivial to try them all. There are 14 possible codes and by &lt;em&gt;compressing&lt;/em&gt; those to one sequence you get down to 20 keystrokes. &lt;/p&gt;

&lt;p&gt;Things get a little more interesting if only three buttons are worn. It turns out that the repeated digits can be placed in the code in six different ways.&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;0012,1002,1200,0102,0120,1020&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's 6x2x3=36 combinations and, maybe a little unintuitive, 12 more than if you are using four different digits. I compressed it down to 49 key strokes (16 more than with four different digits). Unlike the sequence for four different digits I can't find it with google and I know it's kind of security by obscurity but I still chose not to publish it here.&lt;/p&gt;

&lt;p&gt;Be aware that if an attacker knows you are using a 0012-like code he gets a smaller space to search. 6x8x9x10=4320 instead of 10000. You have to weight the risk of button leaks against a code protocol leak.
&lt;br&gt;&lt;br&gt;
&lt;font color="red"&gt;Edit 2010-10-25&lt;/font&gt;&lt;br&gt;
&lt;a href="http://stackoverflow.com/questions/4008603/how-to-compute-de-bruijn-sequences-for-non-power-of-two-sized-alphabets/4009417#4009417"&gt;Uckelman noticed&lt;/a&gt; that the &lt;code&gt;alike&lt;/code&gt; variable in the former version of the debruijn-script wasn't used so I removed it.&lt;/p&gt;</description>
      <pubDate>Sun, 27 Sep 2009 21:02:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:9e10d05b-1a1d-46a1-82da-0ba366d32035</guid>
      <author>Jonas Elfström</author>
      <link>http://www.alicebobandmallory.com/articles/2009/09/27/a-case-for-using-only-three-different-digits-in-keypad-codes</link>
      <category>Security</category>
      <category>Ruby</category>
    </item>
    <item>
      <title>Why you should use four different digits for keypad locks</title>
      <description>&lt;p&gt;I made a couple of very bad mistakes in this article so I took it down. Hopefully I'm more on track in the &lt;a href="http://alicebobandmallory.com/articles/2009/09/27/a-case-for-using-only-three-different-digits-in-keypad-codes"&gt;sequel&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Wed, 23 Sep 2009 19:49:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:327947c8-2f2d-4ca7-9ddf-bdd8b74cd9f4</guid>
      <author>Jonas Elfström</author>
      <link>http://www.alicebobandmallory.com/articles/2009/09/23/why-you-should-use-four-different-digits-for-keypad-locks</link>
      <category>Security</category>
      <category>Ruby</category>
    </item>
    <item>
      <title>Breaking good</title>
      <description>&lt;p&gt;Check out &lt;a href="http://www.veracode.com/blog/2009/04/decoding-the-dbir-2009-cover/"&gt;Chris Eng's post&lt;/a&gt; on how he broke the code on the cover of the  &lt;a href="http://www.verizonbusiness.com/resources/security/reports/2009_databreach_rp.pdf"&gt;2009 Verizon Data Breach Investigations Report&lt;/a&gt;. He makes it seem so simple and without making a big deal of it he also shows the tools and commands he used.&lt;/p&gt;</description>
      <pubDate>Sun, 03 May 2009 23:24:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:6f525b07-1e76-4c82-ac8f-c518d3432101</guid>
      <author>Jonas Elfström</author>
      <link>http://www.alicebobandmallory.com/articles/2009/05/03/breaking-good</link>
      <category>Security</category>
    </item>
    <item>
      <title>Swedish hackers</title>
      <description>&lt;p&gt;The incident I wrote of in &lt;a href="http://alicebobandmallory.com/articles/2007/02/04/hello-this-is-special-agent-brian"&gt;Hello this is special agent Brian&lt;/a&gt; were covered in a Swedish radio documentary a little more than a month ago.
It's all in Swedish. You can find out more &lt;a href="http://www.sr.se/cgi-bin/p3/programsidor/artikel.asp?ProgramID=2519&amp;amp;Artikel=2447808"&gt;here&lt;/a&gt; and you can download the documentary from &lt;a href="http://www.sr.se/laddahem/podradio/SR_p3_dokumentar_081116080008.mp3"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I also would like to add that we did not press charges like the police officers says 37 minutes into the documentary. Not because we thought it wasn't a big deal but we knew that a couple of big players already had so we thought we could spend our time better.&lt;/p&gt;</description>
      <pubDate>Wed, 31 Dec 2008 00:29:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:75c0eb80-02fc-4f10-92bf-d0ee90a49986</guid>
      <author>Jonas Elfström</author>
      <link>http://www.alicebobandmallory.com/articles/2008/12/31/swedish-hackers</link>
      <category>Security</category>
    </item>
    <item>
      <title>Drive encryption matters</title>
      <description>&lt;p&gt;In a recent release &lt;a href="http://www.truecrypt.org/"&gt;TrueCrypt&lt;/a&gt; now supports &lt;a href="http://www.truecrypt.org/docs/?s=system-encryption"&gt;drive/partition&lt;/a&gt; encryption.&lt;/p&gt;

&lt;p&gt;One reason to encrypt on disk instead of file level is that operating systems and applications sometimes accidently stores passwords on your hard drive. This can happen in a number of ways and one common mistake applications make is to not prevent to be put on disk by the OS. Modern systems have a &lt;a href="http://en.wikipedia.org/wiki/Paging"&gt;page/swap file&lt;/a&gt;. If a program gets paged out while holding your clear text password in pageable memory your password will be written to disk. The problem is that there are &lt;a href="http://www.schneier.com/essay-148.html"&gt;password recovery tools&lt;/a&gt; that can scan your page file for passwords.&lt;/p&gt;

&lt;p&gt;You can configure Windows (and surely most other operating systems) to &lt;a href="http://support.microsoft.com/kb/314834"&gt;clear the page file&lt;/a&gt; on shutdown which will give you better protection (and slower shutdowns). Be aware that if you simply turn off the power the page file will be intact.&lt;/p&gt;</description>
      <pubDate>Tue, 12 Feb 2008 00:26:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:fc149744-6fac-475d-8a37-f548b4db2403</guid>
      <author>Jonas Elfström</author>
      <link>http://www.alicebobandmallory.com/articles/2008/02/12/drive-encryption-matters</link>
      <category>Security</category>
    </item>
    <item>
      <title>Scary tools</title>
      <description>&lt;p&gt;I recently attended a session held by &lt;a href="http://truesecurity.se/blogs/murray/"&gt;Marcus Murray&lt;/a&gt;. It seems it was kind of a compressed version of the &lt;a href="http://truesecurity.se/blogs/murray/archive/2007/06/05/session-notes-sec-310-why-i-can-hack-your-network-in-a-day-teched-us-2007-part-1.aspx#comments"&gt;session&lt;/a&gt; he held at TechEd earlier this year. Murray is witty, charismatic and has a broad and deep understanding of IT-security issues. He cracks jokes and practices a little social engineering to keep the audience attentive.
If you and your IT-staff wants to be briefed (and scared) with the latest in IT-security I could easily recommend Murray.&lt;/p&gt;

&lt;p&gt;He demonstrated a couple of tools that both impressed and scared me. First he demonstrated how to set up a mail based attack using the commercial &lt;a href="http://www.coresecurity.com/?module=ContentMod&amp;amp;action=item&amp;amp;id=32"&gt;Core IMPACT&lt;/a&gt;. It's a very impressive tool and mail based attacks are only one out of many attacks this software has the ability to execute. Before seeing this I could never have guessed there are tools this advanced and this easy to use. The lists of exploits it can test, in an all automated fashion, were long and seemed to be up to date.&lt;/p&gt;

&lt;p&gt;Murray also demonstrated &lt;a href="http://www.grc.com/nat/arp.htm"&gt;ARP poisoning&lt;/a&gt; and hijacking of a RDP session by using the free &lt;a href="http://www.oxid.it/index.html"&gt;Cain &amp;amp; Abel &lt;/a&gt; tool. You could feel the discomfort in the air as it dawned on the audience how easy this is to set up.&lt;/p&gt;</description>
      <pubDate>Wed, 12 Dec 2007 17:15:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:a8894523-e498-4a14-9ea2-45acb0672dbf</guid>
      <author>Jonas Elfström</author>
      <link>http://www.alicebobandmallory.com/articles/2007/12/12/scary-tools</link>
      <category>Security</category>
    </item>
    <item>
      <title>Man in the browser</title>
      <description>&lt;p&gt;There's some buzz about a new trojan technique called &lt;a href="http://www.f-secure.com/f-secure/pressroom/news/fs_news_20071122_1_eng.html"&gt;"Man in the browser"&lt;/a&gt;.  The trojan plugs itself into the users browser and then it intercepts the HTML. This have all sorts of implications, for instance the SSL certificate will seem to be valid. &lt;/p&gt;

&lt;p&gt;Even if your virus protection does not detect the "Man in the browser" there are still ways to be quite safe. If your bank uses a security token which you not only logs in with but also use to sign your transactions, the attack will most likely fail. One problem is that it is up to you, the user, to actually verify that you are signing the expected amount to the expected accounts. To get protection against someone who has complete control over your computer the security protocol must "communicate" with the security token both ways. &lt;/p&gt;

&lt;p&gt;It is not enough to only let the user enter the total value of the transactions because the tokens answer to such a simple value could be reused (during a short period of time) also the attack could be crafted to create the correct amount but to other accounts. By asking the user to also sign every new account the attacker will not be able to hide a transaction to his account.&lt;/p&gt;

&lt;p&gt;The challenge is to make the security protocol clear and &lt;a href="/articles/2007/03/27/secure-and-simple-security-tokens-needed"&gt;simple&lt;/a&gt; enough so that the user can understand what he would expect the bank to respond and expect from him.&lt;/p&gt;

&lt;p&gt;It's the usual three: have a firewall, an updated virus protection and a secure bank with a &lt;a href="http://en.wikipedia.org/wiki/Security_token#Digital_signatures"&gt;digital security token&lt;/a&gt; were you sign your transactions and maybe you can sleep a little better.&lt;/p&gt;</description>
      <pubDate>Mon, 26 Nov 2007 21:40:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:4a0b5d22-29f0-418a-b9df-1fe703ad3fdb</guid>
      <author>Jonas Elfström</author>
      <link>http://www.alicebobandmallory.com/articles/2007/11/26/man-in-the-browser</link>
      <category>Security</category>
    </item>
    <item>
      <title>Blowfish in the URL</title>
      <description>&lt;p&gt;Sometimes you do not want to show the database id for a row in the URL. The reason could be that you do not want someone to be able to scan through all the data.&lt;/p&gt;

&lt;p&gt;One solution is to use &lt;a href="http://en.wikipedia.org/wiki/Globally_Unique_Identifier"&gt;GUID's&lt;/a&gt; but they have drawbacks and one of them is that they add a considerable length to the URL. The shortest URL-safe representation of a GUID I've seen is &lt;a href="http://tools.assembla.com/breakout/wiki/FreeSoftware"&gt;22 characters&lt;/a&gt; but usually they are 36 characters.&lt;/p&gt;

&lt;p&gt;Depending on how your id's are implemented a much shorter way could be to simply to encrypt them.&lt;/p&gt;

&lt;p&gt;Here's a &lt;a href="http://www.ruby-lang.org/"&gt;Ruby&lt;/a&gt;-example that Blowfish encrypts, Base64 encodes and URL-encodes an integer value. You can get crypt as a gem:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gem install crypt&lt;/code&gt;&lt;/p&gt;

&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;require &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;rubygems&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;require &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;crypt/blowfish&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;require &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;Base64&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;blowfish = &lt;span style="color:#036;font-weight:bold"&gt;Crypt&lt;/span&gt;::&lt;span style="color:#036;font-weight:bold"&gt;Blowfish&lt;/span&gt;.new(&lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;A key up to 56 bytes long&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;plainId=&lt;span style="color:#00D;font-weight:bold"&gt;123456&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;encrypted = blowfish.encrypt_block(plainId.to_s.ljust(&lt;span style="color:#00D;font-weight:bold"&gt;8&lt;/span&gt;))&lt;tt&gt;
&lt;/tt&gt;idForURL = &lt;span style="color:#036;font-weight:bold"&gt;URI&lt;/span&gt;.escape((&lt;span style="color:#036;font-weight:bold"&gt;Base64&lt;/span&gt;.encode64(encrypted).strip))&lt;tt&gt;
&lt;/tt&gt;decryptedId = blowfish.decrypt_block(  &lt;tt&gt;
&lt;/tt&gt;                          &lt;span style="color:#036;font-weight:bold"&gt;Base64&lt;/span&gt;.decode64(  &lt;tt&gt;
&lt;/tt&gt;                          &lt;span style="color:#036;font-weight:bold"&gt;URI&lt;/span&gt;.unescape(idForURL))).&lt;tt&gt;
&lt;/tt&gt;                          strip.to_i&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;&lt;br&gt;
The .ljust(8) is because &lt;a href="http://www.schneier.com/blowfish.html"&gt;Blowfish&lt;/a&gt; is a 64-bit block &lt;a href="http://en.wikipedia.org/wiki/Blowfish_(cipher)"&gt;cipher&lt;/a&gt; and the &lt;a href="http://crypt.rubyforge.org/"&gt;Ruby-implementation&lt;/a&gt; does not pad the data itself.&lt;/p&gt;

&lt;p&gt;The id in the URL in this case would be &lt;code&gt;c2PSXWgky40=&lt;/code&gt;. Its 12 characters long (11 if you skip the equal sign) and that's 10 or 24 characters shorter than a GUID. Also there is zero percent chance of collusion and if you want to you can even decrypt it.&lt;/p&gt;

&lt;p&gt;This is not a super safe implementation but if you start your id's at a random and not too low number you are making it a bit harder for someone to crack the 56-bit key. Actually a truly random and at least 64-bit big number would be a better choice as it would have no connection to the true id at all. You would have to check for uniqueness before storing those in the database though.&lt;/p&gt;</description>
      <pubDate>Thu, 15 Nov 2007 22:38:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:9071a4d1-aaf0-4f17-a796-4ecd65976d64</guid>
      <author>Jonas Elfström</author>
      <link>http://www.alicebobandmallory.com/articles/2007/11/15/blowfish-in-the-url</link>
      <category>Security</category>
      <category>Ruby</category>
      <category>Cryptography</category>
    </item>
  </channel>
</rss>

