mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
Fix Client Response for RAW command. Client should receives now all response octects.
This commit is contained in:
parent
9d3331511b
commit
4da87d3f96
3 changed files with 36 additions and 50 deletions
|
@ -417,6 +417,7 @@ bool WaitForFelicaReply(uint16_t maxbytes) {
|
||||||
if (DBGLEVEL > 3)
|
if (DBGLEVEL > 3)
|
||||||
Dbprintf("timeout set: %i", timeout);
|
Dbprintf("timeout set: %i", timeout);
|
||||||
//TODO FIX THIS METHOD - Race Condition or something: TIMING/MEMORY ISSUES
|
//TODO FIX THIS METHOD - Race Condition or something: TIMING/MEMORY ISSUES
|
||||||
|
// If you add content here (dbprintf), timing problems appear?! Last Bytes (CRC) of frame will be cutoff.
|
||||||
for (;;) {
|
for (;;) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
|
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
|
||||||
|
@ -442,7 +443,7 @@ bool WaitForFelicaReply(uint16_t maxbytes) {
|
||||||
} else if (c++ > timeout && FelicaFrame.state == STATE_UNSYNCD) {
|
} else if (c++ > timeout && FelicaFrame.state == STATE_UNSYNCD) {
|
||||||
if (DBGLEVEL > 3) Dbprintf("Error: Timeout! STATE_UNSYNCD");
|
if (DBGLEVEL > 3) Dbprintf("Error: Timeout! STATE_UNSYNCD");
|
||||||
return false;
|
return false;
|
||||||
} // If you add content here, timing problems appear?!
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -488,6 +489,14 @@ static void iso18092_setup(uint8_t fpga_minor_mode) {
|
||||||
|
|
||||||
LED_D_ON();
|
LED_D_ON();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void felica_reset_frame_mode(){
|
||||||
|
switch_off();
|
||||||
|
//Resetting Frame mode (First set in fpgaloader.c)
|
||||||
|
AT91C_BASE_SSC->SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD(8) | AT91C_SSC_MSBF | SSC_FRAME_MODE_WORDS_PER_TRANSFER(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// RAW FeliCa commands. Send out commands and store answers.
|
// RAW FeliCa commands. Send out commands and store answers.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -516,11 +525,12 @@ void felica_sendraw(PacketCommandNG *c) {
|
||||||
// if failed selecting, turn off antenna and quite.
|
// if failed selecting, turn off antenna and quite.
|
||||||
if (!(param & FELICA_NO_SELECT)) {
|
if (!(param & FELICA_NO_SELECT)) {
|
||||||
arg0 = felica_select_card(&card);
|
arg0 = felica_select_card(&card);
|
||||||
reply_old(CMD_ACK, arg0, sizeof(card.uid), 0, &card, sizeof(felica_card_select_t));
|
reply_mix(CMD_ACK, arg0, sizeof(card.uid), 0, &card, sizeof(felica_card_select_t));
|
||||||
if (arg0 > 0){
|
if (arg0 > 0){
|
||||||
Dbprintf("Error: Failed selecting card! ");
|
Dbprintf("Error: Failed selecting card! ");
|
||||||
|
felica_reset_frame_mode();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
goto OUT;
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (DBGLEVEL > 3) Dbprintf("No card selection");
|
if (DBGLEVEL > 3) Dbprintf("No card selection");
|
||||||
|
@ -552,24 +562,21 @@ void felica_sendraw(PacketCommandNG *c) {
|
||||||
TransmitFor18092_AsReader(buf, buf[2] + 4, NULL, 1, 0);
|
TransmitFor18092_AsReader(buf, buf[2] + 4, NULL, 1, 0);
|
||||||
arg0 = WaitForFelicaReply(1024);
|
arg0 = WaitForFelicaReply(1024);
|
||||||
if (DBGLEVEL > 3) {
|
if (DBGLEVEL > 3) {
|
||||||
Dbprintf("Received Frame: %d", arg0);
|
Dbprintf("Received Frame Code: %d", arg0);
|
||||||
Dbhexdump(FelicaFrame.len, FelicaFrame.framebytes, 0);
|
Dbhexdump(FelicaFrame.len, FelicaFrame.framebytes, 0);
|
||||||
};
|
};
|
||||||
reply_old(CMD_ACK, arg0, 0, 0, FelicaFrame.framebytes + 2, FelicaFrame.len - 2);
|
uint32_t result = reply_mix(CMD_ACK, FelicaFrame.len, arg0, 0, FelicaFrame.framebytes, FelicaFrame.len);
|
||||||
FelicaFrameReset();
|
if(result){
|
||||||
|
Dbprintf("Reply to Client Error Code: %i", result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if ((param & FELICA_NO_DISCONNECT)){
|
||||||
if ((param & FELICA_NO_DISCONNECT))
|
|
||||||
Dbprintf("Disconnect");
|
Dbprintf("Disconnect");
|
||||||
return;
|
}
|
||||||
|
if (DBGLEVEL > 3)
|
||||||
OUT:
|
Dbprintf("FeliCa_sendraw Exit");
|
||||||
switch_off();
|
felica_reset_frame_mode();
|
||||||
|
return;
|
||||||
//Resetting Frame mode (First set in fpgaloader.c)
|
|
||||||
AT91C_BASE_SSC->SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD(8) | AT91C_SSC_MSBF | SSC_FRAME_MODE_WORDS_PER_TRANSFER(0);
|
|
||||||
|
|
||||||
if (DBGLEVEL > 3) Dbprintf("FeliCa_sendraw Exit");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void felica_sniff(uint32_t samplesToSkip, uint32_t triggersToSkip) {
|
void felica_sniff(uint32_t samplesToSkip, uint32_t triggersToSkip) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ void felica_create_read_block_frame(uint16_t blockNr);
|
||||||
void felica_create_authentication1_frame();
|
void felica_create_authentication1_frame();
|
||||||
void felica_create_authentication2_frame();
|
void felica_create_authentication2_frame();
|
||||||
void felica_send_request_service(uint8_t *request_service);
|
void felica_send_request_service(uint8_t *request_service);
|
||||||
|
void felica_reset_frame_mode();
|
||||||
uint8_t * felica_create_request_service_frame(uint8_t nodeNumber, uint8_t *idm);
|
uint8_t * felica_create_request_service_frame(uint8_t nodeNumber, uint8_t *idm);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -440,17 +440,15 @@ static int CmdHFFelicaDumpLite(const char *Cmd) {
|
||||||
|
|
||||||
static void waitCmdFelica(uint8_t iSelect) {
|
static void waitCmdFelica(uint8_t iSelect) {
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
|
|
||||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||||
uint16_t len = iSelect ? (resp.oldarg[1] & 0xffff) : (resp.oldarg[0] & 0xffff);
|
uint16_t len = iSelect ? (resp.oldarg[1] & 0xffff) : (resp.oldarg[0] & 0xffff);
|
||||||
PrintAndLogEx(NORMAL, "received %i octets", len);
|
PrintAndLogEx(NORMAL, "Client Received %i octets", len);
|
||||||
if (!len)
|
if (!len)
|
||||||
return;
|
return;
|
||||||
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.data.asBytes, len));
|
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.data.asBytes, len));
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
PrintAndLogEx(WARNING, "Timeout while waiting for reply.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdHFFelicaCmdRaw(const char *Cmd) {
|
static int CmdHFFelicaCmdRaw(const char *Cmd) {
|
||||||
|
@ -532,6 +530,7 @@ static int CmdHFFelicaCmdRaw(const char *Cmd) {
|
||||||
if (crc && datalen > 0 && datalen < sizeof(data) - 2) {
|
if (crc && datalen > 0 && datalen < sizeof(data) - 2) {
|
||||||
uint8_t b1, b2;
|
uint8_t b1, b2;
|
||||||
compute_crc(CRC_FELICA, data, datalen, &b1, &b2);
|
compute_crc(CRC_FELICA, data, datalen, &b1, &b2);
|
||||||
|
// TODO FIND OUT IF FeliCa Light has another CRC order - Order changed for FeliCa Standard cards
|
||||||
data[datalen++] = b2;
|
data[datalen++] = b2;
|
||||||
data[datalen++] = b1;
|
data[datalen++] = b1;
|
||||||
}
|
}
|
||||||
|
@ -555,14 +554,16 @@ static int CmdHFFelicaCmdRaw(const char *Cmd) {
|
||||||
datalen = (datalen > PM3_CMD_DATA_SIZE) ? PM3_CMD_DATA_SIZE : datalen;
|
datalen = (datalen > PM3_CMD_DATA_SIZE) ? PM3_CMD_DATA_SIZE : datalen;
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_HF_FELICA_COMMAND, flags, (datalen & 0xFFFF) | (uint32_t)(numbits << 16), 0, data, datalen);
|
SendCommandMIX(CMD_HF_FELICA_COMMAND, flags, (datalen & 0xFFFF) | (uint32_t)(numbits << 16), 0, data, datalen);
|
||||||
|
|
||||||
if (reply) {
|
if (reply) {
|
||||||
if (active_select)
|
if (active_select){
|
||||||
PrintAndLogEx(NORMAL, "Active select wait for FeliCa.");
|
PrintAndLogEx(NORMAL, "Active select wait for FeliCa.");
|
||||||
waitCmdFelica(1);
|
waitCmdFelica(1);
|
||||||
if (datalen > 0)
|
}
|
||||||
|
if (datalen > 0){
|
||||||
waitCmdFelica(0);
|
waitCmdFelica(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -617,37 +618,14 @@ int readFelicaUid(bool verbose) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO FINISH THIS METHOD
|
|
||||||
int dump(const char *Cmd){
|
int dump(const char *Cmd){
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||||
if (ctmp == 'h') return usage_hf_felica_dumplite();
|
if (ctmp == 'h') return usage_hf_felica_dumplite();
|
||||||
|
// TODO FINISH THIS METHOD
|
||||||
|
PrintAndLogEx(SUCCESS, "NOT IMPLEMENTED YET!");
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "FeliCa - dump started");
|
|
||||||
clearCommandBuffer();
|
|
||||||
SendCommandNG(CMD_HF_FELICALITE_DUMP, NULL, 0);
|
|
||||||
PacketResponseNG resp;
|
|
||||||
|
|
||||||
uint8_t timeout = 0;
|
|
||||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
|
||||||
timeout++;
|
|
||||||
printf(".");
|
|
||||||
fflush(stdout);
|
|
||||||
if (kbd_enter_pressed()) {
|
|
||||||
PrintAndLogEx(WARNING, "\n[!] aborted via keyboard!\n");
|
|
||||||
DropField();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (timeout > 100) {
|
|
||||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
|
||||||
DropField();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (resp.oldarg[0] == 0) {
|
|
||||||
PrintAndLogEx(WARNING, "\nButton pressed. Aborted.");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue