mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
chg: lf simfsk\nlf paradox sim\nlf awid sim\n\lf ioprox sim\nlf pyramid sim - NG
This commit is contained in:
parent
270afb89aa
commit
c13e2f09a1
7 changed files with 80 additions and 45 deletions
|
@ -783,16 +783,8 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||
CmdHIDsimTAG(packet->oldarg[0], packet->oldarg[1], 1);
|
||||
break;
|
||||
case CMD_FSK_SIM_TAG: {
|
||||
struct p {
|
||||
uint8_t fchigh;
|
||||
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);
|
||||
lf_fsksim_t *payload = (lf_fsksim_t *)packet->data.asBytes;
|
||||
CmdFSKsimTAG(payload->fchigh, payload->fclow, payload->separator, payload->clock, packet->length - sizeof(lf_fsksim_t), payload->data, 1);
|
||||
break;
|
||||
}
|
||||
case CMD_ASK_SIM_TAG:
|
||||
|
|
|
@ -608,33 +608,23 @@ int CmdLFfskSim(const char *Cmd) {
|
|||
if (fcHigh == 0) fcHigh = 10;
|
||||
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;
|
||||
if (size > sizeof(payload.data)) {
|
||||
PrintAndLogEx(NORMAL, "DemodBuffer too long for current implementation - length: %d - max: %d", size, sizeof(payload.data));
|
||||
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, PM3_CMD_DATA_SIZE - sizeof(lf_fsksim_t));
|
||||
size = PM3_CMD_DATA_SIZE - sizeof(lf_fsksim_t);
|
||||
}
|
||||
|
||||
payload.datalen = (uint16_t)size;
|
||||
memcpy(payload.data, DemodBuffer, size);
|
||||
lf_fsksim_t *payload = calloc(1, sizeof(lf_fsksim_t) + size);
|
||||
payload->fchigh = fcHigh;
|
||||
payload->fclow = fcLow;
|
||||
payload->separator = separator;
|
||||
payload->clock = clk;
|
||||
memcpy(payload->data, DemodBuffer, size);
|
||||
|
||||
PrintAndLogEx(INFO, "Simulating");
|
||||
|
||||
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);
|
||||
PacketResponseNG resp;
|
||||
|
|
|
@ -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;
|
||||
|
||||
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();
|
||||
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);
|
||||
return sendPing();
|
||||
|
@ -313,8 +320,8 @@ static int CmdAWIDRead(const char *Cmd) {
|
|||
static int CmdAWIDSim(const char *Cmd) {
|
||||
uint32_t fc = 0, cn = 0;
|
||||
uint8_t fmtlen = 0;
|
||||
uint8_t bits[96];
|
||||
memset(bits, 0x00, sizeof(bits));
|
||||
uint8_t bs[96];
|
||||
memset(bs, 0x00, sizeof(bs));
|
||||
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
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, "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.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
@ -340,10 +347,20 @@ static int CmdAWIDSim(const char *Cmd) {
|
|||
// arg1 --- fcHigh<<8 + fcLow
|
||||
// arg2 --- Inversion and clk setting
|
||||
// 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();
|
||||
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;
|
||||
WaitForResponse(CMD_FSK_SIM_TAG, &resp);
|
||||
|
||||
PrintAndLogEx(INFO, "Done");
|
||||
if (resp.status != PM3_EOPABORTED)
|
||||
return resp.status;
|
||||
return PM3_SUCCESS;
|
||||
|
|
|
@ -178,8 +178,8 @@ static int CmdIOProxRead(const char *Cmd) {
|
|||
static int CmdIOProxSim(const char *Cmd) {
|
||||
uint16_t cn = 0;
|
||||
uint8_t version = 0, fc = 0;
|
||||
uint8_t bits[64];
|
||||
memset(bits, 0x00, sizeof(bits));
|
||||
uint8_t bs[64];
|
||||
memset(bs, 0x00, sizeof(bs));
|
||||
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
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, "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.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
@ -209,10 +209,19 @@ static int CmdIOProxSim(const char *Cmd) {
|
|||
// arg1 --- fcHigh<<8 + fcLow
|
||||
// arg2 --- Invert and clk setting
|
||||
// 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();
|
||||
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;
|
||||
WaitForResponse(CMD_FSK_SIM_TAG, &resp);
|
||||
|
||||
PrintAndLogEx(INFO, "Done");
|
||||
if (resp.status != PM3_EOPABORTED)
|
||||
return resp.status;
|
||||
return PM3_SUCCESS;
|
||||
|
|
|
@ -134,10 +134,19 @@ static int CmdParadoxSim(const char *Cmd) {
|
|||
|
||||
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();
|
||||
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;
|
||||
WaitForResponse(CMD_FSK_SIM_TAG, &resp);
|
||||
|
||||
PrintAndLogEx(INFO, "Done");
|
||||
if (resp.status != PM3_EOPABORTED)
|
||||
return resp.status;
|
||||
return PM3_SUCCESS;
|
||||
|
|
|
@ -212,7 +212,7 @@ static int CmdPyramidClone(const char *Cmd) {
|
|||
facilitycode = (fc & 0x000000FF);
|
||||
cardnumber = (cn & 0x0000FFFF);
|
||||
|
||||
if (!getPyramidBits(facilitycode, cardnumber, bs)) {
|
||||
if (getPyramidBits(facilitycode, cardnumber, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
@ -275,17 +275,27 @@ static int CmdPyramidSim(const char *Cmd) {
|
|||
facilitycode = (fc & 0x000000FF);
|
||||
cardnumber = (cn & 0x0000FFFF);
|
||||
|
||||
if (!getPyramidBits(facilitycode, cardnumber, bs)) {
|
||||
if (getPyramidBits(facilitycode, cardnumber, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
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();
|
||||
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;
|
||||
WaitForResponse(CMD_FSK_SIM_TAG, &resp);
|
||||
|
||||
PrintAndLogEx(INFO, "Done");
|
||||
if (resp.status != PM3_EOPABORTED)
|
||||
return resp.status;
|
||||
return PM3_SUCCESS;
|
||||
|
@ -323,8 +333,7 @@ int getPyramidBits(uint32_t fc, uint32_t cn, uint8_t *pyramidBits) {
|
|||
// Get 26 wiegand from FacilityCode, CardNumber
|
||||
uint8_t wiegand[24];
|
||||
memset(wiegand, 0x00, sizeof(wiegand));
|
||||
num_to_bytebits(fc, 8, wiegand);
|
||||
num_to_bytebits(cn, 16, wiegand + 8);
|
||||
num_to_bytebits(fc, 8, wiegand); num_to_bytebits(cn, 16, wiegand + 8);
|
||||
|
||||
// add wiegand parity bits (dest, source, len)
|
||||
wiegand_add_parity(pre + 80, wiegand, 24);
|
||||
|
|
|
@ -176,6 +176,15 @@ typedef struct {
|
|||
uint8_t flags;
|
||||
} 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
|
||||
#define CMD_DEVICE_INFO 0x0000
|
||||
#define CMD_SETUP_WRITE 0x0001
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue