mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
tk13 transmit sketch
This commit is contained in:
parent
3aeb745f0a
commit
6a28ca39f6
2 changed files with 38 additions and 17 deletions
|
@ -91,7 +91,7 @@ int HfReadADC(uint32_t samplesCount, bool ledcontrol) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t HfEncodeTkm(uint8_t *uid, uint8_t modulation) {
|
static uint32_t HfEncodeTkm(uint8_t *uid, uint8_t modulation, uint8_t *data) {
|
||||||
uint32_t len = 0;
|
uint32_t len = 0;
|
||||||
if (modulation == 0) {
|
if (modulation == 0) {
|
||||||
// TK-13
|
// TK-13
|
||||||
|
@ -102,6 +102,21 @@ static uint32_t HfEncodeTkm(uint8_t *uid, uint8_t modulation) {
|
||||||
// `1` - 125, 63
|
// `1` - 125, 63
|
||||||
// `0` - 63, 125
|
// `0` - 63, 125
|
||||||
|
|
||||||
|
int indx = 0;
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
for (int j = 0; j < 8; j++) {
|
||||||
|
if (((uid[i] << j) & 0x80) != 0) {
|
||||||
|
// `1`
|
||||||
|
data[indx++] = 125;
|
||||||
|
data[indx++] = 63;
|
||||||
|
} else {
|
||||||
|
// `0`
|
||||||
|
data[indx++] = 63;
|
||||||
|
data[indx++] = 125;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
len = 2;
|
len = 2;
|
||||||
} else {
|
} else {
|
||||||
// TK-17
|
// TK-17
|
||||||
|
@ -123,7 +138,8 @@ int HfWriteTkm(uint8_t *uid, uint8_t modulation, uint32_t timeout) {
|
||||||
|
|
||||||
LEDsoff();
|
LEDsoff();
|
||||||
|
|
||||||
uint32_t elen = HfEncodeTkm(uid, modulation);
|
uint8_t* data = BigBuf_calloc(256);
|
||||||
|
uint32_t elen = HfEncodeTkm(uid, modulation, data);
|
||||||
if (elen == 0) {
|
if (elen == 0) {
|
||||||
DbpString("encode error");
|
DbpString("encode error");
|
||||||
reply_ng(CMD_HF_TEXKOM_SIMULATE, PM3_EAPDU_ENCODEFAIL, NULL, 0);
|
reply_ng(CMD_HF_TEXKOM_SIMULATE, PM3_EAPDU_ENCODEFAIL, NULL, 0);
|
||||||
|
@ -155,22 +171,18 @@ int HfWriteTkm(uint8_t *uid, uint8_t modulation, uint32_t timeout) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinDelay(10);
|
SpinDelay(10);
|
||||||
for (int j = 0; j < 13;) {
|
for (int i = 0; i < elen; i++) {
|
||||||
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
|
for (int j = 0; j < 13;) {
|
||||||
AT91C_BASE_SSC->SSC_THR = 0xff;
|
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
|
||||||
j++;
|
AT91C_BASE_SSC->SSC_THR = 0xff;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
for (int j = 0; j < data[i];) {
|
||||||
for (int j = 0; j < 125;) {
|
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
|
||||||
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
|
AT91C_BASE_SSC->SSC_THR = 0x00;
|
||||||
AT91C_BASE_SSC->SSC_THR = 0x00;
|
j++;
|
||||||
j++;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int j = 0; j < 13;) {
|
|
||||||
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
|
|
||||||
AT91C_BASE_SSC->SSC_THR = 0xff;
|
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -574,6 +574,15 @@ static int CmdHFTexkomSim(const char *Cmd) {
|
||||||
|
|
||||||
// <texkom 8bytes><modulation 1b><timeout 4b>
|
// <texkom 8bytes><modulation 1b><timeout 4b>
|
||||||
uint8_t data[13] = {0};
|
uint8_t data[13] = {0};
|
||||||
|
data[0] = 0xFF;
|
||||||
|
data[1] = 0xFF;
|
||||||
|
data[2] = 0x63;
|
||||||
|
data[3] = 0x8C;
|
||||||
|
data[4] = 0x7D;
|
||||||
|
data[5] = 0xC4;
|
||||||
|
data[6] = 0x55;
|
||||||
|
data[7] = 0x53;
|
||||||
|
|
||||||
data[8] = modulation;
|
data[8] = modulation;
|
||||||
memcpy(&data[9], &cmdtimeout, 4);
|
memcpy(&data[9], &cmdtimeout, 4);
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue