]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Merge branch 'master' of https://github.com/Proxmark/proxmark3
authoriceman1001 <iceman@iuse.se>
Tue, 20 Jan 2015 08:32:53 +0000 (09:32 +0100)
committericeman1001 <iceman@iuse.se>
Tue, 20 Jan 2015 08:32:53 +0000 (09:32 +0100)
Conflicts:
armsrc/appmain.c
armsrc/apps.h

1  2 
armsrc/appmain.c
armsrc/apps.h
armsrc/mifarecmd.c
client/lualibs/commands.lua
client/lualibs/utils.lua
client/scripts/tnp3dump.lua
client/scripts/tnp3sim.lua
common/cmd.h
common/usb_cdc.h

index 13995f591735333a8b897d3ab478418205b3ec78,530dc39cd04b4fa15603998bb069cb27e2fc9029..b998c2a1968569e7b73b42db8e574f6da58539a3
@@@ -798,18 -801,9 +801,18 @@@ void UsbPacketReceived(uint8_t *packet
                case CMD_MIFAREU_READBL:
                        MifareUReadBlock(c->arg[0],c->d.asBytes);
                        break;
 +              case CMD_MIFAREUC_AUTH1:
 +                      MifareUC_Auth1(c->arg[0],c->d.asBytes);
 +                      break;
 +              case CMD_MIFAREUC_AUTH2:
 +                      MifareUC_Auth2(c->arg[0],c->d.asBytes);
 +                      break;
                case CMD_MIFAREU_READCARD:
-                       MifareUReadCard(c->arg[0],c->arg[1],c->d.asBytes);
+                       MifareUReadCard(c->arg[0], c->arg[1], c->d.asBytes);
                          break;
 +              case CMD_MIFAREUC_READCARD:
 +                      MifareUReadCard(c->arg[0],c->arg[1],c->d.asBytes);
 +                        break;
                case CMD_MIFARE_READSC:
                        MifareReadSector(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes);
                        break;
diff --cc armsrc/apps.h
Simple merge
index 470af6a7a9edc9084ac3e5219be651ba76c61e0a,ecd8728db9c4b9dcf3168b3207665cd1bf676597..22926dcfaf399f15c605000865939eafccfb7e70
@@@ -1127,58 -1061,3 +1127,58 @@@ void MifareCIdent()
                        //\r
  // DESFIRE\r
  //\r
- }
 +\r
 +void Mifare_DES_Auth1(uint8_t arg0, uint8_t *datain){\r
 +\r
 +      byte_t dataout[11] = {0x00};\r
 +      uint8_t uid[10] = {0x00};\r
 +      uint32_t cuid;\r
 +    \r
 +      iso14a_clear_trace();\r
 +      iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);\r
 +\r
 +      int len = iso14443a_select_card(uid, NULL, &cuid);\r
 +      if(!len) {\r
 +              if (MF_DBGLEVEL >= MF_DBG_ERROR)        \r
 +                      Dbprintf("Can't select card");\r
 +              OnError(1);\r
 +              return;\r
 +      };\r
 +\r
 +      if(mifare_desfire_des_auth1(cuid, dataout)){\r
 +              if (MF_DBGLEVEL >= MF_DBG_ERROR)        \r
 +                      Dbprintf("Authentication part1: Fail.");\r
 +              OnError(4);\r
 +              return;\r
 +      }\r
 +\r
 +      if (MF_DBGLEVEL >= MF_DBG_EXTENDED) DbpString("AUTH 1 FINISHED");\r
 +    \r
 +    cmd_send(CMD_ACK,1,cuid,0,dataout, sizeof(dataout));\r
 +}\r
 +\r
 +void Mifare_DES_Auth2(uint32_t arg0, uint8_t *datain){\r
 +\r
 +      uint32_t cuid = arg0;\r
 +      uint8_t key[16] = {0x00};\r
 +      byte_t isOK = 0;\r
 +      byte_t dataout[12] = {0x00};\r
 +    \r
 +      memcpy(key, datain, 16);\r
 +      \r
 +      isOK = mifare_desfire_des_auth2(cuid, key, dataout);\r
 +      \r
 +      if( isOK) {\r
 +          if (MF_DBGLEVEL >= MF_DBG_EXTENDED) \r
 +                      Dbprintf("Authentication part2: Failed");  \r
 +              OnError(4);\r
 +              return;\r
 +      }\r
 +\r
 +      if (MF_DBGLEVEL >= MF_DBG_EXTENDED) \r
 +              DbpString("AUTH 2 FINISHED");\r
 +\r
 +      cmd_send(CMD_ACK, isOK, 0, 0, dataout, sizeof(dataout));\r
 +      FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
 +      LEDsoff();\r
++}
index 13b9c8e74fce7aff5ce447b34e227235571a8f02,13b9c8e74fce7aff5ce447b34e227235571a8f02..a5442f2a8b221ee565f07b3da9c857477755c63e
@@@ -49,7 -49,7 +49,7 @@@ local _commands = 
        CMD_EM4X_WRITE_WORD =                                                0x0219,
        CMD_IO_DEMOD_FSK =                                                   0x021A,
    CMD_IO_CLONE_TAG =                                                   0x021B,
--  CMD_EM410X_DEMOD =                                                                                                                                                                                           0x021C,
++      CMD_EM410X_DEMOD =                                                                                                   0x021c,
        --/* CMD_SET_ADC_MUX: ext1 is 0 for lopkd, 1 for loraw, 2 for hipkd, 3 for hiraw */
  
        --// For the 13.56 MHz tags
index e84f70ada526e99b36b69f5077f5be8208e2c587,e84f70ada526e99b36b69f5077f5be8208e2c587..c5baa406955d067012d525e9b57c8bf9cc525a42
@@@ -108,6 -108,6 +108,24 @@@ local Utils 
                return retval\r
        end,\r
        \r
