0 like 0 dislike
321 views
in T20 by Q&A Freshman (102 points)
Hi,

I was able to figure out the mifare classic 4k cards with the methods: m1_multi_sector_read and m1_multi_sector_write.

We would like to implement the same for mifare classic 1k card. Ordinarily for 4k card, we passed m1_multi_sector_read((byte)1,(byte)32) and m1_multi_sector_write((byte)1,(byte)32). Essentially we thought this would apply to 1k card to simply by replacing 32 with 16.

Unfortunately it failed with all the attempts for the nested loops between 1 to 16. I went through the sdk document, but these methods are not covered in the documents.

Please note also that when I call the read block method "m1_read_block", it only works for 4 bytes. which implies i have to change sector for more data. Unfortunately there is not a method in the sdk or its document that provides for this.

I tried to increment counters using: m1_increment(), but no luck too.  I did all this because the sdk document specifies that Mifare Classic Cards are supported. I am assuming, am missing something.

I am applying this the T20 device with serial number: B2BT020000400021.

Please Help.
by Q&A Professional (5.2k points)
edited by
1 0
Hello, about the MiFare classic ev1 1K, "m1_multi_sector_read" the sectors are 0-based, for example: m1_multi_sector_read((byte)0, (byte)16).  About the 4K card, it has 40 sectors, So you have no problem using this method. I have another doubt, what do you mean by saying that this "m1_read_block" only works for 4 bytes?

Please log in or register to answer this question.

1 Answer

0 like 0 dislike
by Q&A Expert (11.0k points)

Hello, about the MiFare classic ev1 1K, "m1_multi_sector_read" the sectors are 0-based, for example: m1_multi_sector_read((byte)0, (byte)16).  About the 4K card, it has 40 sectors, So you have no problem using this method. I have another doubt, what do you mean by saying that this "m1_read_block" only works for 4 bytes?

by Q&A Freshman (102 points)
0 0
Hello Jason,

Thanks lot for the response,

But i tried the multi_sector_read(). for the Mifare Classic ev1 1k cards like this:

try{
            data = nfc.m1_multi_sector_read((byte)0, (byte)16) ;
        }catch (Exception e){
            Toast.makeText(this,, Toast.LENGTH_SHORT).show();
            Log.e(TAG, "readBlockData:    " );
        }
and still getting this exception:
 m1_multi_sector_read return error code = -1003

The same method works for mifare classic ev1 4k cards with parameters (byte)1 and (byte)32

For this: ", what do you mean by saying that this "m1_read_block" only works for 4 bytes?"
I meant it this way:

for (int i = 0; i <= LIMIT; i++) {
            try{
                data = nfc.m1_read_block((byte)i) ;
            }catch (Exception e){
                Toast.makeText(this,i+"", Toast.LENGTH_SHORT).show();
                Log.e(TAG, "readBlockData:    "+i );
            }
            sb.append(StringUtil.toHexString(data));
            data = null;

        }

so if the LIMIT is grater than or equal to 4, then I will get an exception. With this method, we cannot go beyond 4 blocks.

I am still using the demo: DemoSDK20220928 2,
versionCode 2

Thanks
by Q&A Professional (5.2k points)
edited by
1 0
On your 1K card, are all sectors the same password? if not, the result returns -1003. It will get the password you used to authenticate and poll 16 sectors.

for this: "so if the LIMIT is grater than or equal to 4, then I will get an exception. With this method, we cannot go beyond 4 blocks."  If you select blocks of the same sector when authenticating, then you can read all blocks of that sector.

for example, m1_authenticate((byte) 1, (byte)0x0A, passwd), I select the block one, and this is the first sector, right? And you can read the block0-3 by "m1_read_block".
by Q&A Freshman (102 points)
0 0
Hello Michael,

Thanks alot for the response.

I have confirmed that the key is the same for all the blocks in the card by running the m1_authenticate() on all the blocks without exception as here:
for(int i = 0; i<=63;i++){
            try {
                nfc.m1_authenticate((byte)i, (byte)0x0B, passwd);
            } catch (CommonException e) {
                status = false;
                e.printStackTrace();
                Log.e(TAG, "m1CardAuthenticate: "+i );
            }
        }

It sure shows that all the blocks are authenticated using the same Key, which implies that I could perform a multi_sector_read. I also checked the sdk to see if there is any sector level authentication but it seems I can only perform block authentication.

I have tried it on all addresses as seen below but did not get any response from any combination.:
for(int i =0; i<=16;i++){
            for(int j=0;j<=16;j++){
                try {
                    data = nfc.m1_multi_sector_read((byte) i,(byte)j);
                    Log.e(TAG, "readBlockData: "+ StringUtil.toHexString(data));
                } catch (CommonException e) {
                    Log.e(TAG, "readBlockData: "+i );
                    e.printStackTrace();
                }
            }
        }
I believe that m1_multi_sector_read() for mifare classic 1k cards should be m1_multi_sector_read((byte)0,(byte)15), am a bit stuck at why mine wont work even after the trying all possible combinations with brute force.

Thanks,
by Q&A Freshman (102 points)
0 0
Hello Telpo,

Kindly Bumping this up.

Thanks,
by Q&A Professional (5.2k points)
0 0
I wrote a code about this interface, you can try it out. the download link:

http://service.telpo.com:8092/index/user/fetfile?key=APHYkDOC7bWeRnpE

Related questions

0 like 0 dislike
1 answer 28 views
0 like 0 dislike
1 answer 104 views
0 like 0 dislike
1 answer 31 views
asked in T20 by segalla.gio Q&A Freshman (102 points)
0 like 0 dislike
0 answers 13 views
asked in TPS900 by cugwuh Q&A Freshman (104 points)
0 like 0 dislike
1 answer 69 views
0 like 0 dislike
1 answer 46 views
asked in T20 by HandsFree Q&A Freshman (132 points)
0 like 0 dislike
1 answer 302 views
Welcome to Telpo Q&A,

If you have a technical question ,please ask here, in English.
.
If you have faulty devices need be repaired,please create a issue ticket.

Please inquiry your ticket.

Notice :If you have an urgent question or cannot register account of Q&A, you can contact the online support in below jivochat .

Categories

...