Merge branch 'master' into bind

This commit is contained in:
wh201906 2023-10-23 13:57:18 +08:00
commit fcad2127e0
No known key found for this signature in database
3 changed files with 23 additions and 13 deletions

View file

@ -4,6 +4,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
## [unreleased][unreleased]
- Added `bind` option for network connections to specify the outbound address and port (@wh201906)
- Changed `lf em 4x05 dump` - now supports the `--ns` nosave parameter (@iceman1001)
- Added new command `data bmap` - breaks down a hexvalue to a binary template (@iceman1001)
- Changed aid_desfire.json - added entreis from the Metrodroid project (@iceman1001)
- Changed mad.json - added entries from the Metrodroid project (@iceman1001)

View file

@ -82,16 +82,16 @@ local function main(args)
sd = sd or 2000
ed = ed or 2100
if #password ~= 8 then
password = ''
if password ~= '' and #password ~= 8 then
return oops('password must be 4 hex bytes')
end
if #wr_value ~= 8 then
wr_value = 'FFFFFFFF'
return oops('write value must be 4 hex bytes')
end
if #rd_value ~= 8 then
rd_value = 'FFFFFFFF'
return oops('read value must be 4 hex bytes')
end
if sd > ed then
@ -114,7 +114,7 @@ local function main(args)
local set_tearoff_delay = 'hw tearoff --delay %d'
local enable_tearoff = 'hw tearoff --on'
local wr_template = 'lf em 4x05_write %s %s %s'
local wr_template = 'lf em 4x05 write --addr %s --data %s --pwd %s'
-- init addr to value
core.console(wr_template:format(addr, wr_value, password))

View file

@ -514,6 +514,7 @@ int CmdEM4x05Dump(const char *Cmd) {
arg_param_begin,
arg_str0("p", "pwd", "<hex>", "password (00000000)"),
arg_str0("f", "file", "<fn>", "override filename prefix (optional). Default is based on UID"),
arg_lit0(NULL, "ns", "no save to file"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
@ -522,6 +523,7 @@ int CmdEM4x05Dump(const char *Cmd) {
int fnlen = 0;
char filename[FILE_PATH_SIZE] = {0};
CLIParamStrToBuf(arg_get_str(ctx, 2), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
bool nosave = arg_get_lit(ctx, 3);
CLIParserFree(ctx);
uint8_t addr = 0;
@ -693,6 +695,13 @@ int CmdEM4x05Dump(const char *Cmd) {
} else {
}
if (nosave) {
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "Called with no save option");
PrintAndLogEx(NORMAL, "");
return PM3_SUCCESS;
}
// all ok save dump to file
if (success == PM3_SUCCESS) {
@ -741,16 +750,16 @@ int CmdEM4x05Read(const char *Cmd) {
bool use_pwd = false;
if (addr > 15) {
PrintAndLogEx(ERR, "Address must be between 0 and 15");
PrintAndLogEx(ERR, "Address must be between 0 and 15, got " _RED_("%d"), addr);
return PM3_EINVARG;
}
if (inputpwd == 0xFFFFFFFFFFFFFFFF) {
PrintAndLogEx(INFO, "Reading address %02u", addr);
PrintAndLogEx(INFO, "Reading address " _YELLOW_("%02u"), addr);
} else {
pwd = (inputpwd & 0xFFFFFFFF);
use_pwd = true;
PrintAndLogEx(INFO, "Reading address %02u using password %08X", addr, pwd);
PrintAndLogEx(INFO, "Reading address " _YELLOW_("%02u") " using password " _YELLOW_("%08X"), addr, pwd);
}
uint32_t word = 0;
@ -818,14 +827,14 @@ int CmdEM4x05Write(const char *Cmd) {
if (use_pwd) {
if (protect_operation)
PrintAndLogEx(INFO, "Writing protection words data %08X using password %08X", data, pwd);
PrintAndLogEx(INFO, "Writing protection words data " _YELLOW_("%08X") " using password " _YELLOW_("%08X"), data, pwd);
else
PrintAndLogEx(INFO, "Writing address %d data %08X using password %08X", addr, data, pwd);
PrintAndLogEx(INFO, "Writing address " _YELLOW_("%d") " data " _YELLOW_("%08X") " using password " _YELLOW_("%08X"), addr, data, pwd);
} else {
if (protect_operation)
PrintAndLogEx(INFO, "Writing protection words data %08X", data);
PrintAndLogEx(INFO, "Writing protection words data " _YELLOW_("%08X") , data);
else
PrintAndLogEx(INFO, "Writing address %d data %08X", addr, data);
PrintAndLogEx(INFO, "Writing address " _YELLOW_("%d") " data " _YELLOW_("%08X") , addr, data);
}
res = PM3_SUCCESS;
@ -850,7 +859,7 @@ int CmdEM4x05Write(const char *Cmd) {
if (status == PM3_SUCCESS)
PrintAndLogEx(SUCCESS, "Data written and verified");
else if (status == PM3_EFAILED)
PrintAndLogEx(ERR, "Tag denied %s operation", protect_operation ? "Protect" : "Write");
PrintAndLogEx(ERR, "Tag denied " _RED_("%s") " operation", protect_operation ? "Protect" : "Write");
else
PrintAndLogEx(DEBUG, "No answer from tag");