marcus905 / libnfc

Automatically exported from code.google.com/p/libnfc
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Add auto-auth option to mftool #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice to have an "auto-authentication" option in "mftool".

Usage example:

mftool r a dump.mfd
(this is the new usage form)

mftool r a dump.mfd keys.mfd
(please, note the switch between dump and keys for the old usage form)

If no "keys" dump file is specified, the tool tries to authenticate with a
standard key list:

byte_t keys[] = {
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
    0xd3,0xf7,0xd3,0xf7,0xd3,0xf7,
    0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,
    0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,
    0x4d,0x3a,0x99,0xc3,0x51,0xdd,
    0x1a,0x98,0x2c,0x7e,0x45,0x9a,
    0xaa,0xbb,0xcc,0xdd,0xee,0xff
};

Pseudo code:

// Set the authentication information (uid)
memcpy(mp.mpa.abtUid,ti.tia.abtUid,4);

// Determin if we should use the a or the b key
mc = (bUseKeyA) ? MC_AUTH_A : MC_AUTH_B;

int num_keys = sizeof(keys) / 6;

for (int i = 0; i < num_keys; i++)
{
    memcpy(mp.mpa.abtKey, keys + (i*6), 6);
    if (nfc_initiator_mifare_cmd(device, mc, block, &mp))
        return true;

    nfc_initiator_select_tag(device, IM_ISO14443A_106, mp.mpa.abtUid, 4, NULL);
}

return false;

Original issue reported on code.google.com by emanuele.bertoldi on 28 Sep 2009 at 1:57

GoogleCodeExporter commented 9 years ago
Interesting suggest. Do you have any patch ?

Original comment by romu...@libnfc.org on 28 Sep 2009 at 2:54

GoogleCodeExporter commented 9 years ago
Yes but it's untested.

Original comment by emanuele.bertoldi on 28 Sep 2009 at 3:51

Attachments:

GoogleCodeExporter commented 9 years ago
A better patch version (but it has some issues, so please check the 
retro-compatibility).

Original comment by emanuele.bertoldi on 28 Sep 2009 at 4:41

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by r...@libnfc.org on 30 Sep 2009 at 10:15

GoogleCodeExporter commented 9 years ago
Should be fixed in r136.

Original comment by romu...@libnfc.org on 5 Oct 2009 at 3:30