<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://www.tuxz.net/blog/styles/feed.css"?>
<rss version="2.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:admin="http://webns.net/mvcb/">
<channel>
<title>Alexandre De Dommelin weblog</title>
<link>http://www.tuxz.net/blog</link>
<description></description>
<dc:language>en-us</dc:language>
<dc:creator>Alexandre De Dommelin</dc:creator>
<dc:date>2010-07-24T19:29:26+00:00</dc:date>
<admin:generatorAgent rdf:resource="http://nanoblogger.sourceforge.net" />
<item>
<link>http://www.tuxz.net/blog/archives/2010/06/15/index.html#e2010-06-15T20_00_00.txt</link>
<title>Notification in Ratpoison WM when new unread mail in Mutt</title>
<dc:date>2010-06-15T20:00:00+00:00</dc:date>
<dc:creator>Alexandre De Dommelin</dc:creator>
<dc:subject>Articles</dc:subject>
<description>
<![CDATA[<p>After some time spent on Google to find a solution, somebody in #mutt told me to have a look at the status_format option in which we can call an external script ...</p>
<p>The relevant part of the ~/.ratpoisonrc :</p>
<pre class="bash" >
set status_format="/usr/local/bin/notify.sh '%r %f (%L) [Msgs:%?M?%M/?%m%?n? New:%n?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?]'|"
</pre><p>/usr/local/bin/notify.sh (quick 'n dirty but it works!) :</p>
<pre class="bash" >
#!/bin/bash
#
# Small script which display a message in ratpoison 
# when new incoming mail
#

echo "$1" | grep -q "New" > /dev/null 2>&1

if [ $? -eq 0 ];
then
  ratpoison -c "echo Unread mail in Inbox"
fi

echo "$1"

</pre>]]>
</description>
</item>
<item>
<link>http://www.tuxz.net/blog/archives/2010/06/14/index.html#e2010-06-14T20_05_00.txt</link>
<title>Yubiauth : Two-factor authentication with Yubikey in OpenSSH</title>
<dc:date>2010-06-14T20:05:00+00:00</dc:date>
<dc:creator>Alexandre De Dommelin</dc:creator>
<dc:subject>Articles</dc:subject>
<description>
<![CDATA[<p>Some times ago I've described a quick solution to setup two-factor authentication with OpenSSH &amp; Yubikey. I've made a clean Perl rewrite of the script with new features.</p>
<p>Working features :</p>
<ul>
<li>Config file in INI format</li>
<li>Multiple Yubikeys support for each user</li>
<li>"Whitelist" : you can define IP (or networks using CIDR notation) for clients which doesn't need to provide OTP.</li>
<li>HMAC verification</li>
<li>Error logging</li>
</ul>
<p>Planned features :</p>
<ul>
<li>Integration of PreludeEasy to report authentication failures to your Prelude SIEM manager.</li>
</ul>
<p> <br />
Available from my <a href="http://github.com/adedommelin">Git repository</a>.</p>]]>
</description>
</item>
<item>
<link>http://www.tuxz.net/blog/archives/2010/06/14/index.html#e2010-06-14T20_00_00.txt</link>
<title>Improve web browser integration within Ratpoison WM</title>
<dc:date>2010-06-14T20:00:00+00:00</dc:date>
<dc:creator>Alexandre De Dommelin</dc:creator>
<dc:subject>Articles</dc:subject>
<description>
<![CDATA[<p>Here is a solution based on a custom perl script to improve the integration of your web browser inside Ratpoison.</p>
<p>Ratpoison is a keyboard driven window manager.<br />
I've written a small perl script designed to be called via standard Ratpoison bind functions to interact with Midori (can be easily used with other web browsers). Here are the default binds : </p>
<ul>
<li>:gg <terms> : search for <terms> in google.com</li>

<li>:dp <package_name> : load packages.debian.org page of <package_name></li>
<li>:db <package_name> : load bugs.debian.org page of <package_name></li>
<li>:wi <terms> : search for <terms> in Wikipedia</li>

</ul>
<p>There is also a shortcut (actually bind to escape-g) which send the current selection to the browser, if the selection is an URL, load it into the browser, otherwise search for string in Google.</p>
<p>Relevant part of my ~/.ratpoisonrc :</p>
<pre>
# Browser Wrapper
bind g exec ~/bin/browser_wrapper.pl selection `$RATPOISON -c getsel`
alias gg exec ~/bin/browser_wrapper.pl gg
alias dp exec ~/bin/browser_wrapper.pl dp
alias db exec ~/bin/browser_wrapper.pl db
alias wi exec ~/bin/browser_wrapper.pl wi
</pre><p>
~/bin/browser_wrapper.pl :</p>
<pre  class="python">
#!/usr/bin/perl

{
  my $shortcut = $ARGV[0] || 'gg';
  my $browser = "/usr/bin/midori";
  my $request = undef;
  my $url = undef;

  foreach $argnum ( 1 .. $#ARGV ) {
    $request .= $ARGV[$argnum].'%20';
  }

  $request =~ s/\%20$//;

  my $shortcuts_table = {
    'gg' => sub {
              $url = "http://www.google.fr/search?q=" . $request;
              system( $browser . " " . $url );
            },

    'dp' => sub {
              $url = "http://packages.debian.org/" . $request;
              system( $browser . " " . $url );
            },

    'db' => sub {
              $url = "http://bugs.debian.org/" . $request;
              system( $browser . " " . $url );
            },

    'wi' => sub {
              $url = "http://en.wikipedia.org/wiki/" . $request;
              system( $browser . " " . $url );
            },

    'selection' => sub {
              if ( $request =~ m/^http:\/\/.*/ ) {
                $url = $request;
              } else {
                $url = "http://www.google.fr/search?q=" . $request;
              }
              system( $browser . " " . $url );
            }
  };

  $shortcuts_table->{$shortcut} ? $shortcuts_table->{$shortcut}->() : $shortcuts_table->{'gg'}->();
}
0;
</pre>]]>
</description>
</item>
<item>
<link>http://www.tuxz.net/blog/archives/2010/06/08/index.html#e2010-06-08T20_00_00.txt</link>
<title>View HTML emails inside Mutt</title>
<dc:date>2010-06-08T20:00:00+00:00</dc:date>
<dc:creator>Alexandre De Dommelin</dc:creator>
<dc:subject>Tips</dc:subject>
<description>
<![CDATA[<p>More a reminder than a real post, here's how to display HTML emails inside Mutt using w3m.</p>
<p>Put the following line into ~/.mailcap :</p>
<p>text/html; w3m -I %{charset} -T text/html -dump; copiousoutput</p>
<p>And just append :</p>
<p>auto_view text/html</p>
<p>in ~/.mutt/muttrc</p>]]>
</description>
</item>
<item>
<link>http://www.tuxz.net/blog/archives/2010/05/28/index.html#e2010-05-28T20_00_00.txt</link>
<title>New Debian package : libnet-akamai-perl</title>
<dc:date>2010-05-28T20:00:00+00:00</dc:date>
<dc:creator>Alexandre De Dommelin</dc:creator>
<dc:subject>Tips</dc:subject>
<description>
<![CDATA[<p>This package provides a perl module to interact with Akamai CCUAPI to handle multiple purge requests.</p>
<p>Package : <a href="http://packages.debian.org/sid/libnet-akamai-perl" title="http://packages.debian.org/sid/libnet-akamai-perl">http://packages.debian.org/sid/libnet-akamai-perl</a><br />
Bugs : <a href="http://packages.debian.org/libnet-akamai.perl" title="http://packages.debian.org/libnet-akamai.perl">http://packages.debian.org/libnet-akamai.perl</a></p>]]>
</description>
</item>
<item>
<link>http://www.tuxz.net/blog/archives/2010/03/19/index.html#e2010-03-19T20_00_00.txt</link>
<title>Strong Authentication for OpenID : Yubikey integration in SimpleID</title>
<dc:date>2010-03-19T20:00:00+00:00</dc:date>
<dc:creator>Alexandre De Dommelin</dc:creator>
<dc:subject>Articles</dc:subject>
<description>
<![CDATA[<p>In a previous article, I've described a way to <a href="http://blog.tuxz.net/content/openid-how-setup-your-own-identity-server-using-simpleid">setup an OpenID provider using SimpleID</a>. Its only major drawback was the lack of support for any strong authentication ... since today. I've patched and released a version with Yubikey One-Time Password support.</p>
<p>This version is based on the latest released version available on the official SimpleID website: 0.7.1 and also include patches to work correctly with PHP 5.3.1.<br />

I will contact the author to see if he's interested in this feature and if he wants these patches to be included in the official SimpleID tree, but if for any reason they would not be accepted, i'll keep my git repository up-to-date with any future release.</p>
<p>More interesting than a long blahblah here is the git repository : <a href="http://github.com/adedommelin/simpleid-yubikey" title="http://github.com/adedommelin/simpleid-yubikey">http://github.com/adedommelin/simpleid-yubikey</a></p>
<p>Please take 2 minutes to read the small README as it explains how to associate your key to your OpenID Identity.</p>]]>
</description>
</item>
<item>
<link>http://www.tuxz.net/blog/archives/2010/03/17/index.html#e2010-03-17T20_00_00.txt</link>
<title>How to quickly setup Two-Factor SSH authentication using Yubikey</title>
<dc:date>2010-03-17T20:00:00+00:00</dc:date>
<dc:creator>Alexandre De Dommelin</dc:creator>
<dc:subject>Articles</dc:subject>
<description>
<![CDATA[<p>Thanks to the Geneva Application Security Forum, I'm now a proud owner of a Yubikey. This small USB token acts as an OTP (One-Time Password) generator. I'll present you a quick solution to use it within OpenSSH for Two-Factor (T-FA) authentication.</p>

<h2>What is Two-Factor authentication ?</h2>
<p>An authentication factor is a piece of information and process used to authenticate or verify the identity of a person or other entity requesting access under security constraints. Two-factor authentication (T-FA) or (2FA) is a system wherein two different factors are used in conjunction to authenticate. Using two factors as opposed to one factor generally delivers a higher level of authentication assurance. Two-factor authentication typically is a signing-on process where a person proves his or her identity with two of the three methods: "something you know" (e.g., password or PIN), "something you have" (e.g.,smartcard or token), or "something you are" (e.g., fingerprint or iris scan).</p>

<h2>How does the Yubikey work ?</h2>
<p>A Yubikey is a small USB HID device which is seen as a generic keyboard (no driver needed) with a small button. Each time the button is pressed it generates a one-time password secured using AES-128 encryption and ModHex encoding. For more details, you can have a look at this <a href="http://www.linuxjournal.com/magazine/yubikey-one-time-password-authentication">detailed article</a>.</p>
<h2>How to integrate a Yubikey in the SSH login process ?</h2>
<p>There is various solutions available, one of them is to use the a PAM module, but it's still in development and users reports some crashes, so it doesn't sound a very good solution to me at this time.<br />
The other solution (the one I'll present in this article) was to develop a script which will be invoked at each login, before giving a shell to the user, which will check the OTP.</p>
<h2>Ok ... ok ! But how can I use it with my OpenSSH server ?</h2>

<p>Here is the way my solution works : I've added a group called "yubikey" on the system. The SSH server will execute the authentication script for all the members of this group on each login (this is done using the sshd_config Match directive). The script will ask the user to generate an OTP using his Yubikey, check if this key is authorized for this user, parsing ~/.ssh/trusted_yubikeys then proceed to the validation of the password. If everything is fine the script gives the user his shell.<br />
Here are all the steps in detail :</p>
<p><strong>Create the group :</strong></p>
<pre  class="python">
$ groupadd yubikey</pre><p><strong>Add your user inside the group :</strong></p>
<pre  class="python">
$ adduser mon_user yubikey</pre><p><strong>Specify the trusted keys for this user : </strong></p>

<pre  class="python">
$ cd /home/mon_user/.ssh
$ echo "yubikeyid" >> trusted_yubikeys</pre><p><strong>Create the script in /usr/local/bin/yubikey.sh : </strong></p>
<pre  class="python">
#!/bin/bash
#
# (c) 2010 Alexandre De Dommelin
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# <a href="http://sam.zoy.org/wtfpl/COPYING" title="http://sam.zoy.org/wtfpl/COPYING">http://sam.zoy.org/wtfpl/COPYING</a> for more details.
#

YUBICO_API_ID="XXXX"
TRUSTED_KEYS_FILE="$HOME/.ssh/trusted_yubikeys"

STD="\\033[0;39m"
OK="\\033[1;32m[i]$STD"
ERR="\\033[1;31m[e]$STD"

##################################################
## Disconnect clients trying to exit the script ##
##################################################

trap disconnect INT
disconnect() {
  sleep 1
  kill -9 $PPID
  exit 1
}


echo ""
echo "** One-Time Password Validation Step **"
echo ""

echo -n "Please provide Yubi OTP then enter Ctrl-d: "
OTP=`tr -c -d a-z < /dev/tty`
KEY_ID=${OTP:0:12}


####################################
## Get user-trusted yubikeys list ##
####################################

if [ ! -f $TRUSTED_KEYS_FILE ]
then
  echo -e "$ERR Unable to find trusted keys list"
  disconnect
else
  TRUSTED_KEYS=`cat $TRUSTED_KEYS_FILE`
fi



#######################################
## Iterate through trusted keys list ##
#######################################

for trusted in ${TRUSTED_KEYS[@]}
do
  if [ $KEY_ID = $trusted ]
  then
    echo -e "$OK Found key in $TRUSTED_KEYS_FILE - validating OTP now ..."

    if wget "https://api.yubico.com/wsapi/verify?id=$YUBICO_API_ID&otp=$OTP" -O - 2> /dev/null | grep "status=OK" > /dev/null
    then
      echo -e "$OK OTP validated"

      exec `grep "^$(whoami)" /etc/passwd | cut -d ":" -f 7`
    else
      echo -e "$ERR Unable to validate generated OTP" > /dev/stderr
      sleep 1
      disconnect
    fi
  fi
done

echo -e "$ERR Key not trusted" > /dev/stderr
disconnect</pre><p><strong>Give it the right permissions :</strong></p>

<pre  class="python">
$ chmod 755 /usr/local/bin/yubikey.sh</pre><p><strong> Configure /etc/ssh/sshd_config with this parameters :</strong></p>
<pre  class="python">
Match group yubikey
        ForceCommand /usr/local/bin/yubikey.sh
</pre><p><strong>Then restart SSH server :</strong></p>
<pre  class="python">
$ /etc/init.d/ssh restart</pre><p> </p>
<h2>Important notes</h2>
<ul>
<li>Keep an active SSH session during your tests :-)</li>

<li>You have to put your API ID in YUBICO_API_ID inside the script. API ID can be obtained at api.yubico.com</li>
<li>Make sure that ~/.ssh/trusted_keys is readable by the matching user</li>
<li>Of course, you can use your own validation server, just adapt the script accordingly</li>
<li>I'm not responsible of what you do, this script works for me, but it comes with no warranty, if your dog die tomorrow or anything else like that don't blame me</li>
<li>Updated versions will be commited to <a href="http://www.github.com/adedommelin">my Github repository</a></li>
</ul>]]>
</description>
</item>
<item>
<link>http://www.tuxz.net/blog/archives/2010/02/06/index.html#e2010-02-06T20_00_00.txt</link>
<title>Medor v0.1 : How to protect your session using RFID tags</title>
<dc:date>2010-02-06T20:00:00+00:00</dc:date>
<dc:creator>Alexandre De Dommelin</dc:creator>
<dc:subject>Tips</dc:subject>
<description>
<![CDATA[<p>The idea is quite simple, at work I&nbsp;often leave my computer for meetings ... and don't want to have to xlock / unlock my session.<br />

On login, I start ssh-agent with all my different keys (Work & Personnal), so leaving a terminal open with them loaded looks dangerous to me. Medor checks every 5&nbsp;seconds if my keys with my RFID&nbsp;tag are present, if they aren't the screen is locked to prevent somebody to use my session. When my keys are back, the session is unlocked.<br />
There's another protection, if Medor detects that the RFID&nbsp;reader is no longer available (somebody tried to unplug it), the screen is locked, all keys in my ssh-agent are removed and a XMPP message is sent to my cell phone.</p>
<p>Medor use the RFIDIOT library to access the RFID reader, have a look at my <a href="http://blog.tuxz.net/content/how-use-touchatag-rfid-usb-reader-debian-gnulinux">previous article to know how to use it on Debian GNU/Linux</a>.</p>
<p>Here are the 2&nbsp;main scripts (up-to-date release will be available on <a href="http://github.com/adedommelin/">my github</a> under dotfiles/openbox/bin/Medor)</p>

<p>&nbsp;</p>
<p>Medor.sh</p>
<pre  class="bash">
#!/bin/bash
#
# Medor v0.1
# Alex "laotseu" DE DOMMELIN - <a href="http://blog.tuxz.net" title="http://blog.tuxz.net">http://blog.tuxz.net</a>
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# <a href="http://sam.zoy.org/wtfpl/COPYING" title="http://sam.zoy.org/wtfpl/COPYING">http://sam.zoy.org/wtfpl/COPYING</a> for more details.
#

RFID_ID="MYTAGID"
CHECK_TAG_SCRIPT="/home/laotseu/.config/openbox/bin/Medor/python-rfid/checkTag.py"

SCREENLOCK="xlock"
SCREENLOCK_OPTS="-mode blank"
XMPP_ALERT="/home/laotseu/.config/openbox/bin/Medor/xmpp_alert.py"



function protect() {
  (ssh-agent -k > /dev/null 2>&1)
  ($XMPP_ALERT "$(date) Security Alert : RFID reader unplugged" > /dev/null 2>&1)
  lock;
}

function lock() {
  ($SCREENLOCK $SCREENLOCK_OPTS &)
}

function unlock() {
  (/usr/bin/killall -9 $SCREENLOCK)
}



## Main Loop ##

ALERT_SENT=0
while [ 42 ];
do
  TAG=`$CHECK_TAG_SCRIPT 2>/dev/null`

  case $? in
    ############################
    ## Reader not present :-( ##
    ############################
    1 )
      if [ $ALERT_SENT -eq 0 ];
      then
        protect;
        ALERT_SENT=1
      fi;
    ;;


    #################################
    ## No tag present, lock screen ##
    #################################
    255 )
      (/bin/pidof $SCREENLOCK > /dev/null 2>&1)
      if [ $? -eq 1 ];
      then
        lock;
      fi;
    ;;


    #############################################
    ## Tag present, check if allowed to unlock ##
    #############################################
    0 )
      if [ "$TAG" == "$RFID_ID" ];
      then
        (/bin/pidof $SCREENLOCK > /dev/null 2>&1)
        if [ $? -eq 0 ];
        then
          unlock;
          ALERT_SENT=0
        fi;
      else
        (/bin/pidof $SCREENLOCK > /dev/null 2>&1)
        if [ $? -eq 1 ];
        then
          lock;
        fi;
      fi;
      ;;
  esac

  sleep 3
done;

</pre><p>&nbsp;</p>
<p>checkTag.py</p>
<pre  class="python">
#!/usr/bin/python

import RFIDIOtconfig
import os

try:
  card = RFIDIOtconfig.card
except:
  os._exit(1)

if card.select():
  print "%s" % card.uid
else:
  os._exit(-1)
</pre>]]>
</description>
</item>
<item>
<link>http://www.tuxz.net/blog/archives/2010/02/05/index.html#e2010-02-05T20_00_00.txt</link>
<title>How to use Touchatag RFID USB reader on Debian GNU/Linux</title>
<dc:date>2010-02-05T20:00:00+00:00</dc:date>
<dc:creator>Alexandre De Dommelin</dc:creator>
<dc:subject>Tips</dc:subject>
<description>
<![CDATA[<p>I've bougth a few month ago a Touchatag RFID reader, a cheap USB&nbsp;device. It's reported to work on Windows / MacOS but not GNU/Linux. Here's a solution to use it on Debian.</p>
<p>You need to install some packages :<br />
<em> apt-get install python-pyscard pcscd pcsc-tools python-pycryptopp python-serial python-crypto</em></p>
<p>Then download the latest release of RFIDIOT (RFID IO&nbsp;Tools) <a href="http://rfidiot.org/#Where">here</a> and simply extract it.</p>

<p>Plug-in the reader and start pcsc_scan, you should see something like that :</p>
<pre >
<em>found one<br />Scanning present readers<br />0: ACS ACR 38U-CCID 00 00 </em>
</pre><p>The "0:" is the reader id, so ctrl+c out of pcsc_scan, edit RFIDIOtconfig.py, jump down to the readernum= directive, and change that to the correct id given by pcsc_scan.</p>
<p>You should now be able to test your reader using one of the contributed script such as multiselect.py.</p>]]>
</description>
</item>
<item>
<link>http://www.tuxz.net/blog/archives/2010/01/16/index.html#e2010-01-16T20_00_00.txt</link>
<title>OpenID : How to setup your own identity server using SimpleID</title>
<dc:date>2010-01-16T20:00:00+00:00</dc:date>
<dc:creator>Alexandre De Dommelin</dc:creator>
<dc:subject>Articles</dc:subject>
<description>
<![CDATA[<p>OpenID is a way to provide a single digital identity across the Internet. Instead of creating multiple accounts, remember the login/password couples on all the website you visit, you can use a single OpenID identity if this type of authentication is supported by the target website.</p>
<p>An OpenID is in the form of a unique URL, and is authenticated by the user's 'OpenID provider' (that is, the entity hosting their OpenID URL).The OpenID protocol does not rely on a central authority to authenticate a user's identity. Since neither the OpenID protocol nor Web sites requiring identification may mandate a specific type of authentication, non-standard forms of authentication can be used, such as smart cards, biometrics, or ordinary passwords.</p>
<p>While you can create an identity on various providers websites (it's possible you already have one see <a href="http://openid.net/get-an-openid/">Get an Openid</a>) you may want to host your own identity server.</p>
<p>There are a lot of identities servers, in various languages (PHP, Ruby, Python, Java...) i've decided to use <a href="http://simpleid.sourceforge.net/">SimpleID</a> a lightweight PHP-based solution which doesn't rely on any database. Here is an overview of these features :</p>

<ul>
<li>Support for OpenID 1.1 and 2.0</li>
<li>Support for Simple Registration Extension 1.0 and 1.1 draft</li>
<li>Multiple identities support</li>
</ul>
<p>&nbsp;</p>
<h2>Installation</h2>
<p>Start by downloading the archive at <a href="http://sourceforge.net/projects/simpleid/files/">Sourceforge</a>, extract it then move the cache, identities, www folders to your webserver.<br />
Configure your Web Server (apache, lighttpd...) by adding a new virtualhost pointing to the &quot;www&quot; folder. For standard use, you don't need to setup any rewrite rule or anything else. <br />

Rename config.default.inc to config.inc, then edit this file to put correct paths for the different needed folders<br />
&nbsp;</p>
<h2>Add an Identity</h2>
<p>Create an identity file called &quot;yournickname.identity&quot; in the identities folder, your apache/lighttpd user must have read access to this file.</p>
<pre class="php" >
identity=http://vhost.yourdomain.tld
pass=3408cad97ec7f9c09775da84048ecc0
[sreg]
nickname=your_nickname
email=yourmail@domain.tld
administrator=1
fullname=John Doe
dob=1957-01-02
gender=M
postcode=1234
country=ch
language=en
timezone=Europe/Zurich
</pre><p>
As for the &quot;pass&quot; line, you have to put the MD5&nbsp;Hash of your password.</p>

<p>That's all, you can now login to SimpleID&nbsp;using your new identity, and use this identity to login in various websites.</p>]]>
</description>
</item>
</channel>
</rss>
