chg: 'lf awid brute' - added verbose logging option

chg: 'lf hid brute' - added verbose logging option
This commit is contained in:
iceman1001 2017-08-11 18:13:58 +02:00
commit b4d7ed4862
2 changed files with 48 additions and 29 deletions

View file

@ -70,18 +70,19 @@ int usage_lf_awid_brute(void){
PrintAndLog("This is a attack against reader. if cardnumber is given, it starts with it and goes up / down one step");
PrintAndLog("if cardnumber is not given, it starts with 1 and goes up to 65535");
PrintAndLog("");
PrintAndLog("Usage: lf awid brute [h] a <format> f <facility-code> c <cardnumber> d <delay>");
PrintAndLog("Usage: lf awid brute [h] [v] a <format> f <facility-code> c <cardnumber> d <delay>");
PrintAndLog("Options:");
PrintAndLog(" h : This help");
PrintAndLog(" a <format> : format length 26|50");
PrintAndLog(" f <facility-code> : 8|16bit value facility code");
PrintAndLog(" c <cardnumber> : (optional) cardnumber to start with, max 65535");
PrintAndLog(" d <delay> : delay betweens attempts in ms. Default 1000ms");
PrintAndLog(" v : verbose logging, show all tries");
PrintAndLog("");
PrintAndLog("Samples:");
PrintAndLog(" lf awid brute a 26 f 224");
PrintAndLog(" lf awid brute a 50 f 2001 d 2000");
PrintAndLog(" lf awid brute a 50 f 2001 c 200 d 2000");
PrintAndLog(" lf awid brute v a 50 f 2001 c 200 d 2000");
return 0;
}
@ -97,9 +98,12 @@ static int sendPing(void){
return 1;
}
static bool sendTry(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint32_t delay, uint8_t *bs, size_t bs_len){
PrintAndLog("Trying FC: %u; CN: %u", fc, cn);
if ( !getAWIDBits(fmtlen, fc, cn, bs)) {
static bool sendTry(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint32_t delay, uint8_t *bits, size_t bs_len, bool verbose){
if ( verbose )
PrintAndLog("Trying FC: %u; CN: %u", fc, cn);
if ( !getAWIDBits(fmtlen, fc, cn, bits)) {
PrintAndLog("Error with tag bitstream generation.");
return false;
}
@ -109,9 +113,10 @@ static bool sendTry(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint32_t delay, ui
uint64_t arg2 = (invert << 8) + clk;
UsbCommand c = {CMD_FSK_SIM_TAG, {arg1, arg2, bs_len}};
memcpy(c.d.asBytes, bs, bs_len);
memcpy(c.d.asBytes, bits, bs_len);
clearCommandBuffer();
SendCommand(&c);
msleep(delay);
sendPing();
return true;
@ -458,13 +463,12 @@ int CmdAWIDClone(const char *Cmd) {
int CmdAWIDBrute(const char *Cmd) {
bool errors = false;
bool errors = false, verbose = false;
uint32_t fc = 0, cn = 0, delay = 1000;
uint8_t fmtlen = 0;
uint8_t bits[96];
uint8_t *bs = bits;
size_t size = sizeof(bits);
memset(bs, 0x00, size);
memset(bits, 0x00, size);
uint8_t cmdp = 0;
while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {
@ -497,6 +501,11 @@ int CmdAWIDBrute(const char *Cmd) {
fmtlen = param_get8(Cmd, cmdp+1);
cmdp += 2;
break;
case 'v':
case 'V':
verbose = true;
cmdp++;
break;
default:
PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
errors = true;
@ -528,6 +537,7 @@ int CmdAWIDBrute(const char *Cmd) {
uint16_t up = cn;
uint16_t down = cn;
// main loop
for (;;){
if ( offline ) {
@ -542,12 +552,12 @@ int CmdAWIDBrute(const char *Cmd) {
// Do one up
if ( up < 0xFFFF )
if ( !sendTry(fmtlen, fc, up++, delay, bs, size)) return 1;
if ( !sendTry(fmtlen, fc, up++, delay, bits, size, verbose)) return 1;
// Do one down (if cardnumber is given)
if ( cn > 1 )
if ( down > 1 )
if ( !sendTry(fmtlen, fc, --down, delay, bs, size)) return 1;
if ( !sendTry(fmtlen, fc, --down, delay, bits, size, verbose)) return 1;
}
return 0;
}