CHG: "hf mfu crdbl" help text, got at correct length 3des key.

CHG: Added @marshmellows fixes for "hf mfu info"
CHG: moved some debug printandlog statements around.
This commit is contained in:
iceman1001 2015-05-01 15:33:54 +02:00
commit 1c1c5f4cae
2 changed files with 22 additions and 23 deletions

View file

@ -65,7 +65,7 @@ typedef enum TAGTYPE_UL {
UL_ERROR = 0xFF, UL_ERROR = 0xFF,
} TagTypeUL_t; } TagTypeUL_t;
uint8_t GetHF14AMfU_Type(){ uint8_t GetHF14AMfU_Type(void){
TagTypeUL_t tagtype = UNKNOWN; TagTypeUL_t tagtype = UNKNOWN;
iso14a_card_select_t card; iso14a_card_select_t card;
@ -163,7 +163,7 @@ int CmdHF14AMfUInfo(const char *Cmd){
memcpy( datatemp+3, data+4, 4); memcpy( datatemp+3, data+4, 4);
PrintAndLog(" UID : %s ", sprint_hex(datatemp, 7)); PrintAndLog(" UID : %s ", sprint_hex(datatemp, 7));
PrintAndLog(" UID[0] (Manufacturer Byte) = %02x, Manufacturer: %s", datatemp[0], getTagInfo(datatemp[0]) ); PrintAndLog(" UID[0] : (Manufacturer Byte) = %02x, Manufacturer: %s", datatemp[0], getTagInfo(datatemp[0]) );
// BBC // BBC
// CT (cascade tag byte) 0x88 xor SN0 xor SN1 xor SN2 // CT (cascade tag byte) 0x88 xor SN0 xor SN1 xor SN2
@ -188,7 +188,7 @@ int CmdHF14AMfUInfo(const char *Cmd){
PrintAndLog("--- "); PrintAndLog("--- ");
if ( tagtype & UL_C ) { if ((tagtype & UL_C)){
PrintAndLog("Trying some default 3des keys"); PrintAndLog("Trying some default 3des keys");
@ -200,8 +200,8 @@ int CmdHF14AMfUInfo(const char *Cmd){
} }
} }
} }
else if ((tagtype & (UL_EV1_48 || UL_EV1_128))) { else if ((tagtype & (UL_EV1_48 | UL_EV1_128))) {
//TODO //********** TODO ********************************
// --problem, there is a failed pwd tries counter in UL-EV1 // --problem, there is a failed pwd tries counter in UL-EV1
//PrintAndLog("Trying some known EV1 passwords."); //PrintAndLog("Trying some known EV1 passwords.");
} }
@ -325,8 +325,7 @@ int CmdHF14AMfURdBl(const char *Cmd){
return 0; return 0;
} }
int usage_hf_mfu_dump(void)
int usage_hf_mfu_dump()
{ {
PrintAndLog("Reads all pages from Ultralight, Ultralight-C, Ultralight EV1"); PrintAndLog("Reads all pages from Ultralight, Ultralight-C, Ultralight EV1");
PrintAndLog("and saves binary dump into the file `filename.bin` or `cardUID.bin`"); PrintAndLog("and saves binary dump into the file `filename.bin` or `cardUID.bin`");
@ -415,7 +414,6 @@ int CmdHF14AMfUDump(const char *Cmd){
// Load bottom lockbytes if available // Load bottom lockbytes if available
if ( Pages == 44 ) { if ( Pages == 44 ) {
lockbytes_t2 = data + (40*4); lockbytes_t2 = data + (40*4);
lockbytes2[0] = lockbytes_t2[2]; lockbytes2[0] = lockbytes_t2[2];
lockbytes2[1] = lockbytes_t2[3]; lockbytes2[1] = lockbytes_t2[3];
@ -425,12 +423,10 @@ int CmdHF14AMfUDump(const char *Cmd){
} }
for (i = 0; i < Pages; ++i) { for (i = 0; i < Pages; ++i) {
if ( i < 3 ) { if ( i < 3 ) {
PrintAndLog("Block %02x:%s ", i,sprint_hex(data + i * 4, 4)); PrintAndLog("Block %02x:%s ", i,sprint_hex(data + i * 4, 4));
continue; continue;
} }
switch(i){ switch(i){
case 3: tmplockbit = bit[4]; break; case 3: tmplockbit = bit[4]; break;
case 4: tmplockbit = bit[3]; break; case 4: tmplockbit = bit[3]; break;
@ -548,8 +544,8 @@ int CmdHF14AMfucAuth(const char *Cmd){
} }
uint8_t *key = default_3des_keys[keyNo]; uint8_t *key = default_3des_keys[keyNo];
if (try3DesAuthentication(key)) if (try3DesAuthentication(key)>0)
PrintAndLog("Authentication successful. 3des key: %s",sprint_hex(key, 8)); PrintAndLog("Authentication successful. 3des key: %s",sprint_hex(key, 16));
else else
PrintAndLog("Authentication failed"); PrintAndLog("Authentication failed");
@ -585,7 +581,12 @@ int try3DesAuthentication( uint8_t *key){
rol(random_b,8); rol(random_b,8);
memcpy(rnd_ab ,random_a,8); memcpy(rnd_ab ,random_a,8);
memcpy(rnd_ab+8,random_b,8); memcpy(rnd_ab+8,random_b,8);
//PrintAndLog(" RndA :%s", sprint_hex(random_a, 8));
//PrintAndLog(" enc(RndB) :%s", sprint_hex(enc_random_b, 8));
//PrintAndLog(" RndB :%s", sprint_hex(random_b, 8));
//PrintAndLog(" A+B :%s", sprint_hex(rnd_ab, 16));
des3_set2key_enc(&ctx, key); des3_set2key_enc(&ctx, key);
// context, mode, length, IV, input, output // context, mode, length, IV, input, output
des3_crypt_cbc(&ctx, DES_ENCRYPT, sizeof(rnd_ab), enc_random_b, rnd_ab, rnd_ab); des3_crypt_cbc(&ctx, DES_ENCRYPT, sizeof(rnd_ab), enc_random_b, rnd_ab, rnd_ab);
@ -607,16 +608,12 @@ int try3DesAuthentication( uint8_t *key){
// context, mode, length, IV, input, output // context, mode, length, IV, input, output
des3_crypt_cbc( &ctx, DES_DECRYPT, 8, enc_random_b, enc_resp, resp_random_a); des3_crypt_cbc( &ctx, DES_DECRYPT, 8, enc_random_b, enc_resp, resp_random_a);
//PrintAndLog(" enc(A+B) :%s", sprint_hex(rnd_ab, 16));
//PrintAndLog(" enc(RndA') :%s", sprint_hex(enc_resp, 8));
if ( !memcmp(resp_random_a, random_a, 8)) if ( !memcmp(resp_random_a, random_a, 8))
return 1; return 1;
return 0; return 0;
//PrintAndLog(" RndA :%s", sprint_hex(random_a, 8));
//PrintAndLog(" enc(RndB) :%s", sprint_hex(enc_random_b, 8));
//PrintAndLog(" RndB :%s", sprint_hex(random_b, 8));
//PrintAndLog(" A+B :%s", sprint_hex(random_a_and_b, 16));
//PrintAndLog(" enc(A+B) :%s", sprint_hex(random_a_and_b, 16));
//PrintAndLog(" enc(RndA') :%s", sprint_hex(data2+1, 8));
} }
/** /**
@ -730,7 +727,7 @@ int CmdHF14AMfUCRdBl(const char *Cmd)
PrintAndLog("Usage: hf mfu crdbl <block number> <password>"); PrintAndLog("Usage: hf mfu crdbl <block number> <password>");
PrintAndLog(""); PrintAndLog("");
PrintAndLog("sample: hf mfu crdbl 0"); PrintAndLog("sample: hf mfu crdbl 0");
PrintAndLog(" hf mfu crdbl 0 112233445566778899AABBCCDDEEFF"); PrintAndLog(" hf mfu crdbl 0 00112233445566778899AABBCCDDEEFF");
return 0; return 0;
} }
@ -854,6 +851,7 @@ int CmdHF14AMfUCWrBl(const char *Cmd){
int CmdHF14AMfucSetPwd(const char *Cmd){ int CmdHF14AMfucSetPwd(const char *Cmd){
uint8_t pwd[16] = {0x00}; uint8_t pwd[16] = {0x00};
char cmdp = param_getchar(Cmd, 0); char cmdp = param_getchar(Cmd, 0);
if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') { if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') {
@ -886,6 +884,7 @@ int CmdHF14AMfucSetPwd(const char *Cmd){
} }
else { else {
PrintAndLog("command execution time out"); PrintAndLog("command execution time out");
return 1;
} }
return 0; return 0;

View file

@ -19,9 +19,9 @@ void rol (uint8_t *data, const size_t len);
uint8_t requestAuthentication( uint8_t *nonce); uint8_t requestAuthentication( uint8_t *nonce);
int try3DesAuthentication( uint8_t *key); int try3DesAuthentication( uint8_t *key);
uint8_t GetHF14AMfU_Type(); uint8_t GetHF14AMfU_Type(void);
int usage_hf_mfu_dump(); int usage_hf_mfu_dump(void);
int CmdHFMFUltra(const char *Cmd); int CmdHFMFUltra(const char *Cmd);
int CmdHF14AMfUInfo(const char *Cmd); int CmdHF14AMfUInfo(const char *Cmd);