++      -- input parameter is a string\r
++      -- Swaps the endianess and returns a string,  \r
++      -- IE:  'cd7a' -> '7acd'  -> 0x7acd\r
++      SwapEndiannessStr = function(s, len)\r
++              if s == nil then return nil end\r
++              if #s == 0 then return '' end\r
++              if  type(s) ~= 'string' then return nil end\r
++              \r
++              local retval\r
++              if len == 16 then\r
++                      retval = s:sub(3,4)..s:sub(1,2)\r
++              elseif len == 24 then\r
++                      retval = s:sub(5,6)..s:sub(3,4)..s:sub(1,2)\r
++              elseif len == 32 then\r
++                      retval = s:sub(7,8)..s:sub(5,6)..s:sub(3,4)..s:sub(1,2)\r
++              end\r
++              return retval\r
++      end,    \r
        ------------ CONVERSIONS\r
        \r
        --\r
                local B,K,OUT,I,D=16,"0123456789ABCDEF","",0\r
                while IN>0 do\r
                        I=I+1\r
--                      IN,D=math.floor(IN/B),math.mod(IN,B)+1\r
++                      IN , D = math.floor(IN/B), math.modf(IN,B)+1\r
                        OUT=string.sub(K,D,D)..OUT\r
                end\r
                return OUT\r
index 520161b93663856774d57463dda4c7028482c091,520161b93663856774d57463dda4c7028482c091..f41fe8aba3036341ef0761db877977966a374510
@@@ -249,18 -249,18 +249,19 @@@ local function main(args
                end
        end 
        
++
++      local uid = block0:sub(1,8)
++      local itemtype = block1:sub(1,4)
++      local cardid = block1:sub(9,24)
++      
        -- Write dump to files
        if not DEBUG then
--              local foo = dumplib.SaveAsBinary(bindata, outputTemplate..'.bin')
++              local foo = dumplib.SaveAsBinary(bindata, outputTemplate..'_uid_'..uid..'.bin')
                print(("Wrote a BIN dump to the file %s"):format(foo))
--              local bar = dumplib.SaveAsText(emldata, outputTemplate..'.eml')
++              local bar = dumplib.SaveAsText(emldata, outputTemplate..'_uid_'..uid..'.eml')
                print(("Wrote a EML dump to the file %s"):format(bar))
        end
  
--      local uid = block0:sub(1,8)
--      local itemtype = block1:sub(1,4)
--      local cardid = block1:sub(9,24)
--
        -- Show info 
        print( string.rep('--',20) )
        print( (' ITEM TYPE : 0x%s - %s'):format(itemtype, toyNames[itemtype]) )
index f43dafa2495946fc275341b2bb34bb84a1f4dedf,f43dafa2495946fc275341b2bb34bb84a1f4dedf..adc34cce1ca8e84ef54502e9c2ec5f04d5cfbe73
@@@ -241,18 -241,18 +241,20 @@@ local function main(args
        local cmdSetDbgOff = "hf mf dbg 0"
        core.console( cmdSetDbgOff) 
        
--      -- Look for tag present on reader,
--      result, err = lib14a.read1443a(false)
--      if not result then return oops(err)     end
++      -- if not loadFromDump then
++              -- -- Look for tag present on reader,
++              -- result, err = lib14a.read1443a(false)
++              -- if not result then return oops(err)  end
  
--      core.clearCommandBuffer()
++              -- core.clearCommandBuffer()
        
--      if 0x01 ~= result.sak then -- NXP MIFARE TNP3xxx
--              return oops('This is not a TNP3xxx tag. aborting.')
--      end     
++              -- if 0x01 ~= result.sak then -- NXP MIFARE TNP3xxx
++                      -- return oops('This is not a TNP3xxx tag. aborting.')
++              -- end  
  
--      -- Show tag info
--      print((' Found tag : %s'):format(result.name))
++              -- -- Show tag info
++              -- print((' Found tag : %s'):format(result.name))
++      -- end
        
        -- Load dump.bin file
        print( (' Load data from %s'):format(inputTemplate))
                err = LoadEmulator(blocks)
                if err then return oops(err) end        
                core.clearCommandBuffer()
--              print('The simulation is now prepared.\n --> run \"hf mf sim 5 '..uid..'\" <--')
++              print('The simulation is now prepared.\n --> run \"hf mf sim u '..uid..' x\" <--')
        end
  end
  main(args)
diff --cc common/cmd.h
index b330a2193880e178f053cb0dac344f4920ac34a9,b330a2193880e178f053cb0dac344f4920ac34a9..bc69ff617b35d8fd76d1724ea0b22ad74cbf5012
@@@ -33,8 -33,8 +33,8 @@@
  #ifndef _PROXMARK_CMD_H_\r
  #define _PROXMARK_CMD_H_\r
  \r
--#include <common.h>\r
--#include <usb_cmd.h>\r
++#include "common.h"\r
++#include "usb_cmd.h"\r
  #include "usb_cdc.h"\r
  \r
  bool cmd_receive(UsbCommand* cmd);\r
index d7b9c2e5066d5ddf8f877fde23af789dc8ae1d45,d7b9c2e5066d5ddf8f877fde23af789dc8ae1d45..59e73a478f6f37334c681068ed5b22b7bb258b9d
@@@ -35,7 -35,7 +35,7 @@@
  #ifndef _USB_CDC_H_\r
  #define _USB_CDC_H_\r
  \r
--#include <common.h>\r
++#include "common.h"\r
  \r
  void usb_disable();\r
  void usb_enable();\r
Impressum, Datenschutz