Proxmark3 community

Research, development and trades concerning the powerful Proxmark3 device.

Remember; sharing is caring. Bring something back to the community.


"Learn the tools of the trade the hard way." +Fravia

You are not logged in.

Announcement

Time changes and with it the technology
Proxmark3 @ discord

Users of this forum, please be aware that information stored on this site is not private.

#1 2013-08-27 08:17:11

rlepricon
Member
Registered: 2013-08-27
Posts: 3

Ret. code 63 00 while reading block

Hi, guys!
I need some help with mifare classic 1k.

I'm trying to create a little tool for my job for writing/reading information to/from mifare classic 1k. It will be something like a visit card.

I load keys to reader (ret.code 90 00);
I authenticate in block (ret. code 90 00);
But when I'm trying to read from block i got a error (ret.code 63 00);

Can you see my code, and say me, what I'm doing wrong?

#include "stdafx.h"
#include "Winscard.h"

LPTSTR          pmszReaders = NULL;
LPTSTR			pmszCards = NULL;
LPTSTR          pReader = NULL;
LPTSTR			pCard = NULL;
LONG            lReturn, lReturn2;
DWORD           cch = SCARD_AUTOALLOCATE;
SCARDCONTEXT    hSC;
SCARD_READERSTATE readerState;
LPCTSTR			readerNameACS = L"ACS ACR1222 1S Dual Reader 0";
SCARDHANDLE     hCardHandle;
DWORD           dwAP = 0;
BYTE			pbRecv[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
DWORD			dwRecv = 0;

BYTE			cmdGetData[] =			{0xFF, 0xCA, 0x00, 0x00, 0x00};
BYTE			cmdLoadKeyA[] =			{0xFF, 0x82, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
BYTE			cmdAuthKeyABlock[] =	{0xFF, 0x88, 0x00, 0x01, 0x60, 0x00};
BYTE			cmdReadBlock[] =		{0xFF, 0xB0, 0x00, 0x01, 0x0F};



int _tmain(int argc, _TCHAR* argv[]) {
	
	lReturn = SCardEstablishContext(SCARD_SCOPE_USER, NULL, NULL, &hSC);
	if ( SCARD_S_SUCCESS != lReturn )
		printf("Failed SCardEstablishContext\n");
	else {
		lReturn = SCardListReaders(hSC, NULL, (LPTSTR)&pmszReaders, &cch );
		if (lReturn != SCARD_S_SUCCESS) {
			printf("Failed SCardListReaders\n");
		} else {
			pReader = pmszReaders;
			while ( '\0' != *pReader ) {
				printf("Reader: %S\n", pReader );
				pReader = pReader + wcslen((wchar_t *)pReader) + 1;
			}
		}

		memset(&readerState,0,sizeof(readerState));
		readerState.szReader = pmszReaders;


		lReturn = SCardConnect( hSC, readerNameACS, SCARD_SHARE_EXCLUSIVE, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, &hCardHandle, &dwAP );
		if ( SCARD_S_SUCCESS != lReturn ) {
			printf("Failed SCardConnect\n");
			system("pause");
			exit(1);
		} else {
			printf("Success SCardConnect\n");
			switch ( dwAP ) {
				case SCARD_PROTOCOL_T0:
					printf("Active protocol T0\n"); 
					break;
			    case SCARD_PROTOCOL_T1:
					printf("Active protocol T1\n"); 
					break;
				case SCARD_PROTOCOL_UNDEFINED:
				default:
					printf("Active protocol unnegotiated or unknown\n"); 
					break;
			}
		}


		lReturn = SCardTransmit(hCardHandle, SCARD_PCI_T1, cmdGetData, sizeof(cmdGetData), NULL, pbRecv, &dwRecv);
		if ( SCARD_S_SUCCESS != lReturn ) {
			printf("Failed SCardTransmit\n");
		} else {
			printf("Success SCardTransmit - GetData\n");
			printf("Read %u bytes\n", dwRecv);
			for(byte i=0;i<dwRecv;i++) {
				printf("%x ", pbRecv[i]);
			}
			printf("\n");
		}

		lReturn = SCardTransmit(hCardHandle, SCARD_PCI_T1, cmdGetData, sizeof(cmdGetData), NULL, pbRecv, &dwRecv);
		if ( SCARD_S_SUCCESS != lReturn ) {
			printf("Failed SCardTransmit\n");
		} else {
			printf("Success SCardTransmit - GetData\n");
			printf("Read %u bytes\n", dwRecv);
			for(byte i=0;i<dwRecv;i++) {
				printf("%x ", pbRecv[i]);
			}
			printf("\n");
		}
		

		lReturn = SCardTransmit(hCardHandle, SCARD_PCI_T1, cmdLoadKeyA, sizeof(cmdLoadKeyA), NULL, pbRecv, &dwRecv);
		if ( SCARD_S_SUCCESS != lReturn ) {
			printf("Failed SCardTransmit\n");
		} else {
			printf("Success SCardTransmit - LoadKeyA\n");
			printf("Read %u bytes\n", dwRecv);
			for(byte i=0;i<dwRecv;i++) {
				printf("%x ", pbRecv[i]);
			}
			printf("\n");
		}


		lReturn = SCardTransmit(hCardHandle, SCARD_PCI_T1, cmdAuthKeyABlock, sizeof(cmdAuthKeyABlock), NULL, pbRecv, &dwRecv);
		if ( SCARD_S_SUCCESS != lReturn ) {
			printf("Failed SCardTransmit\n");
		} else {
			printf("Success SCardTransmit - Authenticate\n");
			printf("Read %u bytes\n", dwRecv);
			for(byte i=0;i<dwRecv;i++) {
				printf("%x ", pbRecv[i]);
			}
			printf("\n");
		}


		lReturn = SCardTransmit(hCardHandle, SCARD_PCI_T1, cmdReadBlock, sizeof(cmdReadBlock), NULL, pbRecv, &dwRecv);
		if ( SCARD_S_SUCCESS != lReturn ) {
			printf("Failed SCardTransmit\n");
		} else {
			printf("Success SCardTransmit - ReadBlock\n");
			printf("Read %u bytes\n", dwRecv);
			for(byte i=0;i<dwRecv;i++) {
				printf("%x ", pbRecv[i]);
			}
			printf("\n");
		}

	}

	lReturn = SCardDisconnect(hCardHandle, SCARD_LEAVE_CARD);
	if ( SCARD_S_SUCCESS != lReturn ) {
		printf("Failed SCardDisconnect\n");
	} else {
		printf("Success SCardDisconnect\n");
	}
	system("pause");
	return 0;
}

Offline

#2 2013-08-27 08:19:33

rlepricon
Member
Registered: 2013-08-27
Posts: 3

Re: Ret. code 63 00 while reading block

Some more information:
I use cardreader ACR 1222U;
I code in Visual Studion uder Windows 7 x 64;
I use mifare classic 1k.

Offline

#3 2013-08-29 06:58:06

rlepricon
Member
Registered: 2013-08-27
Posts: 3

Re: Ret. code 63 00 while reading block

Nobody can help me?

Offline

#4 2013-12-23 20:10:39

clayer
Contributor
Registered: 2013-12-22
Posts: 45

Re: Ret. code 63 00 while reading block

pls give ICQ or Skype i`m intereresting

Offline

#5 2015-01-23 17:51:01

piwi
Contributor
Registered: 2013-06-04
Posts: 704

Re: Ret. code 63 00 while reading block

@rlepricon: This is the Proxmark developers community. Although there are changes that people in this forum are interested in both PM3 and ACR1222U programming, there might be better places to look for help.
@Mishima01: He doesn't use a Proxmark. Nevertheless: it isn't due to firmware changes that you should have some distance between card and antenna. Well, at least not due to recent changes. See Roels post from the year 2011 (http://www.proxmark.org/forum/viewtopic.php?id=1069):

rule wrote:

Note: If you want to verify, make sure you have a (13v+ antenna) and play around with distance between the card and antenna. It could help if you just put a boring (read thick) book in between wink

Offline

Board footer

Powered by FluxBB