def _defaultSelect(): card = Card.Card() apdu = APDU(card) apdu.selectFID('1001') assert apdu.sw == '9000' apdu.getBalance(True) assert apdu.sw == '9000'
def _parseAndRun(sList): card = Card.Card() apdu = APDU(card) import re apduList = [] for e in sList: cmd = e[1] p1 = re.compile('\(\w.*?\)') brckList = p1.findall(cmd) for f in brckList: if d.has_key(f[1:-1]): cmd = cmd.replace(f, d[f[1:-1]]) elif f[1:-1] == 'MAC': if '8052' in cmd: mac = _CalcMac(type='load', res=apdu.res) else: mac = _CalcMac(type='purchase', res=apdu.res) cmd = cmd.replace(f, mac) else: print f assert 0, 'Unknow ELement!' p = re.compile('\(.*\)') brckList = p.findall(cmd) if len(brckList) > 0: cmd = cmd.replace(brckList[0], brckList[0][1:-1]) if '#' in cmd: cmd = cmd.replace('#', '%02X' % (len(cmd[cmd.index('#'):]) / 2)) apduList.append(cmd) apdu.send(cmd) assert apdu.sw == '9000'
def _defaultSelect(): card = Card.Card() apdu = APDU(card) apdu.selectAID('325041592E5359532E4444463031') apdu.selectAID('A00000033301010600030800005A5954') apdu.selectAID('A0000003335342540000000D') apdu.selectFID('1001') for aid in l: apdu.selectAID(aid)
def ReadLog(aid): card = Card.Card() apdu = APDU(card) apdu.selectAID(aid) apdu.selectFID('1001') for i in range(1, 20): sfi = '18' apdu.updateRecord('00', sfi, 23 * '00', mode='04') #apdu.readRecord('%02X'%i, sfi,'00') assert apdu.sw == '9000'
def test(): card = Card.Card() try: _installPBOC(card) _persoForZYT(card) for i in range(0, 9): aid = l[i] install(aid, card) perso(aid, card) except: print 'Error! Instance number : ', i
def _setOPEN(): card = Card.Card() apdu = APDU(card) apdu.send('00A4040000') assert apdu.sw == '9000' gp = GP.GP('404142434445464748494A4B4C4D4E4F', '404142434445464748494A4B4C4D4E4F', '404142434445464748494A4B4C4D4E4F', '0C') gp.Authentication(card, '01') gp.Send( '80E64000' + LV('00000000' + LV('EF' + LV('A0' + LV('86' + LV( 'A0' + LV('80' + LV('0411223344') + '81' + LV('20') + '82' + LV('0800') + '83' + LV('02535A') + '84' + LV('C0') + '85' + LV('01') + '86' + LV('020200')))))) + '00'), card, '9000')
from apptest import Card, GP from apptest.TLV import LV SD_AID = 'A000000151000000' SZT_PKG_AID = 'A000000333534254FF000010' SZT_MDL_AID = 'A00000033353425400000010' def install(aid, card): card.Transmit('00A4040000') gp = GP.GP('404142434445464748494A4B4C4D4E4F', '404142434445464748494A4B4C4D4E4F', '404142434445464748494A4B4C4D4E4F', '0C') gp.Authentication(card, '01') gp.Delete(aid, card) p = 'C900' + 'EF' + LV('A0' + LV('A5038201C0810101') + 'CF' + LV('00')) #p = 'C900' gp.Install(SZT_PKG_AID, SZT_MDL_AID, aid, card, p) if __name__ == '__main__': card = Card.Card() aid = '535A542E57414C4C45542E454E56' install(aid, card)
def _activeCard(aid): card = Card.Card() apdu = APDU(card) apdu.selectAID(ProxyInstanceAID) card.Transmit('80F0008000') card.Transmit('80F00001' + LV('4F' + LV(aid)), '9000')