mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
Merge branch 'master' into allin
update
This commit is contained in:
+5
-2
@@ -3,8 +3,11 @@ All notable changes to this project will be documented in this file.
|
||||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Add lf t55xx chk e <EM4100> option. Checks calculated password based on the EM4100 id from some white cloners forumla by paleopterix (@mwalker33)
|
||||
- Add lf t55xx sniff to allow extracting commands and passwords used be cloners. (@mwalker33)
|
||||
- Add low level support for 14b' aka Innovatron (@doegox)
|
||||
- Add doc/cliparser.md (@mwalker33)
|
||||
- Add `hf 14b apdu` - send APDU over ISO14443B (@iceman1001)
|
||||
- Add `lf t55xx chk e <EM4100> option` - Checks calculated password based on the EM4100 id from some white cloners forumla by paleopterix (@mwalker33)
|
||||
- Add `lf t55xx sniff` to allow extracting commands and passwords used be cloners. (@mwalker33)
|
||||
- Add options to `lf read`, `lf cmdread`, `lf sniff` for repeated acquisitions (@doegox)
|
||||
- Change options of `lf read` to match `lf cmdread`, this affects historical `d` and `s` options (@doegox)
|
||||
- Add `hf waveshare` to upload picture to Waveshare NFC-Powered e-Paper (@doegox)
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|[Notes on file formats used with Proxmark3](/doc/extensions_notes.md)|[Notes on MFU binary format](/doc/mfu_binary_format_notes.md)|[Notes on FPGA & ARM](/doc/fpga_arm_notes.md)|
|
||||
|[Developing standalone mode](/armsrc/Standalone/readme.md)|[Wiki about standalone mode](https://github.com/RfidResearchGroup/proxmark3/wiki/Standalone-mode)|[Notes on Magic cards](/doc/magic_cards_notes.md)|
|
||||
|[Notes on Color usage](/doc/colors_notes.md)|[Makefile vs CMake](/doc/md/Development/Makefile-vs-CMake.md)|[Notes on Cloner guns](/doc/cloner_notes.md)|
|
||||
|
||||
|[Notes on cliparser usage](/doc/cliparser.md)|||
|
||||
|
||||
## Build for non-RDV4 Proxmark3 platforms
|
||||
|
||||
|
||||
+7
-1
@@ -292,6 +292,12 @@ void tosend_reset(void) {
|
||||
}
|
||||
|
||||
void tosend_stuffbit(int b) {
|
||||
|
||||
if (toSend.max >= TOSEND_BUFFER_SIZE - 1) {
|
||||
Dbprintf(_RED_("toSend overflow"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (toSend.bit >= 8) {
|
||||
toSend.max++;
|
||||
toSend.buf[toSend.max] = 0;
|
||||
@@ -299,7 +305,7 @@ void tosend_stuffbit(int b) {
|
||||
}
|
||||
|
||||
if (b)
|
||||
toSend.buf[ toSend.max] |= (1 << (7 - toSend.bit));
|
||||
toSend.buf[toSend.max] |= (1 << (7 - toSend.bit));
|
||||
|
||||
toSend.bit++;
|
||||
|
||||
|
||||
+1
-2
@@ -1138,11 +1138,10 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
break;
|
||||
}
|
||||
case CMD_HF_ISO14443B_SIMULATE: {
|
||||
SimulateIso14443bTag(packet->oldarg[0]);
|
||||
SimulateIso14443bTag(packet->data.asBytes);
|
||||
break;
|
||||
}
|
||||
case CMD_HF_ISO14443B_COMMAND: {
|
||||
//SendRawCommand14443B(packet->oldarg[0],packet->oldarg[1],packet->oldarg[2],packet->data.asBytes);
|
||||
SendRawCommand14443B_Ex(packet);
|
||||
break;
|
||||
}
|
||||
|
||||
+6
-7
@@ -118,7 +118,7 @@ static int EPA_APDU(uint8_t *apdu, size_t length, uint8_t *response, uint16_t re
|
||||
case 'a':
|
||||
return iso14_apdu(apdu, (uint16_t) length, false, response, NULL);
|
||||
case 'b':
|
||||
return iso14443b_apdu(apdu, length, response, respmaxlen);
|
||||
return iso14443b_apdu(apdu, length, false, response, respmaxlen, NULL);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -222,14 +222,13 @@ int EPA_Read_CardAccess(uint8_t *buffer, size_t max_length) {
|
||||
// since the card doesn't always care for the expected length we send it,
|
||||
// we reserve 262 bytes here just to be safe (256-byte APDU + SW + ISO frame)
|
||||
uint8_t response_apdu[262];
|
||||
int rapdu_length = 0;
|
||||
|
||||
// select the file EF.CardAccess
|
||||
rapdu_length = EPA_APDU((uint8_t *)apdu_select_binary_cardaccess,
|
||||
sizeof(apdu_select_binary_cardaccess),
|
||||
response_apdu,
|
||||
sizeof(response_apdu)
|
||||
);
|
||||
int rapdu_length = EPA_APDU((uint8_t *)apdu_select_binary_cardaccess,
|
||||
sizeof(apdu_select_binary_cardaccess),
|
||||
response_apdu,
|
||||
sizeof(response_apdu)
|
||||
);
|
||||
|
||||
if (rapdu_length < 6
|
||||
|| response_apdu[rapdu_length - 4] != 0x90
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
#include "commonutil.h"
|
||||
#include "dbprint.h"
|
||||
#include "ticks.h"
|
||||
#include "mifare.h"
|
||||
#include "iso18.h"
|
||||
|
||||
// FeliCa timings
|
||||
// minimum time between the start bits of consecutive transfers from reader to tag: 6800 carrier (13.56MHz) cycles
|
||||
|
||||
+17
-4
@@ -1747,6 +1747,7 @@ void WriterHitag(hitag_function htf, hitag_data *htd, int page) {
|
||||
|
||||
// init as reader
|
||||
lf_init(true, false);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
|
||||
// Tag specific configuration settings (sof, timings, etc.)
|
||||
// TODO HTS
|
||||
@@ -1780,9 +1781,10 @@ void WriterHitag(hitag_function htf, hitag_data *htd, int page) {
|
||||
size_t max_nrzs = (8 * HITAG_FRAME_LEN + 5) * 2; // up to 2 nrzs per bit
|
||||
uint8_t nrz_samples[max_nrzs];
|
||||
size_t nrzs = 0;
|
||||
|
||||
int16_t checked = 0;
|
||||
uint32_t signal_size = 10000;
|
||||
bool turn_on = true;
|
||||
|
||||
while (bStop == false && BUTTON_PRESS() == false) {
|
||||
|
||||
// use malloc
|
||||
@@ -1818,9 +1820,20 @@ void WriterHitag(hitag_function htf, hitag_data *htd, int page) {
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for t_wait_2 carrier periods after the last tag bit before transmitting,
|
||||
lf_wait_periods(t_wait_2);
|
||||
command_start += t_wait_2;
|
||||
if (bStop) break;
|
||||
if (turn_on) {
|
||||
// Wait 50ms with field off to be sure the transponder gets reset
|
||||
SpinDelay(50);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);
|
||||
turn_on = false;
|
||||
// Wait with field on to be in "Wait for START_AUTH" timeframe
|
||||
lf_wait_periods(HITAG_T_WAIT_POWERUP + HITAG_T_WAIT_START_AUTH_MAX / 4);
|
||||
command_start += HITAG_T_WAIT_POWERUP + HITAG_T_WAIT_START_AUTH_MAX / 4;
|
||||
} else {
|
||||
// Wait for t_wait_2 carrier periods after the last tag bit before transmitting,
|
||||
lf_wait_periods(t_wait_2);
|
||||
command_start += t_wait_2;
|
||||
}
|
||||
|
||||
// Transmit the reader frame
|
||||
command_duration = hitag_reader_send_frame(tx, txlen);
|
||||
|
||||
+318
-161
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "mifare.h"
|
||||
#include "iso14b.h"
|
||||
#include "pm3_cmd.h"
|
||||
|
||||
#ifndef AddCrc14A
|
||||
@@ -27,12 +27,12 @@
|
||||
#endif
|
||||
|
||||
void iso14443b_setup(void);
|
||||
int iso14443b_apdu(uint8_t const *message, size_t message_length, uint8_t *response, uint16_t respmaxlen);
|
||||
int iso14443b_apdu(uint8_t const *msg, size_t msg_len, bool send_chaining, void *rxdata, uint16_t rxmaxlen, uint8_t *res);
|
||||
|
||||
int iso14443b_select_card(iso14b_card_select_t *card);
|
||||
int iso14443b_select_card_srx(iso14b_card_select_t *card);
|
||||
|
||||
void SimulateIso14443bTag(uint32_t pupi);
|
||||
void SimulateIso14443bTag(uint8_t *pupi);
|
||||
void AcquireRawAdcSamplesIso14443b(uint32_t parameter);
|
||||
void ReadSTMemoryIso14443b(uint16_t numofblocks);
|
||||
void SniffIso14443b(void);
|
||||
|
||||
+1
-1
@@ -465,7 +465,7 @@ void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint16_t period_0, uint
|
||||
} else if (*command == '1') {
|
||||
TurnReadLFOn(period_1);
|
||||
} else {
|
||||
for (uint8_t i=0; i < LF_CMDREAD_MAX_EXTRA_SYMBOLS; i++) {
|
||||
for (uint8_t i = 0; i < LF_CMDREAD_MAX_EXTRA_SYMBOLS; i++) {
|
||||
if (*command == symbol_extra[i]) {
|
||||
TurnReadLFOn(period_extra[i]);
|
||||
break;
|
||||
|
||||
+1
-1
@@ -332,7 +332,7 @@ uint32_t DoAcquisition(uint8_t decimation, uint8_t bits_per_sample, bool avg, in
|
||||
if (verbose) {
|
||||
if (checked == -1) {
|
||||
Dbprintf("lf sampling aborted");
|
||||
} else if ((cancel_counter == cancel_after) && (cancel_after > 0)){
|
||||
} else if ((cancel_counter == cancel_after) && (cancel_after > 0)) {
|
||||
Dbprintf("lf sampling cancelled after %u", cancel_counter);
|
||||
}
|
||||
|
||||
|
||||
@@ -253,6 +253,7 @@ set (TARGET_SOURCES
|
||||
${PM3_ROOT}/client/src/cmdlfguard.c
|
||||
${PM3_ROOT}/client/src/cmdlfhid.c
|
||||
${PM3_ROOT}/client/src/cmdlfhitag.c
|
||||
${PM3_ROOT}/client/src/cmdlfidteck.c
|
||||
${PM3_ROOT}/client/src/cmdlfindala.c
|
||||
${PM3_ROOT}/client/src/cmdlfio.c
|
||||
${PM3_ROOT}/client/src/cmdlfjablotron.c
|
||||
|
||||
@@ -447,6 +447,7 @@ SRCS = aidsearch.c \
|
||||
cmdlfgallagher.c \
|
||||
cmdlfhid.c \
|
||||
cmdlfhitag.c \
|
||||
cmdlfidteck.c \
|
||||
cmdlfindala.c \
|
||||
cmdlfio.c \
|
||||
cmdlfjablotron.c \
|
||||
|
||||
@@ -132,6 +132,7 @@ add_library(pm3rrg_rdv4 SHARED
|
||||
${PM3_ROOT}/client/src/cmdlfguard.c
|
||||
${PM3_ROOT}/client/src/cmdlfhid.c
|
||||
${PM3_ROOT}/client/src/cmdlfhitag.c
|
||||
${PM3_ROOT}/client/src/cmdlfidteck.c
|
||||
${PM3_ROOT}/client/src/cmdlfindala.c
|
||||
${PM3_ROOT}/client/src/cmdlfio.c
|
||||
${PM3_ROOT}/client/src/cmdlfjablotron.c
|
||||
@@ -209,4 +210,4 @@ target_link_libraries(pm3rrg_rdv4
|
||||
pm3rrg_rdv4_reveng
|
||||
pm3rrg_rdv4_whereami
|
||||
android
|
||||
log)
|
||||
log)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env -S pm3 -s
|
||||
|
||||
mem load f mfc_default_keys m
|
||||
mem load f t55xx_default_pwds t
|
||||
mem load f iclass_default_keys i
|
||||
mem load -f mfc_default_keys --mfc
|
||||
mem load -f t55xx_default_pwds --t55xx
|
||||
mem load -f iclass_default_keys --iclass
|
||||
lf t55xx deviceconfig z p
|
||||
|
||||
@@ -4195,7 +4195,8 @@ static void arg_cat_option(char *dest,
|
||||
#endif
|
||||
|
||||
if (datatype) {
|
||||
arg_cat(&dest, "=", &ndest);
|
||||
// arg_cat(&dest, "=", &ndest);
|
||||
arg_cat(&dest, " ", &ndest);
|
||||
if (optvalue) {
|
||||
arg_cat(&dest, "[", &ndest);
|
||||
arg_cat(&dest, datatype, &ndest);
|
||||
@@ -4270,10 +4271,15 @@ static void arg_cat_optionv(char *dest,
|
||||
}
|
||||
|
||||
if (datatype) {
|
||||
if (longopts)
|
||||
/* if (longopts)
|
||||
arg_cat(&dest, "=", &ndest);
|
||||
else if (shortopts)
|
||||
arg_cat(&dest, " ", &ndest);
|
||||
*/
|
||||
if (longopts)
|
||||
arg_cat(&dest, " ", &ndest);
|
||||
else if (shortopts)
|
||||
arg_cat(&dest, " ", &ndest);
|
||||
|
||||
if (optvalue) {
|
||||
arg_cat(&dest, "[", &ndest);
|
||||
|
||||
@@ -11,10 +11,25 @@
|
||||
#include "cliparser.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <util.h> // Get color constants
|
||||
#include <ui.h> // get PrintAndLogEx
|
||||
|
||||
#ifndef ARRAYLEN
|
||||
# define ARRAYLEN(x) (sizeof(x)/sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
// Custom Colors
|
||||
// To default the color return s
|
||||
#define _SectionTagColor_(s) _GREEN_(s)
|
||||
#define _ExampleColor_(s) _YELLOW_(s)
|
||||
#define _CommandColor_(s) _RED_(s)
|
||||
#define _DescriptionColor_(s) _CYAN_(s)
|
||||
#define _ArgColor_(s) s
|
||||
#define _ArgHelpColor_(s) s
|
||||
// End Custom Colors
|
||||
// Option width set to 30 to allow option descriptions to align. approx line 74
|
||||
// Example width set to 50 to allow help descriptions to align. approx line 93
|
||||
|
||||
int CLIParserInit(CLIParserContext **ctx, const char *vprogramName, const char *vprogramHint, const char *vprogramHelp) {
|
||||
*ctx = malloc(sizeof(CLIParserContext));
|
||||
if (!*ctx) {
|
||||
@@ -40,7 +55,7 @@ int CLIParserParseArg(CLIParserContext *ctx, int argc, char **argv, void *vargta
|
||||
/* verify the argtable[] entries were allocated sucessfully */
|
||||
if (arg_nullcheck(ctx->argtable) != 0) {
|
||||
/* NULL entries were detected, some allocations must have failed */
|
||||
printf("ERROR: Insufficient memory\n");
|
||||
PrintAndLogEx(ERR, "ERROR: Insufficient memory\n");
|
||||
fflush(stdout);
|
||||
return 2;
|
||||
}
|
||||
@@ -49,14 +64,50 @@ int CLIParserParseArg(CLIParserContext *ctx, int argc, char **argv, void *vargta
|
||||
|
||||
/* special case: '--help' takes precedence over error reporting */
|
||||
if ((argc < 2 && !allowEmptyExec) || ((struct arg_lit *)(ctx->argtable)[0])->count > 0) { // help must be the first record
|
||||
printf("Usage: %s", ctx->programName);
|
||||
arg_print_syntaxv(stdout, ctx->argtable, "\n");
|
||||
if (ctx->programHint)
|
||||
printf("%s\n\n", ctx->programHint);
|
||||
arg_print_glossary(stdout, ctx->argtable, " %-20s %s\n");
|
||||
printf("\n");
|
||||
if (ctx->programHelp)
|
||||
printf("%s \n", ctx->programHelp);
|
||||
PrintAndLogEx(NORMAL, "\n"_DescriptionColor_("%s"), ctx->programHint);
|
||||
|
||||
PrintAndLogEx(NORMAL, "\n"_SectionTagColor_("usage:"));
|
||||
PrintAndLogEx(NORMAL, " "_CommandColor_("%s")NOLF, ctx->programName);
|
||||
arg_print_syntax(stdout, ctx->argtable, "\n\n");
|
||||
|
||||
PrintAndLogEx(NORMAL, _SectionTagColor_("options:"));
|
||||
|
||||
arg_print_glossary(stdout, ctx->argtable, " "_ArgColor_("%-30s")" "_ArgHelpColor_("%s")"\n");
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
if (ctx->programHelp) {
|
||||
PrintAndLogEx(NORMAL, _SectionTagColor_("examples/notes:"));
|
||||
char *buf = NULL;
|
||||
int idx = 0;
|
||||
buf = realloc(buf, strlen(ctx->programHelp) + 1); // more then enough as we are splitting
|
||||
|
||||
char *p2; // pointer to split example from comment.
|
||||
int egWidth = 30;
|
||||
for (int i = 0; i <= strlen(ctx->programHelp); i++) { // <= so to get string terminator.
|
||||
buf[idx++] = ctx->programHelp[i];
|
||||
if ((ctx->programHelp[i] == '\n') || (ctx->programHelp[i] == 0x00)) {
|
||||
buf[idx - 1] = 0x00;
|
||||
p2 = strstr(buf, "->"); // See if the example has a comment.
|
||||
if (p2 != NULL) {
|
||||
*(p2 - 1) = 0x00;
|
||||
|
||||
if (strlen(buf) > 28)
|
||||
egWidth = strlen(buf) + 5;
|
||||
else
|
||||
egWidth = 30;
|
||||
|
||||
PrintAndLogEx(NORMAL, " "_ExampleColor_("%-*s")" %s", egWidth, buf, p2);
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, " "_ExampleColor_("%-*s"), egWidth, buf);
|
||||
}
|
||||
idx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
free(buf);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
return 1;
|
||||
@@ -66,7 +117,7 @@ int CLIParserParseArg(CLIParserContext *ctx, int argc, char **argv, void *vargta
|
||||
if (nerrors > 0) {
|
||||
/* Display the error details contained in the arg_end struct.*/
|
||||
arg_print_errors(stdout, ((struct arg_end *)(ctx->argtable)[vargtableLen - 1]), ctx->programName);
|
||||
printf("Try '%s --help' for more information.\n", ctx->programName);
|
||||
PrintAndLogEx(WARNING, "Try '%s --help' for more information.\n", ctx->programName);
|
||||
fflush(stdout);
|
||||
return 3;
|
||||
}
|
||||
@@ -74,6 +125,7 @@ int CLIParserParseArg(CLIParserContext *ctx, int argc, char **argv, void *vargta
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
enum ParserState {
|
||||
PS_FIRST,
|
||||
PS_ARGUMENT,
|
||||
@@ -152,7 +204,7 @@ int CLIParamHexToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int
|
||||
*datalen = 0;
|
||||
|
||||
int ibuf = 0;
|
||||
uint8_t tmp_buf[256] = {0};
|
||||
uint8_t tmp_buf[512] = {0};
|
||||
int res = CLIParamStrToBuf(argstr, tmp_buf, maxdatalen * 2, &ibuf); // *2 because here HEX
|
||||
if (res) {
|
||||
printf("Parameter error: buffer overflow.\n");
|
||||
@@ -186,7 +238,7 @@ int CLIParamStrToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int
|
||||
if (!argstr->count)
|
||||
return 0;
|
||||
|
||||
uint8_t tmp_buf[256] = {0};
|
||||
uint8_t tmp_buf[512] = {0};
|
||||
int ibuf = 0;
|
||||
|
||||
for (int i = 0; i < argstr->count; i++) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <stdlib.h>
|
||||
#include "util.h"
|
||||
|
||||
#define arg_param_begin arg_lit0("hH", "help", "This help")
|
||||
#define arg_param_begin arg_lit0("h", "help", "This help")
|
||||
#define arg_param_end arg_end(20)
|
||||
|
||||
#define arg_getsize(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
+13
-11
@@ -93,8 +93,10 @@ Command = {
|
||||
o.data = data
|
||||
return o
|
||||
end,
|
||||
parse = function (packet)
|
||||
local count, cmd, arg1, arg2, arg3, data = bin.unpack('LLLLH511', packet)
|
||||
parse = function(packet)
|
||||
local count, cmd, arg1, arg2, arg3, data = bin.unpack('LLLL', packet)
|
||||
local length = #packet - count + 1
|
||||
count, data = bin.unpack('H'..length, packet, count)
|
||||
return Command:new{cmd = cmd, arg1 = arg1, arg2 = arg2, arg3 = arg3, data = data}
|
||||
end
|
||||
}
|
||||
@@ -121,26 +123,28 @@ end
|
||||
-- @param command - the usb packet to send
|
||||
-- @param ignoreresponse - if set to true, we don't read the device answer packet
|
||||
-- which is usually recipe for fail. If not sent, the host will wait 2s for a
|
||||
-- response of type CMD_ACK
|
||||
-- response of type CMD_ACK or like NG use the CMD as ack..
|
||||
-- @return packet,nil if successful
|
||||
-- nil, errormessage if unsuccessful
|
||||
function Command:sendMIX( ignore_response, timeout )
|
||||
function Command:sendMIX( ignore_response, timeout, use_cmd_ack)
|
||||
if timeout == nil then timeout = TIMEOUT end
|
||||
local data = self.data
|
||||
local cmd = self.cmd
|
||||
local arg1, arg2, arg3 = self.arg1, self.arg2, self.arg3
|
||||
|
||||
local err, msg = core.SendCommandMIX(cmd, arg1, arg2, arg3, data)
|
||||
if err == nil then return err, msg end
|
||||
|
||||
if ignore_response then return true, nil end
|
||||
|
||||
if timeout == nil then timeout = TIMEOUT end
|
||||
local ack = _commands.CMD_ACK
|
||||
if use_cmd_ack then
|
||||
ack = cmd
|
||||
end
|
||||
|
||||
local response, msg = core.WaitForResponseTimeout(_commands.CMD_ACK, timeout)
|
||||
local response, msg = core.WaitForResponseTimeout(ack, timeout)
|
||||
if response == nil then
|
||||
return nil, 'Error, waiting for response timed out :: '..msg
|
||||
end
|
||||
|
||||
-- lets digest
|
||||
data = nil
|
||||
cmd = nil
|
||||
@@ -157,15 +161,13 @@ function Command:sendMIX( ignore_response, timeout )
|
||||
return packed, nil;
|
||||
end
|
||||
function Command:sendNG( ignore_response, timeout )
|
||||
if timeout == nil then timeout = TIMEOUT end
|
||||
local data = self.data
|
||||
local cmd = self.cmd
|
||||
local err, msg = core.SendCommandNG(cmd, data)
|
||||
if err == nil then return nil, msg end
|
||||
|
||||
if ignore_response then return true, nil end
|
||||
|
||||
if timeout == nil then timeout = TIMEOUT end
|
||||
|
||||
local response, msg = core.WaitForResponseTimeout(cmd, timeout)
|
||||
if response == nil then
|
||||
return nil, 'Error, waiting for response timed out :: '..msg
|
||||
|
||||
+12
-12
@@ -15,17 +15,18 @@ local cmds = require('commands')
|
||||
local utils = require('utils')
|
||||
|
||||
-- Shouldn't take longer than 2.5 seconds
|
||||
local TIMEOUT = 2500
|
||||
local TIMEOUT = 2000
|
||||
|
||||
local ISO14B_COMMAND = {
|
||||
ISO14B_CONNECT = 1,
|
||||
ISO14B_DISCONNECT = 2,
|
||||
ISO14B_APDU = 4,
|
||||
ISO14B_RAW = 8,
|
||||
ISO14B_CONNECT = 0x1,
|
||||
ISO14B_DISCONNECT = 0x2,
|
||||
ISO14B_APDU = 0x4,
|
||||
ISO14B_RAW = 0x8,
|
||||
ISO14B_REQUEST_TRIGGER = 0x10,
|
||||
ISO14B_APPEND_CRC = 0x20,
|
||||
ISO14B_SELECT_STD = 0x40,
|
||||
ISO14B_SELECT_SR = 0x80,
|
||||
ISO14B_SET_TIMEOUT = 0x100,
|
||||
}
|
||||
|
||||
local function parse14443b(data)
|
||||
@@ -74,9 +75,11 @@ local function read14443b(disconnect)
|
||||
arg1 = flags
|
||||
}
|
||||
|
||||
local result, err = command:sendMIX()
|
||||
info = nil
|
||||
|
||||
local result, err = command:sendMIX(false, TIMEOUT, true)
|
||||
if result then
|
||||
local count,cmd,arg0,arg1,arg2 = bin.unpack('LLLL',result)
|
||||
local count,cmd,arg0,arg1,arg2 = bin.unpack('LLLL', result)
|
||||
if arg0 == 0 then
|
||||
data = string.sub(result, count)
|
||||
info, err = parse14443b(data)
|
||||
@@ -88,12 +91,10 @@ local function read14443b(disconnect)
|
||||
end
|
||||
|
||||
if err then
|
||||
print(err)
|
||||
return nil, err
|
||||
end
|
||||
return info
|
||||
return info, nil
|
||||
end
|
||||
|
||||
---
|
||||
-- Waits for a mifare card to be placed within the vicinity of the reader.
|
||||
-- @return if successful: an table containing card info
|
||||
@@ -102,12 +103,11 @@ local function waitFor14443b()
|
||||
print('Waiting for card... press Enter to quit')
|
||||
while not core.kbd_enter_pressed() do
|
||||
res, err = read14443b(false)
|
||||
if res then return res end
|
||||
if res then return res, err end
|
||||
-- err means that there was no response from card
|
||||
end
|
||||
return nil, 'Aborted by user'
|
||||
end
|
||||
|
||||
---
|
||||
-- turns on the HF field.
|
||||
local function connect14443b()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user