HF15FindAfi now uses reply_ng and added LeaveFieldOn option for HF15Raw

This commit is contained in:
unknown 2019-11-27 15:11:43 +02:00
parent cef28ad241
commit 931d115ef8
3 changed files with 26 additions and 3 deletions

View file

@ -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]
- Added `hf 15 writeafi`, `hf 15 writedsfid` and detailed info for SLIX2 tags in `hf 15 info`. Also did some refactoring in HF15 commands. (@grspy)
- Fix hf list felica and hf felica sniff (@7homasSutter)
- Added hf felica wrunencrypted (@7homasSutter)
- Added hf felica rdunencrypted (@7homasSutter)

View file

@ -929,6 +929,7 @@ void BruteforceIso15693Afi(uint32_t speed) {
uint8_t buf[ISO15_MAX_FRAME];
memset(buf, 0x00, sizeof(buf));
int datalen = 0, recvlen = 0;
bool aborted = false;
Iso15693InitReader();
@ -968,12 +969,19 @@ void BruteforceIso15693Afi(uint32_t speed) {
if (BUTTON_PRESS()) {
DbpString("button pressed, aborting..");
aborted = true;
break;
}
}
DbpString("AFI Bruteforcing done.");
switch_off();
if (aborted) {
reply_ng(CMD_ACK, PM3_EOPABORTED, NULL, 0);
} else {
reply_ng(CMD_ACK, PM3_SUCCESS, NULL, 0);
}
}
// Allows to directly send commands to the tag via the client

View file

@ -412,6 +412,7 @@ static int usage_15_raw(void) {
{"-r", "do not read response" },
{"-2", "use slower '1 out of 256' mode" },
{"-c", "calculate and append CRC" },
{"-p", "leave the signal field ON" },
{"", "Tip: turn on debugging for verbose output"},
};
PrintAndLogEx(NORMAL, "Usage: hf 15 raw [-r] [-2] [-c] <0A 0B 0C ... hex>\n");
@ -949,6 +950,7 @@ static int CmdHF15Sim(const char *Cmd) {
// (There is no standard way of reading the AFI, although some tags support this)
// helptext
static int CmdHF15FindAfi(const char *Cmd) {
PacketResponseNG resp;
char cmdp = tolower(param_getchar(Cmd, 0));
if (cmdp == 'h') return usage_15_findafi();
@ -956,8 +958,14 @@ static int CmdHF15FindAfi(const char *Cmd) {
clearCommandBuffer();
SendCommandMIX(CMD_HF_ISO15693_FINDAFI, strtol(Cmd, NULL, 0), 0, 0, NULL, 0);
if (WaitForResponseTimeout(CMD_ACK, &resp, 120000)) { // 2 minutes should be enough
DropField();
return resp.status; // PM3_EOPABORTED or PM3_SUCCESS
}
DropField();
return PM3_SUCCESS;
return PM3_ETIMEOUT;
}
// Writes the AFI (Application Family Identifier) of a card
@ -1225,7 +1233,7 @@ static int CmdHF15Raw(const char *Cmd) {
PacketResponseNG resp;
int reply = 1, fast = 1, i = 0;
bool crc = false;
bool crc = false, leaveSignalON = false;
char buf[5] = "";
uint8_t data[100];
uint32_t datalen = 0, temp;
@ -1248,6 +1256,10 @@ static int CmdHF15Raw(const char *Cmd) {
case 'C':
crc = true;
break;
case 'p':
case 'P':
leaveSignalON = true;
break;
default:
PrintAndLogEx(WARNING, "Invalid option");
return PM3_EINVARG;
@ -1292,7 +1304,9 @@ static int CmdHF15Raw(const char *Cmd) {
}
}
DropField();
if (!leaveSignalON)
DropField();
return PM3_SUCCESS;
}