diff --git a/armsrc/appmain.c b/armsrc/appmain.c index d1da448db..ef3d099d0 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -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: diff --git a/armsrc/lfops.c b/armsrc/lfops.c index 31418d5b5..2fed8d962 100644 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@ -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 diff --git a/client/cmdlf.c b/client/cmdlf.c index 8e504df82..af6b97bf6 100644 --- a/client/cmdlf.c +++ b/client/cmdlf.c @@ -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) { diff --git a/client/cmdlfawid.c b/client/cmdlfawid.c index c2d4bc63b..ff7c111bd 100644 --- a/client/cmdlfawid.c +++ b/client/cmdlfawid.c @@ -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) { diff --git a/client/cmdlffdx.c b/client/cmdlffdx.c index 49d91344b..29797474c 100644 --- a/client/cmdlffdx.c +++ b/client/cmdlffdx.c @@ -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[] = { diff --git a/client/cmdlfguard.c b/client/cmdlfguard.c index 2476711ef..cf5a05056 100644 --- a/client/cmdlfguard.c +++ b/client/cmdlfguard.c @@ -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[] = { diff --git a/client/cmdlfhid.c b/client/cmdlfhid.c index b712cb50f..facc3aab7 100644 --- a/client/cmdlfhid.c +++ b/client/cmdlfhid.c @@ -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) { diff --git a/client/cmdlfindala.c b/client/cmdlfindala.c index d1d99db78..f6e4d2850 100644 --- a/client/cmdlfindala.c +++ b/client/cmdlfindala.c @@ -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 diff --git a/client/cmdlfio.c b/client/cmdlfio.c index 50e0ae9d8..6e7ca1e79 100644 --- a/client/cmdlfio.c +++ b/client/cmdlfio.c @@ -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) { diff --git a/client/cmdlfjablotron.c b/client/cmdlfjablotron.c index c2d4b6a78..86752bc82 100644 --- a/client/cmdlfjablotron.c +++ b/client/cmdlfjablotron.c @@ -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[] = { diff --git a/client/cmdlfkeri.c b/client/cmdlfkeri.c index b99560567..fff641b44 100644 --- a/client/cmdlfkeri.c +++ b/client/cmdlfkeri.c @@ -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[] = { diff --git a/client/cmdlfnedap.c b/client/cmdlfnedap.c index 417d4f6cf..03ff95d27 100644 --- a/client/cmdlfnedap.c +++ b/client/cmdlfnedap.c @@ -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) { diff --git a/client/cmdlfnoralsy.c b/client/cmdlfnoralsy.c index 667a80d16..cca9e38ff 100644 --- a/client/cmdlfnoralsy.c +++ b/client/cmdlfnoralsy.c @@ -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[] = { diff --git a/client/cmdlfparadox.c b/client/cmdlfparadox.c index 6b836c846..9b3744878 100644 --- a/client/cmdlfparadox.c +++ b/client/cmdlfparadox.c @@ -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[] = { diff --git a/client/cmdlfpresco.c b/client/cmdlfpresco.c index b710fd112..15068d9e5 100644 --- a/client/cmdlfpresco.c +++ b/client/cmdlfpresco.c @@ -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[] = { diff --git a/client/cmdlfpyramid.c b/client/cmdlfpyramid.c index f5d848672..8201e0a18 100644 --- a/client/cmdlfpyramid.c +++ b/client/cmdlfpyramid.c @@ -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[] = { diff --git a/client/cmdlfviking.c b/client/cmdlfviking.c index 75b84bed4..c5ad9b055 100644 --- a/client/cmdlfviking.c +++ b/client/cmdlfviking.c @@ -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[] = { diff --git a/client/cmdlfvisa2000.c b/client/cmdlfvisa2000.c index 2d5808f29..72ffaff38 100644 --- a/client/cmdlfvisa2000.c +++ b/client/cmdlfvisa2000.c @@ -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[] = { diff --git a/client/comms.c b/client/comms.c index 38b9ff812..764b70089 100644 --- a/client/comms.c +++ b/client/comms.c @@ -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; }