mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-11-10 17:49:32 +08: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;
|
||||
}
|
||||
|
||||
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;
|
||||
if (modulation == 0) {
|
||||
// TK-13
|
||||
|
@ -102,6 +102,21 @@ static uint32_t HfEncodeTkm(uint8_t *uid, uint8_t modulation) {
|
|||
// `1` - 125, 63
|
||||
// `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;
|
||||
} else {
|
||||
// TK-17
|
||||
|
@ -123,7 +138,8 @@ int HfWriteTkm(uint8_t *uid, uint8_t modulation, uint32_t timeout) {
|
|||
|
||||
LEDsoff();
|
||||
|
||||
uint32_t elen = HfEncodeTkm(uid, modulation);
|
||||
uint8_t* data = BigBuf_calloc(256);
|
||||
uint32_t elen = HfEncodeTkm(uid, modulation, data);
|
||||
if (elen == 0) {
|
||||
DbpString("encode error");
|
||||
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);
|
||||
for (int j = 0; j < 13;) {
|
||||
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
|
||||
AT91C_BASE_SSC->SSC_THR = 0xff;
|
||||
j++;
|
||||
for (int i = 0; i < elen; i++) {
|
||||
for (int j = 0; j < 13;) {
|
||||
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
|
||||
AT91C_BASE_SSC->SSC_THR = 0xff;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < 125;) {
|
||||
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
|
||||
AT91C_BASE_SSC->SSC_THR = 0x00;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < 13;) {
|
||||
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
|
||||
AT91C_BASE_SSC->SSC_THR = 0xff;
|
||||
j++;
|
||||
for (int j = 0; j < data[i];) {
|
||||
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
|
||||
AT91C_BASE_SSC->SSC_THR = 0x00;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -574,6 +574,15 @@ static int CmdHFTexkomSim(const char *Cmd) {
|
|||
|
||||
// <texkom 8bytes><modulation 1b><timeout 4b>
|
||||
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;
|
||||
memcpy(&data[9], &cmdtimeout, 4);
|
||||
clearCommandBuffer();
|
||||
|
|
Loading…
Reference in a new issue