chg: lf psksim - uses NG

This commit is contained in:
iceman1001
2019-05-24 09:11:30 -04:00
parent 80a91eba11
commit 0d1438d156
8 changed files with 87 additions and 47 deletions

View File

@@ -831,14 +831,23 @@ int CmdLFpskSim(const char *Cmd) {
}
}
size_t size = DemodBufferLen;
if (size > PM3_CMD_DATA_SIZE) {
PrintAndLogEx(NORMAL, "DemodBuffer too long for current implementation - length: %d - max: %d", size, PM3_CMD_DATA_SIZE);
size = PM3_CMD_DATA_SIZE;
if (size > (PM3_CMD_DATA_SIZE - sizeof(lf_psksim_t))) {
PrintAndLogEx(NORMAL, "DemodBuffer too long for current implementation - length: %d - max: %d", size, PM3_CMD_DATA_SIZE - sizeof(lf_psksim_t));
size = PM3_CMD_DATA_SIZE - sizeof(lf_psksim_t);
}
PrintAndLogEx(DEBUG, "DEBUG: Sending DemodBuffer Length: %d", size);
lf_psksim_t *payload = calloc(1, sizeof(lf_psksim_t) + size);
payload->carrier = carrier;
payload->invert = invert;
payload->clock = clk;
memcpy(payload->data, DemodBuffer, size);
PrintAndLogEx(INFO, "Simulating");
clearCommandBuffer();
SendCommandOLD(CMD_PSK_SIM_TAG, clk << 8 | carrier, invert, size, DemodBuffer, size);
SendCommandNG(CMD_PSK_SIM_TAG, (uint8_t *)payload, sizeof(lf_psksim_t) + size);
free(payload);
PacketResponseNG resp;
WaitForResponse(CMD_PSK_SIM_TAG, &resp);

View File

@@ -332,13 +332,14 @@ static int CmdAWIDSim(const char *Cmd) {
verify_values(&fmtlen, &fc, &cn);
PrintAndLogEx(SUCCESS, "Simulating AWID %u -- FC: %u; CN: %u\n", fmtlen, fc, cn);
PrintAndLogEx(SUCCESS, "Press pm3-button to abort simulation or run another command");
if ( getAWIDBits(fmtlen, fc, cn, bs) != PM3_SUCCESS ) {
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
return PM3_ESOFT;
}
PrintAndLogEx(SUCCESS, "Simulating AWID %u -- FC: %u; CN: %u\n", fmtlen, fc, cn);
PrintAndLogEx(SUCCESS, "Press pm3-button to abort simulation or run another command");
// AWID uses: FSK2a fcHigh: 10, fcLow: 8, clk: 50, invert: 1
// arg1 --- fcHigh<<8 + fcLow
// arg2 --- Inversion and clk setting

View File

@@ -372,8 +372,8 @@ static int CmdIndalaSim(const char *Cmd) {
char cmdp = tolower(param_getchar(Cmd, 0));
if (strlen(Cmd) == 0 || cmdp == 'h') return usage_lf_indala_sim();
uint8_t bits[224];
memset(bits, 0x00, sizeof(bits));
uint8_t bs[224];
memset(bs, 0x00, sizeof(bs));
// uid
uint8_t hexuid[100];
@@ -386,24 +386,35 @@ static int CmdIndalaSim(const char *Cmd) {
uint8_t counter = 223;
for (uint8_t i = 0; i < len; i++) {
for (uint8_t j = 0; j < 8; j++) {
bits[counter--] = hexuid[i] & 1;
bs[counter--] = hexuid[i] & 1;
hexuid[i] >>= 1;
}
}
// indala PSK
uint8_t clk = 32, carrier = 2, invert = 0;
// It has to send either 64bits (8bytes) or 224bits (28bytes). Zero padding needed if not.
// lf simpsk 1 c 32 r 2 d 0102030405060708
PrintAndLogEx(SUCCESS, "Simulating Indala UID: %s", sprint_hex(hexuid, len));
PrintAndLogEx(SUCCESS, "Press pm3-button to abort simulation or run another command");
// indala PSK, clock 32, carrier 0
lf_psksim_t *payload = calloc(1, sizeof(lf_psksim_t) + sizeof(bs));
payload->carrier = 2;
payload->invert = 0;
payload->clock = 32;
memcpy(payload->data, bs, sizeof(bs));
PrintAndLogEx(INFO, "Simulating");
clearCommandBuffer();
SendCommandOLD(CMD_PSK_SIM_TAG, clk << 8 | carrier, invert, sizeof(bits), bits, sizeof(bits));
SendCommandNG(CMD_PSK_SIM_TAG, (uint8_t *)payload, sizeof(lf_psksim_t) + sizeof(bs));
free(payload);
PacketResponseNG resp;
WaitForResponse(CMD_PSK_SIM_TAG, &resp);
PrintAndLogEx(INFO, "Done");
if (resp.status != PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;

View File

@@ -175,28 +175,39 @@ static int CmdKeriClone(const char *Cmd) {
static int CmdKeriSim(const char *Cmd) {
char cmdp = tolower(param_getchar(Cmd, 0));
if (strlen(Cmd) == 0 || cmdp == 'h') return usage_lf_keri_sim();
if (strlen(Cmd) == 0 || cmdp == 'h')
return usage_lf_keri_sim();
uint64_t internalid = param_get32ex(Cmd, 0, 0, 10);
internalid |= 0x80000000;
internalid <<= 3;
internalid += 7;
uint8_t bits[64] = {0x00};
uint8_t bs[64] = {0x00};
// loop to bits
uint8_t j = 0;
for (int8_t i = 63; i >= 0; --i) {
bits[j++] = ((internalid >> i) & 1);
bs[j++] = ((internalid >> i) & 1);
}
uint8_t clk = 32, carrier = 2, invert = 0;
PrintAndLogEx(SUCCESS, "Simulating KERI - Internal Id: %u", internalid);
lf_psksim_t *payload = calloc(1, sizeof(lf_psksim_t) + sizeof(bs));
payload->carrier = 2;
payload->invert = 0;
payload->clock = 32;
memcpy(payload->data, bs, sizeof(bs));
PrintAndLogEx(INFO, "Simulating");
clearCommandBuffer();
SendCommandOLD(CMD_PSK_SIM_TAG, clk << 8 | carrier, invert, sizeof(bits), bits, sizeof(bits));
SendCommandNG(CMD_PSK_SIM_TAG, (uint8_t *)payload, sizeof(lf_psksim_t) + sizeof(bs));
free(payload);
PacketResponseNG resp;
WaitForResponse(CMD_PSK_SIM_TAG, &resp);
PrintAndLogEx(INFO, "Done");
if (resp.status != PM3_EOPABORTED)
return resp.status;
return PM3_SUCCESS;