コード例 #1
0
ファイル: epa.c プロジェクト: richo/proxmark3
//-----------------------------------------------------------------------------
// Set up a communication channel (Card Select, PPS)
// Returns 0 on success or a non-zero error code on failure
//-----------------------------------------------------------------------------
int EPA_Setup()
{
	// return code
	int return_code = 0;
	// card UID
	uint8_t uid[8];
	// card select information
	iso14a_card_select_t card_select_info;
	// power up the field
	iso14443a_setup();

	// select the card
	return_code = iso14443a_select_card(uid, &card_select_info, NULL);
	if (return_code != 1) {
		return 1;
	}

	// send the PPS request
	ReaderTransmit((uint8_t *)pps, sizeof(pps), NULL);
	uint8_t pps_response[3];
	return_code = ReaderReceive(pps_response);
	if (return_code != 3 || pps_response[0] != 0xD0) {
		return return_code == 0 ? 2 : return_code;
	}
	
	return 0;
}
コード例 #2
0
bool InitDesfireCard(){

	iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
	set_tracing(TRUE);

	byte_t cardbuf[USB_CMD_DATA_SIZE] = {0x00};
	iso14a_card_select_t *card = (iso14a_card_select_t*)cardbuf;
	
	int len = iso14443a_select_card(NULL,card,NULL,true,0);

	if (!len) {
		if (MF_DBGLEVEL >= MF_DBG_ERROR)
			Dbprintf("Can't select card");
		OnError(1);
		return false;
	}
	return true;
}
コード例 #3
0
ファイル: epa.c プロジェクト: JohannesStoye/proxmark3
//-----------------------------------------------------------------------------
// Set up a communication channel (Card Select, PPS)
// Returns 0 on success or a non-zero error code on failure
//-----------------------------------------------------------------------------
int EPA_Setup()
{
	int return_code = 0;
	uint8_t uid[10];
	uint8_t pps_response[3];
	uint8_t pps_response_par[1];
	iso14a_card_select_t card_select_info;

	// first, look for type A cards
	// power up the field
	iso14443a_setup(FPGA_HF_ISO14443A_READER_MOD);
	// select the card
	return_code = iso14443a_select_card(uid, &card_select_info, NULL);
	if (return_code == 1) {
	// send the PPS request
	ReaderTransmit((uint8_t *)pps, sizeof(pps), NULL);
	return_code = ReaderReceive(pps_response, pps_response_par);
	if (return_code != 3 || pps_response[0] != 0xD0) {
		return return_code == 0 ? 2 : return_code;
	}
		Dbprintf("ISO 14443 Type A");
		iso_type = 'a';
	return 0;
	}

	// if we're here, there is no type A card, so we look for type B
	// power up the field
	iso14443b_setup();
	// select the card
	return_code = iso14443b_select_card();
	if (return_code == 1) {
		Dbprintf("ISO 14443 Type B");
		iso_type = 'b';
		return 0;
	}
	Dbprintf("No card found.");
	return 1;
}
コード例 #4
0
void MifareDesfireGetInformation(){
		
	int len = 0;
	uint8_t resp[USB_CMD_DATA_SIZE] = {0x00};
	uint8_t dataout[USB_CMD_DATA_SIZE] = {0x00};
	byte_t cardbuf[USB_CMD_DATA_SIZE] = {0x00};
	
	/*
		1 = PCB					1
		2 = cid					2
		3 = desfire command		3 
		4-5 = crc				4  key
								5-6 crc								
		PCB == 0x0A because sending CID byte.
		CID == 0x00 first card?		
	*/
	clear_trace();
	set_tracing(TRUE);
	iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);

	// card select - information
	iso14a_card_select_t *card = (iso14a_card_select_t*)cardbuf;
	byte_t isOK = iso14443a_select_card(NULL, card, NULL, true, 0);
	if ( isOK == 0) {
		if (MF_DBGLEVEL >= MF_DBG_ERROR) {
			Dbprintf("Can't select card");
		}
		OnError(1);
		return;
	}

	memcpy(dataout,card->uid,7);

	LED_A_ON();
	LED_B_OFF();
	LED_C_OFF();
	
	uint8_t cmd[] = {GET_VERSION};	
	size_t cmd_len = sizeof(cmd);
	
	len =  DesfireAPDU(cmd, cmd_len, resp);
	if ( !len ) {
		print_result("ERROR <--: ", resp, len);	
		OnError(2);
		return;
	}
	
	LED_A_OFF();
	LED_B_ON();
	memcpy(dataout+7,resp+3,7);
	
	// ADDITION_FRAME 1
	cmd[0] = ADDITIONAL_FRAME;
	len =  DesfireAPDU(cmd, cmd_len, resp);
	if ( !len ) {
		print_result("ERROR <--: ", resp, len);	
		OnError(2);
		return;
	}	
	
	LED_B_OFF();
	LED_C_ON();
	memcpy(dataout+7+7,resp+3,7);

	// ADDITION_FRAME 2
	len =  DesfireAPDU(cmd, cmd_len, resp);
	if ( !len ) {
		print_result("ERROR <--: ", resp, len);	
		OnError(2);
		return;
	}
	
	memcpy(dataout+7+7+7,resp+3,14);
	
	cmd_send(CMD_ACK,1,0,0,dataout,sizeof(dataout));
		
	// reset the pcb_blocknum,
	pcb_blocknum = 0;
	OnSuccess();
}