X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/ba3fd680fb91335eabb96601fa3ff8ee460b6ede..ce432659f2b238ecaced79ae6fa520750690146c:/client/cmdhfmf.c diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index d9f3e6fd..676a8884 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -434,7 +434,7 @@ int CmdHF14AMfRestore(const char *Cmd) { uint8_t sectorNo,blockNo; uint8_t keyType = 0; - uint8_t key[6] = {0xFF}; + uint8_t key[6] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; uint8_t bldata[16] = {0x00}; uint8_t keyA[40][6]; uint8_t keyB[40][6]; @@ -547,13 +547,15 @@ int CmdHF14AMfNested(const char *Cmd) uint8_t trgKeyType = 0; uint8_t SectorsCnt = 0; uint8_t key[6] = {0, 0, 0, 0, 0, 0}; - uint8_t keyBlock[13*6]; + uint8_t keyBlock[14*6]; uint64_t key64 = 0; bool transferToEml = false; + bool createDumpFile = false; FILE *fkeys; uint8_t standart[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; uint8_t tempkey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; + char cmdp, ctmp; if (strlen(Cmd)<3) { @@ -682,6 +684,9 @@ int CmdHF14AMfNested(const char *Cmd) e_sector[i].Key[j] = key64; e_sector[i].foundKey[j] = 1; } + } + } + // nested sectors iterations = 0; PrintAndLog("nested..."); @@ -776,8 +781,8 @@ int CmdHF14AMfChk(const char *Cmd) PrintAndLog("Usage: hf mf chk |<*card memory> [t|d] [] []"); PrintAndLog(" * - all sectors"); PrintAndLog("card memory - 0 - MINI(320 bytes), 1 - 1K, 2 - 2K, 4 - 4K, - 1K"); - PrintAndLog("d - write keys to binary file\n"); - PrintAndLog("t - write keys to emulator memory"); + PrintAndLog("d - write keys to binary file"); + PrintAndLog("t - write keys to emulator memory\n"); PrintAndLog(" sample: hf mf chk 0 A 1234567890ab keys.dic"); PrintAndLog(" hf mf chk *1 ? t"); PrintAndLog(" hf mf chk *1 ? d"); @@ -1018,7 +1023,6 @@ int CmdHF14AMf1kSim(const char *Cmd) PrintAndLog(" x (Optional) Crack, performs the 'reader attack', nr/ar attack against a legitimate reader, fishes out the key(s)"); PrintAndLog(""); PrintAndLog(" sample: hf mf sim u 0a0a0a0a "); - PrintAndLog(" : hf mf sim u 0a0a0a0a i x"); return 0; } uint8_t pnr = 0; @@ -1198,7 +1202,7 @@ int CmdHF14AMfELoad(const char *Cmd) if (len > FILE_PATH_SIZE) len = FILE_PATH_SIZE; - fnameptr += len; + fnameptr += len-4; sprintf(fnameptr, ".eml"); @@ -1307,7 +1311,7 @@ int CmdHF14AMfESave(const char *Cmd) for (j = 0; j < 7; j++, fnameptr += 2) sprintf(fnameptr, "%02X", buf[j]); } else { - fnameptr += len; + fnameptr += len-4; } // add file extension @@ -1498,13 +1502,13 @@ int CmdHF14AMfCSetBlk(const char *Cmd) uint8_t memBlock[16] = {0x00}; uint8_t blockNo = 0; bool wipeCard = FALSE; - int res = 0; + int res; if (strlen(Cmd) < 1 || param_getchar(Cmd, 0) == 'h') { PrintAndLog("Usage: hf mf csetblk [w]"); PrintAndLog("sample: hf mf csetblk 1 01020304050607080910111213141516"); PrintAndLog("Set block data for magic Chinese card (only works with such cards)"); - PrintAndLog("If you also want to wipe the card then add 'w' at the end of the command line."); + PrintAndLog("If you also want wipe the card then add 'w' at the end of the command line"); return 0; } @@ -1517,14 +1521,13 @@ int CmdHF14AMfCSetBlk(const char *Cmd) char ctmp = param_getchar(Cmd, 2); wipeCard = (ctmp == 'w' || ctmp == 'W'); - PrintAndLog("--block number:%2d data:%s", blockNo, sprint_hex(memBlock, 16)); res = mfCSetBlock(blockNo, memBlock, NULL, wipeCard, CSETBLOCK_SINGLE_OPER); if (res) { PrintAndLog("Can't write block. error=%d", res); return 1; - } + } return 0; } @@ -1572,7 +1575,7 @@ int CmdHF14AMfCLoad(const char *Cmd) if (len > FILE_PATH_SIZE) len = FILE_PATH_SIZE; memcpy(filename, Cmd, len); - fnameptr += len; + fnameptr += len-4; sprintf(fnameptr, ".eml"); @@ -1589,7 +1592,9 @@ int CmdHF14AMfCLoad(const char *Cmd) memset(buf, 0, sizeof(buf)); if (fgets(buf, sizeof(buf), f) == NULL) { + fclose(f); PrintAndLog("File reading error."); + fclose(f); return 2; } @@ -1597,6 +1602,7 @@ int CmdHF14AMfCLoad(const char *Cmd) if(strlen(buf) && feof(f)) break; PrintAndLog("File content error. Block data must include 32 HEX symbols"); + fclose(f); return 2; } for (i = 0; i < 32; i += 2)