mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
Merge remote-tracking branch 'upstream/master' into hf_mf_sim
This commit is contained in:
commit
49f0b35ffd
6 changed files with 56 additions and 18 deletions
|
@ -231,7 +231,7 @@ void HfSniff(int, int);
|
||||||
|
|
||||||
//felica.c
|
//felica.c
|
||||||
extern void felica_sendraw(UsbCommand *c);
|
extern void felica_sendraw(UsbCommand *c);
|
||||||
extern void felica_sniff(uint32_t samples, uint32_t triggers);
|
extern void felica_sniff(uint32_t samplesToSkip, uint32_t triggersToSkip);
|
||||||
extern void felica_sim_lite(uint64_t uid);
|
extern void felica_sim_lite(uint64_t uid);
|
||||||
extern void felica_dump_lite_s();
|
extern void felica_dump_lite_s();
|
||||||
|
|
||||||
|
|
|
@ -611,13 +611,13 @@ void felica_sniff(uint32_t samplesToSkip, uint32_t triggersToSkip) {
|
||||||
#define R_READBLK_LEN 0x21
|
#define R_READBLK_LEN 0x21
|
||||||
//simulate NFC Tag3 card - for now only poll response works
|
//simulate NFC Tag3 card - for now only poll response works
|
||||||
// second half (4 bytes) of NDEF2 goes into nfcid2_0, first into nfcid2_1
|
// second half (4 bytes) of NDEF2 goes into nfcid2_0, first into nfcid2_1
|
||||||
void felica_sim_lite(uint64_t nfcid) {
|
void felica_sim_lite(uint64_t uid) {
|
||||||
|
|
||||||
int i, curlen = 0;
|
int i, curlen = 0;
|
||||||
uint8_t *curresp = 0;
|
uint8_t *curresp = 0;
|
||||||
|
|
||||||
uint8_t ndef[8];
|
uint8_t ndef[8];
|
||||||
num_to_bytes(nfcid, 8, ndef);
|
num_to_bytes(uid, 8, ndef);
|
||||||
|
|
||||||
//prepare our 3 responses...
|
//prepare our 3 responses...
|
||||||
uint8_t resp_poll0[R_POLL0_LEN] = { 0xb2, 0x4d, 0x12, FELICA_POLL_ACK, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf1, 0x00, 0x00, 0x00, 0x01, 0x43, 0x00, 0xb3, 0x7f};
|
uint8_t resp_poll0[R_POLL0_LEN] = { 0xb2, 0x4d, 0x12, FELICA_POLL_ACK, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf1, 0x00, 0x00, 0x00, 0x01, 0x43, 0x00, 0xb3, 0x7f};
|
||||||
|
|
|
@ -485,14 +485,13 @@ int ASKDemod_ext(const char *Cmd, bool verbose, bool emSearch, uint8_t askType,
|
||||||
if (amp == 'a')
|
if (amp == 'a')
|
||||||
askAmp(bits, BitLen);
|
askAmp(bits, BitLen);
|
||||||
|
|
||||||
bool st = false;
|
|
||||||
size_t ststart = 0, stend = 0;
|
size_t ststart = 0, stend = 0;
|
||||||
if (*stCheck)
|
// if (*stCheck)
|
||||||
st = DetectST(bits, &BitLen, &foundclk, &ststart, &stend);
|
bool st = DetectST(bits, &BitLen, &foundclk, &ststart, &stend);
|
||||||
|
clk = (clk == 0) ? foundclk : clk;
|
||||||
|
|
||||||
if (st) {
|
if (st) {
|
||||||
*stCheck = st;
|
*stCheck = st;
|
||||||
clk = (clk == 0) ? foundclk : clk;
|
|
||||||
CursorCPos = ststart;
|
CursorCPos = ststart;
|
||||||
CursorDPos = stend;
|
CursorDPos = stend;
|
||||||
if (verbose)
|
if (verbose)
|
||||||
|
@ -1607,8 +1606,7 @@ int CmdLoad(const char *Cmd) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f)
|
fclose(f);
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "loaded %d samples", GraphTraceLen);
|
PrintAndLogEx(SUCCESS, "loaded %d samples", GraphTraceLen);
|
||||||
|
|
||||||
|
|
|
@ -113,8 +113,8 @@ char *mtostr(const model_t *model) {
|
||||||
+ strlen(strbuf)
|
+ strlen(strbuf)
|
||||||
+ (polystr && *polystr ? strlen(polystr) : 6)
|
+ (polystr && *polystr ? strlen(polystr) : 6)
|
||||||
+ (initstr && *initstr ? strlen(initstr) : 6)
|
+ (initstr && *initstr ? strlen(initstr) : 6)
|
||||||
+ (model->flags & P_REFIN ? 4 : 5)
|
+ ((model->flags & P_REFIN) ? 4 : 5)
|
||||||
+ (model->flags & P_REFOUT ? 4 : 5)
|
+ ((model->flags & P_REFOUT) ? 4 : 5)
|
||||||
+ (xorotstr && *xorotstr ? strlen(xorotstr) : 6)
|
+ (xorotstr && *xorotstr ? strlen(xorotstr) : 6)
|
||||||
+ (checkstr && *checkstr ? strlen(checkstr) : 6)
|
+ (checkstr && *checkstr ? strlen(checkstr) : 6)
|
||||||
+ (magicstr && *magicstr ? strlen(magicstr) : 6)
|
+ (magicstr && *magicstr ? strlen(magicstr) : 6)
|
||||||
|
|
|
@ -1207,7 +1207,7 @@ prhex(char **spp, bmp_t bits, int flags, int bperhx) {
|
||||||
* Set P_UPPER in flags to write A-F in uppercase.
|
* Set P_UPPER in flags to write A-F in uppercase.
|
||||||
*/
|
*/
|
||||||
static const char hex[] = "0123456789abcdef0123456789ABCDEF";
|
static const char hex[] = "0123456789abcdef0123456789ABCDEF";
|
||||||
const int upper = (flags & P_UPPER ? 0x10 : 0);
|
const int upper = ((flags & P_UPPER) ? 0x10 : 0);
|
||||||
while (bperhx > 0) {
|
while (bperhx > 0) {
|
||||||
bperhx -= ((bperhx + 3) & 3) + 1;
|
bperhx -= ((bperhx + 3) & 3) + 1;
|
||||||
*(*spp)++ = hex[(bits >> bperhx & BMP_C(0xf)) | upper];
|
*(*spp)++ = hex[(bits >> bperhx & BMP_C(0xf)) | upper];
|
||||||
|
|
|
@ -480,12 +480,25 @@ int DetectStrongAskClock(uint8_t *dest, size_t size, int high, int low, int *clo
|
||||||
size_t startwave;
|
size_t startwave;
|
||||||
size_t i = 100;
|
size_t i = 100;
|
||||||
size_t minClk = 512;
|
size_t minClk = 512;
|
||||||
int shortestWaveIdx = 0;
|
uint16_t shortestWaveIdx = 0;
|
||||||
|
|
||||||
// get to first full low to prime loop and skip incomplete first pulse
|
// get to first full low to prime loop and skip incomplete first pulse
|
||||||
getNextHigh(dest, size, high, &i);
|
getNextHigh(dest, size, high, &i);
|
||||||
getNextLow(dest, size, low, &i);
|
getNextLow(dest, size, low, &i);
|
||||||
|
|
||||||
|
// clock, numoftimes, first idx
|
||||||
|
uint16_t tmpclk[9][3] = {
|
||||||
|
{8, 0, 0},
|
||||||
|
{16, 0, 0},
|
||||||
|
{32, 0, 0},
|
||||||
|
{40, 0, 0},
|
||||||
|
{50, 0, 0},
|
||||||
|
{64, 0, 0},
|
||||||
|
{128, 0, 0},
|
||||||
|
{256, 0, 0},
|
||||||
|
{384, 0, 0},
|
||||||
|
};
|
||||||
|
|
||||||
// loop through all samples (well, we don't want to go out-of-bounds)
|
// loop through all samples (well, we don't want to go out-of-bounds)
|
||||||
while (i < size - 512) {
|
while (i < size - 512) {
|
||||||
// measure from low to low
|
// measure from low to low
|
||||||
|
@ -499,11 +512,38 @@ int DetectStrongAskClock(uint8_t *dest, size_t size, int high, int low, int *clo
|
||||||
minClk = i - startwave;
|
minClk = i - startwave;
|
||||||
shortestWaveIdx = startwave;
|
shortestWaveIdx = startwave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int foo = getClosestClock(minClk);
|
||||||
|
if (foo > 0 ) {
|
||||||
|
for (uint8_t i = 0; i < 9; i++) {
|
||||||
|
if ( tmpclk[i][0] == foo ) {
|
||||||
|
tmpclk[i][1]++;
|
||||||
|
|
||||||
|
if ( tmpclk[i][2] == 0) {
|
||||||
|
tmpclk[i][2] = shortestWaveIdx;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set clock
|
// find the clock with most hits and it the first index it was encountered.
|
||||||
if (g_debugMode == 2) prnt("DEBUG ASK: DetectStrongAskClock smallest wave: %d", minClk);
|
int max = 0;
|
||||||
*clock = getClosestClock(minClk);
|
for (uint8_t i = 0; i < 9; i++) {
|
||||||
|
if (g_debugMode == 2) {
|
||||||
|
prnt("DEBUG, ASK, clocks %u | hits %u | idx %u"
|
||||||
|
, tmpclk[i][0]
|
||||||
|
, tmpclk[i][1]
|
||||||
|
, tmpclk[i][2]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ( max < tmpclk[i][1] ) {
|
||||||
|
*clock = tmpclk[i][0];
|
||||||
|
shortestWaveIdx = tmpclk[i][2];
|
||||||
|
max = tmpclk[i][1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (*clock == 0)
|
if (*clock == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue