Merge branch 'master' into master

This commit is contained in:
mwalker33 2019-10-11 20:42:36 +11:00 committed by GitHub
commit 33ed92849c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 130 additions and 49 deletions

View file

@ -4,9 +4,13 @@ COVTOKEN=aAbBcCdDeEfFgGhHiIjJkK
COVBINDIR="/opt/cov-analysis-linux64-2019.03/bin"
# Nickname included in scan description:
NICKNAME=myself
# cov can't read gcov from gcc > 7
HOSTCC=gcc-7
HOSTCXX=g++-7
HOSTLD=g++-7
# Do not change it:
COVDIR=cov-int
COVBUILD="cov-build --dir $COVDIR"
# Depending if your kernel > 4.8.x, you might need to activate this to run Coverity executables
# (but latest tools with kernel 5.2 run fine)

View file

@ -5,6 +5,8 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
## [unreleased][unreleased]
- Added lf t55xx dump save and lf t55xx restore for .bin and .eml files (@mwalker33)
- Added lf t55xx detected to try without password first (@mwalker33)
- Chg `lf indala read` - added indala 26bit decoding (@martinbeier)
- Chg `lf t55xx detect` to try without password first (@mwalker33)
- Display high bit for detected Kastle HIDs to allow `lf hid clone [id]` to work properly (@swg0101)
- Add option `-n` to scripts pm3* (@doegox)
- Add `wiegand list/encode/decode` - wiegand format manipulation. Adapted to fit here. (@grauerfuchs)

View file

@ -45,7 +45,9 @@ On the software side: quite a lot, see the [Changelog file](CHANGELOG.md).
## Development
This repo now compiles just fine on
> ⚠ **Note**: This is a bleeding edge repository. The maintainers actively is working out of this repository and will be periodically re-structuring the code to make it easier to comprehend, navigate, build, test, and contribute to, so **DO expect significant changes to code layout on a regular basis**.
This repo compiles nicely on
- Proxspace v3.2
- Windows/mingw environment with Qt5.6.1 & GCC 4.8
- Ubuntu 1404, 1510, 1604, 1804, 1904
@ -54,8 +56,10 @@ This repo now compiles just fine on
- WSL, WSL2 (Windows subsystem linux) on Windows 10
- Docker container
If you intend to contribute to the code, please read the [coding style notes](HACKING.md) first.
> 👉 **Remember!** If you intend to contribute to the code, please read the [coding style notes](HACKING.md) first.
We usually merge your contributions fast since we do like the idea of getting a functionality in the Proxmark3 and weed out the bugs afterwards.
## Notes / helpful documents
- Internal notes on [Coverity Scan Config & Run](/doc/md/Development/Coverity-Scan-Config-%26-Run.md).
- Internal notes on [UART](/doc/uart_notes.md)
- Internal notes on [Frame format](/doc/new_frame_format.md)

View file

@ -12,7 +12,7 @@
#include <stdlib.h> // size_t
#include <string.h>
#include <ctype.h> // tolower
#include <stdio.h> // printf
#include "commonutil.h" // reflect...
#include "comms.h" // clearCommandBuffer
#include "cmdparser.h" // command_t
@ -21,6 +21,7 @@
#include "crc16.h" // crc16 ccitt
#include "tea.h"
#include "legic_prng.h"
#include "cmddata.h" // demodbuffer
static int CmdHelp(const char *Cmd);
@ -36,7 +37,7 @@ static int usage_analyse_lcr(void) {
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " analyse lcr 04008064BA");
PrintAndLogEx(NORMAL, "expected output: Target (BA) requires final LRC XOR byte value: 5A");
return 0;
return PM3_SUCCESS;
}
static int usage_analyse_checksum(void) {
PrintAndLogEx(NORMAL, "The bytes will be added with eachother and than limited with the applied mask");
@ -52,7 +53,7 @@ static int usage_analyse_checksum(void) {
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " analyse chksum b 137AF00A0A0D m FF");
PrintAndLogEx(NORMAL, "expected output: 0x61");
return 0;
return PM3_SUCCESS;
}
static int usage_analyse_crc(void) {
PrintAndLogEx(NORMAL, "A stub method to test different crc implementations inside the PM3 sourcecode. Just because you figured out the poly, doesn't mean you get the desired output");
@ -64,7 +65,7 @@ static int usage_analyse_crc(void) {
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " analyse crc 137AF00A0A0D");
return 0;
return PM3_SUCCESS;
}
static int usage_analyse_nuid(void) {
PrintAndLogEx(NORMAL, "Generate 4byte NUID from 7byte UID");
@ -76,7 +77,7 @@ static int usage_analyse_nuid(void) {
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " analyse nuid 11223344556677");
return 0;
return PM3_SUCCESS;
}
static int usage_analyse_a(void) {
PrintAndLogEx(NORMAL, "Iceman's personal garbage test command");
@ -88,7 +89,19 @@ static int usage_analyse_a(void) {
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " analyse a d 137AF00A0A0D");
return 0;
return PM3_SUCCESS;
}
static int usage_analyse_demodbuffer(void) {
PrintAndLogEx(NORMAL, "loads a binary string into demod buffer");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Usage: analyse demodbuff [h] <binarystring>");
PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h This help");
PrintAndLogEx(NORMAL, " <binarystring> Binary string to load");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " analyse demodbuff 0011101001001011");
return PM3_SUCCESS;
}
static uint8_t calculateLRC(uint8_t *bytes, uint8_t len) {
@ -878,6 +891,39 @@ static int CmdAnalyseNuid(const char *Cmd) {
PrintAndLogEx(NORMAL, "NUID | %s \n", sprint_hex(nuid, 4));
return 0;
}
static int CmdAnalyseDemodBuffer(const char *Cmd) {
char cmdp = tolower(param_getchar(Cmd, 0));
if (strlen(Cmd) == 0 || cmdp == 'h') return usage_analyse_demodbuffer();
int bg = 0, en = 0;
if (param_getptr(Cmd, &bg, &en, 0))
return usage_analyse_demodbuffer();
int len = MIN( (en- bg + 1), MAX_DEMOD_BUF_LEN);
// add 1 for null terminator.
uint8_t *data = calloc(len + 1, sizeof(uint8_t));
if (!data) return PM3_EMALLOC;
for(int i = 0; bg <= en; bg++ , i++) {
char c = Cmd[bg];
if (c == '1')
DemodBuffer[i] = 1;
if (c == '0')
DemodBuffer[i] = 0;
printf("%c", c);
}
printf("\n");
DemodBufferLen = len;
free(data);
return PM3_SUCCESS;
}
static command_t CommandTable[] = {
{"help", CmdHelp, AlwaysAvailable, "This help"},
{"lcr", CmdAnalyseLCR, AlwaysAvailable, "Generate final byte for XOR LRC"},
@ -888,6 +934,7 @@ static command_t CommandTable[] = {
{"lfsr", CmdAnalyseLfsr, AlwaysAvailable, "LFSR tests"},
{"a", CmdAnalyseA, AlwaysAvailable, "num bits test"},
{"nuid", CmdAnalyseNuid, AlwaysAvailable, "create NUID from 7byte UID"},
{"demodbuff", CmdAnalyseDemodBuffer, AlwaysAvailable, "Load binary string to demodbuffer"},
{NULL, NULL, NULL, NULL}
};

View file

@ -137,44 +137,42 @@ static int CmdIndalaDemod(const char *Cmd) {
p1 |= DemodBuffer[32 + 24] << 9;
uint8_t fc = 0;
fc |= DemodBuffer[32+25] << 7; // b8
fc |= DemodBuffer[32+17] << 6; // b7
fc |= DemodBuffer[32+12] << 5; // b6
fc |= DemodBuffer[32+16] << 4; // b5
fc |= DemodBuffer[32+15] << 3; // b4
fc |= DemodBuffer[32+21] << 2; // b3
fc |= DemodBuffer[32+7] << 1; // b2
fc |= DemodBuffer[32+26] << 0; // b1
fc |= DemodBuffer[57] << 7; // b8
fc |= DemodBuffer[49] << 6; // b7
fc |= DemodBuffer[44] << 5; // b6
fc |= DemodBuffer[47] << 4; // b5
fc |= DemodBuffer[48] << 3; // b4
fc |= DemodBuffer[53] << 2; // b3
fc |= DemodBuffer[39] << 1; // b2
fc |= DemodBuffer[58] << 0; // b1
uint16_t csn = 0;
csn |= DemodBuffer[32+10] << 15; // b16
csn |= DemodBuffer[32+13] << 14; // b15
csn |= DemodBuffer[32+11] << 13; // b14
csn |= DemodBuffer[32+8] << 12; // b13
csn |= DemodBuffer[32+20] << 11; // b12
csn |= DemodBuffer[32+4] << 10; // b11
csn |= DemodBuffer[32+3] << 9; // b10
csn |= DemodBuffer[32+19] << 8; // b9
csn |= DemodBuffer[32+14] << 7; // b8
csn |= DemodBuffer[32+1] << 6; // b7
csn |= DemodBuffer[32+5] << 5; // b6
csn |= DemodBuffer[32+22] << 4; // b5
csn |= DemodBuffer[32+24] << 3; // b4
csn |= DemodBuffer[32+27] << 2; // b3
csn |= DemodBuffer[32+18] << 1; // b2
csn |= DemodBuffer[32+9] << 0; // b1
csn |= DemodBuffer[42] << 15; // b16
csn |= DemodBuffer[45] << 14; // b15
csn |= DemodBuffer[43] << 13; // b14
csn |= DemodBuffer[40] << 12; // b13
csn |= DemodBuffer[52] << 11; // b12
csn |= DemodBuffer[36] << 10; // b11
csn |= DemodBuffer[35] << 9; // b10
csn |= DemodBuffer[51] << 8; // b9
csn |= DemodBuffer[46] << 7; // b8
csn |= DemodBuffer[33] << 6; // b7
csn |= DemodBuffer[37] << 5; // b6
csn |= DemodBuffer[54] << 4; // b5
csn |= DemodBuffer[56] << 3; // b4
csn |= DemodBuffer[59] << 2; // b3
csn |= DemodBuffer[50] << 1; // b2
csn |= DemodBuffer[41] << 0; // b1
uint8_t checksum = 0;
checksum |= DemodBuffer[32+30] << 1; // b2
checksum |= DemodBuffer[92+31] << 0; // b1
checksum |= DemodBuffer[62] << 1; // b2
checksum |= DemodBuffer[63] << 0; // b1
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(SUCCESS, "Possible de-scramble patterns");
PrintAndLogEx(SUCCESS, "\tPrinted | __%04d__ [0x%X]", p1, p1);
//PrintAndLogEx(SUCCESS, "\tPrinted | __%04d__ [0x%X]", fc, fc);
PrintAndLogEx(SUCCESS, "\tInternal ID | %" PRIu64, foo);
PrintAndLogEx(SUCCESS, "\nFC %u , CSN %u , checksum %1d%1d", fc, csn, checksum >> 1 & 0x01, checksum & 0x01 );
PrintAndLogEx(SUCCESS, "Fmt 26 bit FC %u , CSN %u , checksum %1d%1d", fc, csn, checksum >> 1 & 0x01, checksum & 0x01 );
} else {
uint32_t uid3 = bytebits_to_byte(DemodBuffer + 64, 32);

View file

@ -5,16 +5,39 @@ set -e
pre_build_hook
rm -rf "$COVDIR"
mkdir "$COVDIR"
mkdir -p "$COVDIR"
make clean
$COVBUILD make -j 4 bootrom
$COVBUILD make -j 4 fullimage
$COVBUILD make -j 4 mfkey
$COVBUILD make -j 4 nonce2key
$COVBUILD make -j 4 fpga_compress
cov-build --dir "$COVDIR" --initialize
#########################################
# Build Host prerequisites #
#########################################
cov-build --dir "$COVDIR" --c-coverage=gcov --no-network-coverage --no-generate-build-id --force make CC=$HOSTCC CXX=$HOSTCXX LD=$HOSTLD fpga_compress
#########################################
# Build ARM, no test coverage #
#########################################
cov-build --dir "$COVDIR" --no-generate-build-id --force make bootrom
cov-build --dir "$COVDIR" --no-generate-build-id --force make fullimage
#########################################
# Build client #
#########################################
# make sure to do client after ARM because Coverity retains one build info per file
# and we want the client-side of the common/ analysis
$COVBUILD make -j 4 client
cov-build --dir "$COVDIR" --c-coverage=gcov --no-network-coverage --no-generate-build-id --force make CC=$HOSTCC CXX=$HOSTCXX LD=$HOSTLD mfkey
cov-build --dir "$COVDIR" --c-coverage=gcov --no-network-coverage --no-generate-build-id --force make CC=$HOSTCC CXX=$HOSTCXX LD=$HOSTLD nonce2key
cov-build --dir "$COVDIR" --c-coverage=gcov --no-network-coverage --no-generate-build-id --force make CC=$HOSTCC CXX=$HOSTCXX LD=$HOSTLD client
#########################################
# Run tests #
#########################################
cov-build --dir "$COVDIR" --c-coverage=gcov --no-network-coverage --test-capture ./pm3test.sh
#cov-manage-emit --dir "$COVDIR" list-coverage-known
#########################################
# Import Git annotations (~ git blame) #
#########################################
cov-import-scm --dir "$COVDIR" --scm git --filename-regex "$PWD" --log ""$COVDIR"/cov-import-scm-log.txt"
post_build_hook

View file

@ -3,4 +3,7 @@
set -e
. .coverity.conf || exit 1
# cov-configure --list-configured-compilers text
cov-configure --template --compiler arm-none-eabi-gcc --comptype gcc
# cov can't read gcov from gcc > 7
cov-configure --template --compiler $HOSTCC --comptype gcc