chg: lf simfsk\nlf paradox sim\nlf awid sim\n\lf ioprox sim\nlf pyramid sim - NG

This commit is contained in:
iceman1001 2019-05-23 17:07:12 -04:00
commit c13e2f09a1
7 changed files with 80 additions and 45 deletions

View file

@ -783,16 +783,8 @@ static void PacketReceived(PacketCommandNG *packet) {
CmdHIDsimTAG(packet->oldarg[0], packet->oldarg[1], 1); CmdHIDsimTAG(packet->oldarg[0], packet->oldarg[1], 1);
break; break;
case CMD_FSK_SIM_TAG: { case CMD_FSK_SIM_TAG: {
struct p { lf_fsksim_t *payload = (lf_fsksim_t *)packet->data.asBytes;
uint8_t fchigh; CmdFSKsimTAG(payload->fchigh, payload->fclow, payload->separator, payload->clock, packet->length - sizeof(lf_fsksim_t), payload->data, 1);
uint8_t fclow;
uint8_t separator;
uint8_t clock;
uint16_t datalen;
} PACKED;
struct p *payload = (struct p*)packet->data.asBytes;
CmdFSKsimTAG(payload->fchigh, payload->fclow, payload->separator, payload->clock, payload->datalen, packet->data.asBytes + 6, 1);
break; break;
} }
case CMD_ASK_SIM_TAG: case CMD_ASK_SIM_TAG:

View file

@ -608,33 +608,23 @@ int CmdLFfskSim(const char *Cmd) {
if (fcHigh == 0) fcHigh = 10; if (fcHigh == 0) fcHigh = 10;
if (fcLow == 0) fcLow = 8; if (fcLow == 0) fcLow = 8;
struct {
uint8_t fchigh;
uint8_t fclow;
uint8_t separator;
uint8_t clock;
uint16_t datalen;
uint8_t data[PM3_CMD_DATA_SIZE - 6];
} PACKED payload;
payload.fchigh = fcHigh;
payload.fclow = fcLow;
payload.separator = separator;
payload.clock = clk;
size_t size = DemodBufferLen; size_t size = DemodBufferLen;
if (size > sizeof(payload.data)) { if (size > (PM3_CMD_DATA_SIZE - sizeof(lf_fsksim_t))) {
PrintAndLogEx(NORMAL, "DemodBuffer too long for current implementation - length: %d - max: %d", size, sizeof(payload.data)); PrintAndLogEx(NORMAL, "DemodBuffer too long for current implementation - length: %d - max: %d", size, PM3_CMD_DATA_SIZE - sizeof(lf_fsksim_t));
size = sizeof(payload.data); size = PM3_CMD_DATA_SIZE - sizeof(lf_fsksim_t);
} }
payload.datalen = (uint16_t)size; lf_fsksim_t *payload = calloc(1, sizeof(lf_fsksim_t) + size);
memcpy(payload.data, DemodBuffer, size); payload->fchigh = fcHigh;
payload->fclow = fcLow;
payload->separator = separator;
payload->clock = clk;
memcpy(payload->data, DemodBuffer, size);
PrintAndLogEx(INFO, "Simulating"); PrintAndLogEx(INFO, "Simulating");
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_FSK_SIM_TAG, (uint8_t *)&payload, 6 + payload.datalen); SendCommandNG(CMD_FSK_SIM_TAG, (uint8_t *)payload, sizeof(lf_fsksim_t) + size);
setClockGrid(clk, 0); setClockGrid(clk, 0);
PacketResponseNG resp; PacketResponseNG resp;

View file

@ -109,8 +109,15 @@ static int sendTry(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint32_t delay, uin
uint8_t clk = 50, high = 10, low = 8, invert = 1; uint8_t clk = 50, high = 10, low = 8, invert = 1;
lf_fsksim_t *payload = calloc(1, sizeof(lf_fsksim_t) + bs_len);
payload->fchigh = high;
payload->fclow = low;
payload->separator = invert;
payload->clock = clk;
memcpy(payload->data, bits, bs_len);
clearCommandBuffer(); clearCommandBuffer();
SendCommandOLD(CMD_FSK_SIM_TAG, (high << 8) + low, (invert << 8) + clk, bs_len, bits, bs_len); SendCommandNG(CMD_FSK_SIM_TAG, (uint8_t *)payload, sizeof(lf_fsksim_t) + bs_len);
msleep(delay); msleep(delay);
return sendPing(); return sendPing();
@ -313,8 +320,8 @@ static int CmdAWIDRead(const char *Cmd) {
static int CmdAWIDSim(const char *Cmd) { static int CmdAWIDSim(const char *Cmd) {
uint32_t fc = 0, cn = 0; uint32_t fc = 0, cn = 0;
uint8_t fmtlen = 0; uint8_t fmtlen = 0;
uint8_t bits[96]; uint8_t bs[96];
memset(bits, 0x00, sizeof(bits)); memset(bs, 0x00, sizeof(bs));
char cmdp = param_getchar(Cmd, 0); char cmdp = param_getchar(Cmd, 0);
if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_awid_sim(); if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_awid_sim();
@ -329,7 +336,7 @@ static int CmdAWIDSim(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Simulating AWID %u -- FC: %u; CN: %u\n", 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"); PrintAndLogEx(SUCCESS, "Press pm3-button to abort simulation or run another command");
if ( getAWIDBits(fmtlen, fc, cn, bits) != PM3_SUCCESS ) { if ( getAWIDBits(fmtlen, fc, cn, bs) != PM3_SUCCESS ) {
PrintAndLogEx(WARNING, "Error with tag bitstream generation."); PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
return PM3_ESOFT; return PM3_ESOFT;
} }
@ -340,10 +347,20 @@ static int CmdAWIDSim(const char *Cmd) {
// arg1 --- fcHigh<<8 + fcLow // arg1 --- fcHigh<<8 + fcLow
// arg2 --- Inversion and clk setting // arg2 --- Inversion and clk setting
// 96 --- Bitstream length: 96-bits == 12 bytes // 96 --- Bitstream length: 96-bits == 12 bytes
lf_fsksim_t *payload = calloc(1, sizeof(lf_fsksim_t) + sizeof(bs));
payload->fchigh = high;
payload->fclow = low;
payload->separator = invert;
payload->clock = clk;
memcpy(payload->data, bs, sizeof(bs));
clearCommandBuffer(); clearCommandBuffer();
SendCommandOLD(CMD_FSK_SIM_TAG, (high << 8) + low, (invert << 8) + clk, sizeof(bits), bits, sizeof(bits)); SendCommandNG(CMD_FSK_SIM_TAG, (uint8_t *)payload, sizeof(lf_fsksim_t) + sizeof(bs));
PacketResponseNG resp; PacketResponseNG resp;
WaitForResponse(CMD_FSK_SIM_TAG, &resp); WaitForResponse(CMD_FSK_SIM_TAG, &resp);
PrintAndLogEx(INFO, "Done");
if (resp.status != PM3_EOPABORTED) if (resp.status != PM3_EOPABORTED)
return resp.status; return resp.status;
return PM3_SUCCESS; return PM3_SUCCESS;

View file

@ -178,8 +178,8 @@ static int CmdIOProxRead(const char *Cmd) {
static int CmdIOProxSim(const char *Cmd) { static int CmdIOProxSim(const char *Cmd) {
uint16_t cn = 0; uint16_t cn = 0;
uint8_t version = 0, fc = 0; uint8_t version = 0, fc = 0;
uint8_t bits[64]; uint8_t bs[64];
memset(bits, 0x00, sizeof(bits)); memset(bs, 0x00, sizeof(bs));
char cmdp = tolower(param_getchar(Cmd, 0)); char cmdp = tolower(param_getchar(Cmd, 0));
if (strlen(Cmd) == 0 || cmdp == 'h') return usage_lf_io_sim(); if (strlen(Cmd) == 0 || cmdp == 'h') return usage_lf_io_sim();
@ -201,7 +201,7 @@ static int CmdIOProxSim(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Simulating IOProx version: %u FC: %u; CN: %u\n", version, fc, cn); PrintAndLogEx(SUCCESS, "Simulating IOProx version: %u FC: %u; CN: %u\n", version, fc, cn);
PrintAndLogEx(SUCCESS, "Press pm3-button to abort simulation or run another command"); PrintAndLogEx(SUCCESS, "Press pm3-button to abort simulation or run another command");
if (getIOProxBits(version, fc, cn, bits) != PM3_SUCCESS) { if (getIOProxBits(version, fc, cn, bs) != PM3_SUCCESS) {
PrintAndLogEx(WARNING, "Error with tag bitstream generation."); PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
return PM3_ESOFT; return PM3_ESOFT;
} }
@ -209,10 +209,19 @@ static int CmdIOProxSim(const char *Cmd) {
// arg1 --- fcHigh<<8 + fcLow // arg1 --- fcHigh<<8 + fcLow
// arg2 --- Invert and clk setting // arg2 --- Invert and clk setting
// size --- 64 bits == 8 bytes // size --- 64 bits == 8 bytes
lf_fsksim_t *payload = calloc(1, sizeof(lf_fsksim_t) + sizeof(bs));
payload->fchigh = high;
payload->fclow = low;
payload->separator = invert;
payload->clock = clk;
memcpy(payload->data, bs, sizeof(bs));
clearCommandBuffer(); clearCommandBuffer();
SendCommandOLD(CMD_FSK_SIM_TAG, high << 8 | low, invert << 8 | clk, sizeof(bits), bits, sizeof(bits)); SendCommandNG(CMD_FSK_SIM_TAG, (uint8_t *)payload, sizeof(lf_fsksim_t) + sizeof(bs));
PacketResponseNG resp; PacketResponseNG resp;
WaitForResponse(CMD_FSK_SIM_TAG, &resp); WaitForResponse(CMD_FSK_SIM_TAG, &resp);
PrintAndLogEx(INFO, "Done");
if (resp.status != PM3_EOPABORTED) if (resp.status != PM3_EOPABORTED)
return resp.status; return resp.status;
return PM3_SUCCESS; return PM3_SUCCESS;

View file

@ -134,10 +134,19 @@ static int CmdParadoxSim(const char *Cmd) {
PrintAndLogEx(NORMAL, "Simulating Paradox - Facility Code: %u, CardNumber: %u", facilitycode, cardnumber); PrintAndLogEx(NORMAL, "Simulating Paradox - Facility Code: %u, CardNumber: %u", facilitycode, cardnumber);
lf_fsksim_t *payload = calloc(1, sizeof(lf_fsksim_t) + sizeof(bs));
payload->fchigh = high;
payload->fclow = low;
payload->separator = invert;
payload->clock = clk;
memcpy(payload->data, bs, sizeof(bs));
clearCommandBuffer(); clearCommandBuffer();
SendCommandOLD(CMD_FSK_SIM_TAG, high << 8 | low, invert << 8 | clk, sizeof(bs), bs, sizeof(bs)); SendCommandNG(CMD_FSK_SIM_TAG, (uint8_t *)payload, sizeof(lf_fsksim_t) + sizeof(bs));
PacketResponseNG resp; PacketResponseNG resp;
WaitForResponse(CMD_FSK_SIM_TAG, &resp); WaitForResponse(CMD_FSK_SIM_TAG, &resp);
PrintAndLogEx(INFO, "Done");
if (resp.status != PM3_EOPABORTED) if (resp.status != PM3_EOPABORTED)
return resp.status; return resp.status;
return PM3_SUCCESS; return PM3_SUCCESS;

View file

@ -212,7 +212,7 @@ static int CmdPyramidClone(const char *Cmd) {
facilitycode = (fc & 0x000000FF); facilitycode = (fc & 0x000000FF);
cardnumber = (cn & 0x0000FFFF); cardnumber = (cn & 0x0000FFFF);
if (!getPyramidBits(facilitycode, cardnumber, bs)) { if (getPyramidBits(facilitycode, cardnumber, bs) != PM3_SUCCESS) {
PrintAndLogEx(WARNING, "Error with tag bitstream generation."); PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
return PM3_ESOFT; return PM3_ESOFT;
} }
@ -275,17 +275,27 @@ static int CmdPyramidSim(const char *Cmd) {
facilitycode = (fc & 0x000000FF); facilitycode = (fc & 0x000000FF);
cardnumber = (cn & 0x0000FFFF); cardnumber = (cn & 0x0000FFFF);
if (!getPyramidBits(facilitycode, cardnumber, bs)) { if (getPyramidBits(facilitycode, cardnumber, bs) != PM3_SUCCESS) {
PrintAndLogEx(WARNING, "Error with tag bitstream generation."); PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
return PM3_ESOFT; return PM3_ESOFT;
} }
PrintAndLogEx(SUCCESS, "Simulating Farpointe/Pyramid - Facility Code: %u, CardNumber: %u", facilitycode, cardnumber); PrintAndLogEx(SUCCESS, "Simulating Farpointe/Pyramid - Facility Code: %u, CardNumber: %u", facilitycode, cardnumber);
lf_fsksim_t *payload = calloc(1, sizeof(lf_fsksim_t) + sizeof(bs));
payload->fchigh = high;
payload->fclow = low;
payload->separator = invert;
payload->clock = clk;
memcpy(payload->data, bs, sizeof(bs));
clearCommandBuffer(); clearCommandBuffer();
SendCommandOLD(CMD_FSK_SIM_TAG, high << 8 | low, invert << 8 | clk, sizeof(bs), bs, sizeof(bs)); SendCommandNG(CMD_FSK_SIM_TAG, (uint8_t *)payload, sizeof(lf_fsksim_t) + sizeof(bs));
PacketResponseNG resp; PacketResponseNG resp;
WaitForResponse(CMD_FSK_SIM_TAG, &resp); WaitForResponse(CMD_FSK_SIM_TAG, &resp);
PrintAndLogEx(INFO, "Done");
if (resp.status != PM3_EOPABORTED) if (resp.status != PM3_EOPABORTED)
return resp.status; return resp.status;
return PM3_SUCCESS; return PM3_SUCCESS;
@ -323,8 +333,7 @@ int getPyramidBits(uint32_t fc, uint32_t cn, uint8_t *pyramidBits) {
// Get 26 wiegand from FacilityCode, CardNumber // Get 26 wiegand from FacilityCode, CardNumber
uint8_t wiegand[24]; uint8_t wiegand[24];
memset(wiegand, 0x00, sizeof(wiegand)); memset(wiegand, 0x00, sizeof(wiegand));
num_to_bytebits(fc, 8, wiegand); num_to_bytebits(fc, 8, wiegand); num_to_bytebits(cn, 16, wiegand + 8);
num_to_bytebits(cn, 16, wiegand + 8);
// add wiegand parity bits (dest, source, len) // add wiegand parity bits (dest, source, len)
wiegand_add_parity(pre + 80, wiegand, 24); wiegand_add_parity(pre + 80, wiegand, 24);

View file

@ -176,6 +176,15 @@ typedef struct {
uint8_t flags; uint8_t flags;
} PACKED t55xx_write_block_t; } PACKED t55xx_write_block_t;
// For CMD_FSK_SIM_TAG
typedef struct {
uint8_t fchigh;
uint8_t fclow;
uint8_t separator;
uint8_t clock;
uint8_t data[];
} PACKED lf_fsksim_t;
// For the bootloader // For the bootloader
#define CMD_DEVICE_INFO 0x0000 #define CMD_DEVICE_INFO 0x0000
#define CMD_SETUP_WRITE 0x0001 #define CMD_SETUP_WRITE 0x0001