mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 18:48:13 -07:00
make style
This commit is contained in:
parent
498bfa56e9
commit
1a19640d18
9 changed files with 198 additions and 136 deletions
|
@ -382,7 +382,7 @@ function getInputBytes(infile)
|
|||
local arr = split(infile, ".")
|
||||
local path = core.search_file(arr[1], "."..arr[2])
|
||||
if (path == nil) then oops("failed to read from file ".. infile); return false; end
|
||||
|
||||
|
||||
local fhi,err = io.open(path,"rb")
|
||||
if err then oops("failed to read from file ".. path); return false; end
|
||||
|
||||
|
@ -688,7 +688,7 @@ end
|
|||
-- write bytes to file
|
||||
function writeFile(bytes, filename)
|
||||
local emlext = ".eml"
|
||||
local res, path
|
||||
local res, path
|
||||
if (filename ~= 'MyLegicClone') then
|
||||
res, path = file_check(filename..emlext)
|
||||
if res then
|
||||
|
@ -765,7 +765,7 @@ function readFromPM3()
|
|||
if not res then return nil end
|
||||
os.remove(path)
|
||||
|
||||
res, path = file_check(infile..".eml")
|
||||
res, path = file_check(infile..".eml")
|
||||
os.remove(path)
|
||||
|
||||
res, path = file_check(infile..".json")
|
||||
|
@ -886,7 +886,7 @@ function loadTagMap(filename)
|
|||
if not res then
|
||||
return oops("input file: "..acyellow..filename..acoff.." not found")
|
||||
else
|
||||
|
||||
|
||||
local fhi,err = io.open(path)
|
||||
while true do
|
||||
line = fhi:read()
|
||||
|
@ -956,7 +956,7 @@ function dumpTagMap(tag, tagMap)
|
|||
else
|
||||
io.write("("..("%04d"):format(v['start']).."-"..("%04d"):format(v['end'])..") "..((v['highlight']) and acmagenta or acyellow)..v['name']..acoff)
|
||||
end
|
||||
|
||||
|
||||
temp = ""
|
||||
while (#v['name'] + temp:len()) < 20 do temp = temp.." " end
|
||||
|
||||
|
@ -1015,14 +1015,14 @@ function editTagMap(tag, tagMap)
|
|||
|
||||
]]..acc..[[Mappings]]..acr..[[
|
||||
|
||||
]]..acy..[[im]]..acr..[[ - insert ]]..acy..[[am]]..acr..[[ - add
|
||||
]]..acy..[[im]]..acr..[[ - insert ]]..acy..[[am]]..acr..[[ - add
|
||||
]]..acy..[[rm]]..acr..[[ - remove ]]..acy..[[mas]]..acr..[[ - map all segments
|
||||
|
||||
]]..acc..[[CRC8]]..acr..[[
|
||||
|
||||
]]..acy..[[ac8]]..acr..[[ - add ]]..acy..[[sc8]]..acr..[[ - show
|
||||
]]..acy..[[ac8]]..acr..[[ - add ]]..acy..[[sc8]]..acr..[[ - show
|
||||
]]..acy..[[rc8]]..acr..[[ - remove
|
||||
|
||||
|
||||
]]..acy..[[q]]..acr..[[ - exit ]]..acy..[[h]]..acr..[[ - Help
|
||||
]]
|
||||
|
||||
|
@ -2446,7 +2446,7 @@ function modifyMode()
|
|||
outfile = input("enter filename:", "hf-legic-"..inTAG.MCD..inTAG.MSN0..inTAG.MSN1..inTAG.MSN2)
|
||||
bytes = tagToBytes(inTAG)
|
||||
--bytes=xorBytes(bytes, inTAG.MCC)
|
||||
if (bytes) then
|
||||
if (bytes) then
|
||||
writeFile(bytes, outfile)
|
||||
end
|
||||
end
|
||||
|
@ -2854,7 +2854,7 @@ function main(args)
|
|||
|
||||
-- write to outfile
|
||||
if (bytes) then
|
||||
|
||||
|
||||
if (outfile) then
|
||||
writeFile(bytes, outfile)
|
||||
end
|
||||
|
|
|
@ -3320,14 +3320,14 @@ int centerThreshold(const int *in, int *out, size_t len, int8_t up, int8_t down)
|
|||
for (size_t i = 0; i < len; ++i) {
|
||||
if ((in[i] <= up) && (in[i] >= down)) {
|
||||
out[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// clean out spikes.
|
||||
for (size_t i = 2; i < len - 2; ++i) {
|
||||
|
||||
int a = out[i-2] + out[i-1];
|
||||
int b = out[i+2] + out[i+1];
|
||||
int a = out[i - 2] + out[i - 1];
|
||||
int b = out[i + 2] + out[i + 1];
|
||||
if (a == 0 && b == 0) {
|
||||
out[i] = 0;
|
||||
}
|
||||
|
@ -3372,7 +3372,7 @@ static int envelope_square(const int *in, int *out, size_t len) {
|
|||
|
||||
for (size_t i = 0; i < len - 5; i++) {
|
||||
|
||||
if (in[i] == 0 && in[i+1] == 0 && in[i+2] == 0 && in[i+3] == 0 && in[i+4] == 0) {
|
||||
if (in[i] == 0 && in[i + 1] == 0 && in[i + 2] == 0 && in[i + 3] == 0 && in[i + 4] == 0) {
|
||||
i += 4;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -273,7 +273,7 @@ int applyIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool i
|
|||
MifareAuthState = masNone;
|
||||
break;
|
||||
case ISO14443A_CMD_RATS:
|
||||
snprintf(exp, size, "RATS - FSDI=%x, CID=%x", (cmd[1] & 0xF0) >> 4, (cmd[1] & 0x0F) );
|
||||
snprintf(exp, size, "RATS - FSDI=%x, CID=%x", (cmd[1] & 0xF0) >> 4, (cmd[1] & 0x0F));
|
||||
break;
|
||||
/* Actually, PPSS is Dx
|
||||
case ISO14443A_CMD_PPS:
|
||||
|
@ -428,7 +428,7 @@ int applyIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool i
|
|||
break;
|
||||
|
||||
default:
|
||||
if ( (cmd[0] & 0xF0) == 0xD0 && ( cmdsize == 4 || cmdsize == 5 )) {
|
||||
if ((cmd[0] & 0xF0) == 0xD0 && (cmdsize == 4 || cmdsize == 5)) {
|
||||
snprintf(exp, size, "PPS - CID=%x", cmd[0] & 0x0F) ;
|
||||
} else {
|
||||
return PM3_ESOFT;
|
||||
|
@ -1241,7 +1241,7 @@ const char *mfpGetAnnotationForCode(uint8_t code) {
|
|||
{ 0, NULL}
|
||||
} ;
|
||||
|
||||
for (struct mfp_code_msg *p=messages ; p->annotation != NULL ; p++) {
|
||||
for (struct mfp_code_msg *p = messages ; p->annotation != NULL ; p++) {
|
||||
if (p->code == code) {
|
||||
return p->annotation ;
|
||||
}
|
||||
|
@ -1249,8 +1249,8 @@ const char *mfpGetAnnotationForCode(uint8_t code) {
|
|||
return NULL ;
|
||||
}
|
||||
|
||||
const char *mfpGetEncryptedForCode(uint8_t code){
|
||||
/*
|
||||
const char *mfpGetEncryptedForCode(uint8_t code) {
|
||||
/*
|
||||
encrypted |plain : bit 1
|
||||
30 A0 0000 32 A2 0010
|
||||
31 A1 0001 33 A3 0011
|
||||
|
@ -1263,10 +1263,10 @@ const char *mfpGetEncryptedForCode(uint8_t code){
|
|||
return "ENCRYPTED" ;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
response |command
|
||||
NOMAC MAC UnMACed MACed
|
||||
30 31 34 30,A0
|
||||
30 31 34 30,A0
|
||||
32 33 35 31,A1
|
||||
A0 A1 36 32,A2
|
||||
A2 A3 37 33,A3
|
||||
|
@ -1274,14 +1274,14 @@ const char *mfpGetEncryptedForCode(uint8_t code){
|
|||
bit 2 is command: UNMACed if 1, MACed if 0
|
||||
*/
|
||||
const char *mfpGetResponseMacedForCode(uint8_t code) {
|
||||
if (( code & 0x01) == 0x00) {
|
||||
if ((code & 0x01) == 0x00) {
|
||||
return "NoMAC" ;
|
||||
}
|
||||
return "MAC" ;
|
||||
}
|
||||
|
||||
const char *mfpGetCommandMacedForCode(uint8_t code) {
|
||||
if (( code & 0x04) == 0x04) {
|
||||
if ((code & 0x04) == 0x04) {
|
||||
return "UnMACed" ;
|
||||
}
|
||||
return "MACed" ;
|
||||
|
@ -1322,14 +1322,14 @@ void annotateMfPlus(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
|||
if (cmdsize > (data - cmd)) {
|
||||
data_size = cmdsize - (data - cmd);
|
||||
}
|
||||
uint8_t opcode=cmd[pos] ;
|
||||
uint8_t opcode = cmd[pos] ;
|
||||
switch (opcode) {
|
||||
case MFP_AUTHENTICATEFIRST:
|
||||
case MFP_AUTHENTICATEFIRST_VARIANT:
|
||||
if (data_size > 1) {
|
||||
// key : uint16_t uKeyNum = 0x4000 + sectorNum * 2 + (keyB ? 1 : 0);
|
||||
uint16_t uKeyNum = MemLeToUint2byte(data) ;
|
||||
snprintf(exp, size, "FIRST AUTH (Keynr 0x%04X: %c sector %d)", uKeyNum, uKeyNum & 0x0001 ? 'B' : 'A', (uKeyNum - 0x4000)/2 );
|
||||
snprintf(exp, size, "FIRST AUTH (Keynr 0x%04X: %c sector %d)", uKeyNum, uKeyNum & 0x0001 ? 'B' : 'A', (uKeyNum - 0x4000) / 2);
|
||||
} else {
|
||||
snprintf(exp, size, "FIRST AUTH") ;
|
||||
}
|
||||
|
@ -1360,7 +1360,7 @@ void annotateMfPlus(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
|||
uint16_t uBlockNum = MemLeToUint2byte(data) ;
|
||||
uint8_t uQty = data[2] ;
|
||||
if (uQty != 1) {
|
||||
snprintf(exp, size, "READ %s(%u-%u) %s_%s", encrypted, uBlockNum, uBlockNum+uQty-1, responseMaced, commandMaced);
|
||||
snprintf(exp, size, "READ %s(%u-%u) %s_%s", encrypted, uBlockNum, uBlockNum + uQty - 1, responseMaced, commandMaced);
|
||||
} else {
|
||||
snprintf(exp, size, "READ %s(%u) %s_%s", encrypted, uBlockNum, responseMaced, commandMaced);
|
||||
}
|
||||
|
@ -1369,11 +1369,11 @@ void annotateMfPlus(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case MFP_WRITEPLAINNOMAC :
|
||||
case MFP_WRITEPLAINMAC :
|
||||
case MFP_WRITEENCRYPTEDNOMAC:
|
||||
case MFP_WRITEENCRYPTEDMAC :{
|
||||
case MFP_WRITEENCRYPTEDMAC : {
|
||||
const char *encrypted = mfpGetEncryptedForCode(opcode) ;
|
||||
const char *responseMaced = mfpGetResponseMacedForCode(opcode) ;
|
||||
|
||||
|
@ -1397,12 +1397,12 @@ void annotateMfPlus(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
|||
case MFP_DECREMENTTRANSFERNOMAC:
|
||||
case MFP_DECREMENTTRANSFERMAC :
|
||||
case MFP_RESTORENOMAC :
|
||||
case MFP_RESTOREMAC :{
|
||||
case MFP_RESTOREMAC : {
|
||||
const char *responseMaced = mfpGetResponseMacedForCode(opcode) ;
|
||||
const char *annotation = mfpGetAnnotationForCode(opcode) ;
|
||||
if (annotation == NULL) {
|
||||
//should not happen outside of default case: it means an entry is mising in mfpGetAnnotationForCode()
|
||||
annotation="?? MISSING OPCODE" ;
|
||||
annotation = "?? MISSING OPCODE" ;
|
||||
}
|
||||
|
||||
if (data_size > 1) {
|
||||
|
|
|
@ -7035,12 +7035,12 @@ static int CmdHf14AMfSuperCard(const char *Cmd) {
|
|||
uint8_t aCHANGE[] = {0x00, 0xa6, 0xa0, 0x00, 0x05, 0xff, 0xff, 0xff, 0xff, 0x00};
|
||||
memcpy(aCHANGE + 5, uid, uidlen);
|
||||
res = ExchangeAPDU14a(
|
||||
aCHANGE, sizeof(aCHANGE),
|
||||
activate_field,
|
||||
keep_field_on,
|
||||
response, sizeof(response),
|
||||
&resplen
|
||||
);
|
||||
aCHANGE, sizeof(aCHANGE),
|
||||
activate_field,
|
||||
keep_field_on,
|
||||
response, sizeof(response),
|
||||
&resplen
|
||||
);
|
||||
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(FAILED, "Super card UID change [ " _RED_("fail") " ]");
|
||||
|
@ -7061,12 +7061,12 @@ static int CmdHf14AMfSuperCard(const char *Cmd) {
|
|||
// --------------- RESET CARD ----------------
|
||||
uint8_t aRESET[] = {0x00, 0xa6, 0xc0, 0x00};
|
||||
res = ExchangeAPDU14a(
|
||||
aRESET, sizeof(aRESET),
|
||||
activate_field,
|
||||
keep_field_on,
|
||||
response, sizeof(response),
|
||||
&resplen
|
||||
);
|
||||
aRESET, sizeof(aRESET),
|
||||
activate_field,
|
||||
keep_field_on,
|
||||
response, sizeof(response),
|
||||
&resplen
|
||||
);
|
||||
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(FAILED, "Super card reset [ " _RED_("fail") " ]");
|
||||
|
@ -7157,11 +7157,11 @@ static int CmdHf14AMfSuperCard(const char *Cmd) {
|
|||
uint64_t key64 = -1;
|
||||
if (mfkey32_moebius(&data, &key64)) {
|
||||
PrintAndLogEx(SUCCESS, "UID: %s Sector %02x key %c [ " _GREEN_("%012" PRIX64) " ]",
|
||||
sprint_hex_inrow(outA, 4),
|
||||
data.sector,
|
||||
(data.keytype == 0x60) ? 'A' : 'B',
|
||||
key64
|
||||
);
|
||||
sprint_hex_inrow(outA, 4),
|
||||
data.sector,
|
||||
(data.keytype == 0x60) ? 'A' : 'B',
|
||||
key64
|
||||
);
|
||||
} else {
|
||||
PrintAndLogEx(FAILED, "failed to recover any key");
|
||||
}
|
||||
|
|
|
@ -631,7 +631,7 @@ static int CmdLFHitagReader(const char *Cmd) {
|
|||
memcpy(key, "MIKR", 4);
|
||||
keylen = 4;
|
||||
}
|
||||
if ((keylen == 0) && use_crypto) {
|
||||
if ((keylen == 0) && use_crypto) {
|
||||
memcpy(key, "ONMIKR", 6);
|
||||
keylen = 6;
|
||||
}
|
||||
|
@ -888,7 +888,7 @@ static int CmdLFHitagWriter(const char *Cmd) {
|
|||
memcpy(key, "MIKR", 4);
|
||||
keylen = 4;
|
||||
}
|
||||
if ((keylen == 0) && use_crypto) {
|
||||
if ((keylen == 0) && use_crypto) {
|
||||
memcpy(key, "ONMIKR", 6);
|
||||
keylen = 6;
|
||||
}
|
||||
|
@ -1047,7 +1047,7 @@ static int CmdLFHitag2Dump(const char *Cmd) {
|
|||
memcpy(key, "MIKR", 4);
|
||||
keylen = 4;
|
||||
}
|
||||
if ((keylen == 0) && use_crypto) {
|
||||
if ((keylen == 0) && use_crypto) {
|
||||
memcpy(key, "ONMIKR", 6);
|
||||
keylen = 6;
|
||||
}
|
||||
|
|
|
@ -120,12 +120,12 @@ int asn1_selftest(void) {
|
|||
|
||||
/*
|
||||
|
||||
ICEMAN:
|
||||
ICEMAN:
|
||||
Problem to be solved, how to extract data back from our asn1 decoder to compare with the expected text found in the following test cases.
|
||||
Thanks @Mistial for the suggestion and links.
|
||||
|
||||
These test cases are from the project lapo-luchini's asn1js (ISC license which is like MIT license)
|
||||
https://github.com/lapo-luchini/asn1js/blob/trunk/test.js
|
||||
https://github.com/lapo-luchini/asn1js/blob/trunk/test.js
|
||||
|
||||
|
||||
const asn1_test tests[] = {
|
||||
|
@ -211,7 +211,7 @@ int asn1_selftest(void) {
|
|||
{"181531393835313130363231303632372E332D31323334", "1985-11-06 21:06:27.3 UTC-12:34", "UTC offsets with minutes"},
|
||||
// GitHub issue #54
|
||||
{"181331393835313130363231303632372E332B3134", "1985-11-06 21:06:27.3 UTC+14:00", "UTC offset +13 and +14"},
|
||||
};
|
||||
};
|
||||
|
||||
int tot = ARRAYLEN(tests);
|
||||
|
||||
|
@ -238,7 +238,7 @@ int asn1_selftest(void) {
|
|||
if (t) {
|
||||
bool candump = false;
|
||||
if (asn1_tag_dump(&t->tag, 0, &candump)) {
|
||||
count++;
|
||||
count++;
|
||||
}
|
||||
tlvdb_free(t);
|
||||
}
|
||||
|
@ -250,6 +250,6 @@ int asn1_selftest(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
*/
|
||||
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ const static vocabulory_t vocabulory[] = {
|
|||
{ 1, "data autocorr" },
|
||||
{ 1, "data dirthreshold" },
|
||||
{ 1, "data decimate" },
|
||||
{ 1, "data envelope" },
|
||||
{ 1, "data undecimate" },
|
||||
{ 1, "data hide" },
|
||||
{ 1, "data hpf" },
|
||||
|
@ -92,6 +93,7 @@ const static vocabulory_t vocabulory[] = {
|
|||
{ 1, "data mtrim" },
|
||||
{ 1, "data norm" },
|
||||
{ 1, "data plot" },
|
||||
{ 1, "data cthreshold" },
|
||||
{ 1, "data rtrim" },
|
||||
{ 1, "data setgraphmarkers" },
|
||||
{ 1, "data shiftgraphzero" },
|
||||
|
@ -599,15 +601,16 @@ const static vocabulory_t vocabulory[] = {
|
|||
{ 0, "lf hid brute" },
|
||||
{ 0, "lf hid watch" },
|
||||
{ 1, "lf hitag help" },
|
||||
{ 0, "lf hitag eload" },
|
||||
{ 1, "lf hitag list" },
|
||||
{ 0, "lf hitag info" },
|
||||
{ 0, "lf hitag reader" },
|
||||
{ 0, "lf hitag sim" },
|
||||
{ 0, "lf hitag sniff" },
|
||||
{ 0, "lf hitag writer" },
|
||||
{ 0, "lf hitag dump" },
|
||||
{ 0, "lf hitag read" },
|
||||
{ 0, "lf hitag wrbl" },
|
||||
{ 0, "lf hitag sniff" },
|
||||
{ 0, "lf hitag cc" },
|
||||
{ 0, "lf hitag ta" },
|
||||
{ 0, "lf hitag eload" },
|
||||
{ 0, "lf hitag sim" },
|
||||
{ 1, "lf idteck help" },
|
||||
{ 1, "lf idteck demod" },
|
||||
{ 0, "lf idteck reader" },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue