diff --git a/config/config.qrc b/config/config.qrc index 36db67f..6d3107c 100644 --- a/config/config.qrc +++ b/config/config.qrc @@ -1,6 +1,7 @@ config_official.json - config_rrgv4.13.json + config_rrgv4.13441.json + config_rrgv4.15864.json diff --git a/config/config_official.json b/config/config_official.json index 0438ed8..b28c942 100644 --- a/config/config_official.json +++ b/config/config_official.json @@ -10,6 +10,13 @@ "2k": "2", "4k": "4" }, + "//": "|---|----------------|---|----------------|---| ", + "//": "|sec|key A |res|key B |res| ", + "//": "|---|----------------|---|----------------|---| ", + "//": "|000| ffffffffffff | 1 | ffffffffffff | 1 | ", + "//": "......", + "//": "|---|----------------|---|----------------|---| ", + "//": "", "key pattern": "\\|\\s*\\d{3}\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|", "key A index": 2, "key B index": 4 @@ -22,6 +29,15 @@ "2k": "2", "4k": "4" }, + "//": "|---|----------------|----------------| ", + "//": "|sec|key A |key B | ", + "//": "|---|----------------|----------------| ", + "//": "|000| ffffffffffff | ffffffffffff | ", + "//": "......", + "//": "|004| ? | ? | ", + "//": "......", + "//": "|---|----------------|----------------| ", + "//": " ", "key pattern": "\\|\\s*\\d{3}\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|", "key A index": 2, "key B index": 3 @@ -39,10 +55,22 @@ "cmd": "hf list mf" }, "dump": { - "cmd": "hf mf dump" + "cmd": "hf mf dump ", + "card type": { + "mini": "0", + "1k": "1", + "2k": "2", + "4k": "4" + } }, "restore": { - "cmd": "hf mf restore" + "cmd": "hf mf restore ", + "card type": { + "mini": "0", + "1k": "1", + "2k": "2", + "4k": "4" + } }, "emulator wipe": { "cmd": "hf mf eclr" @@ -192,14 +220,14 @@ "divisor cmd": "hw setlfdivisor " } }, - "t55xx":{ - "clone em410x":{ - "read":"lf search", - "successful read flag":"Valid EM410x ID", - "pattern":"EM TAG ID\\s*:\\s\\K[0-9a-fA-F]{10}", - "clone cmd":"lf em 410xwrite ", - "t5555 flag":"0", - "t55x7 flag":"1" + "t55xx": { + "clone em410x": { + "read": "lf search", + "successful read flag": "Valid EM410x ID", + "pattern": "EM TAG ID\\s*:\\s\\K[0-9a-fA-F]{10}", + "clone cmd": "lf em 410xwrite ", + "t5555 flag": "0", + "t55x7 flag": "1" } } } \ No newline at end of file diff --git a/config/config_rrgv4.13.json b/config/config_rrgv4.13441.json similarity index 79% rename from config/config_rrgv4.13.json rename to config/config_rrgv4.13441.json index 8d5680d..40784b4 100644 --- a/config/config_rrgv4.13.json +++ b/config/config_rrgv4.13441.json @@ -15,6 +15,13 @@ "A": "a", "B": "b" }, + "//": "[+] |-----|----------------|---|----------------|---|", + "//": "[+] | Sec | key A |res| key B |res|", + "//": "[+] |-----|----------------|---|----------------|---|", + "//": "[+] | 000 | ffffffffffff | 1 | ffffffffffff | 1 |", + "//": "......", + "//": "[+] |-----|----------------|---|----------------|---|", + "//": "[+] ( 0:Failed / 1:Success )", "key pattern": "\\|\\s*\\d{3}\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|", "key A index": 2, "key B index": 4 @@ -27,6 +34,15 @@ "2k": "2k", "4k": "4k" }, + "//": "[+] |-----|----------------|---|----------------|---|", + "//": "[+] | Sec | key A |res| key B |res|", + "//": "[+] |-----|----------------|---|----------------|---|", + "//": "[+] | 000 | ffffffffffff | 1 | ffffffffffff | 1 |", + "//": "......", + "//": "[+] | 004 | ------------ | 0 | ------------ | 0 |", + "//": "......", + "//": "[+] |-----|----------------|---|----------------|---|", + "//": "[+] ( 0:Failed / 1:Success )", "key pattern": "\\|\\s*\\d{3}\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|", "key A index": 2, "key B index": 4 @@ -44,10 +60,22 @@ "cmd": "trace list -t mf" }, "dump": { - "cmd": "hf mf dump" + "cmd": "hf mf dump --", + "card type": { + "mini": "mini", + "1k": "1k", + "2k": "2k", + "4k": "4k" + } }, "restore": { - "cmd": "hf mf restore" + "cmd": "hf mf restore --", + "card type": { + "mini": "mini", + "1k": "1k", + "2k": "2k", + "4k": "4k" + } }, "emulator wipe": { "cmd": "hf mf eclr" @@ -200,14 +228,14 @@ "divisor cmd": "hw setlfdivisor -d " } }, - "t55xx":{ - "clone em410x":{ - "read":"lf em 410x reader", - "successful read flag":"EM 410x ID", - "pattern":"EM 410x ID\\s*\\K[0-9a-fA-F]{10}", - "clone cmd":"lf em 410x clone --id ", - "t5555 flag":"--q5", - "t55x7 flag":"" + "t55xx": { + "clone em410x": { + "read": "lf em 410x reader", + "successful read flag": "EM 410x ID", + "pattern": "EM 410x ID\\s*\\K[0-9a-fA-F]{10}", + "clone cmd": "lf em 410x clone --id ", + "t5555 flag": "--q5", + "t55x7 flag": "" } } } \ No newline at end of file diff --git a/config/config_rrgv4.15864.json b/config/config_rrgv4.15864.json new file mode 100644 index 0000000..a9aad17 --- /dev/null +++ b/config/config_rrgv4.15864.json @@ -0,0 +1,241 @@ +{ + "//": "Based on Proxmark3 rrg repo v4.15864, commit 1f75adc", + "//": "You can change this file if the command format of client changes", + "mifare classic": { + "nested": { + "cmd": "hf mf nested -- --blk - -k ", + "static cmd": "hf mf staticnested -- --blk - -k ", + "card type": { + "mini": "mini", + "1k": "1k", + "2k": "2k", + "4k": "4k" + }, + "key type": { + "A": "a", + "B": "b" + }, + "//": "[+] -----+-----+--------------+---+--------------+----", + "//": "[+] Sec | Blk | key A |res| key B |res", + "//": "[+] -----+-----+--------------+---+--------------+----", + "//": "[+] 000 | 003 | FFFFFFFFFFFF | 1 | FFFFFFFFFFFF | 1", + "//": "......", + "//": "[+] -----+-----+--------------+---+--------------+----", + "//": "[+] ( 0:Failed / 1:Success )", + "key pattern": "\\s*\\d{3}\\s*\\|\\s*\\d{3}\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*$", + "key A index": 2, + "key B index": 4 + }, + "check": { + "cmd": "hf mf chk --", + "card type": { + "mini": "mini", + "1k": "1k", + "2k": "2k", + "4k": "4k" + }, + "//": "[+] -----+-----+--------------+---+--------------+----", + "//": "[+] Sec | Blk | key A |res| key B |res", + "//": "[+] -----+-----+--------------+---+--------------+----", + "//": "[+] 000 | 003 | FFFFFFFFFFFF | 1 | FFFFFFFFFFFF | 1", + "//": "......", + "//": "[+] 004 | 019 | ------------ | 0 | ------------ | 0", + "//": "......", + "//": "[+] -----+-----+--------------+---+--------------+----", + "//": "[+] ( 0:Failed / 1:Success )", + "key pattern": "\\s*\\d{3}\\s*\\|\\s*\\d{3}\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*$", + "key A index": 2, + "key B index": 4 + }, + "info": { + "cmd": "hf 14a info" + }, + "sniff": { + "cmd": "hf sniff" + }, + "sniff 14a": { + "cmd": "hf 14a sniff" + }, + "list": { + "cmd": "trace list -t mf" + }, + "dump": { + "cmd": "hf mf dump --", + "card type": { + "mini": "mini", + "1k": "1k", + "2k": "2k", + "4k": "4k" + } + }, + "restore": { + "cmd": "hf mf restore --", + "card type": { + "mini": "mini", + "1k": "1k", + "2k": "2k", + "4k": "4k" + } + }, + "emulator wipe": { + "cmd": "hf mf eclr" + }, + "Magic Card wipe": { + "cmd": "hf mf cwipe" + }, + "emulator read block": { + "cmd": "hf mf egetblk --blk ", + "data pattern": "([0-9a-fA-F]{2} ){15}[0-9a-fA-F]{2}" + }, + "Magic Card read block": { + "cmd": "hf mf cgetblk --blk ", + "data pattern": "([0-9a-fA-F]{2} ){15}[0-9a-fA-F]{2}" + }, + "normal read block": { + "cmd": "hf mf rdbl --blk - -k ", + "key type": { + "A": "a", + "B": "b" + }, + "data pattern": "([0-9a-fA-F]{2} ){15}[0-9a-fA-F]{2}" + }, + "darkside": { + "cmd": "hf mf darkside" + }, + "save sniff": { + "cmd": "trace save -f " + }, + "load sniff": { + "cmd": "trace load -f ", + "show cmd": "trace list --buffer -t mf" + }, + "hardnested": { + "cmd": "hf mf hardnested --blk - -k --tblk --t", + "known key type": { + "A": "a", + "B": "b" + }, + "target key type": { + "A": "a", + "B": "b" + } + }, + "normal read sector": { + "cmd": "hf mf rdsc --sec - -k ", + "key type": { + "A": "a", + "B": "b" + }, + "data pattern": "([0-9a-fA-F]{2} ){15}[0-9a-fA-F]{2}" + }, + "Magic Card read sector": { + "cmd": "hf mf cgetsc --sec ", + "data pattern": "([0-9a-fA-F]{2} ){15}[0-9a-fA-F]{2}" + }, + "//": "When writing a block, if the result is not empty and doesn't contain the failed flag, the function will return true", + "normal write block": { + "cmd": "hf mf wrbl --blk - -k -d ", + "key type": { + "A": "a", + "B": "b" + }, + "failed flag": [ + "fail", + "error" + ] + }, + "Magic Card write block": { + "cmd": "hf mf csetblk --blk -d ", + "failed flag": [ + "fail", + "error" + ] + }, + "emulator write block": { + "cmd": "hf mf esetblk --blk -d " + }, + "Magic Card lock": { + "cmd": "hf 14a raw ", + "sequence": [ + "-ak -b 7 40", + "-ak 43", + "-ak E0 00 39 F7", + "-ak E1 00 E1 EE", + "-ak 85 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 18 47", + "-a 52" + ] + }, + "Magic Card set parameter": { + "cmd": "hf mf csetuid --uid --atqa --sak " + } + }, + "lf": { + "read": { + "cmd": "lf read -v", + "show cmd": "data plot" + }, + "sniff": { + "cmd": "lf sniff -v", + "show cmd": "data plot" + }, + "search": { + "cmd": "lf search -u" + }, + "tune": { + "cmd": "lf tune --divisor " + }, + "get config": { + "cmd": "hw status", + "field start": "LF Sampling config", + "field end": "\\[#\\] \\S", + "divisor": { + "flag": "divisor", + "pattern": "\\d+" + }, + "bits per sample": { + "flag": "bits per sample", + "pattern": "\\d+" + }, + "decimation": { + "flag": "decimation", + "pattern": "\\d+" + }, + "averaging": { + "flag": "averaging", + "pattern": "\\d+", + "replace": { + "yes": "1", + "no": "0", + "Yes": "1", + "No": "0" + } + }, + "trigger threshold": { + "flag": "trigger threshold", + "pattern": "\\d+" + }, + "samples to skip": { + "flag": "samples to skip", + "pattern": "\\d+" + }, + "//": "execute 'cmd' then find parameters between 'field stard' and 'field end'", + "//": "for each line, if the line doesn't have any flag, skip", + "//": "otherwise, delete characters before 'flag' and 'flag' itself, then use 'pattern' to get the parameter", + "//": "If 'replace' dict exists, replace all keys with respective values before getting parameters" + }, + "set config": { + "cmd": "lf config --divisor --bps --dec --avg --trig --skip ", + "divisor cmd": "hw setlfdivisor -d " + } + }, + "t55xx": { + "clone em410x": { + "read": "lf em 410x reader", + "successful read flag": "EM 410x ID", + "pattern": "EM 410x ID\\s*\\K[0-9a-fA-F]{10}", + "clone cmd": "lf em 410x clone --id ", + "t5555 flag": "--q5", + "t55x7 flag": "" + } + } +} \ No newline at end of file diff --git a/src/module/lf.cpp b/src/module/lf.cpp index 758f0f8..98a2899 100644 --- a/src/module/lf.cpp +++ b/src/module/lf.cpp @@ -81,8 +81,10 @@ void LF::getLFConfig() QVariantMap config = configMap["get config"].toMap(); QString cmd = config["cmd"].toString(); result = util->execCMDWithOutput(cmd, 400); - start = result.indexOf(config["field start"].toString()); - end = result.indexOf(config["field end"].toString()); + reMatch = QRegularExpression(config["field start"].toString(), QRegularExpression::MultilineOption).match(result); + start = reMatch.hasMatch() ? reMatch.capturedEnd() : 0; + reMatch = QRegularExpression(config["field end"].toString(), QRegularExpression::MultilineOption).match(result, start); + end = reMatch.hasMatch() ? reMatch.capturedStart() : result.length(); result = result.mid(start, end - start); #if (QT_VERSION <= QT_VERSION_CHECK(5,14,0)) resultList = result.split("\n", QString::SkipEmptyParts); diff --git a/src/module/mifare.cpp b/src/module/mifare.cpp index 0531a0c..53ee243 100644 --- a/src/module/mifare.cpp +++ b/src/module/mifare.cpp @@ -130,7 +130,7 @@ void Mifare::chk() QString cmd = config["cmd"].toString(); int keyAindex = config["key A index"].toInt(); int keyBindex = config["key B index"].toInt(); - QRegularExpression keyPattern = QRegularExpression(config["key pattern"].toString()); + QRegularExpression keyPattern = QRegularExpression(config["key pattern"].toString(), QRegularExpression::MultilineOption); cmd.replace("", config["card type"].toMap()[cardType.typeText].toString()); result = util->execCMDWithOutput( @@ -169,7 +169,7 @@ void Mifare::nested(bool isStaticNested) cmd = config["cmd"].toString(); int keyAindex = config["key A index"].toInt(); int keyBindex = config["key B index"].toInt(); - QRegularExpression keyPattern = QRegularExpression(config["key pattern"].toString()); + QRegularExpression keyPattern = QRegularExpression(config["key pattern"].toString(), QRegularExpression::MultilineOption); QRegularExpressionMatch reMatch; QString result; int offset = 0; @@ -212,7 +212,7 @@ void Mifare::nested(bool isStaticNested) } result = util->execCMDWithOutput( cmd, - Util::ReturnTrigger(15000, {"Can't found", "Can't authenticate", keyPattern_res->pattern()}), + Util::ReturnTrigger(15000, {"Quit", "Can't found", "Can't authenticate", keyPattern_res->pattern()}), true); if(result.contains("static") && !isStaticNested) @@ -747,14 +747,20 @@ void Mifare::writeSelected(TargetType targetType) void Mifare::dump() { QVariantMap config = configMap["dump"].toMap(); - util->execCMD(config["cmd"].toString()); + QString cmd = config["cmd"].toString(); + if(cmd.contains("")) + cmd.replace("", config["card type"].toMap()[cardType.typeText].toString()); + util->execCMD(cmd); Util::gotoRawTab(); } void Mifare::restore() { QVariantMap config = configMap["restore"].toMap(); - util->execCMD(config["cmd"].toString()); + QString cmd = config["cmd"].toString(); + if(cmd.contains("")) + cmd.replace("", config["card type"].toMap()[cardType.typeText].toString()); + util->execCMD(cmd); Util::gotoRawTab(); }