diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d470b081..99af46c86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,9 @@ 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] -- fix `hf felica raw` - wrong length calculationes. Thanks @dxl for the solutions! (@iceman1001) +- Added `data qrcode` - to generate QR codes from inside the pm3 client (@iceman1001) +- Fix unicode on mingw/proxspace (@nvx) +- Fix `hf felica raw` - wrong length calculationes. Thanks @dxl for the solutions! (@iceman1001) - Added basic QR code generation support. Thanks @mistial-dev for the idea! (@iceman1001) - Added identification of NDEF/Open print tag record (@iceman1001) - Added support for Bruce dump files [.rfid] (@iceman1001) diff --git a/client/src/cmddata.c b/client/src/cmddata.c index c7f225c7d..94bf3662f 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -42,6 +42,7 @@ #include "mbedtls/ctr_drbg.h" // random generator #include "atrs.h" // ATR lookup #include "crypto/libpcrypto.h" // Cryptography +#include "qrcode/qrcode.h" // QR Code lib uint8_t g_DemodBuffer[MAX_DEMOD_BUF_LEN] = { 0x00 }; @@ -3976,6 +3977,74 @@ static int CmdTestSaveState32S(const char *Cmd) { return PM3_SUCCESS; } +static int CmdQRcode(const char *Cmd) { + CLIParserContext *ctx; + CLIParserInit(&ctx, "data qrcode", + "Generate a QR code with the input data", + "data qrcode -f \n" + "data qrcode -d 123456789\n" + ); + + void *argtable[] = { + arg_param_begin, + arg_str0("f", "file", "", "Specify a filename"), + arg_str0("d", "data", "", "message as hex bytes"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, false); + + int fnlen = 0; + char filename[FILE_PATH_SIZE] = { 0 }; + CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen); + + int dlen = 0; + char data[1024] = { 0 }; + CLIParamStrToBuf(arg_get_str(ctx, 2), (uint8_t *)data, sizeof(data), &dlen); + CLIParserFree(ctx); + + if (fnlen && dlen) { + PrintAndLogEx(WARNING, "Please specify filename or datastring"); + return PM3_EINVARG; + } + + QRCode qrcode; + + if (fnlen) { + + uint8_t *dump = NULL; + size_t bytes_read = 0; + + // read from file + int res = pm3_load_dump(filename, (void **)&dump, &bytes_read, (MFBLOCK_SIZE * MIFARE_4K_MAXBLOCK)); + if (res != PM3_SUCCESS) { + return res; + } + + // check file size corresponds to card size. + if (dump != NULL) { + free(dump); + return PM3_EFILE; + } + } + + if (dlen) { + + // calc size of input data to get the correct + int smallest_version = (dlen + 17) / 20; + uint8_t qr_arr[qrcode_getBufferSize(smallest_version)]; + qrcode_initText(&qrcode, qr_arr, smallest_version, ECC_LOW, (char *) data); + + PrintAndLogEx(NORMAL, ""); + qrcode_print_matrix_utf8(&qrcode); + PrintAndLogEx(NORMAL, ""); + PrintAndLogEx(NORMAL, ""); + qrcode_print_matrix_utf8_2x2(&qrcode); + PrintAndLogEx(NORMAL, ""); + } + + return PM3_SUCCESS; +} + static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("General") "-------------------------"}, @@ -4028,6 +4097,7 @@ static command_t CommandTable[] = { {"diff", CmdDiff, AlwaysAvailable, "Diff of input files"}, {"hexsamples", CmdHexsamples, IfPm3Present, "Dump big buffer as hex bytes"}, {"samples", CmdSamples, IfPm3Present, "Get raw samples for graph window ( GraphBuffer )"}, + {"qrcode", CmdQRcode, AlwaysAvailable, "Create a QR code"}, {"-----------", CmdHelp, IfClientDebugEnabled, "------------------------- " _CYAN_("Debug") "-------------------------"}, {"test_ss8", CmdTestSaveState8, IfClientDebugEnabled, "Test the implementation of Buffer Save States (8-bit buffer)"}, diff --git a/client/src/pm3line_vocabulary.h b/client/src/pm3line_vocabulary.h index e25a48d56..2c894eced 100644 --- a/client/src/pm3line_vocabulary.h +++ b/client/src/pm3line_vocabulary.h @@ -120,6 +120,7 @@ const static vocabulary_t vocabulary[] = { { 1, "data diff" }, { 0, "data hexsamples" }, { 0, "data samples" }, + { 1, "data qrcode" }, { 0, "data test_ss8" }, { 0, "data test_ss32" }, { 0, "data test_ss32s" }, @@ -928,6 +929,7 @@ const static vocabulary_t vocabulary[] = { { 0, "script run pm3_mfd2eml.py" }, { 0, "script run pm3_nfc2eml.py" }, { 0, "script run pm3_resources.py" }, + { 0, "script run read_t-union.py" }, { 0, "script run spi_flash_decode.py" }, { 0, "script run theremin.py" }, { 0, "script run xorcheck.py" }, diff --git a/doc/commands.json b/doc/commands.json index 6b4e0e168..3ededab79 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -434,7 +434,7 @@ }, "data help": { "command": "data help", - "description": "help This help ----------- ------------------------- General------------------------- clear Clears various buffers used by the graph window hide Hide the graph window load Load contents of file into graph window num Converts dec/hex/bin plot Show the graph window print Print the data in the DemodBuffer save Save signal trace data setdebugmode Set Debugging Level on client side xor Xor a input string ----------- ------------------------- Modulation------------------------- biphaserawdecode Biphase decode bin stream in DemodBuffer detectclock Detect ASK, FSK, NRZ, PSK clock rate of wave in GraphBuffer fsktonrz Convert fsk2 to nrz wave for alternate fsk demodulating (for weak fsk) manrawdecode Manchester decode binary stream in DemodBuffer modulation Identify LF signal for clock and modulation rawdemod Demodulate the data in the GraphBuffer and output binary ----------- ------------------------- Graph------------------------- askedgedetect Adjust Graph for manual ASK demod autocorr Autocorrelation over window convertbitstream Convert GraphBuffer's 0/1 values to 127 / -127 cthreshold Average out all values between dirthreshold Max rising higher up-thres/ Min falling lower down-thres decimate Decimate samples envelope Generate square envelope of samples grid overlay grid on graph window getbitstream Convert GraphBuffer's >=1 values to 1 and <1 to 0 hpf Remove DC offset from trace iir Apply IIR buttersworth filter on plot data ltrim Trim samples from left of trace mtrim Trim out samples from the specified start to the specified stop norm Normalize max/min to +/-128 rtrim Trim samples from right of trace setgraphmarkers Set the markers in the graph window shiftgraphzero Shift 0 for Graphed wave + or - shift value timescale Set cursor display timescale undecimate Un-decimate samples zerocrossings Count time between zero-crossings ----------- ------------------------- Operations------------------------- asn1 ASN1 decoder atr ATR lookup bmap Convert hex value according a binary template crypto Encrypt and decrypt data diff Diff of input files --------------------------------------------------------------------------------------- data clear available offline: yes This function clears the BigBuf on device side and graph window ( graphbuffer )", + "description": "help This help ----------- ------------------------- General------------------------- clear Clears various buffers used by the graph window hide Hide the graph window load Load contents of file into graph window num Converts dec/hex/bin plot Show the graph window print Print the data in the DemodBuffer save Save signal trace data setdebugmode Set Debugging Level on client side xor Xor a input string ----------- ------------------------- Modulation------------------------- biphaserawdecode Biphase decode bin stream in DemodBuffer detectclock Detect ASK, FSK, NRZ, PSK clock rate of wave in GraphBuffer fsktonrz Convert fsk2 to nrz wave for alternate fsk demodulating (for weak fsk) manrawdecode Manchester decode binary stream in DemodBuffer modulation Identify LF signal for clock and modulation rawdemod Demodulate the data in the GraphBuffer and output binary ----------- ------------------------- Graph------------------------- askedgedetect Adjust Graph for manual ASK demod autocorr Autocorrelation over window convertbitstream Convert GraphBuffer's 0/1 values to 127 / -127 cthreshold Average out all values between dirthreshold Max rising higher up-thres/ Min falling lower down-thres decimate Decimate samples envelope Generate square envelope of samples grid overlay grid on graph window getbitstream Convert GraphBuffer's >=1 values to 1 and <1 to 0 hpf Remove DC offset from trace iir Apply IIR buttersworth filter on plot data ltrim Trim samples from left of trace mtrim Trim out samples from the specified start to the specified stop norm Normalize max/min to +/-128 rtrim Trim samples from right of trace setgraphmarkers Set the markers in the graph window shiftgraphzero Shift 0 for Graphed wave + or - shift value timescale Set cursor display timescale undecimate Un-decimate samples zerocrossings Count time between zero-crossings ----------- ------------------------- Operations------------------------- asn1 ASN1 decoder atr ATR lookup bmap Convert hex value according a binary template crypto Encrypt and decrypt data diff Diff of input files qrcode Create a QR code --------------------------------------------------------------------------------------- data clear available offline: yes This function clears the BigBuf on device side and graph window ( graphbuffer )", "notes": [ "data clear" ], @@ -622,6 +622,21 @@ ], "usage": "data print [-hisx] [-o ]" }, + "data qrcode": { + "command": "data qrcode", + "description": "Generate a QR code with the input data", + "notes": [ + "data qrcode -f ", + "data qrcode -d 123456789" + ], + "offline": true, + "options": [ + "-h, --help This help", + "-f, --file Specify a filename", + "-d, --data message as hex bytes" + ], + "usage": "data qrcode [-h] [-f ] [-d ]" + }, "data rawdemod": { "command": "data rawdemod", "description": "Demodulate the data in the GraphBuffer and output binary", @@ -7442,9 +7457,10 @@ "-e enable special write version/signature -MAGIC NTAG 21* ONLY-", "-r use password found in dumpfile to configure tag. Requires '-e' parameter to work", "-v, --verbose verbose output", - "-z, --dense dense dump output style" + "-z, --dense dense dump output style", + "--schann use secure channel. Must have key" ], - "usage": "hf mfu restore [-hlservz] -f [-k ]" + "usage": "hf mfu restore [-hlservz] -f [-k ] [--schann]" }, "hf mfu setkey": { "command": "hf mfu setkey", @@ -13681,8 +13697,8 @@ } }, "metadata": { - "commands_extracted": 784, + "commands_extracted": 785, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2025-10-17T11:36:43" + "extracted_on": "2025-11-10T15:12:49" } } diff --git a/doc/commands.md b/doc/commands.md index e157fb86a..27608e4c0 100644 --- a/doc/commands.md +++ b/doc/commands.md @@ -139,6 +139,7 @@ Check column "offline" for their availability. |`data diff `|Y |`Diff of input files` |`data hexsamples `|N |`Dump big buffer as hex bytes` |`data samples `|N |`Get raw samples for graph window ( GraphBuffer )` +|`data qrcode `|Y |`Create a QR code` |`data test_ss8 `|N |`Test the implementation of Buffer Save States (8-bit buffer)` |`data test_ss32 `|N |`Test the implementation of Buffer Save States (32-bit buffer)` |`data test_ss32s `|N |`Test the implementation of Buffer Save States (32-bit signed buffer)`