mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
Convert the few files with still Windows carriage returns
This commit is contained in:
parent
d8788bb376
commit
edc19f202a
18 changed files with 11284 additions and 11284 deletions
|
@ -1,4 +1,4 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
// (c) 2009 Henryk Plötz <henryk@ploetzli.ch>
|
||||
// 2018 AntiCat
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
// (c) 2009 Henryk Plötz <henryk@ploetzli.ch>
|
||||
// 2018 AntiCat
|
||||
//
|
||||
|
|
4138
armsrc/mifarecmd.c
4138
armsrc/mifarecmd.c
File diff suppressed because it is too large
Load diff
|
@ -1,28 +1,28 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Merlok - June 2011
|
||||
// Gerhard de Koning Gans - May 2008
|
||||
// Hagen Fritsch - June 2010
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Routines to support ISO 14443 type A.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __MIFARECMD_H
|
||||
#define __MIFARECMD_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "iso14443a.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "mifareutil.h"
|
||||
#include "common.h"
|
||||
#include "crc.h"
|
||||
#include "protocols.h"
|
||||
#include "parity.h"
|
||||
//-----------------------------------------------------------------------------
|
||||
// Merlok - June 2011
|
||||
// Gerhard de Koning Gans - May 2008
|
||||
// Hagen Fritsch - June 2010
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Routines to support ISO 14443 type A.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __MIFARECMD_H
|
||||
#define __MIFARECMD_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "iso14443a.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "mifareutil.h"
|
||||
#include "common.h"
|
||||
#include "crc.h"
|
||||
#include "protocols.h"
|
||||
#include "parity.h"
|
||||
#endif
|
|
@ -1,324 +1,324 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Merlok - 2012
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Routines to support mifare classic sniffer.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "mifaresniff.h"
|
||||
|
||||
//static int sniffState = SNF_INIT;
|
||||
static uint8_t sniffUIDType = 0;
|
||||
static uint8_t sniffUID[10] = {0,0,0,0,0,0,0,0,0,0};
|
||||
static uint8_t sniffATQA[2] = {0,0};
|
||||
static uint8_t sniffSAK = 0;
|
||||
static uint8_t sniffBuf[17];
|
||||
static uint32_t timerData = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MIFARE sniffer.
|
||||
//
|
||||
// if no activity for 2sec, it sends the collected data to the client.
|
||||
//-----------------------------------------------------------------------------
|
||||
// "hf mf sniff"
|
||||
void RAMFUNC SniffMifare(uint8_t param) {
|
||||
// param:
|
||||
// bit 0 - trigger from first card answer
|
||||
// bit 1 - trigger from first reader 7-bit request
|
||||
|
||||
// C(red) A(yellow) B(green)
|
||||
LEDsoff();
|
||||
iso14443a_setup(FPGA_HF_ISO14443A_SNIFFER);
|
||||
|
||||
// Allocate memory from BigBuf for some buffers
|
||||
// free all previous allocations first
|
||||
BigBuf_free(); BigBuf_Clear_ext(false);
|
||||
clear_trace();
|
||||
set_tracing(true);
|
||||
|
||||
// The command (reader -> tag) that we're receiving.
|
||||
uint8_t receivedCmd[MAX_MIFARE_FRAME_SIZE] = {0x00};
|
||||
uint8_t receivedCmdPar[MAX_MIFARE_PARITY_SIZE] = {0x00};
|
||||
|
||||
// The response (tag -> reader) that we're receiving.
|
||||
uint8_t receivedResp[MAX_MIFARE_FRAME_SIZE] = {0x00};
|
||||
uint8_t receivedRespPar[MAX_MIFARE_PARITY_SIZE] = {0x00};
|
||||
|
||||
// allocate the DMA buffer, used to stream samples from the FPGA
|
||||
uint8_t *dmaBuf = BigBuf_malloc(DMA_BUFFER_SIZE);
|
||||
uint8_t *data = dmaBuf;
|
||||
uint8_t previous_data = 0;
|
||||
int maxDataLen = 0;
|
||||
int dataLen = 0;
|
||||
bool ReaderIsActive = false;
|
||||
bool TagIsActive = false;
|
||||
|
||||
// We won't start recording the frames that we acquire until we trigger;
|
||||
// a good trigger condition to get started is probably when we see a
|
||||
// response from the tag.
|
||||
// triggered == false -- to wait first for card
|
||||
//bool triggered = !(param & 0x03);
|
||||
|
||||
|
||||
// Set up the demodulator for tag -> reader responses.
|
||||
DemodInit(receivedResp, receivedRespPar);
|
||||
|
||||
// Set up the demodulator for the reader -> tag commands
|
||||
UartInit(receivedCmd, receivedCmdPar);
|
||||
|
||||
// Setup and start DMA.
|
||||
// set transfer address and number of bytes. Start transfer.
|
||||
if ( !FpgaSetupSscDma(dmaBuf, DMA_BUFFER_SIZE) ){
|
||||
if (MF_DBGLEVEL > 1) Dbprintf("[!] FpgaSetupSscDma failed. Exiting");
|
||||
return;
|
||||
}
|
||||
|
||||
tUart* uart = GetUart();
|
||||
tDemod* demod = GetDemod();
|
||||
|
||||
MfSniffInit();
|
||||
|
||||
uint32_t sniffCounter = 0;
|
||||
// loop and listen
|
||||
while (!BUTTON_PRESS()) {
|
||||
WDT_HIT();
|
||||
LED_A_ON();
|
||||
/*
|
||||
if ((sniffCounter & 0x0000FFFF) == 0) { // from time to time
|
||||
// check if a transaction is completed (timeout after 2000ms).
|
||||
// if yes, stop the DMA transfer and send what we have so far to the client
|
||||
if (BigBuf_get_traceLen()) {
|
||||
MfSniffSend();
|
||||
// Reset everything - we missed some sniffed data anyway while the DMA was stopped
|
||||
sniffCounter = 0;
|
||||
dmaBuf = BigBuf_malloc(DMA_BUFFER_SIZE);
|
||||
data = dmaBuf;
|
||||
maxDataLen = 0;
|
||||
ReaderIsActive = false;
|
||||
TagIsActive = false;
|
||||
FpgaSetupSscDma((uint8_t *)dmaBuf, DMA_BUFFER_SIZE); // set transfer address and number of bytes. Start transfer.
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// number of bytes we have processed so far
|
||||
int register readBufDataP = data - dmaBuf;
|
||||
// number of bytes already transferred
|
||||
int register dmaBufDataP = DMA_BUFFER_SIZE - AT91C_BASE_PDC_SSC->PDC_RCR;
|
||||
if (readBufDataP <= dmaBufDataP) // we are processing the same block of data which is currently being transferred
|
||||
dataLen = dmaBufDataP - readBufDataP; // number of bytes still to be processed
|
||||
else
|
||||
dataLen = DMA_BUFFER_SIZE - readBufDataP + dmaBufDataP; // number of bytes still to be processed
|
||||
|
||||
// test for length of buffer
|
||||
if (dataLen > maxDataLen) { // we are more behind than ever...
|
||||
maxDataLen = dataLen;
|
||||
if (dataLen > (9 * DMA_BUFFER_SIZE / 10)) {
|
||||
Dbprintf("[!] blew circular buffer! | datalen %u", dataLen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (dataLen < 1) continue;
|
||||
|
||||
// primary buffer was stopped ( <-- we lost data!
|
||||
if (!AT91C_BASE_PDC_SSC->PDC_RCR) {
|
||||
AT91C_BASE_PDC_SSC->PDC_RPR = (uint32_t)dmaBuf;
|
||||
AT91C_BASE_PDC_SSC->PDC_RCR = DMA_BUFFER_SIZE;
|
||||
Dbprintf("[-] RxEmpty ERROR | data length %d", dataLen); // temporary
|
||||
}
|
||||
// secondary buffer sets as primary, secondary buffer was stopped
|
||||
if (!AT91C_BASE_PDC_SSC->PDC_RNCR) {
|
||||
AT91C_BASE_PDC_SSC->PDC_RNPR = (uint32_t)dmaBuf;
|
||||
AT91C_BASE_PDC_SSC->PDC_RNCR = DMA_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
LED_A_OFF();
|
||||
|
||||
// Need two samples to feed Miller and Manchester-Decoder
|
||||
if (sniffCounter & 0x01) {
|
||||
|
||||
// no need to try decoding tag data if the reader is sending
|
||||
if (!TagIsActive) {
|
||||
uint8_t readerbyte = (previous_data & 0xF0) | (*data >> 4);
|
||||
if (MillerDecoding(readerbyte, (sniffCounter-1)*4)) {
|
||||
LogTrace(receivedCmd, uart->len, 0, 0, NULL, true);
|
||||
DemodReset();
|
||||
UartReset();
|
||||
}
|
||||
ReaderIsActive = (uart->state != STATE_UNSYNCD);
|
||||
}
|
||||
|
||||
// no need to try decoding tag data if the reader is sending
|
||||
if (!ReaderIsActive) {
|
||||
uint8_t tagbyte = (previous_data << 4) | (*data & 0x0F);
|
||||
if (ManchesterDecoding(tagbyte, 0, (sniffCounter-1)*4)) {
|
||||
LogTrace(receivedResp, demod->len, 0, 0, NULL, false);
|
||||
DemodReset();
|
||||
UartReset();
|
||||
}
|
||||
TagIsActive = (demod->state != DEMOD_UNSYNCD);
|
||||
}
|
||||
}
|
||||
previous_data = *data;
|
||||
sniffCounter++;
|
||||
data++;
|
||||
|
||||
if (data == dmaBuf + DMA_BUFFER_SIZE)
|
||||
data = dmaBuf;
|
||||
|
||||
} // main cycle
|
||||
|
||||
MfSniffEnd();
|
||||
switch_off();
|
||||
}
|
||||
|
||||
void MfSniffInit(void){
|
||||
memset(sniffUID, 0x00, sizeof(sniffUID));
|
||||
memset(sniffATQA, 0x00, sizeof(sniffATQA));
|
||||
memset(sniffBuf, 0x00, sizeof(sniffBuf));
|
||||
sniffSAK = 0;
|
||||
sniffUIDType = SNF_UID_4;
|
||||
timerData = 0;
|
||||
}
|
||||
|
||||
void MfSniffEnd(void){
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK,0,0,0,0,0);
|
||||
LED_B_OFF();
|
||||
}
|
||||
|
||||
/*
|
||||
bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, uint16_t bitCnt, bool reader) {
|
||||
|
||||
// reset on 7-Bit commands from reader
|
||||
if (reader && (len == 1) && (bitCnt == 7)) {
|
||||
sniffState = SNF_INIT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch (sniffState) {
|
||||
case SNF_INIT:{
|
||||
// REQA,WUPA or MAGICWUP from reader
|
||||
if ((len == 1) && (reader) && (bitCnt == 7) ) {
|
||||
MfSniffInit();
|
||||
sniffState = (data[0] == MIFARE_MAGICWUPC1) ? SNF_MAGIC_WUPC2 : SNF_ATQA;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SNF_MAGIC_WUPC2: {
|
||||
if ((len == 1) && (reader) && (data[0] == MIFARE_MAGICWUPC2) ) {
|
||||
sniffState = SNF_CARD_IDLE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SNF_ATQA:{
|
||||
// ATQA from tag
|
||||
if ((!reader) && (len == 2)) {
|
||||
sniffATQA[0] = data[0];
|
||||
sniffATQA[1] = data[1];
|
||||
sniffState = SNF_UID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SNF_UID: {
|
||||
|
||||
if ( !reader ) break;
|
||||
if ( len != 9 ) break;
|
||||
if ( !CheckCrc14443(CRC_14443_A, data, 9)) break;
|
||||
if ( data[1] != 0x70 ) break;
|
||||
|
||||
Dbprintf("[!] UID | %x", data[0]);
|
||||
|
||||
if ((data[0] == ISO14443A_CMD_ANTICOLL_OR_SELECT)) {
|
||||
// UID_4 - select 4 Byte UID from reader
|
||||
memcpy(sniffUID, data+2, 4);
|
||||
sniffUIDType = SNF_UID_4;
|
||||
sniffState = SNF_SAK;
|
||||
} else if ((data[0] == ISO14443A_CMD_ANTICOLL_OR_SELECT_2)) {
|
||||
// UID_7 - Select 2nd part of 7 Byte UID
|
||||
|
||||
// get rid of 0x88
|
||||
sniffUID[0] = sniffUID[1];
|
||||
sniffUID[1] = sniffUID[2];
|
||||
sniffUID[2] = sniffUID[3];
|
||||
//new uid bytes
|
||||
memcpy(sniffUID+3, data+2, 4);
|
||||
sniffUIDType = SNF_UID_7;
|
||||
sniffState = SNF_SAK;
|
||||
} else if ((data[0] == ISO14443A_CMD_ANTICOLL_OR_SELECT_3)) {
|
||||
// UID_10 - Select 3nd part of 10 Byte UID
|
||||
// 3+3+4 = 10.
|
||||
// get ride of previous 0x88
|
||||
sniffUID[3] = sniffUID[4];
|
||||
sniffUID[4] = sniffUID[5];
|
||||
sniffUID[5] = sniffUID[6];
|
||||
// new uid bytes
|
||||
memcpy(sniffUID+6, data+2, 4);
|
||||
sniffUIDType = SNF_UID_10;
|
||||
sniffState = SNF_SAK;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SNF_SAK:{
|
||||
// SAK from card?
|
||||
if ((!reader) && (len == 3) && (CheckCrc14443(CRC_14443_A, data, 3))) {
|
||||
sniffSAK = data[0];
|
||||
// CL2 UID part to be expected
|
||||
if (( sniffSAK == 0x04) && (sniffUIDType == SNF_UID_4)) {
|
||||
sniffState = SNF_UID;
|
||||
// CL3 UID part to be expected
|
||||
} else if ((sniffSAK == 0x04) && (sniffUIDType == SNF_UID_7)) {
|
||||
sniffState = SNF_UID;
|
||||
} else {
|
||||
// select completed
|
||||
sniffState = SNF_CARD_IDLE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SNF_CARD_IDLE:{ // trace the card select sequence
|
||||
sniffBuf[0] = 0xFF;
|
||||
sniffBuf[1] = 0xFF;
|
||||
memcpy(sniffBuf + 2, sniffUID, sizeof(sniffUID));
|
||||
memcpy(sniffBuf + 12, sniffATQA, sizeof(sniffATQA));
|
||||
sniffBuf[14] = sniffSAK;
|
||||
sniffBuf[15] = 0xFF;
|
||||
sniffBuf[16] = 0xFF;
|
||||
LogTrace(sniffBuf, sizeof(sniffBuf), 0, 0, NULL, true);
|
||||
sniffState = SNF_CARD_CMD;
|
||||
} // intentionally no break;
|
||||
case SNF_CARD_CMD:{
|
||||
LogTrace(data, len, 0, 0, NULL, reader);
|
||||
timerData = GetTickCount();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sniffState = SNF_INIT;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
void RAMFUNC MfSniffSend() {
|
||||
uint16_t tracelen = BigBuf_get_traceLen();
|
||||
uint16_t chunksize = 0;
|
||||
int packlen = tracelen; // total number of bytes to send
|
||||
uint8_t *data = BigBuf_get_addr();
|
||||
|
||||
while (packlen > 0) {
|
||||
LED_B_ON();
|
||||
chunksize = MIN(USB_CMD_DATA_SIZE, packlen); // chunk size 512
|
||||
cmd_send(CMD_ACK, 1, tracelen, chunksize, data + tracelen - packlen, chunksize);
|
||||
packlen -= chunksize;
|
||||
LED_B_OFF();
|
||||
}
|
||||
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK, 2, 0, 0, 0, 0); // 2 == data transfer finished.
|
||||
LED_B_OFF();
|
||||
//-----------------------------------------------------------------------------
|
||||
// Merlok - 2012
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Routines to support mifare classic sniffer.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "mifaresniff.h"
|
||||
|
||||
//static int sniffState = SNF_INIT;
|
||||
static uint8_t sniffUIDType = 0;
|
||||
static uint8_t sniffUID[10] = {0,0,0,0,0,0,0,0,0,0};
|
||||
static uint8_t sniffATQA[2] = {0,0};
|
||||
static uint8_t sniffSAK = 0;
|
||||
static uint8_t sniffBuf[17];
|
||||
static uint32_t timerData = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MIFARE sniffer.
|
||||
//
|
||||
// if no activity for 2sec, it sends the collected data to the client.
|
||||
//-----------------------------------------------------------------------------
|
||||
// "hf mf sniff"
|
||||
void RAMFUNC SniffMifare(uint8_t param) {
|
||||
// param:
|
||||
// bit 0 - trigger from first card answer
|
||||
// bit 1 - trigger from first reader 7-bit request
|
||||
|
||||
// C(red) A(yellow) B(green)
|
||||
LEDsoff();
|
||||
iso14443a_setup(FPGA_HF_ISO14443A_SNIFFER);
|
||||
|
||||
// Allocate memory from BigBuf for some buffers
|
||||
// free all previous allocations first
|
||||
BigBuf_free(); BigBuf_Clear_ext(false);
|
||||
clear_trace();
|
||||
set_tracing(true);
|
||||
|
||||
// The command (reader -> tag) that we're receiving.
|
||||
uint8_t receivedCmd[MAX_MIFARE_FRAME_SIZE] = {0x00};
|
||||
uint8_t receivedCmdPar[MAX_MIFARE_PARITY_SIZE] = {0x00};
|
||||
|
||||
// The response (tag -> reader) that we're receiving.
|
||||
uint8_t receivedResp[MAX_MIFARE_FRAME_SIZE] = {0x00};
|
||||
uint8_t receivedRespPar[MAX_MIFARE_PARITY_SIZE] = {0x00};
|
||||
|
||||
// allocate the DMA buffer, used to stream samples from the FPGA
|
||||
uint8_t *dmaBuf = BigBuf_malloc(DMA_BUFFER_SIZE);
|
||||
uint8_t *data = dmaBuf;
|
||||
uint8_t previous_data = 0;
|
||||
int maxDataLen = 0;
|
||||
int dataLen = 0;
|
||||
bool ReaderIsActive = false;
|
||||
bool TagIsActive = false;
|
||||
|
||||
// We won't start recording the frames that we acquire until we trigger;
|
||||
// a good trigger condition to get started is probably when we see a
|
||||
// response from the tag.
|
||||
// triggered == false -- to wait first for card
|
||||
//bool triggered = !(param & 0x03);
|
||||
|
||||
|
||||
// Set up the demodulator for tag -> reader responses.
|
||||
DemodInit(receivedResp, receivedRespPar);
|
||||
|
||||
// Set up the demodulator for the reader -> tag commands
|
||||
UartInit(receivedCmd, receivedCmdPar);
|
||||
|
||||
// Setup and start DMA.
|
||||
// set transfer address and number of bytes. Start transfer.
|
||||
if ( !FpgaSetupSscDma(dmaBuf, DMA_BUFFER_SIZE) ){
|
||||
if (MF_DBGLEVEL > 1) Dbprintf("[!] FpgaSetupSscDma failed. Exiting");
|
||||
return;
|
||||
}
|
||||
|
||||
tUart* uart = GetUart();
|
||||
tDemod* demod = GetDemod();
|
||||
|
||||
MfSniffInit();
|
||||
|
||||
uint32_t sniffCounter = 0;
|
||||
// loop and listen
|
||||
while (!BUTTON_PRESS()) {
|
||||
WDT_HIT();
|
||||
LED_A_ON();
|
||||
/*
|
||||
if ((sniffCounter & 0x0000FFFF) == 0) { // from time to time
|
||||
// check if a transaction is completed (timeout after 2000ms).
|
||||
// if yes, stop the DMA transfer and send what we have so far to the client
|
||||
if (BigBuf_get_traceLen()) {
|
||||
MfSniffSend();
|
||||
// Reset everything - we missed some sniffed data anyway while the DMA was stopped
|
||||
sniffCounter = 0;
|
||||
dmaBuf = BigBuf_malloc(DMA_BUFFER_SIZE);
|
||||
data = dmaBuf;
|
||||
maxDataLen = 0;
|
||||
ReaderIsActive = false;
|
||||
TagIsActive = false;
|
||||
FpgaSetupSscDma((uint8_t *)dmaBuf, DMA_BUFFER_SIZE); // set transfer address and number of bytes. Start transfer.
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// number of bytes we have processed so far
|
||||
int register readBufDataP = data - dmaBuf;
|
||||
// number of bytes already transferred
|
||||
int register dmaBufDataP = DMA_BUFFER_SIZE - AT91C_BASE_PDC_SSC->PDC_RCR;
|
||||
if (readBufDataP <= dmaBufDataP) // we are processing the same block of data which is currently being transferred
|
||||
dataLen = dmaBufDataP - readBufDataP; // number of bytes still to be processed
|
||||
else
|
||||
dataLen = DMA_BUFFER_SIZE - readBufDataP + dmaBufDataP; // number of bytes still to be processed
|
||||
|
||||
// test for length of buffer
|
||||
if (dataLen > maxDataLen) { // we are more behind than ever...
|
||||
maxDataLen = dataLen;
|
||||
if (dataLen > (9 * DMA_BUFFER_SIZE / 10)) {
|
||||
Dbprintf("[!] blew circular buffer! | datalen %u", dataLen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (dataLen < 1) continue;
|
||||
|
||||
// primary buffer was stopped ( <-- we lost data!
|
||||
if (!AT91C_BASE_PDC_SSC->PDC_RCR) {
|
||||
AT91C_BASE_PDC_SSC->PDC_RPR = (uint32_t)dmaBuf;
|
||||
AT91C_BASE_PDC_SSC->PDC_RCR = DMA_BUFFER_SIZE;
|
||||
Dbprintf("[-] RxEmpty ERROR | data length %d", dataLen); // temporary
|
||||
}
|
||||
// secondary buffer sets as primary, secondary buffer was stopped
|
||||
if (!AT91C_BASE_PDC_SSC->PDC_RNCR) {
|
||||
AT91C_BASE_PDC_SSC->PDC_RNPR = (uint32_t)dmaBuf;
|
||||
AT91C_BASE_PDC_SSC->PDC_RNCR = DMA_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
LED_A_OFF();
|
||||
|
||||
// Need two samples to feed Miller and Manchester-Decoder
|
||||
if (sniffCounter & 0x01) {
|
||||
|
||||
// no need to try decoding tag data if the reader is sending
|
||||
if (!TagIsActive) {
|
||||
uint8_t readerbyte = (previous_data & 0xF0) | (*data >> 4);
|
||||
if (MillerDecoding(readerbyte, (sniffCounter-1)*4)) {
|
||||
LogTrace(receivedCmd, uart->len, 0, 0, NULL, true);
|
||||
DemodReset();
|
||||
UartReset();
|
||||
}
|
||||
ReaderIsActive = (uart->state != STATE_UNSYNCD);
|
||||
}
|
||||
|
||||
// no need to try decoding tag data if the reader is sending
|
||||
if (!ReaderIsActive) {
|
||||
uint8_t tagbyte = (previous_data << 4) | (*data & 0x0F);
|
||||
if (ManchesterDecoding(tagbyte, 0, (sniffCounter-1)*4)) {
|
||||
LogTrace(receivedResp, demod->len, 0, 0, NULL, false);
|
||||
DemodReset();
|
||||
UartReset();
|
||||
}
|
||||
TagIsActive = (demod->state != DEMOD_UNSYNCD);
|
||||
}
|
||||
}
|
||||
previous_data = *data;
|
||||
sniffCounter++;
|
||||
data++;
|
||||
|
||||
if (data == dmaBuf + DMA_BUFFER_SIZE)
|
||||
data = dmaBuf;
|
||||
|
||||
} // main cycle
|
||||
|
||||
MfSniffEnd();
|
||||
switch_off();
|
||||
}
|
||||
|
||||
void MfSniffInit(void){
|
||||
memset(sniffUID, 0x00, sizeof(sniffUID));
|
||||
memset(sniffATQA, 0x00, sizeof(sniffATQA));
|
||||
memset(sniffBuf, 0x00, sizeof(sniffBuf));
|
||||
sniffSAK = 0;
|
||||
sniffUIDType = SNF_UID_4;
|
||||
timerData = 0;
|
||||
}
|
||||
|
||||
void MfSniffEnd(void){
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK,0,0,0,0,0);
|
||||
LED_B_OFF();
|
||||
}
|
||||
|
||||
/*
|
||||
bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, uint16_t bitCnt, bool reader) {
|
||||
|
||||
// reset on 7-Bit commands from reader
|
||||
if (reader && (len == 1) && (bitCnt == 7)) {
|
||||
sniffState = SNF_INIT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch (sniffState) {
|
||||
case SNF_INIT:{
|
||||
// REQA,WUPA or MAGICWUP from reader
|
||||
if ((len == 1) && (reader) && (bitCnt == 7) ) {
|
||||
MfSniffInit();
|
||||
sniffState = (data[0] == MIFARE_MAGICWUPC1) ? SNF_MAGIC_WUPC2 : SNF_ATQA;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SNF_MAGIC_WUPC2: {
|
||||
if ((len == 1) && (reader) && (data[0] == MIFARE_MAGICWUPC2) ) {
|
||||
sniffState = SNF_CARD_IDLE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SNF_ATQA:{
|
||||
// ATQA from tag
|
||||
if ((!reader) && (len == 2)) {
|
||||
sniffATQA[0] = data[0];
|
||||
sniffATQA[1] = data[1];
|
||||
sniffState = SNF_UID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SNF_UID: {
|
||||
|
||||
if ( !reader ) break;
|
||||
if ( len != 9 ) break;
|
||||
if ( !CheckCrc14443(CRC_14443_A, data, 9)) break;
|
||||
if ( data[1] != 0x70 ) break;
|
||||
|
||||
Dbprintf("[!] UID | %x", data[0]);
|
||||
|
||||
if ((data[0] == ISO14443A_CMD_ANTICOLL_OR_SELECT)) {
|
||||
// UID_4 - select 4 Byte UID from reader
|
||||
memcpy(sniffUID, data+2, 4);
|
||||
sniffUIDType = SNF_UID_4;
|
||||
sniffState = SNF_SAK;
|
||||
} else if ((data[0] == ISO14443A_CMD_ANTICOLL_OR_SELECT_2)) {
|
||||
// UID_7 - Select 2nd part of 7 Byte UID
|
||||
|
||||
// get rid of 0x88
|
||||
sniffUID[0] = sniffUID[1];
|
||||
sniffUID[1] = sniffUID[2];
|
||||
sniffUID[2] = sniffUID[3];
|
||||
//new uid bytes
|
||||
memcpy(sniffUID+3, data+2, 4);
|
||||
sniffUIDType = SNF_UID_7;
|
||||
sniffState = SNF_SAK;
|
||||
} else if ((data[0] == ISO14443A_CMD_ANTICOLL_OR_SELECT_3)) {
|
||||
// UID_10 - Select 3nd part of 10 Byte UID
|
||||
// 3+3+4 = 10.
|
||||
// get ride of previous 0x88
|
||||
sniffUID[3] = sniffUID[4];
|
||||
sniffUID[4] = sniffUID[5];
|
||||
sniffUID[5] = sniffUID[6];
|
||||
// new uid bytes
|
||||
memcpy(sniffUID+6, data+2, 4);
|
||||
sniffUIDType = SNF_UID_10;
|
||||
sniffState = SNF_SAK;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SNF_SAK:{
|
||||
// SAK from card?
|
||||
if ((!reader) && (len == 3) && (CheckCrc14443(CRC_14443_A, data, 3))) {
|
||||
sniffSAK = data[0];
|
||||
// CL2 UID part to be expected
|
||||
if (( sniffSAK == 0x04) && (sniffUIDType == SNF_UID_4)) {
|
||||
sniffState = SNF_UID;
|
||||
// CL3 UID part to be expected
|
||||
} else if ((sniffSAK == 0x04) && (sniffUIDType == SNF_UID_7)) {
|
||||
sniffState = SNF_UID;
|
||||
} else {
|
||||
// select completed
|
||||
sniffState = SNF_CARD_IDLE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SNF_CARD_IDLE:{ // trace the card select sequence
|
||||
sniffBuf[0] = 0xFF;
|
||||
sniffBuf[1] = 0xFF;
|
||||
memcpy(sniffBuf + 2, sniffUID, sizeof(sniffUID));
|
||||
memcpy(sniffBuf + 12, sniffATQA, sizeof(sniffATQA));
|
||||
sniffBuf[14] = sniffSAK;
|
||||
sniffBuf[15] = 0xFF;
|
||||
sniffBuf[16] = 0xFF;
|
||||
LogTrace(sniffBuf, sizeof(sniffBuf), 0, 0, NULL, true);
|
||||
sniffState = SNF_CARD_CMD;
|
||||
} // intentionally no break;
|
||||
case SNF_CARD_CMD:{
|
||||
LogTrace(data, len, 0, 0, NULL, reader);
|
||||
timerData = GetTickCount();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sniffState = SNF_INIT;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
void RAMFUNC MfSniffSend() {
|
||||
uint16_t tracelen = BigBuf_get_traceLen();
|
||||
uint16_t chunksize = 0;
|
||||
int packlen = tracelen; // total number of bytes to send
|
||||
uint8_t *data = BigBuf_get_addr();
|
||||
|
||||
while (packlen > 0) {
|
||||
LED_B_ON();
|
||||
chunksize = MIN(USB_CMD_DATA_SIZE, packlen); // chunk size 512
|
||||
cmd_send(CMD_ACK, 1, tracelen, chunksize, data + tracelen - packlen, chunksize);
|
||||
packlen -= chunksize;
|
||||
LED_B_OFF();
|
||||
}
|
||||
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK, 2, 0, 0, 0, 0); // 2 == data transfer finished.
|
||||
LED_B_OFF();
|
||||
}
|
|
@ -1,42 +1,42 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Merlok - June 2012
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Routines to support mifare classic sniffer.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __MIFARESNIFF_H
|
||||
#define __MIFARESNIFF_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "iso14443a.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "mifareutil.h"
|
||||
#include "common.h"
|
||||
|
||||
#define SNF_INIT 0
|
||||
#define SNF_NO_FIELD 1
|
||||
#define SNF_ATQA 2
|
||||
#define SNF_UID 3
|
||||
#define SNF_SAK 4
|
||||
#define SNF_CARD_IDLE 5
|
||||
#define SNF_CARD_CMD 6
|
||||
#define SNF_MAGIC_WUPC2 7
|
||||
|
||||
#define SNF_UID_4 0
|
||||
#define SNF_UID_7 0
|
||||
#define SNF_UID_10 0
|
||||
|
||||
void MfSniffInit(void);
|
||||
bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, uint16_t bitCnt, bool reader);
|
||||
void RAMFUNC MfSniffSend(void);
|
||||
void MfSniffEnd(void);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Merlok - June 2012
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Routines to support mifare classic sniffer.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __MIFARESNIFF_H
|
||||
#define __MIFARESNIFF_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "iso14443a.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "mifareutil.h"
|
||||
#include "common.h"
|
||||
|
||||
#define SNF_INIT 0
|
||||
#define SNF_NO_FIELD 1
|
||||
#define SNF_ATQA 2
|
||||
#define SNF_UID 3
|
||||
#define SNF_SAK 4
|
||||
#define SNF_CARD_IDLE 5
|
||||
#define SNF_CARD_CMD 6
|
||||
#define SNF_MAGIC_WUPC2 7
|
||||
|
||||
#define SNF_UID_4 0
|
||||
#define SNF_UID_7 0
|
||||
#define SNF_UID_10 0
|
||||
|
||||
void MfSniffInit(void);
|
||||
bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, uint16_t bitCnt, bool reader);
|
||||
void RAMFUNC MfSniffSend(void);
|
||||
void MfSniffEnd(void);
|
||||
|
||||
#endif
|
1378
armsrc/mifareutil.c
1378
armsrc/mifareutil.c
File diff suppressed because it is too large
Load diff
|
@ -1,106 +1,106 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Merlok, May 2011
|
||||
// Many authors, that makes it possible
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// code for work with mifare cards.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __MIFAREUTIL_H
|
||||
#define __MIFAREUTIL_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "parity.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "iso14443a.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "des.h"
|
||||
#include "random.h" // fast_prand, prand
|
||||
|
||||
// mifare authentication
|
||||
#define CRYPT_NONE 0
|
||||
#define CRYPT_ALL 1
|
||||
#define CRYPT_REQUEST 2
|
||||
#define AUTH_FIRST 0
|
||||
#define AUTH_NESTED 2
|
||||
|
||||
#define AUTHENTICATION_TIMEOUT 848 // card times out 1ms after wrong authentication (according to NXP documentation)
|
||||
#define PRE_AUTHENTICATION_LEADTIME 400 // some (non standard) cards need a pause after select before they are ready for first authentication
|
||||
|
||||
// mifare 4bit card answers
|
||||
#define CARD_ACK 0x0A // 1010 - ACK
|
||||
#define CARD_NACK_NA 0x04 // 0100 - NACK, not allowed (command not allowed)
|
||||
#define CARD_NACK_TR 0x05 // 0101 - NACK, transmission error
|
||||
|
||||
|
||||
|
||||
//mifare emulator states
|
||||
#define MFEMUL_NOFIELD 0
|
||||
#define MFEMUL_IDLE 1
|
||||
#define MFEMUL_SELECT1 2
|
||||
#define MFEMUL_SELECT2 3
|
||||
#define MFEMUL_SELECT3 4
|
||||
#define MFEMUL_AUTH1 5
|
||||
#define MFEMUL_AUTH2 6
|
||||
#define MFEMUL_WORK 7
|
||||
#define MFEMUL_WRITEBL2 8
|
||||
#define MFEMUL_INTREG_INC 9
|
||||
#define MFEMUL_INTREG_DEC 10
|
||||
#define MFEMUL_INTREG_REST 11
|
||||
#define MFEMUL_HALTED 12
|
||||
|
||||
#define cardSTATE_TO_IDLE() cardSTATE = MFEMUL_IDLE; LED_B_OFF(); LED_C_OFF();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Merlok, May 2011
|
||||
// Many authors, that makes it possible
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// code for work with mifare cards.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __MIFAREUTIL_H
|
||||
#define __MIFAREUTIL_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "parity.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "iso14443a.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "des.h"
|
||||
#include "random.h" // fast_prand, prand
|
||||
|
||||
// mifare authentication
|
||||
#define CRYPT_NONE 0
|
||||
#define CRYPT_ALL 1
|
||||
#define CRYPT_REQUEST 2
|
||||
#define AUTH_FIRST 0
|
||||
#define AUTH_NESTED 2
|
||||
|
||||
#define AUTHENTICATION_TIMEOUT 848 // card times out 1ms after wrong authentication (according to NXP documentation)
|
||||
#define PRE_AUTHENTICATION_LEADTIME 400 // some (non standard) cards need a pause after select before they are ready for first authentication
|
||||
|
||||
// mifare 4bit card answers
|
||||
#define CARD_ACK 0x0A // 1010 - ACK
|
||||
#define CARD_NACK_NA 0x04 // 0100 - NACK, not allowed (command not allowed)
|
||||
#define CARD_NACK_TR 0x05 // 0101 - NACK, transmission error
|
||||
|
||||
|
||||
|
||||
//mifare emulator states
|
||||
#define MFEMUL_NOFIELD 0
|
||||
#define MFEMUL_IDLE 1
|
||||
#define MFEMUL_SELECT1 2
|
||||
#define MFEMUL_SELECT2 3
|
||||
#define MFEMUL_SELECT3 4
|
||||
#define MFEMUL_AUTH1 5
|
||||
#define MFEMUL_AUTH2 6
|
||||
#define MFEMUL_WORK 7
|
||||
#define MFEMUL_WRITEBL2 8
|
||||
#define MFEMUL_INTREG_INC 9
|
||||
#define MFEMUL_INTREG_DEC 10
|
||||
#define MFEMUL_INTREG_REST 11
|
||||
#define MFEMUL_HALTED 12
|
||||
|
||||
#define cardSTATE_TO_IDLE() cardSTATE = MFEMUL_IDLE; LED_B_OFF(); LED_C_OFF();
|
||||
|
||||
//functions
|
||||
int mifare_sendcmd(uint8_t cmd, uint8_t *data, uint8_t data_size, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);
|
||||
int mifare_sendcmd(uint8_t cmd, uint8_t *data, uint8_t data_size, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);
|
||||
int mifare_sendcmd_short(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);
|
||||
|
||||
// mifare classic
|
||||
int mifare_classic_auth(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t keyType, uint64_t ui64Key, uint8_t isNested);
|
||||
// mifare classic
|
||||
int mifare_classic_auth(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t keyType, uint64_t ui64Key, uint8_t isNested);
|
||||
int mifare_classic_authex(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t keyType, uint64_t ui64Key, uint8_t isNested, uint32_t * ntptr, uint32_t *timing);
|
||||
int mifare_classic_readblock(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_classic_halt(struct Crypto1State *pcs, uint32_t uid);
|
||||
int mifare_classic_halt_ex(struct Crypto1State *pcs);
|
||||
int mifare_classic_writeblock(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t *blockData);
|
||||
|
||||
// Ultralight/NTAG...
|
||||
int mifare_ul_ev1_auth(uint8_t *key, uint8_t *pack);
|
||||
int mifare_ultra_auth(uint8_t *key);
|
||||
int mifare_ultra_readblock(uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_classic_readblock(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_classic_halt(struct Crypto1State *pcs, uint32_t uid);
|
||||
int mifare_classic_halt_ex(struct Crypto1State *pcs);
|
||||
int mifare_classic_writeblock(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t *blockData);
|
||||
|
||||
// Ultralight/NTAG...
|
||||
int mifare_ul_ev1_auth(uint8_t *key, uint8_t *pack);
|
||||
int mifare_ultra_auth(uint8_t *key);
|
||||
int mifare_ultra_readblock(uint8_t blockNo, uint8_t *blockData);
|
||||
//int mifare_ultra_writeblock_compat(uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_ultra_writeblock(uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_ultra_halt();
|
||||
|
||||
// desfire
|
||||
int mifare_sendcmd_special(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t* data, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);
|
||||
int mifare_sendcmd_special2(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t* data, uint8_t* answer,uint8_t *answer_parity, uint32_t *timing);
|
||||
int mifare_desfire_des_auth1(uint32_t uid, uint8_t *blockData);
|
||||
int mifare_desfire_des_auth2(uint32_t uid, uint8_t *key, uint8_t *blockData);
|
||||
|
||||
// desfire
|
||||
int mifare_sendcmd_special(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t* data, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);
|
||||
int mifare_sendcmd_special2(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t* data, uint8_t* answer,uint8_t *answer_parity, uint32_t *timing);
|
||||
int mifare_desfire_des_auth1(uint32_t uid, uint8_t *blockData);
|
||||
int mifare_desfire_des_auth2(uint32_t uid, uint8_t *key, uint8_t *blockData);
|
||||
|
||||
// crypto functions
|
||||
void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *receivedCmd, int len);
|
||||
void mf_crypto1_decryptEx(struct Crypto1State *pcs, uint8_t *data_in, int len, uint8_t *data_out);
|
||||
void mf_crypto1_encrypt(struct Crypto1State *pcs, uint8_t *data, uint16_t len, uint8_t *par);
|
||||
uint8_t mf_crypto1_encrypt4bit(struct Crypto1State *pcs, uint8_t data);
|
||||
|
||||
// Mifare memory structure
|
||||
uint8_t NumBlocksPerSector(uint8_t sectorNo);
|
||||
uint8_t FirstBlockOfSector(uint8_t sectorNo);
|
||||
|
||||
// emulator functions
|
||||
void emlClearMem(void);
|
||||
void emlSetMem(uint8_t *data, int blockNum, int blocksCount);
|
||||
void emlSetMem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidth);
|
||||
void emlGetMem(uint8_t *data, int blockNum, int blocksCount);
|
||||
void emlGetMemBt(uint8_t *data, int bytePtr, int byteCount);
|
||||
uint64_t emlGetKey(int sectorNum, int keyType);
|
||||
int emlGetValBl(uint32_t *blReg, uint8_t *blBlock, int blockNum);
|
||||
void mf_crypto1_decryptEx(struct Crypto1State *pcs, uint8_t *data_in, int len, uint8_t *data_out);
|
||||
void mf_crypto1_encrypt(struct Crypto1State *pcs, uint8_t *data, uint16_t len, uint8_t *par);
|
||||
uint8_t mf_crypto1_encrypt4bit(struct Crypto1State *pcs, uint8_t data);
|
||||
|
||||
// Mifare memory structure
|
||||
uint8_t NumBlocksPerSector(uint8_t sectorNo);
|
||||
uint8_t FirstBlockOfSector(uint8_t sectorNo);
|
||||
|
||||
// emulator functions
|
||||
void emlClearMem(void);
|
||||
void emlSetMem(uint8_t *data, int blockNum, int blocksCount);
|
||||
void emlSetMem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidth);
|
||||
void emlGetMem(uint8_t *data, int blockNum, int blocksCount);
|
||||
void emlGetMemBt(uint8_t *data, int bytePtr, int byteCount);
|
||||
uint64_t emlGetKey(int sectorNum, int keyType);
|
||||
int emlGetValBl(uint32_t *blReg, uint8_t *blBlock, int blockNum);
|
||||
int emlSetValBl(uint32_t blReg, uint8_t blBlock, int blockNum);
|
||||
int emlCheckValBl(int blockNum);
|
||||
|
||||
|
|
6944
client/cmdhfmf.c
6944
client/cmdhfmf.c
File diff suppressed because it is too large
Load diff
152
client/cmdhfmf.h
152
client/cmdhfmf.h
|
@ -1,76 +1,76 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2011 Merlok
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// High frequency MIFARE commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef CMDHFMF_H__
|
||||
#define CMDHFMF_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <mbedtls/aes.h>
|
||||
#include "proxmark3.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
#include "common.h"
|
||||
#include "util.h"
|
||||
#include "mifare.h" // nonces_t struct
|
||||
#include "mifare/mfkey.h" // mfkey32_moebious
|
||||
#include "cmdhfmfhard.h"
|
||||
#include "mifare/mifarehost.h" // icesector_t, sector_t
|
||||
#include "util_posix.h" // msclock
|
||||
#include "mifare/mifaredefault.h" // mifare default key array
|
||||
#include "cmdhf14a.h" // dropfield
|
||||
#include "cliparser/cliparser.h" // argtable
|
||||
#include "hardnested/hardnested_bf_core.h" // SetSIMDInstr
|
||||
|
||||
extern int CmdHFMF(const char *Cmd);
|
||||
|
||||
extern int CmdHF14AMfList(const char *Cmd);
|
||||
extern int CmdHF14AMfDbg(const char* cmd);
|
||||
extern int CmdHF14AMfRdBl(const char* cmd);
|
||||
extern int CmdHF14AMfURdBl(const char* cmd);
|
||||
extern int CmdHF14AMfRdSc(const char* cmd);
|
||||
extern int CmdHF14SMfURdCard(const char* cmd);
|
||||
extern int CmdHF14AMfDump(const char* cmd);
|
||||
extern int CmdHF14AMfRestore(const char* cmd);
|
||||
extern int CmdHF14AMfWrBl(const char* cmd);
|
||||
extern int CmdHF14AMfUWrBl(const char* cmd);
|
||||
extern int CmdHF14AMfChk(const char* cmd);
|
||||
extern int CmdHF14AMfDarkside(const char* cmd);
|
||||
extern int CmdHF14AMfNested(const char* cmd);
|
||||
extern int CmdHF14AMfNestedHard(const char *Cmd);
|
||||
//extern int CmdHF14AMfSniff(const char* cmd);
|
||||
extern int CmdHF14AMf1kSim(const char* cmd);
|
||||
extern int CmdHF14AMfKeyBrute(const char *Cmd);
|
||||
extern int CmdHF14AMfEClear(const char* cmd);
|
||||
extern int CmdHF14AMfEGet(const char* cmd);
|
||||
extern int CmdHF14AMfESet(const char* cmd);
|
||||
extern int CmdHF14AMfELoad(const char* cmd);
|
||||
extern int CmdHF14AMfESave(const char* cmd);
|
||||
extern int CmdHF14AMfECFill(const char* cmd);
|
||||
extern int CmdHF14AMfEKeyPrn(const char* cmd);
|
||||
extern int CmdHF14AMfCSetUID(const char* cmd);
|
||||
extern int CmdHF14AMfCSetBlk(const char* cmd);
|
||||
extern int CmdHF14AMfCGetBlk(const char* cmd);
|
||||
extern int CmdHF14AMfCGetSc(const char* cmd);
|
||||
extern int CmdHF14AMfCLoad(const char* cmd);
|
||||
extern int CmdHF14AMfCSave(const char* cmd);
|
||||
extern int CmdHf14MfDecryptBytes(const char *Cmd);
|
||||
extern int CmdHf14AMfSetMod(const char *Cmd);
|
||||
extern int CmdHf14AMfNack(const char *Cmd);
|
||||
|
||||
void showSectorTable(void);
|
||||
void readerAttack(nonces_t data, bool setEmulatorMem, bool verbose);
|
||||
void printKeyTable( uint8_t sectorscnt, sector_t *e_sector );
|
||||
void printKeyTable_fast( uint8_t sectorscnt, icesector_t *e_sector, uint64_t bar, uint64_t foo );
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2011 Merlok
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// High frequency MIFARE commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef CMDHFMF_H__
|
||||
#define CMDHFMF_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <mbedtls/aes.h>
|
||||
#include "proxmark3.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
#include "common.h"
|
||||
#include "util.h"
|
||||
#include "mifare.h" // nonces_t struct
|
||||
#include "mifare/mfkey.h" // mfkey32_moebious
|
||||
#include "cmdhfmfhard.h"
|
||||
#include "mifare/mifarehost.h" // icesector_t, sector_t
|
||||
#include "util_posix.h" // msclock
|
||||
#include "mifare/mifaredefault.h" // mifare default key array
|
||||
#include "cmdhf14a.h" // dropfield
|
||||
#include "cliparser/cliparser.h" // argtable
|
||||
#include "hardnested/hardnested_bf_core.h" // SetSIMDInstr
|
||||
|
||||
extern int CmdHFMF(const char *Cmd);
|
||||
|
||||
extern int CmdHF14AMfList(const char *Cmd);
|
||||
extern int CmdHF14AMfDbg(const char* cmd);
|
||||
extern int CmdHF14AMfRdBl(const char* cmd);
|
||||
extern int CmdHF14AMfURdBl(const char* cmd);
|
||||
extern int CmdHF14AMfRdSc(const char* cmd);
|
||||
extern int CmdHF14SMfURdCard(const char* cmd);
|
||||
extern int CmdHF14AMfDump(const char* cmd);
|
||||
extern int CmdHF14AMfRestore(const char* cmd);
|
||||
extern int CmdHF14AMfWrBl(const char* cmd);
|
||||
extern int CmdHF14AMfUWrBl(const char* cmd);
|
||||
extern int CmdHF14AMfChk(const char* cmd);
|
||||
extern int CmdHF14AMfDarkside(const char* cmd);
|
||||
extern int CmdHF14AMfNested(const char* cmd);
|
||||
extern int CmdHF14AMfNestedHard(const char *Cmd);
|
||||
//extern int CmdHF14AMfSniff(const char* cmd);
|
||||
extern int CmdHF14AMf1kSim(const char* cmd);
|
||||
extern int CmdHF14AMfKeyBrute(const char *Cmd);
|
||||
extern int CmdHF14AMfEClear(const char* cmd);
|
||||
extern int CmdHF14AMfEGet(const char* cmd);
|
||||
extern int CmdHF14AMfESet(const char* cmd);
|
||||
extern int CmdHF14AMfELoad(const char* cmd);
|
||||
extern int CmdHF14AMfESave(const char* cmd);
|
||||
extern int CmdHF14AMfECFill(const char* cmd);
|
||||
extern int CmdHF14AMfEKeyPrn(const char* cmd);
|
||||
extern int CmdHF14AMfCSetUID(const char* cmd);
|
||||
extern int CmdHF14AMfCSetBlk(const char* cmd);
|
||||
extern int CmdHF14AMfCGetBlk(const char* cmd);
|
||||
extern int CmdHF14AMfCGetSc(const char* cmd);
|
||||
extern int CmdHF14AMfCLoad(const char* cmd);
|
||||
extern int CmdHF14AMfCSave(const char* cmd);
|
||||
extern int CmdHf14MfDecryptBytes(const char *Cmd);
|
||||
extern int CmdHf14AMfSetMod(const char *Cmd);
|
||||
extern int CmdHf14AMfNack(const char *Cmd);
|
||||
|
||||
void showSectorTable(void);
|
||||
void readerAttack(nonces_t data, bool setEmulatorMem, bool verbose);
|
||||
void printKeyTable( uint8_t sectorscnt, sector_t *e_sector );
|
||||
void printKeyTable_fast( uint8_t sectorscnt, icesector_t *e_sector, uint64_t bar, uint64_t foo );
|
||||
#endif
|
||||
|
|
4112
client/cmdlft55xx.c
4112
client/cmdlft55xx.c
File diff suppressed because it is too large
Load diff
|
@ -1,171 +1,171 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Low frequency T55xx commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef CMDLFT55XX_H__
|
||||
#define CMDLFT55XX_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <time.h>
|
||||
#include <ctype.h>
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "graph.h"
|
||||
#include "comms.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmddata.h"
|
||||
#include "cmdlf.h"
|
||||
#include "util.h"
|
||||
#include "lfdemod.h"
|
||||
#include "cmdhf14a.h" //for getTagInfo
|
||||
|
||||
|
||||
#define T55x7_CONFIGURATION_BLOCK 0x00
|
||||
#define T55x7_PAGE0 0x00
|
||||
#define T55x7_PAGE1 0x01
|
||||
#define T55x7_PWD 0x00000010
|
||||
#define REGULAR_READ_MODE_BLOCK 0xFF
|
||||
|
||||
// config blocks
|
||||
#define T55X7_DEFAULT_CONFIG_BLOCK 0x000880E8 // ASK, compat mode, data rate 32, manchester, STT, 7 data blocks
|
||||
#define T55X7_RAW_CONFIG_BLOCK 0x000880E0 // ASK, compat mode, data rate 32, manchester, 7 data blocks
|
||||
#define T55X7_EM_UNIQUE_CONFIG_BLOCK 0x00148040 // ASK, emulate em4x02/unique - compat mode, manchester, data rate 64, 2 data blocks
|
||||
// FDXB requires data inversion and BiPhase 57 is simply BiPhase 50 inverted, so we can either do it using the modulation scheme or the inversion flag
|
||||
// we've done both below to prove that it works either way, and the modulation value for BiPhase 50 in the Atmel data sheet of binary "10001" (17) is a typo,
|
||||
// and it should actually be "10000" (16)
|
||||
// #define T55X7_FDXB_CONFIG_BLOCK 903F8080 // emulate fdx-b - xtended mode, BiPhase ('57), data rate 32, 4 data blocks
|
||||
#define T55X7_FDXB_CONFIG_BLOCK 0x903F0082 // emulate fdx-b - xtended mode, BiPhase ('50), invert data, data rate 32, 4 data blocks
|
||||
#define T55X7_HID_26_CONFIG_BLOCK 0x00107060 // hid 26 bit - compat mode, FSK2a, data rate 50, 3 data blocks
|
||||
#define T55X7_PYRAMID_CONFIG_BLOCK 0x00107080 // Pyramid 26 bit - compat mode, FSK2a, data rate 50, 4 data blocks
|
||||
#define T55X7_INDALA_64_CONFIG_BLOCK 0x00081040 // emulate indala 64 bit - compat mode, PSK1, psk carrier FC * 2, data rate 32, maxblock 2
|
||||
#define T55X7_INDALA_224_CONFIG_BLOCK 0x000810E0 // emulate indala 224 bit - compat mode, PSK1, psk carrier FC * 2, data rate 32, maxblock 7
|
||||
#define T55X7_GUARDPROXII_CONFIG_BLOCK 0x00150060 // bitrate 64pcb, Direct modulation, Biphase, 3 data blocks
|
||||
#define T55X7_VIKING_CONFIG_BLOCK 0x00088040 // ASK, compat mode, data rate 32, Manchester, 2 data blocks
|
||||
#define T55X7_NORALYS_CONFIG_BLOCK 0x00088C6A // ASK, compat mode, (NORALYS - KCP3000)
|
||||
#define T55X7_IOPROX_CONFIG_BLOCK 0x00147040 // ioprox - FSK2a, data rate 64, 2 data blocks
|
||||
#define T55X7_PRESCO_CONFIG_BLOCK 0x00088088 // ASK, data rate 32, Manchester, 5 data blocks, STT
|
||||
#define T55X7_NEDAP_64_CONFIG_BLOCK 0x907f0042 // BiPhase, data rate 64, 3 data blocks
|
||||
#define T55X7_NEDAP_128_CONFIG_BLOCK 0x907f0082 // BiPhase, data rate 64, 5 data blocks
|
||||
#define T55X7_bin 0b0010
|
||||
|
||||
#define T5555_DEFAULT_CONFIG_BLOCK 0x6001F004 // data rate 64 , ask, manchester, 2 data blocks?
|
||||
enum {
|
||||
T55x7_RAW = 0x00,
|
||||
T55x7_DEFAULT = 0x00,
|
||||
T5555_DEFAULT = 0x01,
|
||||
EM_UNIQUE = 0x0,
|
||||
FDBX = 0x02,
|
||||
HID_26 = 0x03,
|
||||
INDALA_64 = 0x04,
|
||||
INDALA_224 = 0x05,
|
||||
GUARDPROXXII = 0x06,
|
||||
VIKING = 0x07,
|
||||
NORALSYS = 0x08,
|
||||
IOPROX = 0x09,
|
||||
NEDAP_64 = 0x0A,
|
||||
NEDAP_128 = 0x0B,
|
||||
} t55xx_tag;
|
||||
|
||||
typedef struct {
|
||||
uint32_t bl1;
|
||||
uint32_t bl2;
|
||||
uint32_t acl;
|
||||
uint32_t mfc;
|
||||
uint32_t cid;
|
||||
uint32_t year;
|
||||
uint32_t quarter;
|
||||
uint32_t icr;
|
||||
uint32_t lotid;
|
||||
uint32_t wafer;
|
||||
uint32_t dw;
|
||||
} t55x7_tracedata_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t bl1;
|
||||
uint32_t bl2;
|
||||
uint32_t icr;
|
||||
char lotidc;
|
||||
uint32_t lotid;
|
||||
uint32_t wafer;
|
||||
uint32_t dw;
|
||||
} t5555_tracedata_t;
|
||||
|
||||
typedef struct {
|
||||
enum {
|
||||
DEMOD_NRZ = 0x00,
|
||||
DEMOD_PSK1 = 0x01,
|
||||
DEMOD_PSK2 = 0x02,
|
||||
DEMOD_PSK3 = 0x03,
|
||||
DEMOD_FSK1 = 0x04,
|
||||
DEMOD_FSK1a = 0x05,
|
||||
DEMOD_FSK2 = 0x06,
|
||||
DEMOD_FSK2a = 0x07,
|
||||
DEMOD_FSK = 0xF0, //generic FSK (auto detect FCs)
|
||||
DEMOD_ASK = 0x08,
|
||||
DEMOD_BI = 0x10,
|
||||
DEMOD_BIa = 0x18,
|
||||
} modulation;
|
||||
bool inverted;
|
||||
uint8_t offset;
|
||||
uint32_t block0;
|
||||
enum {
|
||||
RF_8 = 0x00,
|
||||
RF_16 = 0x01,
|
||||
RF_32 = 0x02,
|
||||
RF_40 = 0x03,
|
||||
RF_50 = 0x04,
|
||||
RF_64 = 0x05,
|
||||
RF_100 = 0x06,
|
||||
RF_128 = 0x07,
|
||||
} bitrate;
|
||||
bool Q5;
|
||||
bool ST;
|
||||
} t55xx_conf_block_t;
|
||||
|
||||
t55xx_conf_block_t Get_t55xx_Config(void);
|
||||
void Set_t55xx_Config(t55xx_conf_block_t conf);
|
||||
|
||||
extern int CmdLFT55XX(const char *Cmd);
|
||||
extern int CmdT55xxChk(const char *Cmd);
|
||||
extern int CmdT55xxBruteForce(const char *Cmd);
|
||||
extern int CmdT55xxSetConfig(const char *Cmd);
|
||||
extern int CmdT55xxReadBlock(const char *Cmd);
|
||||
extern int CmdT55xxWriteBlock(const char *Cmd);
|
||||
extern int CmdT55xxReadTrace(const char *Cmd);
|
||||
extern int CmdT55xxInfo(const char *Cmd);
|
||||
extern int CmdT55xxDetect(const char *Cmd);
|
||||
extern int CmdResetRead(const char *Cmd);
|
||||
extern int CmdT55xxWipe(const char *Cmd);
|
||||
|
||||
char * GetBitRateStr(uint32_t id, bool xmode);
|
||||
char * GetSaferStr(uint32_t id);
|
||||
char * GetModulationStr( uint32_t id);
|
||||
char * GetModelStrFromCID(uint32_t cid);
|
||||
char * GetSelectedModulationStr( uint8_t id);
|
||||
uint32_t PackBits(uint8_t start, uint8_t len, uint8_t *bitstream);
|
||||
void printT5xxHeader(uint8_t page);
|
||||
void printT55xxBlock(const char *demodStr);
|
||||
int printConfiguration( t55xx_conf_block_t b);
|
||||
|
||||
bool DecodeT55xxBlock(void);
|
||||
bool tryDetectModulation(void);
|
||||
bool testKnownConfigBlock(uint32_t block0);
|
||||
extern bool tryDetectP1(bool getData);
|
||||
bool test(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t clk, bool *Q5);
|
||||
int special(const char *Cmd);
|
||||
bool AquireData( uint8_t page, uint8_t block, bool pwdmode, uint32_t password );
|
||||
bool AquireDataEx( uint8_t page, uint8_t block, bool pwdmode, uint32_t password, uint32_t timing ) ;
|
||||
|
||||
bool detectPassword(int password);
|
||||
|
||||
void printT55x7Trace( t55x7_tracedata_t data, uint8_t repeat );
|
||||
void printT5555Trace( t5555_tracedata_t data, uint8_t repeat );
|
||||
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Low frequency T55xx commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef CMDLFT55XX_H__
|
||||
#define CMDLFT55XX_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <time.h>
|
||||
#include <ctype.h>
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "graph.h"
|
||||
#include "comms.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmddata.h"
|
||||
#include "cmdlf.h"
|
||||
#include "util.h"
|
||||
#include "lfdemod.h"
|
||||
#include "cmdhf14a.h" //for getTagInfo
|
||||
|
||||
|
||||
#define T55x7_CONFIGURATION_BLOCK 0x00
|
||||
#define T55x7_PAGE0 0x00
|
||||
#define T55x7_PAGE1 0x01
|
||||
#define T55x7_PWD 0x00000010
|
||||
#define REGULAR_READ_MODE_BLOCK 0xFF
|
||||
|
||||
// config blocks
|
||||
#define T55X7_DEFAULT_CONFIG_BLOCK 0x000880E8 // ASK, compat mode, data rate 32, manchester, STT, 7 data blocks
|
||||
#define T55X7_RAW_CONFIG_BLOCK 0x000880E0 // ASK, compat mode, data rate 32, manchester, 7 data blocks
|
||||
#define T55X7_EM_UNIQUE_CONFIG_BLOCK 0x00148040 // ASK, emulate em4x02/unique - compat mode, manchester, data rate 64, 2 data blocks
|
||||
// FDXB requires data inversion and BiPhase 57 is simply BiPhase 50 inverted, so we can either do it using the modulation scheme or the inversion flag
|
||||
// we've done both below to prove that it works either way, and the modulation value for BiPhase 50 in the Atmel data sheet of binary "10001" (17) is a typo,
|
||||
// and it should actually be "10000" (16)
|
||||
// #define T55X7_FDXB_CONFIG_BLOCK 903F8080 // emulate fdx-b - xtended mode, BiPhase ('57), data rate 32, 4 data blocks
|
||||
#define T55X7_FDXB_CONFIG_BLOCK 0x903F0082 // emulate fdx-b - xtended mode, BiPhase ('50), invert data, data rate 32, 4 data blocks
|
||||
#define T55X7_HID_26_CONFIG_BLOCK 0x00107060 // hid 26 bit - compat mode, FSK2a, data rate 50, 3 data blocks
|
||||
#define T55X7_PYRAMID_CONFIG_BLOCK 0x00107080 // Pyramid 26 bit - compat mode, FSK2a, data rate 50, 4 data blocks
|
||||
#define T55X7_INDALA_64_CONFIG_BLOCK 0x00081040 // emulate indala 64 bit - compat mode, PSK1, psk carrier FC * 2, data rate 32, maxblock 2
|
||||
#define T55X7_INDALA_224_CONFIG_BLOCK 0x000810E0 // emulate indala 224 bit - compat mode, PSK1, psk carrier FC * 2, data rate 32, maxblock 7
|
||||
#define T55X7_GUARDPROXII_CONFIG_BLOCK 0x00150060 // bitrate 64pcb, Direct modulation, Biphase, 3 data blocks
|
||||
#define T55X7_VIKING_CONFIG_BLOCK 0x00088040 // ASK, compat mode, data rate 32, Manchester, 2 data blocks
|
||||
#define T55X7_NORALYS_CONFIG_BLOCK 0x00088C6A // ASK, compat mode, (NORALYS - KCP3000)
|
||||
#define T55X7_IOPROX_CONFIG_BLOCK 0x00147040 // ioprox - FSK2a, data rate 64, 2 data blocks
|
||||
#define T55X7_PRESCO_CONFIG_BLOCK 0x00088088 // ASK, data rate 32, Manchester, 5 data blocks, STT
|
||||
#define T55X7_NEDAP_64_CONFIG_BLOCK 0x907f0042 // BiPhase, data rate 64, 3 data blocks
|
||||
#define T55X7_NEDAP_128_CONFIG_BLOCK 0x907f0082 // BiPhase, data rate 64, 5 data blocks
|
||||
#define T55X7_bin 0b0010
|
||||
|
||||
#define T5555_DEFAULT_CONFIG_BLOCK 0x6001F004 // data rate 64 , ask, manchester, 2 data blocks?
|
||||
enum {
|
||||
T55x7_RAW = 0x00,
|
||||
T55x7_DEFAULT = 0x00,
|
||||
T5555_DEFAULT = 0x01,
|
||||
EM_UNIQUE = 0x0,
|
||||
FDBX = 0x02,
|
||||
HID_26 = 0x03,
|
||||
INDALA_64 = 0x04,
|
||||
INDALA_224 = 0x05,
|
||||
GUARDPROXXII = 0x06,
|
||||
VIKING = 0x07,
|
||||
NORALSYS = 0x08,
|
||||
IOPROX = 0x09,
|
||||
NEDAP_64 = 0x0A,
|
||||
NEDAP_128 = 0x0B,
|
||||
} t55xx_tag;
|
||||
|
||||
typedef struct {
|
||||
uint32_t bl1;
|
||||
uint32_t bl2;
|
||||
uint32_t acl;
|
||||
uint32_t mfc;
|
||||
uint32_t cid;
|
||||
uint32_t year;
|
||||
uint32_t quarter;
|
||||
uint32_t icr;
|
||||
uint32_t lotid;
|
||||
uint32_t wafer;
|
||||
uint32_t dw;
|
||||
} t55x7_tracedata_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t bl1;
|
||||
uint32_t bl2;
|
||||
uint32_t icr;
|
||||
char lotidc;
|
||||
uint32_t lotid;
|
||||
uint32_t wafer;
|
||||
uint32_t dw;
|
||||
} t5555_tracedata_t;
|
||||
|
||||
typedef struct {
|
||||
enum {
|
||||
DEMOD_NRZ = 0x00,
|
||||
DEMOD_PSK1 = 0x01,
|
||||
DEMOD_PSK2 = 0x02,
|
||||
DEMOD_PSK3 = 0x03,
|
||||
DEMOD_FSK1 = 0x04,
|
||||
DEMOD_FSK1a = 0x05,
|
||||
DEMOD_FSK2 = 0x06,
|
||||
DEMOD_FSK2a = 0x07,
|
||||
DEMOD_FSK = 0xF0, //generic FSK (auto detect FCs)
|
||||
DEMOD_ASK = 0x08,
|
||||
DEMOD_BI = 0x10,
|
||||
DEMOD_BIa = 0x18,
|
||||
} modulation;
|
||||
bool inverted;
|
||||
uint8_t offset;
|
||||
uint32_t block0;
|
||||
enum {
|
||||
RF_8 = 0x00,
|
||||
RF_16 = 0x01,
|
||||
RF_32 = 0x02,
|
||||
RF_40 = 0x03,
|
||||
RF_50 = 0x04,
|
||||
RF_64 = 0x05,
|
||||
RF_100 = 0x06,
|
||||
RF_128 = 0x07,
|
||||
} bitrate;
|
||||
bool Q5;
|
||||
bool ST;
|
||||
} t55xx_conf_block_t;
|
||||
|
||||
t55xx_conf_block_t Get_t55xx_Config(void);
|
||||
void Set_t55xx_Config(t55xx_conf_block_t conf);
|
||||
|
||||
extern int CmdLFT55XX(const char *Cmd);
|
||||
extern int CmdT55xxChk(const char *Cmd);
|
||||
extern int CmdT55xxBruteForce(const char *Cmd);
|
||||
extern int CmdT55xxSetConfig(const char *Cmd);
|
||||
extern int CmdT55xxReadBlock(const char *Cmd);
|
||||
extern int CmdT55xxWriteBlock(const char *Cmd);
|
||||
extern int CmdT55xxReadTrace(const char *Cmd);
|
||||
extern int CmdT55xxInfo(const char *Cmd);
|
||||
extern int CmdT55xxDetect(const char *Cmd);
|
||||
extern int CmdResetRead(const char *Cmd);
|
||||
extern int CmdT55xxWipe(const char *Cmd);
|
||||
|
||||
char * GetBitRateStr(uint32_t id, bool xmode);
|
||||
char * GetSaferStr(uint32_t id);
|
||||
char * GetModulationStr( uint32_t id);
|
||||
char * GetModelStrFromCID(uint32_t cid);
|
||||
char * GetSelectedModulationStr( uint8_t id);
|
||||
uint32_t PackBits(uint8_t start, uint8_t len, uint8_t *bitstream);
|
||||
void printT5xxHeader(uint8_t page);
|
||||
void printT55xxBlock(const char *demodStr);
|
||||
int printConfiguration( t55xx_conf_block_t b);
|
||||
|
||||
bool DecodeT55xxBlock(void);
|
||||
bool tryDetectModulation(void);
|
||||
bool testKnownConfigBlock(uint32_t block0);
|
||||
extern bool tryDetectP1(bool getData);
|
||||
bool test(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t clk, bool *Q5);
|
||||
int special(const char *Cmd);
|
||||
bool AquireData( uint8_t page, uint8_t block, bool pwdmode, uint32_t password );
|
||||
bool AquireDataEx( uint8_t page, uint8_t block, bool pwdmode, uint32_t password, uint32_t timing ) ;
|
||||
|
||||
bool detectPassword(int password);
|
||||
|
||||
void printT55x7Trace( t55x7_tracedata_t data, uint8_t repeat );
|
||||
void printT5555Trace( t5555_tracedata_t data, uint8_t repeat );
|
||||
|
||||
#endif
|
||||
|
|
126
common/cmd.c
126
common/cmd.c
|
@ -1,64 +1,64 @@
|
|||
/*
|
||||
* Proxmark send and receive commands
|
||||
*
|
||||
* Copyright (c) 2012, Roel Verdult
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holders nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @file cmd.c
|
||||
* @brief
|
||||
*/
|
||||
#include "cmd.h"
|
||||
|
||||
uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void* data, size_t len) {
|
||||
UsbCommand txcmd;
|
||||
|
||||
for (size_t i=0; i < sizeof(UsbCommand); i++)
|
||||
((uint8_t*)&txcmd)[i] = 0x00;
|
||||
|
||||
// Compose the outgoing command frame
|
||||
txcmd.cmd = cmd;
|
||||
txcmd.arg[0] = arg0;
|
||||
txcmd.arg[1] = arg1;
|
||||
txcmd.arg[2] = arg2;
|
||||
|
||||
// Add the (optional) content to the frame, with a maximum size of USB_CMD_DATA_SIZE
|
||||
if (data && len) {
|
||||
len = MIN(len, USB_CMD_DATA_SIZE);
|
||||
for (size_t i=0; i<len; i++) {
|
||||
txcmd.d.asBytes[i] = ((uint8_t*)data)[i];
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t sendlen = 0;
|
||||
// Send frame and make sure all bytes are transmitted
|
||||
sendlen = usb_write( (uint8_t*)&txcmd, sizeof(UsbCommand) );
|
||||
|
||||
#ifdef WITH_FPC
|
||||
// usart_init();
|
||||
// usart_writebuffer( (uint8_t*)&txcmd, sizeof(UsbCommand) );
|
||||
#endif
|
||||
|
||||
return sendlen;
|
||||
/*
|
||||
* Proxmark send and receive commands
|
||||
*
|
||||
* Copyright (c) 2012, Roel Verdult
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holders nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @file cmd.c
|
||||
* @brief
|
||||
*/
|
||||
#include "cmd.h"
|
||||
|
||||
uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void* data, size_t len) {
|
||||
UsbCommand txcmd;
|
||||
|
||||
for (size_t i=0; i < sizeof(UsbCommand); i++)
|
||||
((uint8_t*)&txcmd)[i] = 0x00;
|
||||
|
||||
// Compose the outgoing command frame
|
||||
txcmd.cmd = cmd;
|
||||
txcmd.arg[0] = arg0;
|
||||
txcmd.arg[1] = arg1;
|
||||
txcmd.arg[2] = arg2;
|
||||
|
||||
// Add the (optional) content to the frame, with a maximum size of USB_CMD_DATA_SIZE
|
||||
if (data && len) {
|
||||
len = MIN(len, USB_CMD_DATA_SIZE);
|
||||
for (size_t i=0; i<len; i++) {
|
||||
txcmd.d.asBytes[i] = ((uint8_t*)data)[i];
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t sendlen = 0;
|
||||
// Send frame and make sure all bytes are transmitted
|
||||
sendlen = usb_write( (uint8_t*)&txcmd, sizeof(UsbCommand) );
|
||||
|
||||
#ifdef WITH_FPC
|
||||
// usart_init();
|
||||
// usart_writebuffer( (uint8_t*)&txcmd, sizeof(UsbCommand) );
|
||||
#endif
|
||||
|
||||
return sendlen;
|
||||
}
|
90
common/cmd.h
90
common/cmd.h
|
@ -1,45 +1,45 @@
|
|||
/*
|
||||
* Proxmark send and receive commands
|
||||
*
|
||||
* Copyright (c) 2010, Roel Verdult
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holders nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @file cmd.h
|
||||
* @brief
|
||||
*/
|
||||
|
||||
#ifndef _PROXMARK_CMD_H_
|
||||
#define _PROXMARK_CMD_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "usb_cmd.h"
|
||||
#include "usb_cdc.h"
|
||||
#include "usart.h"
|
||||
#include "proxmark3.h"
|
||||
|
||||
uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void* data, size_t len);
|
||||
|
||||
#endif // _PROXMARK_CMD_H_
|
||||
|
||||
/*
|
||||
* Proxmark send and receive commands
|
||||
*
|
||||
* Copyright (c) 2010, Roel Verdult
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holders nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @file cmd.h
|
||||
* @brief
|
||||
*/
|
||||
|
||||
#ifndef _PROXMARK_CMD_H_
|
||||
#define _PROXMARK_CMD_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "usb_cmd.h"
|
||||
#include "usb_cdc.h"
|
||||
#include "usart.h"
|
||||
#include "proxmark3.h"
|
||||
|
||||
uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void* data, size_t len);
|
||||
|
||||
#endif // _PROXMARK_CMD_H_
|
||||
|
||||
|
|
1894
common/usb_cdc.c
1894
common/usb_cdc.c
File diff suppressed because it is too large
Load diff
126
common/usb_cdc.h
126
common/usb_cdc.h
|
@ -1,63 +1,63 @@
|
|||
/*
|
||||
* at91sam7s USB CDC device implementation
|
||||
*
|
||||
* Copyright (c) 2012, Roel Verdult
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holders nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* based on the "Basic USB Example" from ATMEL (doc6123.pdf)
|
||||
*
|
||||
* @file usb_cdc.c
|
||||
* @brief
|
||||
*/
|
||||
|
||||
#ifndef _USB_CDC_H_
|
||||
#define _USB_CDC_H_
|
||||
|
||||
#include <wchar.h>
|
||||
#include "at91sam7s512.h"
|
||||
#include "config_gpio.h"
|
||||
#include "proxmark3.h" // USB_CONNECT()
|
||||
#include "common.h"
|
||||
|
||||
extern void usb_disable();
|
||||
extern void usb_enable();
|
||||
extern bool usb_check();
|
||||
extern bool usb_poll();
|
||||
extern bool usb_poll_validate_length();
|
||||
extern uint32_t usb_read(byte_t* data, size_t len);
|
||||
extern uint32_t usb_write(const byte_t* data, const size_t len);
|
||||
|
||||
extern void SetUSBreconnect(int value);
|
||||
extern int GetUSBreconnect(void);
|
||||
extern void SetUSBconfigured(int value);
|
||||
extern int GetUSBconfigured(void);
|
||||
|
||||
extern void AT91F_USB_SendData(AT91PS_UDP pUdp, const char *pData, uint32_t length);
|
||||
extern void AT91F_USB_SendZlp(AT91PS_UDP pUdp);
|
||||
extern void AT91F_USB_SendStall(AT91PS_UDP pUdp);
|
||||
extern void AT91F_CDC_Enumerate();
|
||||
|
||||
#endif // _USB_CDC_H_
|
||||
|
||||
/*
|
||||
* at91sam7s USB CDC device implementation
|
||||
*
|
||||
* Copyright (c) 2012, Roel Verdult
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holders nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* based on the "Basic USB Example" from ATMEL (doc6123.pdf)
|
||||
*
|
||||
* @file usb_cdc.c
|
||||
* @brief
|
||||
*/
|
||||
|
||||
#ifndef _USB_CDC_H_
|
||||
#define _USB_CDC_H_
|
||||
|
||||
#include <wchar.h>
|
||||
#include "at91sam7s512.h"
|
||||
#include "config_gpio.h"
|
||||
#include "proxmark3.h" // USB_CONNECT()
|
||||
#include "common.h"
|
||||
|
||||
extern void usb_disable();
|
||||
extern void usb_enable();
|
||||
extern bool usb_check();
|
||||
extern bool usb_poll();
|
||||
extern bool usb_poll_validate_length();
|
||||
extern uint32_t usb_read(byte_t* data, size_t len);
|
||||
extern uint32_t usb_write(const byte_t* data, const size_t len);
|
||||
|
||||
extern void SetUSBreconnect(int value);
|
||||
extern int GetUSBreconnect(void);
|
||||
extern void SetUSBconfigured(int value);
|
||||
extern int GetUSBconfigured(void);
|
||||
|
||||
extern void AT91F_USB_SendData(AT91PS_UDP pUdp, const char *pData, uint32_t length);
|
||||
extern void AT91F_USB_SendZlp(AT91PS_UDP pUdp);
|
||||
extern void AT91F_USB_SendStall(AT91PS_UDP pUdp);
|
||||
extern void AT91F_CDC_Enumerate();
|
||||
|
||||
#endif // _USB_CDC_H_
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue