#!/bin/sh # Smart Card Authentication Helper (c) 2008 Timothy Pearson # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . authscript="C0 84 00 00 08" echo $authscript > authscript scriptor_standalone authscript | grep 'Normal processing' > challenge perl -pi -e 's/ //g' challenge perl -pi -e 's/:Normalprocessing.//g' challenge perl -pi -e 's/ response # Send the response! scriptor_standalone response > response2 # Get the result dd if=response2 of=response bs=1 count=5 skip=95 perl -pi -e 's/ //g' response response1=$(cat response) authokresponse="9000" if [ "$response1" = "$authokresponse" ]; then echo "Smart card validation successfull!" # Get encryption key authscript="C0 A4 00 00 02 10 01" echo $authscript > authscript scriptor_standalone authscript #authscript="C0 B0 00 00 00" authscript="" echo $authscript > authscript scriptor_standalone authscript > smart mkdir smartcard cd smartcard echo "get 1001" | opensc-explorer cd .. rm smart mv smartcard/*_1001 smart.key else echo "Authentication failed!" fi rm authscript & rm response & rm response2 & rm challenge &