X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/05446d5bc3d9263efc6a12026f6cf84bb421735e..68e6434527996c0e9f98e5a64a3511161643c047:/client/scripts/tnp3sim.lua diff --git a/client/scripts/tnp3sim.lua b/client/scripts/tnp3sim.lua index fc403758..af3d2d4c 100644 --- a/client/scripts/tnp3sim.lua +++ b/client/scripts/tnp3sim.lua @@ -4,7 +4,7 @@ local bin = require('bin') local lib14a = require('read14a') local utils = require('utils') local md5 = require('md5') -local toyNames = require('default_toys') +local toys = require('default_toys') example =[[ 1. script run tnp3sim @@ -26,7 +26,7 @@ Arguments: ]] local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds -local DEBUG = false -- the debug flag +local DEBUG = true -- the debug flag local band = bit32.band @@ -302,25 +302,25 @@ function DivideByK(msw, lsw) remainder = num % RADIX return remainder, highLSW, lowLSW - uint num = 0 | (msw >> 16) & 0xffff; + -- uint num = 0 | (msw >> 16) & 0xffff; - highLSW = 0 | (num / RADIX) << 16; - remainder = num % RADIX; + -- highLSW = 0 | (num / RADIX) << 16; + -- remainder = num % RADIX; - num = (remainder << 16) | (msw & 0xffff); + -- num = (remainder << 16) | (msw & 0xffff); - highLSW |= num / RADIX; - remainder = num % RADIX; + -- highLSW |= num / RADIX; + -- remainder = num % RADIX; - num = (remainder << 16) | ((lsw >> 16) & 0xffff); + -- num = (remainder << 16) | ((lsw >> 16) & 0xffff); - lowLSW = 0 | (num / RADIX) << 16; - remainder = num % RADIX; + -- lowLSW = 0 | (num / RADIX) << 16; + -- remainder = num % RADIX; - num = (remainder << 16) | (lsw & 0xffff); + -- num = (remainder << 16) | (lsw & 0xffff); - lowLSW |= num / RADIX; - remainder = num % RADIX; + -- lowLSW |= num / RADIX; + -- remainder = num % RADIX; end @@ -382,22 +382,27 @@ local function main(args) print( string.rep('--',20) ) print(' Gathering info') local uid = blocks[0]:sub(1,8) - local itemtype = blocks[1]:sub(1,4) + local toytype = blocks[1]:sub(1,4) local cardidLsw = blocks[1]:sub(9,16) local cardidMsw = blocks[1]:sub(17,24) + local subtype = blocks[1]:sub(25,28) - local itemtypename = toyNames[itemtype] - if itemtypename == nil then - itemtypename = toyNames[utils.SwapEndiannessStr(itemtype,16)] - end - -- Show info print( string.rep('--',20) ) - print( (' ITEM TYPE : 0x%s - %s'):format(itemtype, itemtypename) ) + + local item = toys.Find( toytype, subtype) + if item then + local itemStr = ('%s - %s (%s)'):format(item[6],item[5], item[4]) + print(' ITEM TYPE :'..itemStr ) + else + print( (' ITEM TYPE : 0x%s 0x%s'):format(toytype, subtype) ) + end + print( (' UID : 0x%s'):format(uid) ) print( (' CARDID : 0x%s %s [%s]'):format( cardidMsw,cardidLsw, - Num2Card(cardidMsw, cardidLsw)) + --Num2Card(cardidMsw, cardidLsw)) + '') ) print( string.rep('--',20) )