mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 18:48:13 -07:00
CHG: generic code clean up. Removal of commented code.
CHG: USB_CMD_DATA_SIZE is now used as maxsize for transfer of data between client and pm3device CHG: suggested a fix for the underscore problem in ioclass\fileutils.c ADD: tnp3xx support ADD: nxp tag idents. ADD: identifiction of chinese backdoor commands to hf 14a reader.
This commit is contained in:
parent
6f101995b6
commit
3fe4ff4f03
40 changed files with 518 additions and 700 deletions
|
@ -329,7 +329,7 @@ int CmdBiphaseDecodeRaw(const char *Cmd)
|
|||
//prints binary found and saves in graphbuffer for further commands
|
||||
int Cmdaskrawdemod(const char *Cmd)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
int invert=0;
|
||||
int clk=0;
|
||||
uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0};
|
||||
|
@ -340,7 +340,7 @@ int Cmdaskrawdemod(const char *Cmd)
|
|||
}
|
||||
int BitLen = getFromGraphBuf(BitStream);
|
||||
int errCnt=0;
|
||||
errCnt = askrawdemod(BitStream, &BitLen,&clk,&invert);
|
||||
errCnt = askrawdemod(BitStream, &BitLen, &clk, &invert);
|
||||
if (errCnt==-1){ //throw away static - allow 1 and -1 (in case of threshold command first)
|
||||
PrintAndLog("no data found");
|
||||
return 0;
|
||||
|
@ -349,19 +349,14 @@ int Cmdaskrawdemod(const char *Cmd)
|
|||
PrintAndLog("Using Clock: %d - invert: %d - Bits Found: %d",clk,invert,BitLen);
|
||||
//PrintAndLog("Data start pos:%d, lastBit:%d, stop pos:%d, numBits:%d",iii,lastBit,i,bitnum);
|
||||
//move BitStream back to GraphBuffer
|
||||
|
||||
ClearGraph(0);
|
||||
for (i=0; i < BitLen; ++i){
|
||||
GraphBuffer[i]=BitStream[i];
|
||||
}
|
||||
GraphTraceLen=BitLen;
|
||||
RepaintGraphWindow();
|
||||
|
||||
//output
|
||||
setGraphBuf(BitStream, BitLen);
|
||||
|
||||
if (errCnt>0){
|
||||
PrintAndLog("# Errors during Demoding (shown as 77 in bit stream): %d",errCnt);
|
||||
}
|
||||
|
||||
PrintAndLog("ASK demoded bitstream:");
|
||||
|
||||
// Now output the bitstream to the scrollback by line of 16 bits
|
||||
printBitStream(BitStream,BitLen);
|
||||
|
||||
|
@ -477,10 +472,6 @@ int CmdBitstream(const char *Cmd)
|
|||
bit ^= 1;
|
||||
|
||||
AppendGraph(0, clock, bit);
|
||||
// for (j = 0; j < (int)(clock/2); j++)
|
||||
// GraphBuffer[(i * clock) + j] = bit ^ 1;
|
||||
// for (j = (int)(clock/2); j < clock; j++)
|
||||
// GraphBuffer[(i * clock) + j] = bit;
|
||||
}
|
||||
|
||||
RepaintGraphWindow();
|
||||
|
@ -510,8 +501,6 @@ int CmdDec(const char *Cmd)
|
|||
int CmdDetectClockRate(const char *Cmd)
|
||||
{
|
||||
GetClock("",0,0);
|
||||
//int clock = DetectASKClock(0);
|
||||
//PrintAndLog("Auto-detected clock rate: %d", clock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -773,8 +762,7 @@ int CmdFSKdemod(const char *Cmd) //old CmdFSKdemod needs updating
|
|||
PrintAndLog("actual data bits start at sample %d", maxPos);
|
||||
PrintAndLog("length %d/%d", highLen, lowLen);
|
||||
|
||||
uint8_t bits[46];
|
||||
bits[sizeof(bits)-1] = '\0';
|
||||
uint8_t bits[46] = {0x00};
|
||||
|
||||
// find bit pairs and manchester decode them
|
||||
for (i = 0; i < arraylen(bits) - 1; ++i) {
|
||||
|
@ -881,22 +869,21 @@ int CmdHpf(const char *Cmd)
|
|||
|
||||
int CmdSamples(const char *Cmd)
|
||||
{
|
||||
int cnt = 0;
|
||||
int n;
|
||||
uint8_t got[40000];
|
||||
uint8_t got[40000] = {0x00};
|
||||
|
||||
n = strtol(Cmd, NULL, 0);
|
||||
if (n == 0) n = 6000;
|
||||
if (n > sizeof(got)) n = sizeof(got);
|
||||
int n = strtol(Cmd, NULL, 0);
|
||||
if (n == 0)
|
||||
n = 20000;
|
||||
|
||||
if (n > sizeof(got))
|
||||
n = sizeof(got);
|
||||
|
||||
PrintAndLog("Reading %d samples\n", n);
|
||||
PrintAndLog("Reading %d samples from device memory\n", n);
|
||||
GetFromBigBuf(got,n,0);
|
||||
WaitForResponse(CMD_ACK,NULL);
|
||||
for (int j = 0; j < n; j++) {
|
||||
GraphBuffer[cnt++] = ((int)got[j]) - 128;
|
||||
for (int j = 0; j < n; ++j) {
|
||||
GraphBuffer[j] = ((int)got[j]) - 128;
|
||||
}
|
||||
|
||||
PrintAndLog("Done!\n");
|
||||
GraphTraceLen = n;
|
||||
RepaintGraphWindow();
|
||||
return 0;
|
||||
|
@ -1340,8 +1327,8 @@ static command_t CommandTable[] =
|
|||
{"help", CmdHelp, 1, "This help"},
|
||||
{"amp", CmdAmp, 1, "Amplify peaks"},
|
||||
{"askdemod", Cmdaskdemod, 1, "<0 or 1> -- Attempt to demodulate simple ASK tags"},
|
||||
{"askmandemod", Cmdaskmandemod, 1, "[clock] [invert<0 or 1>] -- Attempt to demodulate ASK/Manchester tags and output binary (args optional[clock will try Auto-detect])"},
|
||||
{"askrawdemod", Cmdaskrawdemod, 1, "[clock] [invert<0 or 1>] -- Attempt to demodulate ASK tags and output binary (args optional[clock will try Auto-detect])"},
|
||||
{"askmandemod", Cmdaskmandemod, 1, "[clock] [invert <0|1>] -- Attempt to demodulate ASK/Manchester tags and output binary"},
|
||||
{"askrawdemod", Cmdaskrawdemod, 1, "[clock] [invert <0|1>] -- Attempt to demodulate ASK tags and output binary"},
|
||||
{"autocorr", CmdAutoCorr, 1, "<window length> -- Autocorrelation over window"},
|
||||
{"biphaserawdecode",CmdBiphaseDecodeRaw,1,"[offset] Biphase decode binary stream already in graph buffer (offset = bit to start decode from)"},
|
||||
{"bitsamples", CmdBitsamples, 0, "Get raw samples as bitstring"},
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
//#include "proxusb.h"
|
||||
#include "proxmark3.h"
|
||||
#include "graph.h"
|
||||
#include "ui.h"
|
||||
|
|
|
@ -67,6 +67,7 @@ int CmdHF14AReader(const char *Cmd)
|
|||
|
||||
switch (card.sak) {
|
||||
case 0x00: PrintAndLog("TYPE : NXP MIFARE Ultralight | Ultralight C"); break;
|
||||
case 0x01: PrintAndLog("TYPE : NXP TNP3xxx Activision Game Appliance"); break;
|
||||
case 0x04: PrintAndLog("TYPE : NXP MIFARE (various !DESFire !DESFire EV1)"); break;
|
||||
case 0x08: PrintAndLog("TYPE : NXP MIFARE CLASSIC 1k | Plus 2k SL1"); break;
|
||||
case 0x09: PrintAndLog("TYPE : NXP MIFARE Mini 0.3k"); break;
|
||||
|
@ -301,6 +302,7 @@ int CmdHF14ASim(const char *Cmd)
|
|||
PrintAndLog(" 2 = MIFARE Ultralight");
|
||||
PrintAndLog(" 3 = MIFARE DESFIRE");
|
||||
PrintAndLog(" 4 = ISO/IEC 14443-4");
|
||||
PrintAndLog(" 5 = MIFARE TNP3XXX");
|
||||
PrintAndLog("");
|
||||
return 1;
|
||||
}
|
||||
|
@ -328,10 +330,6 @@ int CmdHF14ASim(const char *Cmd)
|
|||
// At lease save the mandatory first part of the UID
|
||||
c.arg[0] = long_uid & 0xffffffff;
|
||||
|
||||
|
||||
// At lease save the mandatory first part of the UID
|
||||
c.arg[0] = long_uid & 0xffffffff;
|
||||
|
||||
if (c.arg[1] == 0) {
|
||||
PrintAndLog("Emulating ISO/IEC 14443 type A tag with UID %01d %08x %08x",c.arg[0],c.arg[1],c.arg[2]);
|
||||
}
|
||||
|
|
|
@ -14,15 +14,16 @@
|
|||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "iso14443crc.h"
|
||||
//#include "proxusb.h"
|
||||
#include "proxmark3.h"
|
||||
#include "data.h"
|
||||
#include "graph.h"
|
||||
#include "util.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmdhf14b.h"
|
||||
#include "cmdmain.h"
|
||||
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
int CmdHF14BDemod(const char *Cmd)
|
||||
|
@ -387,6 +388,66 @@ int CmdHF14BCmdRaw (const char *cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CmdHF14BWrite( const char *Cmd){
|
||||
|
||||
/*
|
||||
* For SRIX4K blocks 00 - 7F
|
||||
* hf 14b raw -c -p 09 $srix4kwblock $srix4kwdata
|
||||
*
|
||||
* For SR512 blocks 00 - 0F
|
||||
* hf 14b raw -c -p 09 $sr512wblock $sr512wdata
|
||||
*
|
||||
* Special block FF = otp_lock_reg block.
|
||||
* Data len 4 bytes-
|
||||
*/
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
uint8_t blockno = -1;
|
||||
uint8_t data[4] = {0x00};
|
||||
bool isSrix4k = true;
|
||||
char str[20];
|
||||
|
||||
if (cmdp == 'h' || cmdp == 'H') {
|
||||
PrintAndLog("Usage: hf 14b write <1|2> <BLOCK> <DATA>");
|
||||
PrintAndLog("");
|
||||
PrintAndLog(" sample: hf 14b write 1 127 11223344");
|
||||
PrintAndLog(" sample: hf 14b write 1 255 11223344");
|
||||
PrintAndLog(" sample: hf 14b write 2 15 11223344");
|
||||
PrintAndLog(" sample: hf 14b write 2 255 11223344");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( param_getchar(Cmd, 0) == '2' )
|
||||
isSrix4k = false;
|
||||
|
||||
blockno = param_get8(Cmd, 1);
|
||||
|
||||
if ( isSrix4k ){
|
||||
if ( blockno > 0x7f && blockno != 0xff ){
|
||||
PrintAndLog("Block number out of range");
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if ( blockno > 0x0f && blockno != 0xff ){
|
||||
PrintAndLog("Block number out of range");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (param_gethex(Cmd, 2, data, 8)) {
|
||||
PrintAndLog("Data must include 8 HEX symbols");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( blockno == 0xff)
|
||||
PrintAndLog("Writing to special block %02X [ %s]", blockno, sprint_hex(data,4) );
|
||||
else
|
||||
PrintAndLog("Writing to block %02X [ %s]", blockno, sprint_hex(data,4) );
|
||||
|
||||
sprintf(str, "-c -p 09 %02x %02x%02x%02x%02x", blockno, data[0], data[1], data[2], data[3]);
|
||||
CmdHF14BCmdRaw(str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static command_t CommandTable[] =
|
||||
{
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
|
@ -399,6 +460,7 @@ static command_t CommandTable[] =
|
|||
{"sri512read", CmdSri512Read, 0, "Read contents of a SRI512 tag"},
|
||||
{"srix4kread", CmdSrix4kRead, 0, "Read contents of a SRIX4K tag"},
|
||||
{"raw", CmdHF14BCmdRaw, 0, "Send raw hex data to tag"},
|
||||
{"write", CmdHF14BWrite, 0, "Write data to a SRI512 | SRIX4K tag"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
|
|
@ -21,5 +21,6 @@ int CmdHFSimlisten(const char *Cmd);
|
|||
int CmdHF14BSnoop(const char *Cmd);
|
||||
int CmdSri512Read(const char *Cmd);
|
||||
int CmdSrix4kRead(const char *Cmd);
|
||||
int CmdHF14BWrite( const char *cmd);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,11 +26,12 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
//#include "proxusb.h"
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "data.h"
|
||||
#include "graph.h"
|
||||
#include "ui.h"
|
||||
#include "util.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmdhf15.h"
|
||||
#include "iso15693tools.h"
|
||||
|
@ -58,8 +59,10 @@ const productName uidmapping[] = {
|
|||
{ 0xE001000000000000LL, 16, "Motorola" },
|
||||
{ 0xE002000000000000LL, 16, "ST Microelectronics" },
|
||||
{ 0xE003000000000000LL, 16, "Hitachi" },
|
||||
{ 0xE004000000000000LL, 16, "Philips" },
|
||||
{ 0xE004010000000000LL, 24, "Philips; IC SL2 ICS20" },
|
||||
{ 0xE004000000000000LL, 16, "NXP(Philips)" },
|
||||
{ 0xE004010000000000LL, 24, "NXP(Philips); IC SL2 ICS20/ICS21(SLI) ICS2002/ICS2102(SLIX)" },
|
||||
{ 0xE004020000000000LL, 24, "NXP(Philips); IC SL2 ICS53/ICS54(SLI-S) ICS5302/ICS5402(SLIX-S)" },
|
||||
{ 0xE004030000000000LL, 24, "NXP(Philips); IC SL2 ICS50/ICS51(SLI-L) ICS5002/ICS5102(SLIX-L)" },
|
||||
{ 0xE005000000000000LL, 16, "Infineon" },
|
||||
{ 0xE005400000000000LL, 24, "Infineon; 56x32bit" },
|
||||
{ 0xE006000000000000LL, 16, "Cylinc" },
|
||||
|
@ -273,7 +276,28 @@ int CmdHF15Reader(const char *Cmd)
|
|||
// Simulation is still not working very good
|
||||
int CmdHF15Sim(const char *Cmd)
|
||||
{
|
||||
UsbCommand c = {CMD_SIMTAG_ISO_15693, {strtol(Cmd, NULL, 0), 0, 0}};
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
uint8_t uid[8] = {0x00};
|
||||
|
||||
//E0 16 24 00 00 00 00 00
|
||||
if (cmdp == 'h' || cmdp == 'H') {
|
||||
PrintAndLog("Usage: hf 15 sim <UID>");
|
||||
PrintAndLog("");
|
||||
PrintAndLog(" sample: hf 15 sim E016240000000000");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (param_gethex(Cmd, 0, uid, 16)) {
|
||||
PrintAndLog("UID must include 16 HEX symbols");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PrintAndLog("Starting simulating UID %02X %02X %02X %02X %02X %02X %02X %02X",
|
||||
uid[0],uid[1],uid[2],uid[3],uid[4], uid[5], uid[6], uid[7]);
|
||||
|
||||
UsbCommand c = {CMD_SIMTAG_ISO_15693, {0, 0, 0}};
|
||||
memcpy(c.d.asBytes,uid,8);
|
||||
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
}
|
||||
|
@ -324,7 +348,7 @@ int CmdHF15DumpMem(const char*Cmd) {
|
|||
if (!(recv[0] & ISO15_RES_ERROR)) {
|
||||
retry=0;
|
||||
*output=0; // reset outputstring
|
||||
sprintf(output, "Block %2i ",blocknum);
|
||||
sprintf(output, "Block %02x ",blocknum);
|
||||
for ( int i=1; i<resp.arg[0]-2; i++) { // data in hex
|
||||
sprintf(output+strlen(output),"%02X ",recv[i]);
|
||||
}
|
||||
|
@ -421,8 +445,9 @@ int CmdHF15CmdInquiry(const char *Cmd)
|
|||
int CmdHF15CmdDebug( const char *cmd) {
|
||||
int debug=atoi(cmd);
|
||||
if (strlen(cmd)<1) {
|
||||
PrintAndLog("Usage: hf 15 cmd debug <0/1>");
|
||||
PrintAndLog(" 0..no debugging output 1..turn debugging on");
|
||||
PrintAndLog("Usage: hf 15 cmd debug <0|1>");
|
||||
PrintAndLog(" 0 no debugging");
|
||||
PrintAndLog(" 1 turn debugging on");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -536,7 +561,7 @@ int CmdHF15CmdRaw (const char *cmd) {
|
|||
int prepareHF15Cmd(char **cmd, UsbCommand *c, uint8_t iso15cmd[], int iso15cmdlen) {
|
||||
int temp;
|
||||
uint8_t *req=c->d.asBytes;
|
||||
uint8_t uid[8] = {0};
|
||||
uint8_t uid[8] = {0x00};
|
||||
uint32_t reqlen=0;
|
||||
|
||||
// strip
|
||||
|
|
|
@ -45,7 +45,7 @@ int CmdHFEPACollectPACENonces(const char *Cmd)
|
|||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
|
||||
WaitForResponse(CMD_ACK,&resp);
|
||||
WaitForResponse(CMD_ACK,&resp);
|
||||
|
||||
// check if command failed
|
||||
if (resp.arg[0] != 0) {
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include <sys/stat.h>
|
||||
#include "iso14443crc.h" // Can also be used for iClass, using 0xE012 as CRC-type
|
||||
#include "data.h"
|
||||
//#include "proxusb.h"
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
//#include "proxusb.h"
|
||||
#include "proxmark3.h"
|
||||
#include "data.h"
|
||||
#include "ui.h"
|
||||
|
@ -266,7 +265,6 @@ int CmdLegicSave(const char *Cmd)
|
|||
int remainder = requested % 8;
|
||||
requested = requested + 8 - remainder;
|
||||
}
|
||||
|
||||
if (offset + requested > sizeof(got)) {
|
||||
PrintAndLog("Tried to read past end of buffer, <bytes> + <offset> > 1024");
|
||||
return 0;
|
||||
|
|
|
@ -36,7 +36,6 @@ start:
|
|||
//flush queue
|
||||
while (ukbhit()) getchar();
|
||||
|
||||
|
||||
// wait cycle
|
||||
while (true) {
|
||||
printf(".");
|
||||
|
@ -78,6 +77,7 @@ start:
|
|||
num_to_bytes(r_key, 6, keyBlock);
|
||||
isOK = mfCheckKeys(0, 0, 1, keyBlock, &r_key);
|
||||
}
|
||||
|
||||
if (!isOK)
|
||||
PrintAndLog("Found valid key:%012"llx, r_key);
|
||||
else
|
||||
|
@ -88,6 +88,7 @@ start:
|
|||
goto start;
|
||||
}
|
||||
|
||||
PrintAndLog("");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -437,7 +438,6 @@ int CmdHF14AMfRdSc(const char *Cmd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
uint8_t FirstBlockOfSector(uint8_t sectorNo)
|
||||
{
|
||||
if (sectorNo < 32) {
|
||||
|
@ -447,7 +447,6 @@ uint8_t FirstBlockOfSector(uint8_t sectorNo)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
uint8_t NumBlocksPerSector(uint8_t sectorNo)
|
||||
{
|
||||
if (sectorNo < 32) {
|
||||
|
@ -457,7 +456,6 @@ uint8_t NumBlocksPerSector(uint8_t sectorNo)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int CmdHF14AMfDump(const char *Cmd)
|
||||
{
|
||||
uint8_t sectorNo, blockNo;
|
||||
|
@ -497,8 +495,7 @@ int CmdHF14AMfDump(const char *Cmd)
|
|||
return 1;
|
||||
}
|
||||
|
||||
// Read key file
|
||||
|
||||
// Read keys A from file
|
||||
for (sectorNo=0; sectorNo<numSectors; sectorNo++) {
|
||||
if (fread( keyA[sectorNo], 1, 6, fin ) == 0) {
|
||||
PrintAndLog("File reading error.");
|
||||
|
@ -507,6 +504,7 @@ int CmdHF14AMfDump(const char *Cmd)
|
|||
}
|
||||
}
|
||||
|
||||
// Read keys B from file
|
||||
for (sectorNo=0; sectorNo<numSectors; sectorNo++) {
|
||||
if (fread( keyB[sectorNo], 1, 6, fin ) == 0) {
|
||||
PrintAndLog("File reading error.");
|
||||
|
@ -556,6 +554,7 @@ int CmdHF14AMfDump(const char *Cmd)
|
|||
for (sectorNo = 0; isOK && sectorNo < numSectors; sectorNo++) {
|
||||
for (blockNo = 0; isOK && blockNo < NumBlocksPerSector(sectorNo); blockNo++) {
|
||||
bool received = false;
|
||||
|
||||
if (blockNo == NumBlocksPerSector(sectorNo) - 1) { // sector trailer. At least the Access Conditions can always be read with key A.
|
||||
UsbCommand c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + blockNo, 0, 0}};
|
||||
memcpy(c.d.asBytes, keyA[sectorNo], 6);
|
||||
|
@ -610,7 +609,6 @@ int CmdHF14AMfDump(const char *Cmd)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isOK) {
|
||||
|
@ -627,10 +625,8 @@ int CmdHF14AMfDump(const char *Cmd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CmdHF14AMfRestore(const char *Cmd)
|
||||
{
|
||||
|
||||
uint8_t sectorNo,blockNo;
|
||||
uint8_t keyType = 0;
|
||||
uint8_t key[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
|
@ -737,7 +733,6 @@ int CmdHF14AMfRestore(const char *Cmd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CmdHF14AMfNested(const char *Cmd)
|
||||
{
|
||||
int i, j, res, iterations;
|
||||
|
@ -886,6 +881,7 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
PrintAndLog("-----------------------------------------------");
|
||||
if(mfnested(blockNo, keyType, key, FirstBlockOfSector(sectorNo), trgKeyType, keyBlock, calibrate)) {
|
||||
PrintAndLog("Nested error.\n");
|
||||
free(e_sector);
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
|
@ -960,11 +956,9 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
|
||||
free(e_sector);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CmdHF14AMfChk(const char *Cmd)
|
||||
{
|
||||
if (strlen(Cmd)<3) {
|
||||
|
@ -994,7 +988,6 @@ int CmdHF14AMfChk(const char *Cmd)
|
|||
int transferToEml = 0;
|
||||
int createDumpFile = 0;
|
||||
|
||||
|
||||
keyBlock = calloc(stKeyBlock, 6);
|
||||
if (keyBlock == NULL) return 1;
|
||||
|
||||
|
@ -1021,7 +1014,6 @@ int CmdHF14AMfChk(const char *Cmd)
|
|||
num_to_bytes(defaultKeys[defaultKeyCounter], 6, (uint8_t*)(keyBlock + defaultKeyCounter * 6));
|
||||
}
|
||||
|
||||
|
||||
if (param_getchar(Cmd, 0)=='*') {
|
||||
blockNo = 3;
|
||||
switch(param_getchar(Cmd+1, 0)) {
|
||||
|
@ -1114,6 +1106,7 @@ int CmdHF14AMfChk(const char *Cmd)
|
|||
PrintAndLog("File: %s: not found or locked.", filename);
|
||||
free(keyBlock);
|
||||
return 1;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1191,11 +1184,10 @@ int CmdHF14AMfChk(const char *Cmd)
|
|||
}
|
||||
|
||||
free(keyBlock);
|
||||
|
||||
PrintAndLog("");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CmdHF14AMf1kSim(const char *Cmd)
|
||||
{
|
||||
uint8_t uid[7] = {0, 0, 0, 0, 0, 0, 0};
|
||||
|
@ -1261,7 +1253,6 @@ int CmdHF14AMf1kSim(const char *Cmd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CmdHF14AMfDbg(const char *Cmd)
|
||||
{
|
||||
int dbgMode = param_get32ex(Cmd, 0, 0, 10);
|
||||
|
@ -1286,7 +1277,6 @@ int CmdHF14AMfDbg(const char *Cmd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CmdHF14AMfEGet(const char *Cmd)
|
||||
{
|
||||
uint8_t blockNo = 0;
|
||||
|
@ -1310,7 +1300,6 @@ int CmdHF14AMfEGet(const char *Cmd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CmdHF14AMfEClear(const char *Cmd)
|
||||
{
|
||||
if (param_getchar(Cmd, 0) == 'h') {
|
||||
|
@ -1383,7 +1372,7 @@ int CmdHF14AMfELoad(const char *Cmd)
|
|||
// open file
|
||||
f = fopen(filename, "r");
|
||||
if (f == NULL) {
|
||||
PrintAndLog("File not found or locked.");
|
||||
PrintAndLog("File %s not found or locked", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1407,8 +1396,8 @@ int CmdHF14AMfELoad(const char *Cmd)
|
|||
}
|
||||
for (i = 0; i < 32; i += 2) {
|
||||
sscanf(&buf[i], "%02x", (unsigned int *)&buf8[i / 2]);
|
||||
// PrintAndLog("data[%02d]:%s", blockNum, sprint_hex(buf8, 16));
|
||||
}
|
||||
|
||||
if (mfEmlSetMem(buf8, blockNum, 1)) {
|
||||
PrintAndLog("Cant set emul block: %3d", blockNum);
|
||||
fclose(f);
|
||||
|
@ -1476,7 +1465,7 @@ int CmdHF14AMfESave(const char *Cmd)
|
|||
break;
|
||||
}
|
||||
for (j = 0; j < 16; j++)
|
||||
fprintf(f, "%02x", buf[j]);
|
||||
fprintf(f, "%02X", buf[j]);
|
||||
fprintf(f,"\n");
|
||||
}
|
||||
fclose(f);
|
||||
|
@ -1554,8 +1543,8 @@ int CmdHF14AMfEKeyPrn(const char *Cmd)
|
|||
int CmdHF14AMfCSetUID(const char *Cmd)
|
||||
{
|
||||
uint8_t wipeCard = 0;
|
||||
uint8_t uid[8] = {0};
|
||||
uint8_t oldUid[8]= {0};
|
||||
uint8_t uid[8] = {0x00};
|
||||
uint8_t oldUid[8] = {0x00};
|
||||
int res;
|
||||
|
||||
if (strlen(Cmd) < 1 || param_getchar(Cmd, 0) == 'h') {
|
||||
|
@ -1583,10 +1572,10 @@ int CmdHF14AMfCSetUID(const char *Cmd)
|
|||
}
|
||||
|
||||
PrintAndLog("old UID:%s", sprint_hex(oldUid, 4));
|
||||
PrintAndLog("new UID:%s", sprint_hex(uid, 4));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CmdHF14AMfCSetBlk(const char *Cmd)
|
||||
{
|
||||
uint8_t uid[8];
|
||||
|
@ -1721,7 +1710,6 @@ int CmdHF14AMfCLoad(const char *Cmd)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int CmdHF14AMfCGetBlk(const char *Cmd) {
|
||||
uint8_t memBlock[16];
|
||||
uint8_t blockNo = 0;
|
||||
|
@ -1877,7 +1865,7 @@ int CmdHF14AMfCSave(const char *Cmd) {
|
|||
|
||||
|
||||
int CmdHF14AMfSniff(const char *Cmd){
|
||||
// params
|
||||
|
||||
bool wantLogToFile = 0;
|
||||
bool wantDecrypt = 0;
|
||||
//bool wantSaveToEml = 0; TODO
|
||||
|
@ -1904,8 +1892,8 @@ int CmdHF14AMfSniff(const char *Cmd){
|
|||
PrintAndLog(" l - save encrypted sequence to logfile `uid.log`");
|
||||
PrintAndLog(" d - decrypt sequence and put it to log file `uid.log`");
|
||||
PrintAndLog(" n/a e - decrypt sequence, collect read and write commands and save the result of the sequence to emulator memory");
|
||||
PrintAndLog(" r - decrypt sequence, collect read and write commands and save the result of the sequence to emulator dump file `uid.eml`");
|
||||
PrintAndLog("Usage: hf mf sniff [l][d][e][r]");
|
||||
PrintAndLog(" f - decrypt sequence, collect read and write commands and save the result of the sequence to emulator dump file `uid.eml`");
|
||||
PrintAndLog("Usage: hf mf sniff [l][d][e][f]");
|
||||
PrintAndLog(" sample: hf mf sniff l d e");
|
||||
return 0;
|
||||
}
|
||||
|
@ -1961,8 +1949,9 @@ int CmdHF14AMfSniff(const char *Cmd){
|
|||
PrintAndLog("received trace len: %d packages: %d", blockLen, pckNum);
|
||||
num = 0;
|
||||
while (bufPtr - buf < blockLen) {
|
||||
bufPtr += 6; // ignore void timing information
|
||||
bufPtr += 6;
|
||||
len = *((uint16_t *)bufPtr);
|
||||
|
||||
if(len & 0x8000) {
|
||||
isTag = true;
|
||||
len &= 0x7fff;
|
||||
|
@ -1971,6 +1960,7 @@ int CmdHF14AMfSniff(const char *Cmd){
|
|||
}
|
||||
bufPtr += 2;
|
||||
if ((len == 14) && (bufPtr[0] == 0xff) && (bufPtr[1] == 0xff) && (bufPtr[12] == 0xff) && (bufPtr[13] == 0xff)) {
|
||||
|
||||
memcpy(uid, bufPtr + 2, 7);
|
||||
memcpy(atqa, bufPtr + 2 + 7, 2);
|
||||
uid_len = (atqa[0] & 0xC0) == 0x40 ? 7 : 4;
|
||||
|
@ -1985,18 +1975,21 @@ int CmdHF14AMfSniff(const char *Cmd){
|
|||
FillFileNameByUID(logHexFileName, uid + (7 - uid_len), ".log", uid_len);
|
||||
AddLogCurrentDT(logHexFileName);
|
||||
}
|
||||
if (wantDecrypt) mfTraceInit(uid, atqa, sak, wantSaveToEmlFile);
|
||||
if (wantDecrypt)
|
||||
mfTraceInit(uid, atqa, sak, wantSaveToEmlFile);
|
||||
} else {
|
||||
PrintAndLog("%s(%d):%s", isTag ? "TAG":"RDR", num, sprint_hex(bufPtr, len));
|
||||
if (wantLogToFile) AddLogHex(logHexFileName, isTag ? "TAG: ":"RDR: ", bufPtr, len);
|
||||
if (wantDecrypt) mfTraceDecode(bufPtr, len, wantSaveToEmlFile);
|
||||
if (wantLogToFile)
|
||||
AddLogHex(logHexFileName, isTag ? "TAG: ":"RDR: ", bufPtr, len);
|
||||
if (wantDecrypt)
|
||||
mfTraceDecode(bufPtr, len, wantSaveToEmlFile);
|
||||
}
|
||||
bufPtr += len;
|
||||
bufPtr += ((len-1)/8+1); // ignore parity
|
||||
num++;
|
||||
}
|
||||
}
|
||||
} // resp not NILL
|
||||
} // resp not NULL
|
||||
} // while (true)
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "proxmark3.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "data.h"
|
||||
//#include "proxusb.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
#include "common.h"
|
||||
|
|
109
client/cmdlf.c
109
client/cmdlf.c
|
@ -12,7 +12,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
//#include "proxusb.h"
|
||||
#include "proxmark3.h"
|
||||
#include "data.h"
|
||||
#include "graph.h"
|
||||
|
@ -77,22 +76,18 @@ int CmdFlexdemod(const char *Cmd)
|
|||
|
||||
GraphBuffer[start] = 2;
|
||||
GraphBuffer[start+1] = -2;
|
||||
uint8_t bits[64] = {0x00};
|
||||
|
||||
uint8_t bits[64];
|
||||
|
||||
int bit;
|
||||
int bit, sum;
|
||||
i = start;
|
||||
for (bit = 0; bit < 64; bit++) {
|
||||
int j;
|
||||
int sum = 0;
|
||||
for (j = 0; j < 16; j++) {
|
||||
sum = 0;
|
||||
for (int j = 0; j < 16; j++) {
|
||||
sum += GraphBuffer[i++];
|
||||
}
|
||||
if (sum > 0) {
|
||||
bits[bit] = 1;
|
||||
} else {
|
||||
bits[bit] = 0;
|
||||
}
|
||||
|
||||
bits[bit] = (sum > 0) ? 1 : 0;
|
||||
|
||||
PrintAndLog("bit %d sum %d", bit, sum);
|
||||
}
|
||||
|
||||
|
@ -110,15 +105,14 @@ int CmdFlexdemod(const char *Cmd)
|
|||
}
|
||||
}
|
||||
|
||||
// HACK writing back to graphbuffer.
|
||||
GraphTraceLen = 32*64;
|
||||
i = 0;
|
||||
int phase = 0;
|
||||
for (bit = 0; bit < 64; bit++) {
|
||||
if (bits[bit] == 0) {
|
||||
phase = 0;
|
||||
} else {
|
||||
phase = 1;
|
||||
}
|
||||
|
||||
phase = (bits[bit] == 0) ? 0 : 1;
|
||||
|
||||
int j;
|
||||
for (j = 0; j < 32; j++) {
|
||||
GraphBuffer[i++] = phase;
|
||||
|
@ -137,8 +131,10 @@ int CmdIndalaDemod(const char *Cmd)
|
|||
int state = -1;
|
||||
int count = 0;
|
||||
int i, j;
|
||||
|
||||
// worst case with GraphTraceLen=64000 is < 4096
|
||||
// under normal conditions it's < 2048
|
||||
|
||||
uint8_t rawbits[4096];
|
||||
int rawbit = 0;
|
||||
int worst = 0, worstPos = 0;
|
||||
|
@ -171,10 +167,14 @@ int CmdIndalaDemod(const char *Cmd)
|
|||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (rawbit>0){
|
||||
PrintAndLog("Recovered %d raw bits, expected: %d", rawbit, GraphTraceLen/32);
|
||||
PrintAndLog("worst metric (0=best..7=worst): %d at pos %d", worst, worstPos);
|
||||
} else return 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Finding the start of a UID
|
||||
int uidlen, long_wait;
|
||||
if (strcmp(Cmd, "224") == 0) {
|
||||
|
@ -184,6 +184,7 @@ int CmdIndalaDemod(const char *Cmd)
|
|||
uidlen = 64;
|
||||
long_wait = 29;
|
||||
}
|
||||
|
||||
int start;
|
||||
int first = 0;
|
||||
for (start = 0; start <= rawbit - uidlen; start++) {
|
||||
|
@ -197,6 +198,7 @@ int CmdIndalaDemod(const char *Cmd)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (start == rawbit - uidlen + 1) {
|
||||
PrintAndLog("nothing to wait for");
|
||||
return 0;
|
||||
|
@ -210,12 +212,12 @@ int CmdIndalaDemod(const char *Cmd)
|
|||
}
|
||||
|
||||
// Dumping UID
|
||||
uint8_t bits[224];
|
||||
char showbits[225];
|
||||
showbits[uidlen]='\0';
|
||||
uint8_t bits[224] = {0x00};
|
||||
char showbits[225] = {0x00};
|
||||
int bit;
|
||||
i = start;
|
||||
int times = 0;
|
||||
|
||||
if (uidlen > rawbit) {
|
||||
PrintAndLog("Warning: not enough raw bits to get a full UID");
|
||||
for (bit = 0; bit < rawbit; bit++) {
|
||||
|
@ -237,8 +239,8 @@ int CmdIndalaDemod(const char *Cmd)
|
|||
//convert UID to HEX
|
||||
uint32_t uid1, uid2, uid3, uid4, uid5, uid6, uid7;
|
||||
int idx;
|
||||
uid1=0;
|
||||
uid2=0;
|
||||
uid1 = uid2 = 0;
|
||||
|
||||
if (uidlen==64){
|
||||
for( idx=0; idx<64; idx++) {
|
||||
if (showbits[idx] == '0') {
|
||||
|
@ -252,11 +254,8 @@ int CmdIndalaDemod(const char *Cmd)
|
|||
PrintAndLog("UID=%s (%x%08x)", showbits, uid1, uid2);
|
||||
}
|
||||
else {
|
||||
uid3=0;
|
||||
uid4=0;
|
||||
uid5=0;
|
||||
uid6=0;
|
||||
uid7=0;
|
||||
uid3 = uid4 = uid5 = uid6 = uid7 = 0;
|
||||
|
||||
for( idx=0; idx<224; idx++) {
|
||||
uid1=(uid1<<1)|(uid2>>31);
|
||||
uid2=(uid2<<1)|(uid3>>31);
|
||||
|
@ -264,15 +263,19 @@ int CmdIndalaDemod(const char *Cmd)
|
|||
uid4=(uid4<<1)|(uid5>>31);
|
||||
uid5=(uid5<<1)|(uid6>>31);
|
||||
uid6=(uid6<<1)|(uid7>>31);
|
||||
if (showbits[idx] == '0') uid7=(uid7<<1)|0;
|
||||
else uid7=(uid7<<1)|1;
|
||||
|
||||
if (showbits[idx] == '0')
|
||||
uid7 = (uid7<<1) | 0;
|
||||
else
|
||||
uid7 = (uid7<<1) | 1;
|
||||
}
|
||||
PrintAndLog("UID=%s (%x%08x%08x%08x%08x%08x%08x)", showbits, uid1, uid2, uid3, uid4, uid5, uid6, uid7);
|
||||
}
|
||||
|
||||
// Checking UID against next occurrences
|
||||
for (; i + uidlen <= rawbit;) {
|
||||
int failed = 0;
|
||||
for (; i + uidlen <= rawbit;) {
|
||||
failed = 0;
|
||||
for (bit = 0; bit < uidlen; bit++) {
|
||||
if (bits[bit] != rawbits[i++]) {
|
||||
failed = 1;
|
||||
|
@ -284,9 +287,12 @@ int CmdIndalaDemod(const char *Cmd)
|
|||
}
|
||||
times += 1;
|
||||
}
|
||||
|
||||
PrintAndLog("Occurrences: %d (expected %d)", times, (rawbit - start) / uidlen);
|
||||
|
||||
// Remodulating for tag cloning
|
||||
// HACK: 2015-01-04 this will have an impact on our new way of seening lf commands (demod)
|
||||
// since this changes graphbuffer data.
|
||||
GraphTraceLen = 32*uidlen;
|
||||
i = 0;
|
||||
int phase = 0;
|
||||
|
@ -309,15 +315,10 @@ int CmdIndalaDemod(const char *Cmd)
|
|||
|
||||
int CmdIndalaClone(const char *Cmd)
|
||||
{
|
||||
unsigned int uid1, uid2, uid3, uid4, uid5, uid6, uid7;
|
||||
UsbCommand c;
|
||||
uid1=0;
|
||||
uid2=0;
|
||||
uid3=0;
|
||||
uid4=0;
|
||||
uid5=0;
|
||||
uid6=0;
|
||||
uid7=0;
|
||||
unsigned int uid1, uid2, uid3, uid4, uid5, uid6, uid7;
|
||||
|
||||
uid1 = uid2 = uid3 = uid4 = uid5 = uid6 = uid7 = 0;
|
||||
int n = 0, i = 0;
|
||||
|
||||
if (strchr(Cmd,'l') != 0) {
|
||||
|
@ -339,9 +340,7 @@ int CmdIndalaClone(const char *Cmd)
|
|||
c.d.asDwords[4] = uid5;
|
||||
c.d.asDwords[5] = uid6;
|
||||
c.d.asDwords[6] = uid7;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
while (sscanf(&Cmd[i++], "%1x", &n ) == 1) {
|
||||
uid1 = (uid1 << 4) | (uid2 >> 28);
|
||||
uid2 = (uid2 << 4) | (n & 0xf);
|
||||
|
@ -359,13 +358,16 @@ int CmdIndalaClone(const char *Cmd)
|
|||
int CmdLFRead(const char *Cmd)
|
||||
{
|
||||
UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_125K};
|
||||
|
||||
// 'h' means higher-low-frequency, 134 kHz
|
||||
if(*Cmd == 'h') {
|
||||
c.arg[0] = 1;
|
||||
} else if (*Cmd == '\0') {
|
||||
c.arg[0] = 0;
|
||||
} else if (sscanf(Cmd, "%"lli, &c.arg[0]) != 1) {
|
||||
PrintAndLog("use 'read' or 'read h', or 'read <divisor>'");
|
||||
PrintAndLog("Samples 1: 'lf read'");
|
||||
PrintAndLog(" 2: 'lf read h'");
|
||||
PrintAndLog(" 3: 'lf read <divisor>'");
|
||||
return 0;
|
||||
}
|
||||
SendCommand(&c);
|
||||
|
@ -417,7 +419,9 @@ int CmdLFSim(const char *Cmd)
|
|||
|
||||
int CmdLFSimBidir(const char *Cmd)
|
||||
{
|
||||
/* Set ADC to twice the carrier for a slight supersampling */
|
||||
// Set ADC to twice the carrier for a slight supersampling
|
||||
// HACK: not implemented in ARMSRC.
|
||||
PrintAndLog("Not implemented yet.");
|
||||
UsbCommand c = {CMD_LF_SIMULATE_BIDIR, {47, 384, 0}};
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -429,23 +433,17 @@ int CmdLFSimManchester(const char *Cmd)
|
|||
static int clock, gap;
|
||||
static char data[1024], gapstring[8];
|
||||
|
||||
/* get settings/bits */
|
||||
sscanf(Cmd, "%i %s %i", &clock, &data[0], &gap);
|
||||
|
||||
/* clear our graph */
|
||||
ClearGraph(0);
|
||||
|
||||
/* fill it with our bitstream */
|
||||
for (int i = 0; i < strlen(data) ; ++i)
|
||||
AppendGraph(0, clock, data[i]- '0');
|
||||
|
||||
/* modulate */
|
||||
CmdManchesterMod("");
|
||||
|
||||
/* show what we've done */
|
||||
RepaintGraphWindow();
|
||||
|
||||
/* simulate */
|
||||
sprintf(&gapstring[0], "%i", gap);
|
||||
CmdLFSim(gapstring);
|
||||
return 0;
|
||||
|
@ -454,20 +452,23 @@ int CmdLFSimManchester(const char *Cmd)
|
|||
int CmdLFSnoop(const char *Cmd)
|
||||
{
|
||||
UsbCommand c = {CMD_LF_SNOOP_RAW_ADC_SAMPLES};
|
||||
|
||||
// 'h' means higher-low-frequency, 134 kHz
|
||||
c.arg[0] = 0;
|
||||
c.arg[1] = -1;
|
||||
if (*Cmd == 0) {
|
||||
// empty
|
||||
} else if (*Cmd == 'l') {
|
||||
|
||||
if (*Cmd == 'l') {
|
||||
sscanf(Cmd, "l %"lli, &c.arg[1]);
|
||||
} else if(*Cmd == 'h') {
|
||||
c.arg[0] = 1;
|
||||
sscanf(Cmd, "h %"lli, &c.arg[1]);
|
||||
} else if (sscanf(Cmd, "%"lli" %"lli, &c.arg[0], &c.arg[1]) < 1) {
|
||||
PrintAndLog("use 'snoop' or 'snoop {l,h} [trigger threshold]', or 'snoop <divisor> [trigger threshold]'");
|
||||
PrintAndLog("usage 1: snoop");
|
||||
PrintAndLog(" 2: snoop {l,h} [trigger threshold]");
|
||||
PrintAndLog(" 3: snoop <divisor> [trigger threshold]");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SendCommand(&c);
|
||||
WaitForResponse(CMD_ACK,NULL);
|
||||
return 0;
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
//#include "proxusb.h"
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "util.h"
|
||||
#include "graph.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmddata.h"
|
||||
|
@ -22,20 +22,16 @@
|
|||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
|
||||
|
||||
int CmdEMdemodASK(const char *Cmd)
|
||||
{
|
||||
int findone=0;
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
int findone = (cmdp == '1') ? 1 : 0;
|
||||
UsbCommand c={CMD_EM410X_DEMOD};
|
||||
if(Cmd[0]=='1') findone=1;
|
||||
c.arg[0]=findone;
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Read the ID of an EM410x tag.
|
||||
* Format:
|
||||
* 1111 1111 1 <-- standard non-repeatable header
|
||||
|
@ -48,8 +44,8 @@ int CmdEM410xRead(const char *Cmd)
|
|||
{
|
||||
int i, j, clock, header, rows, bit, hithigh, hitlow, first, bit2idx, high, low;
|
||||
int parity[4];
|
||||
char id[11];
|
||||
char id2[11];
|
||||
char id[11] = {0x00};
|
||||
char id2[11] = {0x00};
|
||||
int retested = 0;
|
||||
uint8_t BitStream[MAX_GRAPH_TRACE_LEN];
|
||||
high = low = 0;
|
||||
|
@ -201,7 +197,25 @@ retest:
|
|||
*/
|
||||
int CmdEM410xSim(const char *Cmd)
|
||||
{
|
||||
int i, n, j, h, binary[4], parity[4];
|
||||
int i, n, j, binary[4], parity[4];
|
||||
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
uint8_t uid[5] = {0x00};
|
||||
|
||||
if (cmdp == 'h' || cmdp == 'H') {
|
||||
PrintAndLog("Usage: lf em4x 410xsim <UID>");
|
||||
PrintAndLog("");
|
||||
PrintAndLog(" sample: lf em4x 410xsim 0F0368568B");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (param_gethex(Cmd, 0, uid, 10)) {
|
||||
PrintAndLog("UID must include 10 HEX symbols");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PrintAndLog("Starting simulating UID %02X%02X%02X%02X%02X", uid[0],uid[1],uid[2],uid[3],uid[4]);
|
||||
PrintAndLog("Press pm3-button to about simulation");
|
||||
|
||||
/* clock is 64 in EM410x tags */
|
||||
int clock = 64;
|
||||
|
@ -209,9 +223,6 @@ int CmdEM410xSim(const char *Cmd)
|
|||
/* clear our graph */
|
||||
ClearGraph(0);
|
||||
|
||||
/* write it out a few times */
|
||||
for (h = 0; h < 4; h++)
|
||||
{
|
||||
/* write 9 start bits */
|
||||
for (i = 0; i < 9; i++)
|
||||
AppendGraph(0, clock, 1);
|
||||
|
@ -248,38 +259,38 @@ int CmdEM410xSim(const char *Cmd)
|
|||
AppendGraph(0, clock, parity[3]);
|
||||
|
||||
/* stop bit */
|
||||
AppendGraph(0, clock, 0);
|
||||
}
|
||||
|
||||
/* modulate that biatch */
|
||||
CmdManchesterMod("");
|
||||
|
||||
/* booyah! */
|
||||
RepaintGraphWindow();
|
||||
|
||||
CmdLFSim("");
|
||||
AppendGraph(1, clock, 0);
|
||||
|
||||
CmdLFSim("240"); //240 start_gap.
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Function is equivalent of loread + losamples + em410xread
|
||||
* looped until an EM410x tag is detected */
|
||||
/* Function is equivalent of lf read + data samples + em410xread
|
||||
* looped until an EM410x tag is detected
|
||||
*
|
||||
* Why is CmdSamples("16000")?
|
||||
* TBD: Auto-grow sample size based on detected sample rate. IE: If the
|
||||
* rate gets lower, then grow the number of samples
|
||||
* Changed by martin, 4000 x 4 = 16000,
|
||||
* see http://www.proxmark.org/forum/viewtopic.php?pid=7235#p7235
|
||||
|
||||
*/
|
||||
int CmdEM410xWatch(const char *Cmd)
|
||||
{
|
||||
int read_h = (*Cmd == 'h');
|
||||
do
|
||||
{
|
||||
CmdLFRead(read_h ? "h" : "");
|
||||
// 2000 samples is OK for clock=64, but not clock=32. Probably want
|
||||
// 8000 for clock=16. Don't want to go too high since old HID driver
|
||||
// is very slow
|
||||
// TBD: Auto-grow sample size based on detected sample rate. IE: If the
|
||||
// rate gets lower, then grow the number of samples
|
||||
|
||||
// Changed by martin, 4000 x 4 = 16000,
|
||||
// see http://www.proxmark.org/forum/viewtopic.php?pid=7235#p7235
|
||||
CmdSamples("16000");
|
||||
} while ( ! CmdEM410xRead(""));
|
||||
return 0;
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
int read_h = (cmdp == 'h');
|
||||
do {
|
||||
if (ukbhit()) {
|
||||
printf("\naborted via keyboard!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
CmdLFRead(read_h ? "h" : "");
|
||||
CmdSamples("6000");
|
||||
} while (
|
||||
!CmdEM410xRead("")
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Read the transmitted data of an EM4x50 tag
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
//#include "proxusb.h"
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "graph.h"
|
||||
|
@ -41,8 +40,8 @@ int CmdHIDDemod(const char *Cmd)
|
|||
int CmdHIDDemodFSK(const char *Cmd)
|
||||
{
|
||||
int findone=0;
|
||||
if(Cmd[0]=='1') findone=1;
|
||||
UsbCommand c={CMD_HID_DEMOD_FSK};
|
||||
if(Cmd[0]=='1') findone=1;
|
||||
c.arg[0]=findone;
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -59,6 +58,7 @@ int CmdHIDSim(const char *Cmd)
|
|||
}
|
||||
|
||||
PrintAndLog("Emulating tag with ID %x%16x", hi, lo);
|
||||
PrintAndLog("Press pm3-button to abort simulation");
|
||||
|
||||
UsbCommand c = {CMD_HID_SIM_TAG, {hi, lo, 0}};
|
||||
SendCommand(&c);
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "data.h"
|
||||
//#include "proxusb.h"
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
|
@ -225,7 +224,7 @@ int CmdLFHitagReader(const char *Cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static command_t CommandTableHitag[] =
|
||||
static command_t CommandTable[] =
|
||||
{
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
{"list", CmdLFHitagList, 1, "List Hitag trace history"},
|
||||
|
@ -237,12 +236,12 @@ static command_t CommandTableHitag[] =
|
|||
|
||||
int CmdLFHitag(const char *Cmd)
|
||||
{
|
||||
CmdsParse(CommandTableHitag, Cmd);
|
||||
CmdsParse(CommandTable, Cmd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdHelp(const char *Cmd)
|
||||
{
|
||||
CmdsHelp(CommandTableHitag);
|
||||
CmdsHelp(CommandTable);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
//#include "proxusb.h"
|
||||
#include "proxmark3.h"
|
||||
#include "data.h"
|
||||
#include "graph.h"
|
||||
|
@ -19,26 +18,21 @@ int CmdIODemodFSK(const char *Cmd)
|
|||
{
|
||||
int findone=0;
|
||||
if(Cmd[0]=='1') findone=1;
|
||||
|
||||
UsbCommand c={CMD_IO_DEMOD_FSK};
|
||||
c.arg[0]=findone;
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CmdIOProxDemod(const char *Cmd){
|
||||
if (GraphTraceLen < 4800) {
|
||||
PrintAndLog("too short; need at least 4800 samples");
|
||||
return 0;
|
||||
}
|
||||
|
||||
GraphTraceLen = 4800;
|
||||
for (int i = 0; i < GraphTraceLen; ++i) {
|
||||
if (GraphBuffer[i] < 0) {
|
||||
GraphBuffer[i] = 0;
|
||||
} else {
|
||||
GraphBuffer[i] = 1;
|
||||
}
|
||||
GraphBuffer[i] = (GraphBuffer[i] < 0) ? 0 : 1;
|
||||
}
|
||||
RepaintGraphWindow();
|
||||
return 0;
|
||||
|
@ -61,7 +55,7 @@ int CmdIOClone(const char *Cmd)
|
|||
}
|
||||
|
||||
PrintAndLog("Cloning tag with ID %08x %08x", hi, lo);
|
||||
|
||||
PrintAndLog("Press pm3-button to abort simulation");
|
||||
c.cmd = CMD_IO_CLONE_TAG;
|
||||
c.arg[0] = hi;
|
||||
c.arg[1] = lo;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
//#include "proxusb.h"
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "graph.h"
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
//#include "proxusb.h"
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "graph.h"
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "crc16.h"
|
||||
//#include "proxusb.h"
|
||||
#include "proxmark3.h"
|
||||
#include "data.h"
|
||||
#include "ui.h"
|
||||
|
|
|
@ -28,9 +28,6 @@
|
|||
|
||||
|
||||
unsigned int current_command = CMD_UNKNOWN;
|
||||
//unsigned int received_command = CMD_UNKNOWN;
|
||||
//UsbCommand current_response;
|
||||
//UsbCommand current_response_user;
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
static int CmdQuit(const char *Cmd);
|
||||
|
@ -47,9 +44,9 @@ static command_t CommandTable[] =
|
|||
{
|
||||
{"help", CmdHelp, 1, "This help. Use '<command> help' for details of a particular command."},
|
||||
{"data", CmdData, 1, "{ Plot window / data buffer manipulation... }"},
|
||||
{"hf", CmdHF, 1, "{ HF commands... }"},
|
||||
{"hf", CmdHF, 1, "{ High Frequency commands... }"},
|
||||
{"hw", CmdHW, 1, "{ Hardware commands... }"},
|
||||
{"lf", CmdLF, 1, "{ LF commands... }"},
|
||||
{"lf", CmdLF, 1, "{ Low Frequency commands... }"},
|
||||
{"script", CmdScript, 1,"{ Scripting commands }"},
|
||||
{"quit", CmdQuit, 1, "Exit program"},
|
||||
{"exit", CmdQuit, 1, "Exit program"},
|
||||
|
@ -146,10 +143,8 @@ bool WaitForResponseTimeout(uint32_t cmd, UsbCommand* response, size_t ms_timeou
|
|||
while(getCommand(response))
|
||||
{
|
||||
if(response->cmd == cmd){
|
||||
//We got what we expected
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
msleep(10); // XXX ugh
|
||||
if (dm_seconds == 200) { // Two seconds elapsed
|
||||
|
@ -178,25 +173,12 @@ void CommandReceived(char *Cmd) {
|
|||
//-----------------------------------------------------------------------------
|
||||
void UsbCommandReceived(UsbCommand *UC)
|
||||
{
|
||||
/*
|
||||
// Debug
|
||||
printf("UsbCommand length[len=%zd]\n",sizeof(UsbCommand));
|
||||
printf(" cmd[len=%zd]: %"llx"\n",sizeof(UC->cmd),UC->cmd);
|
||||
printf(" arg0[len=%zd]: %"llx"\n",sizeof(UC->arg[0]),UC->arg[0]);
|
||||
printf(" arg1[len=%zd]: %"llx"\n",sizeof(UC->arg[1]),UC->arg[1]);
|
||||
printf(" arg2[len=%zd]: %"llx"\n",sizeof(UC->arg[2]),UC->arg[2]);
|
||||
printf(" data[len=%zd]: %02x%02x%02x...\n",sizeof(UC->d.asBytes),UC->d.asBytes[0],UC->d.asBytes[1],UC->d.asBytes[2]);
|
||||
*/
|
||||
|
||||
// printf("%s(%x) current cmd = %x\n", __FUNCTION__, c->cmd, current_command);
|
||||
// If we recognize a response, return to avoid further processing
|
||||
switch(UC->cmd) {
|
||||
// First check if we are handling a debug message
|
||||
case CMD_DEBUG_PRINT_STRING: {
|
||||
char s[USB_CMD_DATA_SIZE+1];
|
||||
char s[USB_CMD_DATA_SIZE+1] = {0x00};
|
||||
size_t len = MIN(UC->arg[0],USB_CMD_DATA_SIZE);
|
||||
memcpy(s,UC->d.asBytes,len);
|
||||
s[len] = 0x00;
|
||||
PrintAndLog("#db# %s ", s);
|
||||
return;
|
||||
} break;
|
||||
|
@ -206,67 +188,15 @@ void UsbCommandReceived(UsbCommand *UC)
|
|||
return;
|
||||
} break;
|
||||
|
||||
// case CMD_MEASURED_ANTENNA_TUNING: {
|
||||
// int peakv, peakf;
|
||||
// int vLf125, vLf134, vHf;
|
||||
// vLf125 = UC->arg[0] & 0xffff;
|
||||
// vLf134 = UC->arg[0] >> 16;
|
||||
// vHf = UC->arg[1] & 0xffff;;
|
||||
// peakf = UC->arg[2] & 0xffff;
|
||||
// peakv = UC->arg[2] >> 16;
|
||||
// PrintAndLog("");
|
||||
// PrintAndLog("# LF antenna: %5.2f V @ 125.00 kHz", vLf125/1000.0);
|
||||
// PrintAndLog("# LF antenna: %5.2f V @ 134.00 kHz", vLf134/1000.0);
|
||||
// PrintAndLog("# LF optimal: %5.2f V @%9.2f kHz", peakv/1000.0, 12000.0/(peakf+1));
|
||||
// PrintAndLog("# HF antenna: %5.2f V @ 13.56 MHz", vHf/1000.0);
|
||||
// if (peakv<2000)
|
||||
// PrintAndLog("# Your LF antenna is unusable.");
|
||||
// else if (peakv<10000)
|
||||
// PrintAndLog("# Your LF antenna is marginal.");
|
||||
// if (vHf<2000)
|
||||
// PrintAndLog("# Your HF antenna is unusable.");
|
||||
// else if (vHf<5000)
|
||||
// PrintAndLog("# Your HF antenna is marginal.");
|
||||
// } break;
|
||||
|
||||
case CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K: {
|
||||
// printf("received samples: ");
|
||||
// print_hex(UC->d.asBytes,512);
|
||||
sample_buf_len += UC->arg[1];
|
||||
// printf("samples: %zd offset: %d\n",sample_buf_len,UC->arg[0]);
|
||||
memcpy(sample_buf+(UC->arg[0]),UC->d.asBytes,UC->arg[1]);
|
||||
} break;
|
||||
|
||||
|
||||
// case CMD_ACK: {
|
||||
// PrintAndLog("Receive ACK\n");
|
||||
// } break;
|
||||
|
||||
default: {
|
||||
// Maybe it's a response
|
||||
/*
|
||||
switch(current_command) {
|
||||
case CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K: {
|
||||
if (UC->cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) {
|
||||
PrintAndLog("unrecognized command %08x\n", UC->cmd);
|
||||
break;
|
||||
}
|
||||
// int i;
|
||||
PrintAndLog("received samples %d\n",UC->arg[0]);
|
||||
memcpy(sample_buf+UC->arg[0],UC->d.asBytes,48);
|
||||
sample_buf_len += 48;
|
||||
// for(i=0; i<48; i++) sample_buf[i] = UC->d.asBytes[i];
|
||||
//received_command = UC->cmd;
|
||||
} break;
|
||||
|
||||
default: {
|
||||
} break;
|
||||
}*/
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
storeCommand(UC);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <stdint.h>
|
||||
#include "data.h"
|
||||
#include "ui.h"
|
||||
//#include "proxusb.h"
|
||||
#include "proxmark3.h"
|
||||
#include "cmdmain.h"
|
||||
|
||||
|
@ -23,22 +22,6 @@ void GetFromBigBuf(uint8_t *dest, int bytes, int start_index)
|
|||
{
|
||||
sample_buf_len = 0;
|
||||
sample_buf = dest;
|
||||
// start_index = ((start_index/12)*12);
|
||||
// int n = start_index + bytes;
|
||||
/*
|
||||
if (n % 48 != 0) {
|
||||
PrintAndLog("bad len in GetFromBigBuf");
|
||||
return;
|
||||
}
|
||||
*/
|
||||
UsbCommand c = {CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K, {start_index, bytes, 0}};
|
||||
SendCommand(&c);
|
||||
/*
|
||||
for (int i = start_index; i < n; i += 48) {
|
||||
UsbCommand c = {CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K, {i, 0, 0}};
|
||||
SendCommand(&c);
|
||||
// WaitForResponse(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K);
|
||||
// memcpy(dest+(i*4), sample_buf, 48);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <stdlib.h>
|
||||
#include "proxmark3.h"
|
||||
#include "sleep.h"
|
||||
//#include "proxusb.h"
|
||||
#include "flash.h"
|
||||
#include "elf.h"
|
||||
#include "proxendian.h"
|
||||
|
@ -276,7 +275,6 @@ static int get_proxmark_state(uint32_t *state)
|
|||
{
|
||||
UsbCommand c;
|
||||
c.cmd = CMD_DEVICE_INFO;
|
||||
// SendCommand_(&c);
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
ReceiveCommand(&resp);
|
||||
|
@ -391,7 +389,6 @@ int flash_start_flashing(int enable_bl_writes,char *serial_port_name)
|
|||
c.arg[2] = 0;
|
||||
}
|
||||
SendCommand(&c);
|
||||
// SendCommand_(&c);
|
||||
return wait_for_ack();
|
||||
} else {
|
||||
fprintf(stderr, "Note: Your bootloader does not understand the new START_FLASH command\n");
|
||||
|
@ -408,22 +405,8 @@ static int write_block(uint32_t address, uint8_t *data, uint32_t length)
|
|||
memset(block_buf, 0xFF, BLOCK_SIZE);
|
||||
memcpy(block_buf, data, length);
|
||||
UsbCommand c;
|
||||
/*
|
||||
c.cmd = {CMD_SETUP_WRITE};
|
||||
for (int i = 0; i < 240; i += 48) {
|
||||
memcpy(c.d.asBytes, block_buf + i, 48);
|
||||
c.arg[0] = i / 4;
|
||||
SendCommand(&c);
|
||||
// SendCommand_(&c);
|
||||
if (wait_for_ack() < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
*/
|
||||
c.cmd = CMD_FINISH_WRITE;
|
||||
c.arg[0] = address;
|
||||
// memcpy(c.d.asBytes, block_buf+240, 16);
|
||||
// SendCommand_(&c);
|
||||
memcpy(c.d.asBytes, block_buf, length);
|
||||
SendCommand(&c);
|
||||
return wait_for_ack();
|
||||
|
@ -486,7 +469,6 @@ void flash_free(flash_file_t *ctx)
|
|||
// just reset the unit
|
||||
int flash_stop_flashing(void) {
|
||||
UsbCommand c = {CMD_HARDWARE_RESET};
|
||||
// SendCommand_(&c);
|
||||
SendCommand(&c);
|
||||
msleep(100);
|
||||
return 0;
|
||||
|
|
|
@ -11,8 +11,14 @@
|
|||
* @return
|
||||
*/
|
||||
int fileExists(const char *filename) {
|
||||
|
||||
#ifdef _WIN32
|
||||
struct _stat st;
|
||||
int result = _stat(filename, &st);
|
||||
#else
|
||||
struct stat st;
|
||||
int result = stat(filename, &st);
|
||||
#endif
|
||||
return result == 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,6 @@ int compar_int(const void * a, const void * b) {
|
|||
else return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Compare 16 Bits out of cryptostate
|
||||
int Compare16Bits(const void * a, const void * b) {
|
||||
if ((*(uint64_t*)b & 0x00ff000000ff0000) == (*(uint64_t*)a & 0x00ff000000ff0000)) return 0;
|
||||
|
@ -35,7 +33,6 @@ int Compare16Bits(const void * a, const void * b) {
|
|||
else return -1;
|
||||
}
|
||||
|
||||
|
||||
typedef
|
||||
struct {
|
||||
union {
|
||||
|
@ -70,16 +67,12 @@ void* nested_worker_thread(void *arg)
|
|||
return statelist->head.slhead;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t * key, uint8_t trgBlockNo, uint8_t trgKeyType, uint8_t * resultKey, bool calibrate)
|
||||
{
|
||||
uint16_t i, len;
|
||||
uint32_t uid;
|
||||
UsbCommand resp;
|
||||
|
||||
|
||||
StateList_t statelists[2];
|
||||
struct Crypto1State *p1, *p2, *p3, *p4;
|
||||
|
||||
|
@ -239,12 +232,11 @@ int mfEmlSetMem(uint8_t *data, int blockNum, int blocksCount) {
|
|||
// "MAGIC" CARD
|
||||
|
||||
int mfCSetUID(uint8_t *uid, uint8_t *oldUID, bool wantWipe) {
|
||||
uint8_t block0[16];
|
||||
memset(block0, 0, 16);
|
||||
uint8_t block0[16] = {0x00};
|
||||
memcpy(block0, uid, 4);
|
||||
block0[4] = block0[0]^block0[1]^block0[2]^block0[3]; // Mifare UID BCC
|
||||
// mifare classic SAK(byte 5) and ATQA(byte 6 and 7)
|
||||
block0[5] = 0x88;
|
||||
block0[5] = 0x08;
|
||||
block0[6] = 0x04;
|
||||
block0[7] = 0x00;
|
||||
|
||||
|
@ -252,9 +244,9 @@ int mfCSetUID(uint8_t *uid, uint8_t *oldUID, bool wantWipe) {
|
|||
}
|
||||
|
||||
int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, bool wantWipe, uint8_t params) {
|
||||
uint8_t isOK = 0;
|
||||
|
||||
UsbCommand c = {CMD_MIFARE_EML_CSETBLOCK, {wantWipe, params & (0xFE | (uid == NULL ? 0:1)), blockNo}};
|
||||
uint8_t isOK = 0;
|
||||
UsbCommand c = {CMD_MIFARE_CSETBLOCK, {wantWipe, params & (0xFE | (uid == NULL ? 0:1)), blockNo}};
|
||||
memcpy(c.d.asBytes, data, 16);
|
||||
SendCommand(&c);
|
||||
|
||||
|
@ -273,7 +265,7 @@ int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, bool wantWipe, uin
|
|||
int mfCGetBlock(uint8_t blockNo, uint8_t *data, uint8_t params) {
|
||||
uint8_t isOK = 0;
|
||||
|
||||
UsbCommand c = {CMD_MIFARE_EML_CGETBLOCK, {params, 0, blockNo}};
|
||||
UsbCommand c = {CMD_MIFARE_CGETBLOCK, {params, 0, blockNo}};
|
||||
SendCommand(&c);
|
||||
|
||||
UsbCommand resp;
|
||||
|
@ -296,7 +288,7 @@ static uint8_t trailerAccessBytes[4] = {0x08, 0x77, 0x8F, 0x00};
|
|||
// variables
|
||||
char logHexFileName[200] = {0x00};
|
||||
static uint8_t traceCard[4096] = {0x00};
|
||||
static char traceFileName[200] = {0};
|
||||
static char traceFileName[200] = {0x00};
|
||||
static int traceState = TRACE_IDLE;
|
||||
static uint8_t traceCurBlock = 0;
|
||||
static uint8_t traceCurKey = 0;
|
||||
|
@ -522,7 +514,6 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
|
|||
case TRACE_AUTH1:
|
||||
if (len == 4) {
|
||||
traceState = TRACE_AUTH2;
|
||||
|
||||
nt = bytes_to_num(data, 4);
|
||||
return 0;
|
||||
} else {
|
||||
|
@ -558,6 +549,7 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
|
|||
lfsr_rollback_word(revstate, 0, 0);
|
||||
lfsr_rollback_word(revstate, nr_enc, 1);
|
||||
lfsr_rollback_word(revstate, uid ^ nt, 0);
|
||||
|
||||
crypto1_get_lfsr(revstate, &lfsr);
|
||||
printf("key> %x%x\n", (unsigned int)((lfsr & 0xFFFFFFFF00000000) >> 32), (unsigned int)(lfsr & 0xFFFFFFFF));
|
||||
AddLogUint64(logHexFileName, "key> ", lfsr);
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "cmdmain.h"
|
||||
#include "ui.h"
|
||||
#include "data.h"
|
||||
//#include "proxusb.h"
|
||||
#include "util.h"
|
||||
#include "nonce2key/nonce2key.h"
|
||||
#include "nonce2key/crapto1.h"
|
||||
|
|
|
@ -66,21 +66,6 @@ struct main_loop_arg {
|
|||
char *script_cmds_file;
|
||||
};
|
||||
|
||||
//static void *usb_receiver(void *targ) {
|
||||
// struct receiver_arg *arg = (struct receiver_arg*)targ;
|
||||
// UsbCommand cmdbuf;
|
||||
//
|
||||
// while (arg->run) {
|
||||
// if (ReceiveCommandPoll(&cmdbuf)) {
|
||||
// UsbCommandReceived(&cmdbuf);
|
||||
// fflush(NULL);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// pthread_exit(NULL);
|
||||
// return NULL;
|
||||
//}
|
||||
|
||||
byte_t rx[0x1000000];
|
||||
byte_t* prx = rx;
|
||||
|
||||
|
@ -129,7 +114,7 @@ static void *main_loop(void *targ) {
|
|||
}
|
||||
|
||||
FILE *script_file = NULL;
|
||||
char script_cmd_buf[256];
|
||||
char script_cmd_buf[256]; // iceman, needs lua script the same file_path_buffer as the rest
|
||||
|
||||
if (arg->script_cmds_file)
|
||||
{
|
||||
|
@ -211,14 +196,6 @@ static void *main_loop(void *targ) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
//static void dumpHelp(char *parent, ...)
|
||||
//{
|
||||
// printf("## %s\n\n", parent);
|
||||
// CommandReceived(parent);
|
||||
//
|
||||
// printf("\n");
|
||||
//}
|
||||
|
||||
static void dumpAllHelp(int markdown)
|
||||
{
|
||||
printf("\n%sProxmark3 command dump%s\n\n",markdown?"# ":"",markdown?"":"\n======================");
|
||||
|
@ -258,17 +235,6 @@ int main(int argc, char* argv[]) {
|
|||
};
|
||||
pthread_t main_loop_t;
|
||||
|
||||
/*
|
||||
usb_init();
|
||||
if (!OpenProxmark(1)) {
|
||||
fprintf(stderr,"PROXMARK3: NOT FOUND!\n");
|
||||
marg.usb_present = 0;
|
||||
offline = 1;
|
||||
} else {
|
||||
marg.usb_present = 1;
|
||||
offline = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
sp = uart_open(argv[1]);
|
||||
if (sp == INVALID_SERIAL_PORT) {
|
||||
|
@ -309,10 +275,6 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
pthread_join(main_loop_t, NULL);
|
||||
|
||||
// if (marg.usb_present == 1) {
|
||||
// CloseProxmark();
|
||||
// }
|
||||
|
||||
// Clean up the port
|
||||
uart_close(sp);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue