J'essaie de lire des informations spécifiques à partir d'une carte d'identité.Acessing Structure de la carte à puce
Je veux obtenir le nom, numéro d'identification, date de naissance et ainsi de suite. C'est une carte à puce.
J'ai codé un programme Java qui se connecte également au lecteur de cartes et à la carte.
Le seul problème est quand je veux lire les informations de la carte, je ne sais pas exactement où sont les fichiers situés dans quels fichiers DF (fichiers dédiés) ou EF (fichiers élémentaires). MF est fixé à 3F00 mais d'autres je ne sais pas.
Voici un exemple pour la carte d'identité belge Emplacement du fichier:
static byte[] IDENTITY_FILE_AID = new byte[] {
(byte) 0x3F,// MASTER FILE, Head directory MF "3f00"
(byte) 0x00,
(byte) 0xDF,// Dedicated File, subdirectory identity DF(ID) "DF01"
(byte) 0x01,
(byte) 0x40,// Elementary File, the identity file itself EF(ID#RN) "4031"
(byte) 0x31 };
Mais cela est fonctionne pas avec notre carte d'identité dans notre pays et gouvernement de ne pas mentionner la structure de la carte. Est-il possible de connaître la structure ou de lire la carte entière sans mentionner de fichier spécifique?
Le fichier est sélectionné avec:
CommandAPDU selectFileApdu = new CommandAPDU(
0x00, //CLA
0xA4, //INS
0x08, //P1
0x0C, //P2
IDENTITY_FILE_AID);
Je pense que le seul problème est le:
IDENTITY_FILE_AID
C'est tout le code du programme:
import java.util.*;
import javax.smartcardio.*;
public class Mainn {
static byte[] IDENTITY_FILE_AID = new byte[] {
(byte) 0x3F,// MASTER FILE, Head directory MF "3f00"
(byte) 0x00,
(byte) 0xDF,// Dedicated File, subdirectory identity DF(ID) "DF01"
(byte) 0x01,
(byte) 0x40,// Elementary File, the identity file itself EF(ID#RN) "4031"
(byte) 0x31
};
static byte FIRST_NAME_TAG = (byte) 0x08;
static byte LAST_NAME_TAG = (byte) 0x07;
static byte NATIONAL_NUMBER_TAG = (byte) 0x06;
static byte BIRTH_DATE_TAG = (byte) 0x0C;
///////////////////////////// Let's program it now !
public static void main(String[] args) {
TerminalFactory factory = TerminalFactory.getDefault();
try{
System.out.println("First");
List<CardTerminal> terminals = factory.terminals().list();
System.out.println("Second");
// get the first terminal
// This is the device for reading the card
CardTerminal terminal = terminals.get(0);
System.out.println("Third");
// establish a connection with the card
Card card = terminal.connect("*");
System.out.println("Fourth");
CardChannel channel = card.getBasicChannel();
System.out.println("Fifth");
// SELECT FILE COMMAND
// See BEID cardpecs v2.0 page 21
CommandAPDU selectFileApdu = new CommandAPDU(
0x00, //CLA
0xA4, //INS
0x08, //P1
0x0C, //P2
IDENTITY_FILE_AID);
ResponseAPDU r = channel.transmit(selectFileApdu);
int offset = 0;
byte[] file = new byte[4096];
byte[] data;
do {
CommandAPDU readBinaryApdu = new CommandAPDU(
0x00, //CLA
0xB0, //Read binary command
offset >> 8, //OFF_H higher byte of the offset (bit 8 = 0)
offset & 0xFF, //OFF_L lower byte of the offset
0xFF); //empty
ResponseAPDU responseApdu = channel.transmit(readBinaryApdu);
data = responseApdu.getData();
System.arraycopy(data, 0, file, offset, data.length);
offset += data.length;
}
while (0xFF == data.length);
card.disconnect(false);
// locate the first name field within the identity file
System.out.println("Sixth");
int idx = 0;
byte length = 0;
while (idx < file.length) {
byte tag = file[idx];
idx++;
length = file[idx];
idx++;
String firstName = new String(Arrays.copyOfRange(file, idx, idx + length));
System.out.println("first name: " + firstName);
idx += length;
}
}
catch(CardException ioe) {
System.out.println("Something Wrong With The Insertion of the reader or the card");
}
}
}
Le problème que j'ai, c'est que je ne sais pas exactement où les informations sont sauvegardées.
Alors, que dois-je faire?
Quel est le type de carte? –
L'IDENTITY SMART CARD est une carte Java Hybrid Smart composée d'un contact micro ST EEPROM 66K et d'une puce mifare sans contact EEPROM 1K. – user3800653
Certaines cartes mifare ont des failles de sécurité qui vous permettent de lire des informations arbitraires sur la carte - il y a des outils pour cela comme https://code.google.com/p/mfcuk/ et http: // nfc-tools. org/index.php? title = Libnfc: nfc-mfclassic - il suffit de creuser autour de cela et je suppose que vous pourriez faire quelque chose –