mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
Fixed - search in inverted bitsteam as well
This commit is contained in:
parent
00a13f8164
commit
cc7054fc9b
2 changed files with 42 additions and 18 deletions
|
@ -3,6 +3,7 @@ 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...
|
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]
|
## [unreleased][unreleased]
|
||||||
|
- Fixed `lf viking reader` - search in inverted bitsteam as well (#doegox)
|
||||||
- Added more default keys (@CONIGUERO)
|
- Added more default keys (@CONIGUERO)
|
||||||
- Change `hf 14a info` - it now detects FUDAN (@iceman1001) Thanks to @secit-pl
|
- Change `hf 14a info` - it now detects FUDAN (@iceman1001) Thanks to @secit-pl
|
||||||
- Fixed support to clone Pyramic, Paradox and Awid on EM4x05 (@doegox)
|
- Fixed support to clone Pyramic, Paradox and Awid on EM4x05 (@doegox)
|
||||||
|
|
|
@ -266,28 +266,51 @@ uint64_t getVikingBits(uint32_t id) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isValidVikingChecksum(uint8_t *src) {
|
||||||
|
uint32_t checkCalc = bytebits_to_byte(src, 8) ^
|
||||||
|
bytebits_to_byte(src + 8, 8) ^
|
||||||
|
bytebits_to_byte(src + 16, 8) ^
|
||||||
|
bytebits_to_byte(src + 24, 8) ^
|
||||||
|
bytebits_to_byte(src + 32, 8) ^
|
||||||
|
bytebits_to_byte(src + 40, 8) ^
|
||||||
|
bytebits_to_byte(src + 48, 8) ^
|
||||||
|
bytebits_to_byte(src + 56, 8) ^
|
||||||
|
0xA8;
|
||||||
|
return checkCalc == 0;
|
||||||
|
}
|
||||||
|
|
||||||
// find viking preamble 0xF200 in already demoded data
|
// find viking preamble 0xF200 in already demoded data
|
||||||
int detectViking(uint8_t *src, size_t *size) {
|
int detectViking(uint8_t *src, size_t *size) {
|
||||||
//make sure buffer has data
|
//make sure buffer has data
|
||||||
if (*size < 64) return -2;
|
if (*size < 64) return -2;
|
||||||
|
size_t tsize = *size;
|
||||||
size_t startIdx = 0;
|
size_t startIdx = 0;
|
||||||
|
bool preamblefound = false;
|
||||||
uint8_t preamble[] = {1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
uint8_t preamble[] = {1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
if (!preambleSearch(src, preamble, sizeof(preamble), size, &startIdx))
|
if (preambleSearch(src, preamble, sizeof(preamble), size, &startIdx)) {
|
||||||
return -4; //preamble not found
|
preamblefound = true;
|
||||||
|
if (*size != 64) return -6;
|
||||||
uint32_t checkCalc = bytebits_to_byte(src + startIdx, 8) ^
|
if (isValidVikingChecksum(src + startIdx)) {
|
||||||
bytebits_to_byte(src + startIdx + 8, 8) ^
|
//return start position
|
||||||
bytebits_to_byte(src + startIdx + 16, 8) ^
|
return (int)startIdx;
|
||||||
bytebits_to_byte(src + startIdx + 24, 8) ^
|
}
|
||||||
bytebits_to_byte(src + startIdx + 32, 8) ^
|
}
|
||||||
bytebits_to_byte(src + startIdx + 40, 8) ^
|
// Invert bits and try again
|
||||||
bytebits_to_byte(src + startIdx + 48, 8) ^
|
*size = tsize;
|
||||||
bytebits_to_byte(src + startIdx + 56, 8);
|
for (uint32_t i = 0; i < *size; i++) src[i] ^= 1;
|
||||||
|
if (preambleSearch(src, preamble, sizeof(preamble), size, &startIdx)) {
|
||||||
if (checkCalc != 0xA8) return -5;
|
preamblefound = true;
|
||||||
if (*size != 64) return -6;
|
if (*size != 64) return -6;
|
||||||
//return start position
|
if (isValidVikingChecksum(src + startIdx)) {
|
||||||
return (int)startIdx;
|
//return start position
|
||||||
|
return (int)startIdx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Restore buffer
|
||||||
|
*size = tsize;
|
||||||
|
for (uint32_t i = 0; i < *size; i++) src[i] ^= 1;
|
||||||
|
if (preamblefound)
|
||||||
|
return -5;
|
||||||
|
else
|
||||||
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue