all LF sim: client waits till button pressed

This commit is contained in:
Philippe Teuwen 2019-05-09 00:08:59 +02:00
parent ddd62e2848
commit 2c10482279
19 changed files with 104 additions and 24 deletions

View file

@ -799,6 +799,7 @@ static void PacketReceived(PacketCommandNG *packet) {
case CMD_SIMULATE_TAG_125K:
LED_A_ON();
SimulateTagLowFrequency(packet->oldarg[0], packet->oldarg[1], 1);
reply_ng(CMD_SIMULATE_TAG_125K, PM3_EOPABORTED, NULL, 0);
LED_A_OFF();
break;
case CMD_LF_SIMULATE_BIDIR:

View file

@ -595,7 +595,7 @@ void SimulateTagLowFrequencyEx(int period, int gap, int ledcontrol, int numcycle
if (x != numcycles) {
++x;
} else {
// exit without turning of field
// exit without turning off field
return;
}
}
@ -819,6 +819,7 @@ void CmdHIDsimTAGEx(uint32_t hi, uint32_t lo, int ledcontrol, int numcycles) {
void CmdHIDsimTAG(uint32_t hi, uint32_t lo, int ledcontrol) {
CmdHIDsimTAGEx(hi, lo, ledcontrol, -1);
DbpString("[!] simulation finished");
reply_ng(CMD_HID_SIM_TAG, PM3_EOPABORTED, NULL, 0);
}
// prepare a waveform pattern in the buffer based on the ID given then
@ -859,6 +860,7 @@ void CmdFSKsimTAG(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *bits, int
if (ledcontrol) LED_A_ON();
SimulateTagLowFrequency(n, 0, ledcontrol);
if (ledcontrol) LED_A_OFF();
reply_ng(CMD_FSK_SIM_TAG, PM3_EOPABORTED, NULL, 0);
}
// compose ask waveform for one bit(ASK)
@ -943,6 +945,7 @@ void CmdASKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *bits, int
if (ledcontrol) LED_A_ON();
SimulateTagLowFrequency(n, 0, ledcontrol);
if (ledcontrol) LED_A_OFF();
reply_ng(CMD_ASK_SIM_TAG, PM3_EOPABORTED, NULL, 0);
}
//carrier can be 2,4 or 8
@ -992,6 +995,7 @@ void CmdPSKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *bits, int
if (ledcontrol) LED_A_ON();
SimulateTagLowFrequency(n, 0, ledcontrol);
if (ledcontrol) LED_A_OFF();
reply_ng(CMD_PSK_SIM_TAG, PM3_EOPABORTED, NULL, 0);
}
// loop to get raw HID waveform then FSK demodulate the TAG ID from it

View file

@ -439,7 +439,11 @@ int CmdLFSim(const char *Cmd) {
clearCommandBuffer();
SendCommandMIX(CMD_SIMULATE_TAG_125K, GraphTraceLen, gap, 0, NULL, 0);
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_SIMULATE_TAG_125K, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
// by marshmellow - sim fsk data given clock, fcHigh, fcLow, invert
@ -526,7 +530,11 @@ int CmdLFfskSim(const char *Cmd) {
SendCommandOLD(CMD_FSK_SIM_TAG, fcHigh << 8 | fcLow, (separator << 8) | clk, size, DemodBuffer, size);
setClockGrid(clk, 0);
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_FSK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
// by marshmellow - sim ask data given clock, invert, manchester or raw, separator
@ -611,7 +619,11 @@ int CmdLFaskSim(const char *Cmd) {
PrintAndLogEx(NORMAL, "preparing to sim ask data: %d bits", size);
clearCommandBuffer();
SendCommandOLD(CMD_ASK_SIM_TAG, clk << 8 | encoding, invert << 8 | separator, size, DemodBuffer, size);
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_ASK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
// by marshmellow - sim psk data given carrier, clock, invert
@ -714,7 +726,11 @@ int CmdLFpskSim(const char *Cmd) {
PrintAndLogEx(DEBUG, "DEBUG: Sending DemodBuffer Length: %d", size);
clearCommandBuffer();
SendCommandOLD(CMD_PSK_SIM_TAG, clk << 8 | carrier, invert, size, DemodBuffer, size);
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_PSK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
int CmdLFSimBidir(const char *Cmd) {

View file

@ -343,7 +343,11 @@ static int CmdAWIDSim(const char *Cmd) {
// 96 --- Bitstream length: 96-bits == 12 bytes
clearCommandBuffer();
SendCommandOLD(CMD_FSK_SIM_TAG, (high << 8) + low, (invert << 8) + clk, sizeof(bits), bits, sizeof(bits));
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_FSK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
static int CmdAWIDClone(const char *Cmd) {

View file

@ -322,7 +322,11 @@ static int CmdFdxSim(const char *Cmd) {
getFDXBits(animalid, countryid, 1, 0, 0, data);
clearCommandBuffer();
SendCommandOLD(CMD_ASK_SIM_TAG, clk << 8 | encoding, invert << 8 | separator, sizeof(data), data, sizeof(data));
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_ASK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
static command_t CommandTable[] = {

View file

@ -216,7 +216,11 @@ static int CmdGuardSim(const char *Cmd) {
clearCommandBuffer();
SendCommandOLD(CMD_ASK_SIM_TAG, (clock1 << 8) | encoding, (invert << 8) | separator, sizeof(bs), bs, sizeof(bs));
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_ASK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
static command_t CommandTable[] = {

View file

@ -260,7 +260,11 @@ static int CmdHIDSim(const char *Cmd) {
clearCommandBuffer();
SendCommandMIX(CMD_HID_SIM_TAG, hi, lo, 0, NULL, 0);
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_HID_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
static int CmdHIDClone(const char *Cmd) {

View file

@ -402,7 +402,11 @@ static int CmdIndalaSim(const char *Cmd) {
clearCommandBuffer();
SendCommandOLD(CMD_PSK_SIM_TAG, clk << 8 | carrier, invert, sizeof(bits), bits, sizeof(bits));
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_PSK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
// iceman - needs refactoring

View file

@ -212,7 +212,11 @@ static int CmdIOProxSim(const char *Cmd) {
// size --- 64 bits == 8 bytes
clearCommandBuffer();
SendCommandOLD(CMD_FSK_SIM_TAG, high << 8 | low, invert << 8 | clk, sizeof(bits), bits, sizeof(bits));
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_FSK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
static int CmdIOProxClone(const char *Cmd) {

View file

@ -195,7 +195,11 @@ static int CmdJablotronSim(const char *Cmd) {
getJablotronBits(fullcode, data);
clearCommandBuffer();
SendCommandOLD(CMD_ASK_SIM_TAG, clk << 8 | encoding, invert << 8 | separator, sizeof(data), data, sizeof(data));
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_ASK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
static command_t CommandTable[] = {

View file

@ -189,8 +189,11 @@ static int CmdKeriSim(const char *Cmd) {
clearCommandBuffer();
SendCommandOLD(CMD_PSK_SIM_TAG, clk << 8 | carrier, invert, sizeof(bits), bits, sizeof(bits));
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_PSK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
static command_t CommandTable[] = {

View file

@ -249,7 +249,11 @@ static int CmdLFNedapSim(const char *Cmd) {
clearCommandBuffer();
SendCommandOLD(CMD_ASK_SIM_TAG, clk << 8 | encoding, invert << 8 | separator, sizeof(bs), bs, sizeof(bs));
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_ASK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
static int CmdLFNedapChk(const char *Cmd) {

View file

@ -198,7 +198,11 @@ static int CmdNoralsySim(const char *Cmd) {
clearCommandBuffer();
SendCommandOLD(CMD_ASK_SIM_TAG, clk << 8 | encoding, invert << 8 | separator, sizeof(bits), bits, sizeof(bits));
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_ASK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
static command_t CommandTable[] = {

View file

@ -136,9 +136,13 @@ static int CmdParadoxSim(const char *Cmd) {
clearCommandBuffer();
SendCommandOLD(CMD_FSK_SIM_TAG, high << 8 | low, invert << 8 | clk, sizeof(bs), bs, sizeof(bs));
PacketResponseNG resp;
WaitForResponse(CMD_FSK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
PrintAndLogEx(NORMAL, "UNFINISHED");
return 0;
// PrintAndLogEx(NORMAL, "UNFINISHED");
}
static command_t CommandTable[] = {

View file

@ -154,7 +154,11 @@ static int CmdPrescoSim(const char *Cmd) {
uint8_t data[128];
getPrescoBits(fullcode, data);
SendCommandOLD(CMD_ASK_SIM_TAG, clk << 8 | encoding, invert << 8 | separator, sizeof(data), data, sizeof(data));
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_ASK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
static command_t CommandTable[] = {

View file

@ -278,7 +278,11 @@ static int CmdPyramidSim(const char *Cmd) {
clearCommandBuffer();
SendCommandOLD(CMD_FSK_SIM_TAG, high << 8 | low, invert << 8 | clk, sizeof(bs), bs, sizeof(bs));
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_FSK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
static command_t CommandTable[] = {

View file

@ -117,7 +117,11 @@ static int CmdVikingSim(const char *Cmd) {
num_to_bytebits(rawID, sizeof(data), data);
clearCommandBuffer();
SendCommandOLD(CMD_ASK_SIM_TAG, clk << 8 | encoding, invert << 8 | separator, sizeof(data), data, sizeof(data));
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_ASK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
static command_t CommandTable[] = {

View file

@ -205,7 +205,11 @@ static int CmdVisa2kSim(const char *Cmd) {
clearCommandBuffer();
SendCommandOLD(CMD_ASK_SIM_TAG, clk << 8 | encoding, invert << 8 | separator, sizeof(data), data, sizeof(data));
return 0;
PacketResponseNG resp;
WaitForResponse(CMD_ASK_SIM_TAG, &resp);
if (resp.status!=PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;
}
static command_t CommandTable[] = {

View file

@ -714,12 +714,12 @@ bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms
}
tmp_clk = __atomic_load_n(&timeout_start_time, __ATOMIC_SEQ_CST);
if (msclock() - tmp_clk > ms_timeout)
if ((ms_timeout != (size_t) -1) && (msclock() - tmp_clk > ms_timeout))
break;
if (msclock() - tmp_clk > 3000 && show_warning) {
// 3 seconds elapsed (but this doesn't mean the timeout was exceeded)
PrintAndLogEx(INFO, "Waiting for a response from the proxmark3...");
// PrintAndLogEx(INFO, "Waiting for a response from the proxmark3...");
PrintAndLogEx(INFO, "You can cancel this operation by pressing the pm3 button");
show_warning = false;
}