monster merge...

all those changes marshmellow did..  and more...
This commit is contained in:
iceman1001 2017-07-30 09:17:48 +02:00
commit f28da2da6e
107 changed files with 5087 additions and 3777 deletions

View file

@ -72,6 +72,18 @@ int getnoralsyBits(uint32_t id, uint16_t year, uint8_t *bits) {
return 1;
}
// by iceman
// find Noralsy preamble in already demoded data
int detectNoralsy(uint8_t *dest, size_t *size) {
if (*size < 96) return -1; //make sure buffer has data
size_t startIdx = 0;
uint8_t preamble[] = {1,0,1,1,1,0,1,1,0,0,0,0};
if (!preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx))
return -2; //preamble not found
if (*size != 96) return -3; //wrong demoded size
//return start position
return (int)startIdx;
}
/*
*
* 2520116 | BB0214FF2529900116360000 | 10111011 00000011 00010100 11111111 00100101 00101001 10010000 00000001 00010110 00110110 00000000 00000000
@ -97,7 +109,7 @@ int CmdNoralsyDemod(const char *Cmd) {
if (!st) return 0;
size_t size = DemodBufferLen;
int ans = NoralsyDemod_AM(DemodBuffer, &size);
int ans = detectNoralsy(DemodBuffer, &size);
if (ans < 0){
if (g_debugMode){
if (ans == -1)
@ -112,7 +124,7 @@ int CmdNoralsyDemod(const char *Cmd) {
return 0;
}
setDemodBuf(DemodBuffer, 96, ans);
setGrid_Clock(32);
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans*g_DemodClock));
//got a good demod
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
@ -136,21 +148,24 @@ int CmdNoralsyDemod(const char *Cmd) {
chk2 = bytebits_to_byte(DemodBuffer+76, 4);
// test checksums
if ( chk1 != calc1 ) {
printf("checksum 1 failed %x - %x\n", chk1, calc1);
if (g_debugMode) PrintAndLog("DEBUG: Error - Noralsy: checksum 1 failed %x - %x\n", chk1, calc1);
return 0;
}
if ( chk2 != calc2 ) {
printf("checksum 2 failed %x - %x\n", chk2, calc2);
if (g_debugMode) PrintAndLog("DEBUG: Error - Noralsy: checksum 2 failed %x - %x\n", chk2, calc2);
return 0;
}
PrintAndLog("Noralsy Tag Found: Card ID %u, Year: %u Raw: %08X%08X%08X", cardid, year, raw1 ,raw2, raw3);
if (raw1 != 0xBB0214FF) {
PrintAndLog("Unknown bits set in first block! Expected 0xBB0214FF, Found: 0x%08X", raw1);
PrintAndLog("Please post this output in forum to further research on this format");
}
return 1;
}
int CmdNoralsyRead(const char *Cmd) {
CmdLFRead("s");
getSamples("8000",true);
lf_read(true, 8000);
return CmdNoralsyDemod(Cmd);
}
@ -246,9 +261,10 @@ int CmdNoralsySim(const char *Cmd) {
static command_t CommandTable[] = {
{"help", CmdHelp, 1, "This help"},
{"read", CmdNoralsyRead, 0, "Attempt to read and extract tag data"},
{"clone", CmdNoralsyClone,0, "clone Noralsy tag"},
{"sim", CmdNoralsySim, 0, "simulate Noralsy tag"},
{"demod", CmdNoralsyDemod,1, "Demodulate an Noralsy tag from the GraphBuffer"},
{"read", CmdNoralsyRead, 0, "Attempt to read and extract tag data from the antenna"},
{"sim", CmdNoralsySim, 0, "Noralsy tag simulator"},
{"clone", CmdNoralsyClone,0, "clone Noralsy to T55x7"},
{NULL, NULL, 0, NULL}
};