mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
amii tool now using fileutils
This commit is contained in:
parent
9293a25e3e
commit
bb0d309304
4 changed files with 18 additions and 20 deletions
|
@ -1,5 +1,5 @@
|
||||||
MYSRCPATHS =
|
MYSRCPATHS =
|
||||||
MYINCLUDES = -I. -I.. -I../jansson -I../../../common -I../../../common/mbedtls -I../../../include
|
MYINCLUDES = -I. -I.. -I../../../common -I../../../common/mbedtls -I../../../include -I../../src -I../../../include -I../jansson
|
||||||
MYCFLAGS =
|
MYCFLAGS =
|
||||||
MYDEFS =
|
MYDEFS =
|
||||||
MYSRCS = \
|
MYSRCS = \
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
#include "md.h"
|
#include "md.h"
|
||||||
#include "aes.h"
|
#include "aes.h"
|
||||||
#include "commonutil.h"
|
#include "commonutil.h"
|
||||||
|
#include "../src/fileutils.h"
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
#define HMAC_POS_DATA 0x008
|
#define HMAC_POS_DATA 0x008
|
||||||
#define HMAC_POS_TAG 0x1B4
|
#define HMAC_POS_TAG 0x1B4
|
||||||
|
|
||||||
|
@ -131,24 +133,29 @@ void nfc3d_amiibo_pack(const nfc3d_amiibo_keys *amiiboKeys, const uint8_t *plain
|
||||||
nfc3d_amiibo_internal_to_tag(cipher, tag);
|
nfc3d_amiibo_internal_to_tag(cipher, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nfc3d_amiibo_load_keys(nfc3d_amiibo_keys *amiiboKeys, const char *path) {
|
bool nfc3d_amiibo_load_keys(nfc3d_amiibo_keys *amiiboKeys) {
|
||||||
FILE *f = fopen(path, "rb");
|
|
||||||
if (!f) {
|
#define amiboo_key_fn "key_retail.bin"
|
||||||
|
|
||||||
|
uint8_t *dump = NULL;
|
||||||
|
size_t bytes_read = 0;
|
||||||
|
if (loadFile_safe(amiboo_key_fn, "", (void **)&dump, &bytes_read) != PM3_SUCCESS) {
|
||||||
|
PrintAndLogEx(FAILED, "File: " _YELLOW_("%s") ": not found or locked.", amiboo_key_fn);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t len = fread(amiiboKeys, sizeof(*amiiboKeys), 1, f);
|
if (bytes_read != sizeof(*amiiboKeys)) {
|
||||||
fclose(f);
|
free(dump);
|
||||||
|
|
||||||
if (len != sizeof(*amiiboKeys)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((amiiboKeys->data.magicBytesSize > 16) ||
|
if ((amiiboKeys->data.magicBytesSize > 16) || (amiiboKeys->tag.magicBytesSize > 16)) {
|
||||||
(amiiboKeys->tag.magicBytesSize > 16)) {
|
free(dump);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memcpy(amiiboKeys, dump, bytes_read);
|
||||||
|
free(dump);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ typedef struct {
|
||||||
|
|
||||||
bool nfc3d_amiibo_unpack(const nfc3d_amiibo_keys *amiiboKeys, const uint8_t *tag, uint8_t *plain);
|
bool nfc3d_amiibo_unpack(const nfc3d_amiibo_keys *amiiboKeys, const uint8_t *tag, uint8_t *plain);
|
||||||
void nfc3d_amiibo_pack(const nfc3d_amiibo_keys *amiiboKeys, const uint8_t *plain, uint8_t *tag);
|
void nfc3d_amiibo_pack(const nfc3d_amiibo_keys *amiiboKeys, const uint8_t *plain, uint8_t *tag);
|
||||||
bool nfc3d_amiibo_load_keys(nfc3d_amiibo_keys *amiiboKeys, const char *path);
|
bool nfc3d_amiibo_load_keys(nfc3d_amiibo_keys *amiiboKeys);
|
||||||
void nfc3d_amiibo_copy_app_data(const uint8_t *src, uint8_t *dst);
|
void nfc3d_amiibo_copy_app_data(const uint8_t *src, uint8_t *dst);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -33,15 +33,6 @@ void amiitool_usage(void) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool LoadAmiikey(nfc3d_amiibo_keys keys, char *keyfile) {
|
|
||||||
|
|
||||||
if (!nfc3d_amiibo_load_keys(&keys, keyfile)) {
|
|
||||||
PrintAndLogEx(ERR, "Could not load keys from '%s'", keyfile);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
self = argv[0];
|
self = argv[0];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue