Thursday, June 9, 2011

Using the OmniKey CardMan 5321/5325 in BackTrack 5

Although BackTrack is great, sometimes it needs some fudging to get everything you want working correctly. Its understandable... If you want to use the OmniKey CardMan 5321 in BackTrack 5, follow these steps. I did this all in a VM.


First download the omnikey drivers:

then:

root@bt:~# tar -zxvf ifdokrfid_lnx_i686-2.8.3.1.tar.gz
root@bt:~# cd ifdokrfid_lnx_i686-2.8.3.1
root@bt:~# ./install


and you should see:

root@bt:~# ./install

Installing HID Global OMNIKEY RFID Smartcard reader driver ...

PCSC-Lite found: /usr/sbin/pcscd
Copying ifdokrfid_lnx_i686-2.8.3.1.bundle to /usr/lib/pcsc/drivers ...

Installation finished!


So thats the standard installation, but its likely, it wont work. to test try this:

root@bt:~# pcscd
root@bt:~# /pentest/rfid/RFIDIOt/cardselect.py -L
PCSC devices:
    No: 0               OMNIKEY CardMan 5x21 00 00



If the output of cardselect.py looks like that (only one reader being shown), you'll have to do a little more work. The RFID interface isnt actually showing, instead its just the smartcard reader. The problem/resolution is identified in the README, but i wrote a script to speed up the process:


root@bt:~# ./cardman_install_fix.sh
PCSC-Lite found: /usr/sbin/pcscd
Found drop dir: /usr/lib/pcsc/drivers
Backing up Info.plist
Line Numbers:
        ProductID:  238
        0x5321: 275
        VendorID: 105
        FriendlyName: 371
Offsets:
        General: 37
        VendorID: 142
        FriendlyName: 408
Deleting all the lines!


Now one more time:

root@bt:~# pcscd
root@bt:~# /pentest/rfid/RFIDIOt/cardselect.py -L
PCSC devices:
    No: 0               OMNIKEY CardMan 5x21 00 00
    No: 1               OMNIKEY CardMan 5x21 00 01


That looks better, now pcscd is using the Omnikey Driver

Enjoy!

Here's  ./cardman_install_fix.sh

root@bt:~# cat usb/cardman_install_fix.sh
#!/bin/bash

# quick script to make the omnikey cardman work with bt5
# by brad antoniewicz
killall -9 pcscd

localpcsc=`which pcscd`
if [ "${localpcsc}" != "" ]; then
 echo "PCSC-Lite found: ${localpcsc}"
 dropdir=`$localpcsc -v | grep usbdropdir | sed 's/^.*usbdropdir=\(.*\) .*$/\1/' | cut -f1 -d' '`
 echo "Found drop dir: $dropdir"

cd "$dropdir/ifd-ccid.bundle/Contents"
INFO_FILE="Info.plist"
LINE_PRODID=`grep -n "ifdProductID" $INFO_FILE | cut -d: -f 1`
LINE_0x5321=`grep -n 0x5321 $INFO_FILE | cut -d: -f 1`
LINE_VEND=`grep -n "ifdVendorID" $INFO_FILE | cut -d: -f 1`
LINE_FRIEND=`grep -n "ifdFriendlyName" $INFO_FILE | cut -d: -f 1`

if [[ -n $LINE_PRODID && -n $LINE_0x5321 && -n $LINE_VEND && -n $LINE_FRIEND ]]; then
 echo "Backing up $INFO_FILE"
 cp $INFO_FILE $INFO_FILE.backup
 echo -e "Line Numbers:"
 echo -e "\tProductID:  $LINE_PRODID"
 echo -e "\t0x5321: $LINE_0x5321"
 echo -e "\tVendorID: $LINE_VEND"
 echo -e "\tFriendlyName: $LINE_FRIEND"
 echo -e "Offsets:"
 OFFSET=$(($LINE_0x5321 - $LINE_PRODID))
 echo -e "\tGeneral: $OFFSET"
 OFFSET_VEND=$((LINE_VEND + $OFFSET))
 echo -e "\tVendorID: $OFFSET_VEND"
 OFFSET_FRIEND=$((LINE_FRIEND + $OFFSET))
 echo -e "\tFriendlyName: $OFFSET_FRIEND"

 echo "Deleting all the lines!"
 echo -i $LINE_0x5321' d'
 echo -i
sed -i $LINE_0x5321' d;'$OFFSET_VEND' d;'$OFFSET_FRIEND' d;' $INFO_FILE
else
 echo "Could not find a critical line in $INFO_FILE"
fi

else
 echo "PCSC-Lite is not found in current path!"
 echo "Retry with appropriate user or go visit"
 echo "http://alioth.debian.org/projects/pcsclite/"
 echo "and install the latest version of pcsc-lite."
 fi
 

3 comments:

  1. Hello

    in first Thank you for your indication

    i follow your indication and it put me a syntaxe error in ligne 20
    if [[ -n $LINE_PRODID && -n $LINE_0x5321 && -n $LINE_VEND && -n $LINE_FRIEND ]]; then

    &amp dont look to be understand.

    Please could you help me
    Thank you for your support

    ReplyDelete
  2. You need to make sure you are running that script with "bash", not "dash" or some other crappy shell. You'll get that error from the use of "[[" with dash. -Josh

    ReplyDelete
  3. Updated blog post: http://blog.opensecurityresearch.com/2013/10/using-omnikey-cardman-53215325-in-kali.html

    ReplyDelete