From 1b75698cb7c184951d01057c3cf6354d826dc51a Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 20 Jan 2017 18:26:03 +0100 Subject: [PATCH] FIX: 'lf hitag2' forgot to add some of @marshmellow42 's changes. Lf search should works just fine now. --- client/cmdlfhitag.c | 14 ++++++++++++-- common/cmd.c | 2 -- common/cmd.h | 2 ++ common/crc32.c | 5 +---- common/crc32.h | 12 ++++++++++++ common/protocols.c | 3 --- common/protocols.h | 5 +++++ 7 files changed, 32 insertions(+), 11 deletions(-) diff --git a/client/cmdlfhitag.c b/client/cmdlfhitag.c index a5c3b8eb..ec290d89 100644 --- a/client/cmdlfhitag.c +++ b/client/cmdlfhitag.c @@ -222,9 +222,14 @@ int CmdLFHitagReader(const char *Cmd) { case RHT2F_TEST_AUTH_ATTEMPTS: { // No additional parameters needed } break; + case RHT2F_UID_ONLY: { + // No additional parameters needed + } break; default: { - PrintAndLog("Error: unkown reader function %d",htf); - PrintAndLog("Hitag reader functions"); + PrintAndLog("\nError: unkown reader function %d",htf); + PrintAndLog(""); + PrintAndLog("Usage: hitag reader "); + PrintAndLog("Reader Functions:"); PrintAndLog(" HitagS (0*)"); PrintAndLog(" 01 (Challenge) read all pages from a Hitag S tag"); PrintAndLog(" 02 (set to 0 if no authentication is needed) read all pages from a Hitag S tag"); @@ -234,6 +239,7 @@ int CmdLFHitagReader(const char *Cmd) { PrintAndLog(" 22 (authentication)"); PrintAndLog(" 23 (authentication) key is in format: ISK high + ISK low"); PrintAndLog(" 25 (test recorded authentications)"); + PrintAndLog(" 26 just read UID"); return 1; } break; } @@ -250,6 +256,9 @@ int CmdLFHitagReader(const char *Cmd) { uint32_t id = bytes_to_num(resp.d.asBytes,4); + if (htf == RHT2F_UID_ONLY){ + PrintAndLog("Valid Hitag2 tag found - UID: %08x",id); + } else { char filename[FILE_PATH_SIZE]; FILE* f = NULL; sprintf(filename,"%08x_%04x.ht2",id,(rand() & 0xffff)); @@ -263,6 +272,7 @@ int CmdLFHitagReader(const char *Cmd) { fwrite(resp.d.asBytes, 1, 48, f); fclose(f); PrintAndLog("Succesfully saved tag memory to [%s]",filename); + } return 0; } diff --git a/common/cmd.c b/common/cmd.c index 02257ac0..2111a8f5 100644 --- a/common/cmd.c +++ b/common/cmd.c @@ -31,8 +31,6 @@ */ #include "cmd.h" -#include "string.h" -#include "proxmark3.h" bool cmd_receive(UsbCommand* cmd) { diff --git a/common/cmd.h b/common/cmd.h index bc69ff61..2d25c5b2 100644 --- a/common/cmd.h +++ b/common/cmd.h @@ -36,6 +36,8 @@ #include "common.h" #include "usb_cmd.h" #include "usb_cdc.h" +#include "proxmark3.h" +#include "string.h" bool cmd_receive(UsbCommand* cmd); bool cmd_send(uint32_t cmd, uint32_t arg0, uint32_t arg1, uint32_t arg2, void* data, size_t len); diff --git a/common/crc32.c b/common/crc32.c index 69d770f4..bdf7b230 100644 --- a/common/crc32.c +++ b/common/crc32.c @@ -1,11 +1,8 @@ -#include -#include #include "crc32.h" #define htole32(x) (x) #define CRC32_PRESET 0xFFFFFFFF - static void crc32_byte (uint32_t *crc, const uint8_t value); static void crc32_byte (uint32_t *crc, const uint8_t value) { @@ -32,4 +29,4 @@ void crc32 (const uint8_t *data, const size_t len, uint8_t *crc) { void crc32_append (uint8_t *data, const size_t len) { crc32 (data, len, data + len); -} +} \ No newline at end of file diff --git a/common/crc32.h b/common/crc32.h index 7df7c79d..8876dc96 100644 --- a/common/crc32.h +++ b/common/crc32.h @@ -9,7 +9,19 @@ #ifndef __CRC32_H #define __CRC32_H +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + void crc32 (const uint8_t *data, const size_t len, uint8_t *crc); void crc32_append (uint8_t *data, const size_t len); +#ifdef __cplusplus +} +#endif + #endif diff --git a/common/protocols.c b/common/protocols.c index 420d575a..c78aeef4 100644 --- a/common/protocols.c +++ b/common/protocols.c @@ -1,6 +1,3 @@ -#include -#include -#include #include "protocols.h" // ATA55xx shared presets & routines diff --git a/common/protocols.h b/common/protocols.h index 7bec6a12..96a4b178 100644 --- a/common/protocols.h +++ b/common/protocols.h @@ -1,6 +1,11 @@ #ifndef PROTOCOLS_H #define PROTOCOLS_H +#include +#include +#include + + //The following data is taken from http://www.proxmark.org/forum/viewtopic.php?pid=13501#p13501 /* ISO14443A (usually NFC tags) -- 2.39.2