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...
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Fixed `lf viking reader` - search in inverted bitsteam as well (#doegox)
|
||||
- Added more default keys (@CONIGUERO)
|
||||
- Change `hf 14a info` - it now detects FUDAN (@iceman1001) Thanks to @secit-pl
|
||||
- Fixed support to clone Pyramic, Paradox and Awid on EM4x05 (@doegox)
|
||||
|
|
|
@ -266,28 +266,51 @@ uint64_t getVikingBits(uint32_t id) {
|
|||
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
|
||||
int detectViking(uint8_t *src, size_t *size) {
|
||||
//make sure buffer has data
|
||||
if (*size < 64) return -2;
|
||||
size_t tsize = *size;
|
||||
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};
|
||||
if (!preambleSearch(src, preamble, sizeof(preamble), size, &startIdx))
|
||||
return -4; //preamble not found
|
||||
|
||||
uint32_t checkCalc = bytebits_to_byte(src + startIdx, 8) ^
|
||||
bytebits_to_byte(src + startIdx + 8, 8) ^
|
||||
bytebits_to_byte(src + startIdx + 16, 8) ^
|
||||
bytebits_to_byte(src + startIdx + 24, 8) ^
|
||||
bytebits_to_byte(src + startIdx + 32, 8) ^
|
||||
bytebits_to_byte(src + startIdx + 40, 8) ^
|
||||
bytebits_to_byte(src + startIdx + 48, 8) ^
|
||||
bytebits_to_byte(src + startIdx + 56, 8);
|
||||
|
||||
if (checkCalc != 0xA8) return -5;
|
||||
if (preambleSearch(src, preamble, sizeof(preamble), size, &startIdx)) {
|
||||
preamblefound = true;
|
||||
if (*size != 64) return -6;
|
||||
if (isValidVikingChecksum(src + startIdx)) {
|
||||
//return start position
|
||||
return (int)startIdx;
|
||||
}
|
||||
}
|
||||
// Invert bits and try again
|
||||
*size = tsize;
|
||||
for (uint32_t i = 0; i < *size; i++) src[i] ^= 1;
|
||||
if (preambleSearch(src, preamble, sizeof(preamble), size, &startIdx)) {
|
||||
preamblefound = true;
|
||||
if (*size != 64) return -6;
|
||||
if (isValidVikingChecksum(src + 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