From ad10a6e78916ea99817783c1d9edce6d5bd76189 Mon Sep 17 00:00:00 2001 From: wh201906 Date: Sat, 8 Aug 2020 21:49:43 +0800 Subject: [PATCH] Support Choose Trailer block --- lang/en_US.ts | 304 +++++++++++++++++++++++----------------------- lang/zh_CN.ts | 304 +++++++++++++++++++++++----------------------- ui/mainwindow.cpp | 82 ++++++++++++- ui/mainwindow.h | 3 + ui/mainwindow.ui | 33 ++--- 5 files changed, 400 insertions(+), 326 deletions(-) diff --git a/lang/en_US.ts b/lang/en_US.ts index acc7497..b881d0e 100644 --- a/lang/en_US.ts +++ b/lang/en_US.ts @@ -290,552 +290,554 @@ It could make the whole sector blocked irreversibly! - + Refresh - + Connect - + Disconnect - + Mifare - + + Select Trailer + + + + Card Type - + MINI 320 - + 1K 1024 - + 2K 2048 - + 4K 4096 - + File - - + + Load - - + + Save - - + + Data - + Key - + Attack - + Card Info - + Check Default - + Nested - + Hardnested - + Read/Write - + Block: - + Key: - + Key Type: - + Snoop - + List Data - + Data: - + Normal(Require Password) - - Read All - - - - + Dump - + Restore - + Chinese Magic Card(Without Password) - + Lock UFUID Card - - + + About UID Card - + Set Parameter - + Wipe - - + + Simulate - - Load from data above - - - - - + + Clear - + Select All - + KeyBlocks->Key - + KeyBlocks<-Key - + Fill Keys - + Trailer Decoder - + Set Fonts - - + + Read One - - + + Write One - - + + + Read Selected - - + + + Write Selected - - + + Sniff - + RawCommand - - + + History: - + ClearHistory - + Send - + ClearOutput - - - - - - - - - - - + + + + + + + + + + + Info - + Plz choose a port first - + Connected - - - + + + Not Connected - + Binary Data Files(*.bin *.dump);;Text Data Files(*.txt *.eml);;All Files(*.*) - - - + + + Failed to open - + Continue? - + + Check Update + + + + Some of the data and key will be cleared. - + Plz select the font of data widget and key widget - + Data must consists of 32 Hex symbols(Whitespace is allowed) - - + + Key must consists of 12 Hex symbols(Whitespace is allowed) - + Plz select the data file: - + Plz select the key file: - + Binary Key Files(*.bin *.dump);;Binary Data Files(*.bin *.dump);;All Files(*.*) - + Plz select the location to save data file: - + Binary Data Files(*.bin *.dump);;Text Data Files(*.txt *.eml) - - - + + + Failed to save to - + Plz select the location to save key file: - + Binary Key Files(*.bin *.dump) - + Normally, the Block 0 of a typical Mifare card, which contains the UID, is locked during the manufacture. Users cannot write anything to Block 0 or set a new UID to a normal Mifare card. - + Chinese Magic Cards(aka UID Cards) are some special cards whose Block 0 are writeable. And you can change UID by writing to it. - + There are two versions of Chinese Magic Cards, the Gen1 and the Gen2. - + Gen1: - + also called UID card in China. It responses to some backdoor commands so you can access any blocks without password. The Proxmark3 has a bunch of related commands(csetblk, cgetblk, ...) to deal with this type of card, and my GUI also support these commands. - + Gen2: - + doesn't response to the backdoor commands, which means that a reader cannot detect whether it is a Chinese Magic Card or not by sending backdoor commands. - + There are some types of Chinese Magic Card Gen2. - + CUID Card: - + the Block 0 is writeable, you can write to this block repeatedly by normal wrbl command. - + (hf mf wrbl 0 A FFFFFFFFFFFF <the data you want to write>) - + FUID Card: - + you can only write to Block 0 once. After that, it seems like a typical Mifare card(Block 0 cannot be written to). - + (some readers might try changing the Block 0, which could detect the CUID Card. In that case, you should use FUID card.) - + UFUID Card: - + It behaves like a CUID card(or UID card? I'm not sure) before you send some special command to lock it. Once it is locked, you cannot change its Block 0(just like a typical Mifare card). - + Seemingly, these Chinese Magic Cards are more easily to be compromised by Nested Attack(it takes little time to get an unknown key). - + Plz select the trace file: - + Trace Files(*.trc);;All Files(*.*) - + Plz select the location to save trace file: - + Trace Files(*.trc) - - + + Idle - - + + Sec - + Blk - + KeyA - + KeyB - + HW Version: - + PM3: - + State: - + Running @@ -843,18 +845,15 @@ It could make the whole sector blocked irreversibly! Mifare - - + Success! - - - - - + + + Info @@ -864,14 +863,13 @@ It could make the whole sector blocked irreversibly! - - - + + Failed! - + Failed to read card. diff --git a/lang/zh_CN.ts b/lang/zh_CN.ts index 2035f0b..316cf77 100644 --- a/lang/zh_CN.ts +++ b/lang/zh_CN.ts @@ -294,552 +294,554 @@ It could make the whole sector blocked irreversibly! 路径: - + Refresh 刷新端口 - + Connect 连接 - + Disconnect 断开 - + Mifare Mifare(IC)卡 - + + Select Trailer + 选中密码块 + + + Card Type 卡类型 - + MINI 320 - + 1K 1024 - + 2K 2048 - + 4K 4096 - + File 文件 - - + + Load 加载 - - + + Save 保存 - - + + Data - + Key - + Attack 破解 - + Card Info 读卡片信息 - + Check Default 验证默认密码 - + Nested Nested攻击 - + Hardnested Hardested攻击 - + Read/Write 读/写 - + Block: - + Key: - + Key Type: Key类型: - + Snoop 嗅探(Snoop) - + List Data 列出嗅探数据 - + Data: - + Normal(Require Password) 普通卡(需要密码) - - Read All - 读所有块 - - - + Dump Dump命令 - + Restore Restore命令 - + Chinese Magic Card(Without Password) UID卡(不需要密码) - + Lock UFUID Card 锁定UFUID卡 - - + + About UID Card 关于UID卡 - + Set Parameter 设置卡参数 - + Wipe 擦除 - - + + Simulate 模拟 - - Load from data above - 从上方数据导入 - - - - + + Clear 清空 - + Select All 全选 - + KeyBlocks->Key 密码区->密码 - + KeyBlocks<-Key 密码区<-密码 - + Fill Keys 填充密码 - + Trailer Decoder Trailer解码 - + Set Fonts 设置字体 - - + + Read One 读取单个区 - - + + Write One 写入单个区 - - + + + Read Selected 读取选中块 - - + + + Write Selected 写入选中块 - - + + Sniff 嗅探 - + RawCommand 原始命令 - - + + History: 命令历史: - + ClearHistory 清空历史 - + Send 发送 - + ClearOutput 清空输出 - - - - - - - - - - - + + + + + + + + + + + Info 信息 - + Plz choose a port first 请先选择端口 - + Connected 已连接 - - - + + + Not Connected 未连接 - + Binary Data Files(*.bin *.dump);;Text Data Files(*.txt *.eml);;All Files(*.*) 二进制Data文件(*.bin *.dump);;文本Data文件(*.txt *.eml);;所有文件(*.*) - - - + + + Failed to open 无法打开 - + Continue? 确定? - + + Check Update + 检查更新 + + + Some of the data and key will be cleared. 部分数据和密码将被清除 - + Plz select the font of data widget and key widget 请选择Data窗口和Key窗口的字体 - + Data must consists of 32 Hex symbols(Whitespace is allowed) Data必须由32个十六进制字符组成(中间可含有空格) - - + + Key must consists of 12 Hex symbols(Whitespace is allowed) Key必须由12个十六进制字符组成(中间可含有空格) - + Plz select the data file: 请选择data文件: - + Plz select the key file: 请选择key文件: - + Binary Key Files(*.bin *.dump);;Binary Data Files(*.bin *.dump);;All Files(*.*) 二进制Key文件(*.bin *.dump)二进制Data文件(*.bin *.dump);;所有文件(*.*) - + Plz select the location to save data file: 请选择文件保存的位置: - + Binary Data Files(*.bin *.dump);;Text Data Files(*.txt *.eml) 二进制Data文件(*.bin *.dump);;文本Data文件(*.txt *.eml) - - - + + + Failed to save to 无法保存至 - + Plz select the location to save key file: 请选择key文件保存的位置: - + Binary Key Files(*.bin *.dump) 二进制Key文件(*.bin *.dump) - + Normally, the Block 0 of a typical Mifare card, which contains the UID, is locked during the manufacture. Users cannot write anything to Block 0 or set a new UID to a normal Mifare card. 普通Mifare卡的Block0无法写入,UID也不能更改 - + Chinese Magic Cards(aka UID Cards) are some special cards whose Block 0 are writeable. And you can change UID by writing to it. UID卡(在国外叫Chinese Magic Card)的Block0可写,UID可变 - + There are two versions of Chinese Magic Cards, the Gen1 and the Gen2. 国外把UID卡分为Chinese Magic Card Gen1和Gen2 - + Gen1: - + also called UID card in China. It responses to some backdoor commands so you can access any blocks without password. The Proxmark3 has a bunch of related commands(csetblk, cgetblk, ...) to deal with this type of card, and my GUI also support these commands. 指通常所说的UID卡,可以通过后门指令直接读写块而无需密码,在PM3和此GUI中有特殊命令处理这类卡片 - + Gen2: - + doesn't response to the backdoor commands, which means that a reader cannot detect whether it is a Chinese Magic Card or not by sending backdoor commands. 这个叫法在国内比较罕见,在国外指CUID/FUID/UFUID这类对后门指令不响应的卡(防火墙卡) - + There are some types of Chinese Magic Card Gen2. 以下是Gen2卡的详细介绍 - + CUID Card: CUID卡: - + the Block 0 is writeable, you can write to this block repeatedly by normal wrbl command. 可通过普通的写块命令来写Block0,可重复擦写 - + (hf mf wrbl 0 A FFFFFFFFFFFF <the data you want to write>) (hf mf wrbl 0 A FFFFFFFFFFFF <待写入数据>) - + FUID Card: FUID卡: - + you can only write to Block 0 once. After that, it seems like a typical Mifare card(Block 0 cannot be written to). Block0只能写入一次 - + (some readers might try changing the Block 0, which could detect the CUID Card. In that case, you should use FUID card.) (更高级的穿防火墙卡,可以过一些能识别出CUID卡的读卡器) - + UFUID Card: UFUID卡: - + It behaves like a CUID card(or UID card? I'm not sure) before you send some special command to lock it. Once it is locked, you cannot change its Block 0(just like a typical Mifare card). 锁卡前和普通UID/CUID卡一样可以反复读写Block0,用特殊命令锁卡后就和FUID卡一样了 - + Seemingly, these Chinese Magic Cards are more easily to be compromised by Nested Attack(it takes little time to get an unknown key). 所有UID卡都似乎更容易被Nested攻击破解 - + Plz select the trace file: 请选择trace文件: - + Trace Files(*.trc);;All Files(*.*) Trace文件(*.trc);;所有文件(*.*) - + Plz select the location to save trace file: 请选择trace文件保存的位置: - + Trace Files(*.trc) Trace文件(*.trc) - - + + Idle 空闲 - - + + Sec - + Blk - + KeyA - + KeyB - + HW Version: 固件版本: - + PM3: 连接状态: - + State: 运行状态: - + Running 运行中 @@ -847,18 +849,15 @@ It could make the whole sector blocked irreversibly! Mifare - - + Success! 成功! - - - - - + + + Info 信息 @@ -868,14 +867,13 @@ It could make the whole sector blocked irreversibly! 请至少提供一个已知密码 - - - + + Failed! 失败! - + Failed to read card. 读卡失败。 diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 6b33e30..fc350cf 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -7,11 +7,17 @@ MainWindow::MainWindow(QWidget *parent): { ui->setupUi(this); myInfo = new QAction("wh201906", this); + checkUpdate = new QAction(tr("Check Update"), this); connect(myInfo, &QAction::triggered, [ = ]() { QDesktopServices::openUrl(QUrl("https://github.com/wh201906")); }); + connect(checkUpdate, &QAction::triggered, [ = ]() + { + QDesktopServices::openUrl(QUrl("https://github.com/wh201906/Proxmark3GUI/releases")); + }); this->addAction(myInfo); + this->addAction(checkUpdate); settings = new QSettings("GUIsettings.ini", QSettings::IniFormat); @@ -206,6 +212,7 @@ void MainWindow::on_MF_selectAllBox_stateChanged(int arg1) { ui->MF_dataWidget->blockSignals(true); ui->MF_selectAllBox->blockSignals(true); + ui->MF_selectTrailerBox->blockSignals(true); if(arg1 == Qt::PartiallyChecked) { ui->MF_selectAllBox->setTristate(false); @@ -219,10 +226,54 @@ void MainWindow::on_MF_selectAllBox_stateChanged(int arg1) { ui->MF_dataWidget->item(mifare->cardType.blks[i], 0)->setCheckState(ui->MF_selectAllBox->checkState()); } + ui->MF_selectTrailerBox->setCheckState(ui->MF_selectAllBox->checkState()); + ui->MF_dataWidget->blockSignals(false); + ui->MF_selectAllBox->blockSignals(false); + ui->MF_selectTrailerBox->blockSignals(false); +} + + +void MainWindow::on_MF_selectTrailerBox_stateChanged(int arg1) +{ + int selectedSubBlocks = 0; + + ui->MF_dataWidget->blockSignals(true); + ui->MF_selectAllBox->blockSignals(true); + ui->MF_selectTrailerBox->blockSignals(true); + if(arg1 == Qt::PartiallyChecked) + { + ui->MF_selectTrailerBox->setTristate(false); + ui->MF_selectTrailerBox->setCheckState(Qt::Checked); + } + for(int i = 0; i < mifare->cardType.sector_size; i++) + { + ui->MF_dataWidget->item(mifare->cardType.blks[i] + mifare->cardType.blk[i] - 1, 1)->setCheckState(ui->MF_selectTrailerBox->checkState()); + selectedSubBlocks = 0; + for(int j = 0; j < mifare->cardType.blk[i]; j++) + { + if(ui->MF_dataWidget->item(j + mifare->cardType.blks[i], 1)->checkState() == Qt::Checked) + selectedSubBlocks++; + } + if(selectedSubBlocks == 0) + { + ui->MF_dataWidget->item(mifare->cardType.blks[i], 0)->setCheckState(Qt::Unchecked); + } + else if(selectedSubBlocks == mifare->cardType.blk[i]) + { + ui->MF_dataWidget->item(mifare->cardType.blks[i], 0)->setCheckState(Qt::Checked); + } + else + { + ui->MF_dataWidget->item(mifare->cardType.blks[i], 0)->setCheckState(Qt::PartiallyChecked); + } + } + ui->MF_dataWidget->blockSignals(false); ui->MF_selectAllBox->blockSignals(false); + ui->MF_selectTrailerBox->blockSignals(false); } + void MainWindow::on_MF_data2KeyButton_clicked() { mifare->data_data2Key(); @@ -260,6 +311,7 @@ void MainWindow::on_MF_dataWidget_itemChanged(QTableWidgetItem *item) { ui->MF_dataWidget->blockSignals(true); ui->MF_selectAllBox->blockSignals(true); + ui->MF_selectTrailerBox->blockSignals(true); if(item->column() == 0) { int selectedSectors = 0; @@ -278,34 +330,40 @@ void MainWindow::on_MF_dataWidget_itemChanged(QTableWidgetItem *item) if(selectedSectors == 0) { ui->MF_selectAllBox->setCheckState(Qt::Unchecked); + ui->MF_selectTrailerBox->setCheckState(Qt::Unchecked); } else if(selectedSectors == mifare->cardType.sector_size) { ui->MF_selectAllBox->setCheckState(Qt::Checked); + ui->MF_selectTrailerBox->setCheckState(Qt::Checked); } else { ui->MF_selectAllBox->setCheckState(Qt::PartiallyChecked); + ui->MF_selectTrailerBox->setCheckState(Qt::PartiallyChecked); } } else if(item->column() == 1) { int selectedSubBlocks = 0; int selectedBlocks = 0; + int selectedTrailers = 0; for(int i = 0; i < mifare->cardType.block_size; i++) { if(ui->MF_dataWidget->item(i, 1)->checkState() == Qt::Checked) - { selectedBlocks++; - } } for(int i = 0; i < mifare->cardType.blk[Mifare::data_b2s(item->row())]; i++) { if(ui->MF_dataWidget->item(i + mifare->cardType.blks[Mifare::data_b2s(item->row())], 1)->checkState() == Qt::Checked) - { selectedSubBlocks++; - } + } + for(int i = 0; i < mifare->cardType.sector_size; i++) + { + int targetBlock = mifare->cardType.blks[i] + mifare->cardType.blk[i] - 1; + if(ui->MF_dataWidget->item(targetBlock, 1)->checkState() == Qt::Checked) + selectedTrailers++; } if(selectedBlocks == 0) { @@ -331,6 +389,18 @@ void MainWindow::on_MF_dataWidget_itemChanged(QTableWidgetItem *item) { ui->MF_dataWidget->item(mifare->cardType.blks[Mifare::data_b2s(item->row())], 0)->setCheckState(Qt::PartiallyChecked); } + if(selectedTrailers == 0) + { + ui->MF_selectTrailerBox->setCheckState(Qt::Unchecked); + } + else if(selectedTrailers == mifare->cardType.sector_size) + { + ui->MF_selectTrailerBox->setCheckState(Qt::Checked); + } + else + { + ui->MF_selectTrailerBox->setCheckState(Qt::PartiallyChecked); + } } else if(item->column() == 2) { @@ -347,6 +417,7 @@ void MainWindow::on_MF_dataWidget_itemChanged(QTableWidgetItem *item) } ui->MF_dataWidget->blockSignals(false); ui->MF_selectAllBox->blockSignals(false); + ui->MF_selectTrailerBox->blockSignals(false); } void MainWindow::on_MF_keyWidget_itemChanged(QTableWidgetItem *item) @@ -691,6 +762,7 @@ void MainWindow::MF_widgetReset() ui->MF_dataWidget->blockSignals(true); ui->MF_keyWidget->blockSignals(true); ui->MF_selectAllBox->blockSignals(true); + ui->MF_selectTrailerBox->blockSignals(true); for(int i = 0; i < blks; i++) { @@ -710,10 +782,12 @@ void MainWindow::MF_widgetReset() ui->MF_dataWidget->item(mifare->cardType.blks[i], 0)->setCheckState(Qt::Checked); } ui->MF_selectAllBox->setCheckState(Qt::Checked); + ui->MF_selectTrailerBox->setCheckState(Qt::Checked); ui->MF_dataWidget->blockSignals(false); ui->MF_keyWidget->blockSignals(false); ui->MF_selectAllBox->blockSignals(false); + ui->MF_selectTrailerBox->blockSignals(false); } // ************************************************ diff --git a/ui/mainwindow.h b/ui/mainwindow.h index 9f19b29..873f6d4 100644 --- a/ui/mainwindow.h +++ b/ui/mainwindow.h @@ -146,6 +146,8 @@ private slots: void on_MF_trailerDecoderButton_clicked(); + void on_MF_selectTrailerBox_stateChanged(int arg1); + private: Ui::MainWindow* ui; QButtonGroup* typeBtnGroup; @@ -153,6 +155,7 @@ private: QLabel* programStatusBar; QLabel* PM3VersionBar; QAction* myInfo; + QAction* checkUpdate; QSettings* settings; void uiInit(); diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui index 42e918e..edd93f4 100644 --- a/ui/mainwindow.ui +++ b/ui/mainwindow.ui @@ -201,24 +201,31 @@ Select All - - false - - - - 40 - 0 - - Select Trailer + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + @@ -530,12 +537,6 @@ 0 - - - 40 - 0 - - Check Default @@ -660,7 +661,7 @@ - 35 + 45 0