mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
Merge pull request #1740 from gtalusan/emrtd-images
add -i to hf emrtd info
This commit is contained in:
commit
1ec4e98a3c
6 changed files with 23 additions and 104 deletions
|
@ -1433,42 +1433,7 @@ static int emrtd_print_ef_dg2_info(uint8_t *data, size_t datalen) {
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_jpg = (data[offset] == 0xFF);
|
ShowPictureWindow(data + offset, datalen);
|
||||||
|
|
||||||
size_t fn_len = strlen(dg_table[EF_DG2].filename) + 4 + 1;
|
|
||||||
char *fn = calloc(fn_len, sizeof(uint8_t));
|
|
||||||
if (fn == NULL)
|
|
||||||
return PM3_EMALLOC;
|
|
||||||
|
|
||||||
snprintf(fn, fn_len * sizeof(uint8_t), "%s.%s", dg_table[EF_DG2].filename, (is_jpg) ? "jpg" : "jp2");
|
|
||||||
|
|
||||||
PrintAndLogEx(DEBUG, "image filename `" _YELLOW_("%s") "`", fn);
|
|
||||||
|
|
||||||
char *path;
|
|
||||||
if (searchHomeFilePath(&path, NULL, fn, false) != PM3_SUCCESS) {
|
|
||||||
free(fn);
|
|
||||||
return PM3_EFILE;
|
|
||||||
}
|
|
||||||
free(fn);
|
|
||||||
|
|
||||||
// remove old file
|
|
||||||
if (fileExists(path)) {
|
|
||||||
PrintAndLogEx(DEBUG, "Delete old temp file `" _YELLOW_("%s") "`", path);
|
|
||||||
remove(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// temp file.
|
|
||||||
PrintAndLogEx(DEBUG, "Save temp file `" _YELLOW_("%s") "`", path);
|
|
||||||
saveFile(path, "", data + offset, datalen);
|
|
||||||
|
|
||||||
PrintAndLogEx(DEBUG, "view temp file `" _YELLOW_("%s") "`", path);
|
|
||||||
ShowPictureWindow(path);
|
|
||||||
msleep(500);
|
|
||||||
|
|
||||||
// delete temp file
|
|
||||||
PrintAndLogEx(DEBUG, "Deleting temp file `" _YELLOW_("%s") "`", path);
|
|
||||||
remove(path);
|
|
||||||
//free(path);
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1493,42 +1458,7 @@ static int emrtd_print_ef_dg5_info(uint8_t *data, size_t datalen) {
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_jpg = (data[offset] == 0xFF);
|
ShowPictureWindow(data + offset, datalen);
|
||||||
|
|
||||||
size_t fn_len = strlen(dg_table[EF_DG5].filename) + 4 + 1;
|
|
||||||
char *fn = calloc(fn_len, sizeof(uint8_t));
|
|
||||||
if (fn == NULL)
|
|
||||||
return PM3_EMALLOC;
|
|
||||||
|
|
||||||
snprintf(fn, fn_len * sizeof(uint8_t), "%s.%s", dg_table[EF_DG5].filename, (is_jpg) ? "jpg" : "jp2");
|
|
||||||
|
|
||||||
PrintAndLogEx(DEBUG, "image filename `" _YELLOW_("%s") "`", fn);
|
|
||||||
|
|
||||||
char *path;
|
|
||||||
if (searchHomeFilePath(&path, NULL, fn, false) != PM3_SUCCESS) {
|
|
||||||
free(fn);
|
|
||||||
return PM3_EFILE;
|
|
||||||
}
|
|
||||||
free(fn);
|
|
||||||
|
|
||||||
// remove old file
|
|
||||||
if (fileExists(path)) {
|
|
||||||
PrintAndLogEx(DEBUG, "Delete old temp file `" _YELLOW_("%s") "`", path);
|
|
||||||
remove(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// temp file.
|
|
||||||
PrintAndLogEx(DEBUG, "Save temp file `" _YELLOW_("%s") "`", path);
|
|
||||||
saveFile(path, "", data + offset, datalen);
|
|
||||||
|
|
||||||
PrintAndLogEx(DEBUG, "view temp file `" _YELLOW_("%s") "`", path);
|
|
||||||
ShowPictureWindow(path);
|
|
||||||
msleep(500);
|
|
||||||
|
|
||||||
// delete temp file
|
|
||||||
PrintAndLogEx(DEBUG, "Deleting temp file `" _YELLOW_("%s") "`", path);
|
|
||||||
remove(path);
|
|
||||||
//free(path);
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1915,7 +1845,7 @@ static int emrtd_print_ef_cardaccess_info(uint8_t *data, size_t datalen) {
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int infoHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_available) {
|
int infoHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_available, bool only_fast) {
|
||||||
uint8_t response[EMRTD_MAX_FILE_SIZE] = { 0x00 };
|
uint8_t response[EMRTD_MAX_FILE_SIZE] = { 0x00 };
|
||||||
size_t resplen = 0;
|
size_t resplen = 0;
|
||||||
uint8_t ssc[8] = { 0x00 };
|
uint8_t ssc[8] = { 0x00 };
|
||||||
|
@ -2001,7 +1931,7 @@ int infoHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_availab
|
||||||
PrintAndLogEx(INFO, "File tag not found, skipping: %02X", filelist[i]);
|
PrintAndLogEx(INFO, "File tag not found, skipping: %02X", filelist[i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (dg->fastdump && !dg->pace && !dg->eac) {
|
if (((dg->fastdump && only_fast) || !only_fast) && !dg->pace && !dg->eac) {
|
||||||
if (emrtd_select_and_read(response, &resplen, dg->fileid, ks_enc, ks_mac, ssc, BAC)) {
|
if (emrtd_select_and_read(response, &resplen, dg->fileid, ks_enc, ks_mac, ssc, BAC)) {
|
||||||
if (dg->parser != NULL)
|
if (dg->parser != NULL)
|
||||||
dg->parser(response, resplen);
|
dg->parser(response, resplen);
|
||||||
|
@ -2263,6 +2193,7 @@ static int CmdHFeMRTDInfo(const char *Cmd) {
|
||||||
arg_str0("e", "expiry", "<YYMMDD>", "expiry in YYMMDD format"),
|
arg_str0("e", "expiry", "<YYMMDD>", "expiry in YYMMDD format"),
|
||||||
arg_str0("m", "mrz", "<[0-9A-Z<]>", "2nd line of MRZ, 44 chars (passports only)"),
|
arg_str0("m", "mrz", "<[0-9A-Z<]>", "2nd line of MRZ, 44 chars (passports only)"),
|
||||||
arg_str0(NULL, "path", "<dirpath>", "display info from offline dump stored in dirpath"),
|
arg_str0(NULL, "path", "<dirpath>", "display info from offline dump stored in dirpath"),
|
||||||
|
arg_lit0("i", "images", "show images"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
};
|
};
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
|
@ -2329,6 +2260,7 @@ static int CmdHFeMRTDInfo(const char *Cmd) {
|
||||||
}
|
}
|
||||||
uint8_t path[FILENAME_MAX] = { 0x00 };
|
uint8_t path[FILENAME_MAX] = { 0x00 };
|
||||||
bool is_offline = CLIParamStrToBuf(arg_get_str(ctx, 5), path, sizeof(path), &slen) == 0 && slen > 0;
|
bool is_offline = CLIParamStrToBuf(arg_get_str(ctx, 5), path, sizeof(path), &slen) == 0 && slen > 0;
|
||||||
|
bool show_images = arg_get_lit(ctx, 6);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
if ((! IfPm3Iso14443()) && (! is_offline)) {
|
if ((! IfPm3Iso14443()) && (! is_offline)) {
|
||||||
PrintAndLogEx(WARNING, "Only offline mode is available");
|
PrintAndLogEx(WARNING, "Only offline mode is available");
|
||||||
|
@ -2344,7 +2276,7 @@ static int CmdHFeMRTDInfo(const char *Cmd) {
|
||||||
if (g_debugMode >= 2) {
|
if (g_debugMode >= 2) {
|
||||||
SetAPDULogging(true);
|
SetAPDULogging(true);
|
||||||
}
|
}
|
||||||
int res = infoHF_EMRTD((char *)docnum, (char *)dob, (char *)expiry, BAC);
|
int res = infoHF_EMRTD((char *)docnum, (char *)dob, (char *)expiry, BAC, !show_images);
|
||||||
SetAPDULogging(restore_apdu_logging);
|
SetAPDULogging(restore_apdu_logging);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ typedef struct emrtd_pacesdp_s {
|
||||||
int CmdHFeMRTD(const char *Cmd);
|
int CmdHFeMRTD(const char *Cmd);
|
||||||
|
|
||||||
int dumpHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_available, const char *path);
|
int dumpHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_available, const char *path);
|
||||||
int infoHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_available);
|
int infoHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_available, bool only_fast);
|
||||||
int infoHF_EMRTD_offline(const char *path);
|
int infoHF_EMRTD_offline(const char *path);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -67,11 +67,13 @@ extern "C" void RepaintGraphWindow(void) {
|
||||||
|
|
||||||
|
|
||||||
// hook up picture viewer
|
// hook up picture viewer
|
||||||
extern "C" void ShowPictureWindow(char *fn) {
|
extern "C" void ShowPictureWindow(uint8_t *data, int len) {
|
||||||
// No support for jpeg2000 in Qt Image since a while...
|
// No support for jpeg2000 in Qt Image since a while...
|
||||||
// https://doc.qt.io/qt-5/qtimageformats-index.html
|
// https://doc.qt.io/qt-5/qtimageformats-index.html
|
||||||
if (strlen(fn) > 4 && !strcmp(fn + strlen(fn) - 4, ".jp2"))
|
QImage img = QImage::fromData(data, len);
|
||||||
|
if (img.isNull()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (!gui) {
|
if (!gui) {
|
||||||
// Show a notice if X11/XQuartz isn't available
|
// Show a notice if X11/XQuartz isn't available
|
||||||
#if defined(__MACH__) && defined(__APPLE__)
|
#if defined(__MACH__) && defined(__APPLE__)
|
||||||
|
@ -82,7 +84,7 @@ extern "C" void ShowPictureWindow(char *fn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gui->ShowPictureWindow(fn);
|
gui->ShowPictureWindow(img);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void ShowBase64PictureWindow(char *b64) {
|
extern "C" void ShowBase64PictureWindow(char *b64) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ void HideGraphWindow(void);
|
||||||
void RepaintGraphWindow(void);
|
void RepaintGraphWindow(void);
|
||||||
|
|
||||||
// hook up picture viewer
|
// hook up picture viewer
|
||||||
void ShowPictureWindow(char *fn);
|
void ShowPictureWindow(uint8_t *data, int len);
|
||||||
void ShowBase64PictureWindow(char *b64);
|
void ShowBase64PictureWindow(char *b64);
|
||||||
void HidePictureWindow(void);
|
void HidePictureWindow(void);
|
||||||
void RepaintPictureWindow(void);
|
void RepaintPictureWindow(void);
|
||||||
|
|
|
@ -65,8 +65,8 @@ void ProxGuiQT::HideGraphWindow(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// emit picture viewer signals
|
// emit picture viewer signals
|
||||||
void ProxGuiQT::ShowPictureWindow(char *fn) {
|
void ProxGuiQT::ShowPictureWindow(const QImage &img) {
|
||||||
emit ShowPictureWindowSignal(fn);
|
emit ShowPictureWindowSignal(img);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProxGuiQT::ShowBase64PictureWindow(char *b64) {
|
void ProxGuiQT::ShowBase64PictureWindow(char *b64) {
|
||||||
|
@ -116,24 +116,14 @@ void ProxGuiQT::_HideGraphWindow(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// picture viewer
|
// picture viewer
|
||||||
void ProxGuiQT::_ShowPictureWindow(char *fn) {
|
void ProxGuiQT::_ShowPictureWindow(const QImage &img) {
|
||||||
|
|
||||||
if (!plotapp)
|
if (!plotapp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fn == NULL)
|
if (img.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
size_t slen = strlen(fn);
|
|
||||||
if (slen == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
char *myfn = (char *)calloc(slen + 1, sizeof(uint8_t));
|
|
||||||
if (myfn == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
memcpy(myfn, fn, slen);
|
|
||||||
|
|
||||||
if (!pictureWidget) {
|
if (!pictureWidget) {
|
||||||
|
|
||||||
#if defined(__MACH__) && defined(__APPLE__)
|
#if defined(__MACH__) && defined(__APPLE__)
|
||||||
|
@ -143,12 +133,7 @@ void ProxGuiQT::_ShowPictureWindow(char *fn) {
|
||||||
pictureWidget = new PictureWidget();
|
pictureWidget = new PictureWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap pm;
|
QPixmap pm = QPixmap::fromImage(img);
|
||||||
if (pm.load(myfn) == false) {
|
|
||||||
qWarning("Failed to load %s", myfn);
|
|
||||||
}
|
|
||||||
free(myfn);
|
|
||||||
free(fn);
|
|
||||||
|
|
||||||
//QPixmap newPixmap = pm.scaled(QSize(50,50), Qt::KeepAspectRatio);
|
//QPixmap newPixmap = pm.scaled(QSize(50,50), Qt::KeepAspectRatio);
|
||||||
//pm = pm.scaled(pictureController->lbl_pm->size(), Qt::KeepAspectRatio);
|
//pm = pm.scaled(pictureController->lbl_pm->size(), Qt::KeepAspectRatio);
|
||||||
|
@ -264,7 +249,7 @@ void ProxGuiQT::MainLoop() {
|
||||||
connect(this, SIGNAL(ExitSignal()), this, SLOT(_Exit()));
|
connect(this, SIGNAL(ExitSignal()), this, SLOT(_Exit()));
|
||||||
|
|
||||||
// hook up picture viewer signals
|
// hook up picture viewer signals
|
||||||
connect(this, SIGNAL(ShowPictureWindowSignal(char *)), this, SLOT(_ShowPictureWindow(char *)));
|
connect(this, SIGNAL(ShowPictureWindowSignal(const QImage &)), this, SLOT(_ShowPictureWindow(const QImage &)));
|
||||||
connect(this, SIGNAL(ShowBase64PictureWindowSignal(char *)), this, SLOT(_ShowBase64PictureWindow(char *)));
|
connect(this, SIGNAL(ShowBase64PictureWindowSignal(char *)), this, SLOT(_ShowBase64PictureWindow(char *)));
|
||||||
connect(this, SIGNAL(RepaintPictureWindowSignal()), this, SLOT(_RepaintPictureWindow()));
|
connect(this, SIGNAL(RepaintPictureWindowSignal()), this, SLOT(_RepaintPictureWindow()));
|
||||||
connect(this, SIGNAL(HidePictureWindowSignal()), this, SLOT(_HidePictureWindow()));
|
connect(this, SIGNAL(HidePictureWindowSignal()), this, SLOT(_HidePictureWindow()));
|
||||||
|
|
|
@ -156,7 +156,7 @@ class ProxGuiQT : public QObject {
|
||||||
void HideGraphWindow(void);
|
void HideGraphWindow(void);
|
||||||
|
|
||||||
// hook up picture viewer
|
// hook up picture viewer
|
||||||
void ShowPictureWindow(char *fn);
|
void ShowPictureWindow(const QImage &img);
|
||||||
void ShowBase64PictureWindow(char *b64);
|
void ShowBase64PictureWindow(char *b64);
|
||||||
void HidePictureWindow(void);
|
void HidePictureWindow(void);
|
||||||
void RepaintPictureWindow(void);
|
void RepaintPictureWindow(void);
|
||||||
|
@ -170,7 +170,7 @@ class ProxGuiQT : public QObject {
|
||||||
void _HideGraphWindow(void);
|
void _HideGraphWindow(void);
|
||||||
|
|
||||||
// hook up picture viewer
|
// hook up picture viewer
|
||||||
void _ShowPictureWindow(char *fn);
|
void _ShowPictureWindow(const QImage &img);
|
||||||
void _ShowBase64PictureWindow(char *b64);
|
void _ShowBase64PictureWindow(char *b64);
|
||||||
void _HidePictureWindow(void);
|
void _HidePictureWindow(void);
|
||||||
void _RepaintPictureWindow(void);
|
void _RepaintPictureWindow(void);
|
||||||
|
@ -185,7 +185,7 @@ class ProxGuiQT : public QObject {
|
||||||
void ExitSignal(void);
|
void ExitSignal(void);
|
||||||
|
|
||||||
// hook up picture viewer signals
|
// hook up picture viewer signals
|
||||||
void ShowPictureWindowSignal(char *fn);
|
void ShowPictureWindowSignal(const QImage &img);
|
||||||
void ShowBase64PictureWindowSignal(char *b64);
|
void ShowBase64PictureWindowSignal(char *b64);
|
||||||
void HidePictureWindowSignal(void);
|
void HidePictureWindowSignal(void);
|
||||||
void RepaintPictureWindowSignal(void);
|
void RepaintPictureWindowSignal(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue