mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
prepare libamiibo.a inclusion
This commit is contained in:
parent
f7f80a9b9f
commit
bccb9069f9
7 changed files with 42 additions and 11 deletions
|
@ -40,6 +40,8 @@ CBORLIBPATH = ./tinycbor
|
||||||
CBORLIB = $(CBORLIBPATH)/tinycbor.a
|
CBORLIB = $(CBORLIBPATH)/tinycbor.a
|
||||||
REVENGPATH = ./reveng
|
REVENGPATH = ./reveng
|
||||||
REVENGLIB = $(REVENGPATH)/libreveng.a
|
REVENGLIB = $(REVENGPATH)/libreveng.a
|
||||||
|
AMIIBOLIBPATH = ./amiitool
|
||||||
|
AMIIBOLIB = $(AMIIBOLIBPATH)/libamiibo.a
|
||||||
|
|
||||||
# common libraries
|
# common libraries
|
||||||
MBEDTLSLIBPATH = ../common/mbedtls
|
MBEDTLSLIBPATH = ../common/mbedtls
|
||||||
|
@ -47,7 +49,7 @@ MBEDTLSLIB = $(OBJDIR)/libmbedtls.a
|
||||||
ZLIBPATH = ../common/zlib
|
ZLIBPATH = ../common/zlib
|
||||||
ZLIB = $(OBJDIR)/libz.a
|
ZLIB = $(OBJDIR)/libz.a
|
||||||
|
|
||||||
LIBS = -I$(LUALIBPATH) -I$(MBEDTLSLIBPATH) -I$(JANSSONLIBPATH) -I$(CBORLIBPATH) -I$(ZLIBPATH) -I$(REVENGPATH)
|
LIBS = -I$(LUALIBPATH) -I$(MBEDTLSLIBPATH) -I$(JANSSONLIBPATH) -I$(CBORLIBPATH) -I$(ZLIBPATH) -I$(REVENGPATH) -I$(AMIIBOLIBPATH)
|
||||||
INCLUDES_CLIENT = -I. -I../include -I../common -Iuart $(LIBS)
|
INCLUDES_CLIENT = -I. -I../include -I../common -Iuart $(LIBS)
|
||||||
CFLAGS ?= -Wall -Werror -g -O3
|
CFLAGS ?= -Wall -Werror -g -O3
|
||||||
# We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env:
|
# We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env:
|
||||||
|
@ -287,8 +289,8 @@ all: $(BINS)
|
||||||
all-static: LDLIBS:=-static $(LDLIBS)
|
all-static: LDLIBS:=-static $(LDLIBS)
|
||||||
all-static: $(BINS)
|
all-static: $(BINS)
|
||||||
|
|
||||||
proxmark3: LDLIBS+=$(LUALIB) $(JANSSONLIB) $(MBEDTLSLIB) $(CBORLIB) $(ZLIB) $(REVENGLIB) $(QTLDLIBS)
|
proxmark3: LDLIBS+=$(LUALIB) $(JANSSONLIB) $(MBEDTLSLIB) $(CBORLIB) $(ZLIB) $(REVENGLIB) $(AMIIBOLIB) $(QTLDLIBS)
|
||||||
proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(LUALIB) $(JANSSONLIB) $(CBORLIB) $(REVENGLIB) $(MBEDTLSLIB) $(ZLIB) lualibs/pm3_cmd.lua lualibs/mfc_default_keys.lua
|
proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(LUALIB) $(JANSSONLIB) $(CBORLIB) $(REVENGLIB) $(MBEDTLSLIB) $(ZLIB) $(AMIIBOLIB) lualibs/pm3_cmd.lua lualibs/mfc_default_keys.lua
|
||||||
$(info [=] LD $@)
|
$(info [=] LD $@)
|
||||||
$(Q)$(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(LDLIBS) -o $@
|
$(Q)$(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(LDLIBS) -o $@
|
||||||
|
|
||||||
|
@ -321,6 +323,7 @@ clean:
|
||||||
$(Q)$(MAKE) --no-print-directory -C $(JANSSONLIBPATH) clean
|
$(Q)$(MAKE) --no-print-directory -C $(JANSSONLIBPATH) clean
|
||||||
$(Q)$(MAKE) --no-print-directory -C $(CBORLIBPATH) clean
|
$(Q)$(MAKE) --no-print-directory -C $(CBORLIBPATH) clean
|
||||||
$(Q)$(MAKE) --no-print-directory -C $(REVENGPATH) clean
|
$(Q)$(MAKE) --no-print-directory -C $(REVENGPATH) clean
|
||||||
|
$(Q)$(MAKE) --no-print-directory -C $(AMIIBOLIBPATH) clean
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
$(info [@] Installing client to $(DESTDIR)$(PREFIX)...)
|
$(info [@] Installing client to $(DESTDIR)$(PREFIX)...)
|
||||||
|
@ -365,6 +368,10 @@ $(REVENGLIB):
|
||||||
$(info [*] MAKE reveng)
|
$(info [*] MAKE reveng)
|
||||||
$(Q)$(MAKE) --no-print-directory -C $(REVENGPATH) all
|
$(Q)$(MAKE) --no-print-directory -C $(REVENGPATH) all
|
||||||
|
|
||||||
|
$(AMIIBOLIB):
|
||||||
|
$(info [*] MAKE amiibo)
|
||||||
|
$(Q)$(MAKE) --no-print-directory -C $(AMIIBOLIBPATH) all
|
||||||
|
|
||||||
# common libraries:
|
# common libraries:
|
||||||
$(MBEDTLSLIB):
|
$(MBEDTLSLIB):
|
||||||
$(info [*] MAKE mbedtls)
|
$(info [*] MAKE mbedtls)
|
||||||
|
|
19
client/amiitool/Makefile
Normal file
19
client/amiitool/Makefile
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
MYSRCPATHS =
|
||||||
|
MYINCLUDES = -I. -I.. -I../jansson -I../../common/ -I../../include/
|
||||||
|
MYCFLAGS = -std=c99 -D_ISOC99_SOURCE
|
||||||
|
MYDEFS =
|
||||||
|
MYSRCS = \
|
||||||
|
amiibo.c \
|
||||||
|
drbg.c \
|
||||||
|
keygen.c
|
||||||
|
|
||||||
|
LIB_A = libamiibo.a
|
||||||
|
|
||||||
|
include ../../Makefile.host
|
||||||
|
|
||||||
|
# just for testing amiitool before complete migration into a lib:
|
||||||
|
|
||||||
|
amiitool:
|
||||||
|
gcc $(CFLAGS) \
|
||||||
|
amiitool.c $(MYSRCS) ../../common/commonutil.c ../ui.c -lreadline -lm ../../common/mbedtls/libmbedtls.a \
|
||||||
|
-o amiitool
|
|
@ -8,6 +8,7 @@
|
||||||
#include "amiibo.h"
|
#include "amiibo.h"
|
||||||
#include "mbedtls/md.h"
|
#include "mbedtls/md.h"
|
||||||
#include "mbedtls/aes.h"
|
#include "mbedtls/aes.h"
|
||||||
|
#include "commonutil.h"
|
||||||
|
|
||||||
#define HMAC_POS_DATA 0x008
|
#define HMAC_POS_DATA 0x008
|
||||||
#define HMAC_POS_TAG 0x1B4
|
#define HMAC_POS_TAG 0x1B4
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "keygen.h"
|
#include "keygen.h"
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
#define NFC3D_AMIIBO_SIZE 520
|
#define NFC3D_AMIIBO_SIZE 520
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <amiibo.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../loclass/fileutils.h"
|
#include "fileutils.h"
|
||||||
|
#include "amiibo.h"
|
||||||
|
#include "getopt.h"
|
||||||
|
|
||||||
#define NTAG215_SIZE 540
|
#define NTAG215_SIZE 540
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ static char *self;
|
||||||
|
|
||||||
void amiitool_usage() {
|
void amiitool_usage() {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"amiitool build %i (commit %s-%08x)\n"
|
/*"amiitool build %i (commit %s-%08x)\n"*/
|
||||||
"by Marcos Del Sol Vives <marcos@dracon.es>\n"
|
"by Marcos Del Sol Vives <marcos@dracon.es>\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Usage: %s (-e|-d|-c) -k keyfile [-i input] [-s input2] [-o output]\n"
|
"Usage: %s (-e|-d|-c) -k keyfile [-i input] [-s input2] [-o output]\n"
|
||||||
|
@ -28,7 +29,7 @@ void amiitool_usage() {
|
||||||
" -s input save file, save from this file will replace input file ones.\n"
|
" -s input save file, save from this file will replace input file ones.\n"
|
||||||
" -o output file. If not specified, stdout will be used.\n"
|
" -o output file. If not specified, stdout will be used.\n"
|
||||||
" -l decrypt files with invalid signatures.\n",
|
" -l decrypt files with invalid signatures.\n",
|
||||||
, self
|
self
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +63,9 @@ int main(int argc, char **argv) {
|
||||||
case 'i':
|
case 'i':
|
||||||
infile = optarg;
|
infile = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'k':
|
||||||
|
keyfile = optarg;
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
savefile = optarg;
|
savefile = optarg;
|
||||||
break;
|
break;
|
||||||
|
@ -83,7 +87,8 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
nfc3d_amiibo_keys amiiboKeys;
|
nfc3d_amiibo_keys amiiboKeys;
|
||||||
|
if (! LoadAmiikey(amiiboKeys, keyfile))
|
||||||
|
return 5;
|
||||||
|
|
||||||
uint8_t original[NTAG215_SIZE];
|
uint8_t original[NTAG215_SIZE];
|
||||||
uint8_t modified[NFC3D_AMIIBO_SIZE];
|
uint8_t modified[NFC3D_AMIIBO_SIZE];
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "drbg.h"
|
#include "drbg.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <mbedtls/md.h>
|
#include "mbedtls/md.h"
|
||||||
|
|
||||||
void nfc3d_drbg_init(nfc3d_drbg_ctx *ctx, const uint8_t *hmacKey, size_t hmacKeySize, const uint8_t *seed, size_t seedSize) {
|
void nfc3d_drbg_init(nfc3d_drbg_ctx *ctx, const uint8_t *hmacKey, size_t hmacKeySize, const uint8_t *seed, size_t seedSize) {
|
||||||
assert(ctx != NULL);
|
assert(ctx != NULL);
|
||||||
|
|
|
@ -19,7 +19,7 @@ void nfc3d_keygen_prepare_seed(const nfc3d_keygen_masterkeys *baseKeys, const ui
|
||||||
uint8_t *start = output;
|
uint8_t *start = output;
|
||||||
|
|
||||||
// 1: Copy whole type string
|
// 1: Copy whole type string
|
||||||
output = memccpy(output, baseKeys->typeString, '\0', sizeof(baseKeys->typeString));
|
output = (uint8_t *)strcpy((char *)output, baseKeys->typeString);
|
||||||
|
|
||||||
// 2: Append (16 - magicBytesSize) from the input seed
|
// 2: Append (16 - magicBytesSize) from the input seed
|
||||||
size_t leadingSeedBytes = 16 - baseKeys->magicBytesSize;
|
size_t leadingSeedBytes = 16 - baseKeys->magicBytesSize;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue