This commit is contained in:
iceman1001 2021-02-17 07:33:29 +01:00
commit b979ed3e17

View file

@ -40,7 +40,7 @@ typedef struct {
// sample set for selftest. // sample set for selftest.
jooki_test_t jooks[] = { jooki_test_t jooks[] = {
{ {0x04, 0xDA, 0xB7, 0x6A, 0xE7, 0x4C, 0x80}, "ruxow8lnn88uyeX+", 0x01, 0x00}, { {0x04, 0xDA, 0xB7, 0x6A, 0xE7, 0x4C, 0x80}, "ruxow8lnn88uyeX+", 0x01, 0x00},
{ {0x04, 0xf0, 0x22, 0xc2, 0x33, 0x5e, 0x80}, "\0", 0x01 , 0x00}, { {0x04, 0xf0, 0x22, 0xc2, 0x33, 0x5e, 0x80}, "\0", 0x01, 0x00},
{ {0x04, 0x8C, 0xEC, 0xDA, 0xF0, 0x4A, 0x80}, "ONrsVf7jX6IaSNV6", 0x01, 0x01}, { {0x04, 0x8C, 0xEC, 0xDA, 0xF0, 0x4A, 0x80}, "ONrsVf7jX6IaSNV6", 0x01, 0x01},
{ {0x04, 0x92, 0xA7, 0x6A, 0xE7, 0x4C, 0x81}, "Hjjpcx/mZwuveTF+", 0x01, 0x02}, { {0x04, 0x92, 0xA7, 0x6A, 0xE7, 0x4C, 0x81}, "Hjjpcx/mZwuveTF+", 0x01, 0x02},
{ {0x04, 0xD0, 0xB0, 0x3A, 0xD3, 0x63, 0x80}, "\0", 0x01, 0x02}, { {0x04, 0xD0, 0xB0, 0x3A, 0xD3, 0x63, 0x80}, "\0", 0x01, 0x02},
@ -106,7 +106,7 @@ jooki_figure_t jooks_figures[] = {
}; };
static int jooki_lookup(uint8_t tid, uint8_t fid) { static int jooki_lookup(uint8_t tid, uint8_t fid) {
for (int i=0; i < ARRAYLEN(jooks_figures); i++) { for (int i = 0; i < ARRAYLEN(jooks_figures); i++) {
jooki_figure_t tmp = jooks_figures[i]; jooki_figure_t tmp = jooks_figures[i];
if (tmp.typeid == tid && tmp.figureid == fid) { if (tmp.typeid == tid && tmp.figureid == fid) {
return i; return i;
@ -135,7 +135,7 @@ static int jooki_encode(uint8_t *iv, uint8_t tid, uint8_t fid, uint8_t *uid, uin
return PM3_EINVARG; return PM3_EINVARG;
} }
uint8_t d[JOOKI_PLAIN_LEN] = {iv[0], iv[1],iv[2], tid, fid, uid[0], uid[1], uid[2], uid[3], uid[4], uid[5], uid[6]}; uint8_t d[JOOKI_PLAIN_LEN] = {iv[0], iv[1], iv[2], tid, fid, uid[0], uid[1], uid[2], uid[3], uid[4], uid[5], uid[6]};
uint8_t enc[JOOKI_PLAIN_LEN] = {0}; uint8_t enc[JOOKI_PLAIN_LEN] = {0};
for (uint8_t i = 0; i < JOOKI_PLAIN_LEN; i++) { for (uint8_t i = 0; i < JOOKI_PLAIN_LEN; i++) {
@ -150,7 +150,7 @@ static int jooki_encode(uint8_t *iv, uint8_t tid, uint8_t fid, uint8_t *uid, uin
size_t b64len = 0; size_t b64len = 0;
uint8_t b64[20]; uint8_t b64[20];
memset(b64, 0, 20); memset(b64, 0, 20);
mbedtls_base64_encode(b64, sizeof(b64), &b64len, (const unsigned char*)enc, sizeof(enc)); mbedtls_base64_encode(b64, sizeof(b64), &b64len, (const unsigned char *)enc, sizeof(enc));
memcpy(out, b64, b64len); memcpy(out, b64, b64len);
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -158,7 +158,7 @@ static int jooki_encode(uint8_t *iv, uint8_t tid, uint8_t fid, uint8_t *uid, uin
static int jooki_decode(uint8_t *b64, uint8_t *result) { static int jooki_decode(uint8_t *b64, uint8_t *result) {
uint8_t ndef[JOOKI_PLAIN_LEN] = {0}; uint8_t ndef[JOOKI_PLAIN_LEN] = {0};
size_t outputlen = 0; size_t outputlen = 0;
mbedtls_base64_decode(ndef, sizeof(ndef), &outputlen, (const unsigned char*)b64, 16); mbedtls_base64_decode(ndef, sizeof(ndef), &outputlen, (const unsigned char *)b64, 16);
PrintAndLogEx(DEBUG, "(decode_jooki) raw encoded... " _GREEN_("%s"), sprint_hex(ndef, sizeof(ndef))); PrintAndLogEx(DEBUG, "(decode_jooki) raw encoded... " _GREEN_("%s"), sprint_hex(ndef, sizeof(ndef)));
@ -237,7 +237,7 @@ static int jooki_selftest(void) {
uint8_t iv[JOOKI_IV_LEN] = {0}; uint8_t iv[JOOKI_IV_LEN] = {0};
uint8_t uid[JOOKI_UID_LEN] = {0}; uint8_t uid[JOOKI_UID_LEN] = {0};
uint8_t result[JOOKI_PLAIN_LEN] = {0}; uint8_t result[JOOKI_PLAIN_LEN] = {0};
jooki_decode((uint8_t*)jooks[i].b64, result); jooki_decode((uint8_t *)jooks[i].b64, result);
memcpy(iv, result, JOOKI_IV_LEN); memcpy(iv, result, JOOKI_IV_LEN);
uint8_t tid = result[3]; uint8_t tid = result[3];
@ -250,7 +250,7 @@ static int jooki_selftest(void) {
int idx = jooki_lookup(tid, fid); int idx = jooki_lookup(tid, fid);
PrintAndLogEx(INFO, "Encoded URL.. %s ( %s )", sprint_hex((const uint8_t*)jooks[i].b64, 12), jooks[i].b64); PrintAndLogEx(INFO, "Encoded URL.. %s ( %s )", sprint_hex((const uint8_t *)jooks[i].b64, 12), jooks[i].b64);
PrintAndLogEx(INFO, "Type......... %02x - " _GREEN_("%s") " ( %s )", tid, (idx != -1) ? jooks_figures[idx].typedesc : "n/a", tid_ok ? _GREEN_("ok") : _RED_("fail")); PrintAndLogEx(INFO, "Type......... %02x - " _GREEN_("%s") " ( %s )", tid, (idx != -1) ? jooks_figures[idx].typedesc : "n/a", tid_ok ? _GREEN_("ok") : _RED_("fail"));
PrintAndLogEx(INFO, "Figurine..... %02x - " _GREEN_("%s") " ( %s )", fid, (idx != -1) ? jooks_figures[idx].figdesc : "n/a", fid_ok ? _GREEN_("ok") : _RED_("fail")); PrintAndLogEx(INFO, "Figurine..... %02x - " _GREEN_("%s") " ( %s )", fid, (idx != -1) ? jooks_figures[idx].figdesc : "n/a", fid_ok ? _GREEN_("ok") : _RED_("fail"));
PrintAndLogEx(INFO, "iv........... %s", sprint_hex(iv, sizeof(iv))); PrintAndLogEx(INFO, "iv........... %s", sprint_hex(iv, sizeof(iv)));
@ -265,7 +265,7 @@ static int jooki_selftest(void) {
PrintAndLogEx(INFO, "NDEF raw .... %s", sprint_hex(ndefmsg, sizeof(ndefmsg))); PrintAndLogEx(INFO, "NDEF raw .... %s", sprint_hex(ndefmsg, sizeof(ndefmsg)));
int status = NDEFRecordsDecodeAndPrint(ndefmsg, sizeof(ndefmsg)); int status = NDEFRecordsDecodeAndPrint(ndefmsg, sizeof(ndefmsg));
if ( status != PM3_SUCCESS) { if (status != PM3_SUCCESS) {
status = NDEFDecodeAndPrint(ndefmsg, sizeof(ndefmsg), true); status = NDEFDecodeAndPrint(ndefmsg, sizeof(ndefmsg), true);
} }
PrintAndLogEx(INFO, "=================================================================="); PrintAndLogEx(INFO, "==================================================================");
@ -346,11 +346,11 @@ static int CmdHF14AJookiEncode(const char *Cmd) {
uint8_t tid, fid; uint8_t tid, fid;
if( ftid || ffid ) { if (ftid || ffid) {
figure_abbr = false; figure_abbr = false;
} }
if ( ftid > 0x04 || ffid > 0x20 ) { if (ftid > 0x04 || ffid > 0x20) {
PrintAndLogEx(ERR, "Use a valid Figure Type ID and Figure ID"); PrintAndLogEx(ERR, "Use a valid Figure Type ID and Figure ID");
return PM3_EINVARG; return PM3_EINVARG;
} }
@ -484,7 +484,7 @@ static int CmdHF14AJookiSim(const char *Cmd) {
uint8_t *data = calloc(144, sizeof(uint8_t)); uint8_t *data = calloc(144, sizeof(uint8_t));
memcpy(data, uid, 3); memcpy(data, uid, 3);
memcpy(data + (1*4), uid + 3, 4); memcpy(data + (1 * 4), uid + 3, 4);
// bbc0 // bbc0
data[3] = 0x88 ^ data[0] ^ data[1] ^ data[2]; data[3] = 0x88 ^ data[0] ^ data[1] ^ data[2];
@ -493,7 +493,7 @@ static int CmdHF14AJookiSim(const char *Cmd) {
data[8] = data[4] ^ data[5] ^ data[6] ^ data[7]; data[8] = data[4] ^ data[5] ^ data[6] ^ data[7];
// copy NDEF magic firs, skip BBC1 // copy NDEF magic firs, skip BBC1
memcpy(data + (2*4) + 1, "\x48\x00\x00\xE1\x10\x12\x00", 7); memcpy(data + (2 * 4) + 1, "\x48\x00\x00\xE1\x10\x12\x00", 7);
// copy raw NDEF // copy raw NDEF
jooki_create_ndef(b64, data + (4 * 4)); jooki_create_ndef(b64, data + (4 * 4));
@ -573,7 +573,7 @@ static int CmdHF14AJookiSim(const char *Cmd) {
} }
free(data); free(data);
PrintAndLogEx(INFO, "Done"); PrintAndLogEx(INFO, "Done");
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf 14a list") "` to view trace log" ); PrintAndLogEx(HINT, "Try `" _YELLOW_("hf 14a list") "` to view trace log");
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -651,7 +651,7 @@ static int CmdHF14AJookiClone(const char *Cmd) {
} }
PrintAndLogEx(INFO, "Done"); PrintAndLogEx(INFO, "Done");
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf mfu ndef") "` to view" ); PrintAndLogEx(HINT, "Try `" _YELLOW_("hf mfu ndef") "` to view");
return PM3_SUCCESS; return PM3_SUCCESS;
} }