style
This commit is contained in:
1 parent
0446509d1e
commit
a776f9a0bd
10 files changed
+231
-187
No files matched your search
@@ -102,7 +102,7 @@ local function reanimate_t5577(password)
|
||||
p:console('lf t55 write -b 0 -d 000880E0 --pg1 --r0 -p 00000000')
|
||||
p:console('lf t55 write -b 0 -d 000880E0 --pg1 --r1 -p 00000000')
|
||||
p:console('lf t55 write -b 0 -d 000880E0 --pg1 --r2 -p 00000000')
|
||||
p:console('lf t55 write -b 0 -d 000880E0 --pg1 --r3 -p 00000000')
|
||||
p:console('lf t55 write -b 0 -d 000880E0 --pg1 --r3 -p 00000000')
|
||||
reset_log_file()
|
||||
end
|
||||
|
||||
@@ -118,7 +118,7 @@ local function main(args)
|
||||
print(dash)
|
||||
print("::: "..ac.cyan.."Hold on, I'm searching for a password in the dictionary"..ac.reset.." :::")
|
||||
print(dash)
|
||||
p:console('lf t55 chk')
|
||||
p:console('lf t55 chk')
|
||||
local log_content = read_log_file(logfile)
|
||||
local password = log_content and extract_password(log_content) or nil
|
||||
reanimate_t5577(password)
|
||||
@@ -141,4 +141,4 @@ local function main(args)
|
||||
print(dash)
|
||||
end
|
||||
|
||||
main(args)
|
||||
main(args)
|
||||
@@ -9,14 +9,14 @@ local command = core.console
|
||||
command('clear')
|
||||
author = ' Author: jareckib - 12.03.2025'
|
||||
version = ' version v1.03'
|
||||
desc = [[
|
||||
desc = [[
|
||||
This simple script stores 1, 2 or 3 different EM4102 on a single T5577.
|
||||
There is an option to enter the number engraved on the fob in decimal form.
|
||||
The script can therefore be useful if the original EM4102 doesn't work but
|
||||
has an engraved ID number. By entering such an ID as a single EM4102, we
|
||||
The script can therefore be useful if the original EM4102 doesn't work but
|
||||
has an engraved ID number. By entering such an ID as a single EM4102, we
|
||||
can create a working copy of our damaged fob.
|
||||
A tag T5577 created in this way works with the following USB readers:
|
||||
|
||||
|
||||
- ACM08Y
|
||||
- ACM26C
|
||||
- Sycreader R60D
|
||||
@@ -121,7 +121,7 @@ local function get_uid_from_user()
|
||||
while true do
|
||||
print(dash)
|
||||
io.write(ac.cyan .. '(1)' .. ac.reset .. ' Manual entry UID |' .. ac.cyan .. ' (2)' .. ac.reset .. ' Read via Proxmark3 ')
|
||||
|
||||
|
||||
local choice
|
||||
repeat
|
||||
choice = io.read()
|
||||
@@ -159,7 +159,7 @@ local function get_uid_from_user()
|
||||
io.read()
|
||||
|
||||
while true do
|
||||
reset_log_file()
|
||||
reset_log_file()
|
||||
command('lf em 410x read')
|
||||
local log_content = read_log_file(logfile)
|
||||
local uid = extract_uid(log_content)
|
||||
@@ -178,7 +178,7 @@ end
|
||||
local function main(args)
|
||||
for o, a in getopt.getopt(args, 'h') do
|
||||
if o == 'h' then return help() end
|
||||
end
|
||||
end
|
||||
local blocks = {}
|
||||
local uid_count = 0
|
||||
|
||||
@@ -224,4 +224,4 @@ local function main(args)
|
||||
print(ac.green .. "Successfully written " .. uid_count .. " EM4102 UID(s) to T5577" .. ac.reset)
|
||||
end
|
||||
|
||||
main(args)
|
||||
main(args)
|
||||
@@ -459,4 +459,4 @@ local function main(args)
|
||||
end
|
||||
end
|
||||
|
||||
main(args)
|
||||
main(args)
|
||||
@@ -77,14 +77,14 @@ def parse_config(config: str):
|
||||
cfg_auth_type = config[8:10]
|
||||
cfg_cuid = config[12:14]
|
||||
cfg_memory_config = config[14:16]
|
||||
|
||||
|
||||
log_magic_wup = "Magic wakeup " + ("en" if cfg_magic_wup != "8500" else "dis") + "abled" + (" with config access" if cfg_magic_wup == "7AFF" else "")
|
||||
log_wup_style = "Magic wakeup style " + ("Gen1a 40(7)/43" if cfg_wup_style == "00" else ("GDM 20(7)/23" if cfg_wup_style == "85" else "unknown"))
|
||||
log_regular_available = "Config " + ("" if cfg_regular_available == "A0" else "un") + "available in regular mode"
|
||||
log_auth_type = "Auth type " + ("1B - PWD" if cfg_auth_type == "00" else "1A - 3DES")
|
||||
log_cuid = "CUID " + ("dis" if cfg_cuid == "A0" else "en") + "abled"
|
||||
log_memory_config = "Maximum memory configuration: " + (MEMORY_CONFIG[cfg_memory_config] if cfg_memory_config in MEMORY_CONFIG.keys() else "unknown")
|
||||
|
||||
|
||||
print(SUCCESS + "^^^^............................ " + log_magic_wup)
|
||||
print(SUCCESS + "....^^.......................... " + log_wup_style)
|
||||
print(SUCCESS + "......^^........................ " + log_regular_available)
|
||||
@@ -93,7 +93,7 @@ def parse_config(config: str):
|
||||
print(SUCCESS + "............^^.................. " + log_cuid)
|
||||
print(SUCCESS + "..............^^................ " + log_memory_config)
|
||||
print(SUCCESS + "................^^^^^^^^^^^^^^^^ version info")
|
||||
|
||||
|
||||
def try_auth_magic(enforced = False):
|
||||
if enforced and not (gen1a | alt):
|
||||
print(ERROR + "Magic wakeup required. Please select one.")
|
||||
@@ -158,7 +158,7 @@ elif write_backdoor != None:
|
||||
if len(data) % 8 != 0:
|
||||
print(ERROR + "Data must be a multiple of 4 bytes.")
|
||||
exit()
|
||||
|
||||
|
||||
try_auth_magic(True)
|
||||
for i in range(len(data) // 8):
|
||||
p.console("hf 14a raw -" + ("k" if i != (len(data) // 8 - 1) else "") + f"c A2{(write_backdoor_num + i):02x}{data[8*i:8*i+8]}", False, False)
|
||||
@@ -171,13 +171,13 @@ elif uid != None:
|
||||
p.console(f"hf 14a raw -kc" + ("s" if not (gen1a or alt) else "") + " 3002")
|
||||
block_2 = p.grabbed_output.split("\n")[-2][4:-9].replace(" ", "")[:8]
|
||||
uid_bytes = [int(uid[2*x:2*x+2], 16) for x in range(7)]
|
||||
|
||||
|
||||
bcc_0 = 0x88 ^ uid_bytes[0] ^ uid_bytes[1] ^ uid_bytes[2]
|
||||
new_block_0 = ""
|
||||
for i in range(3):
|
||||
new_block_0 += f"{uid_bytes[i]:02x}"
|
||||
new_block_0 += f"{bcc_0:02x}"
|
||||
|
||||
|
||||
bcc_1 = uid_bytes[3] ^ uid_bytes[4] ^ uid_bytes[5] ^ uid_bytes[6]
|
||||
new_block_1 = uid[6:]
|
||||
new_block_2 = f"{bcc_1:02x}" + block_2[2:]
|
||||
|
||||
@@ -42,7 +42,7 @@ typedef struct _em4x70_tag_info_t {
|
||||
/// * UM2 does not exist on the tag
|
||||
/// * Pin does not exist on the tag
|
||||
/// * UM1 (including the lock bits) might be one-time programmable (OTP)
|
||||
///
|
||||
///
|
||||
/// [31] == Block 15 MSB == UM2₆₃..UM2₅₆
|
||||
/// [30] == Block 15 LSB == UM2₅₅..UM2₄₈
|
||||
/// [29] == Block 14 MSB == UM2₄₇..UM2₄₀
|
||||
|
||||
+68
-24
@@ -186,6 +186,7 @@ static void fill_grabber(const char *string) {
|
||||
g_grabbed_output.ptr = tmp;
|
||||
g_grabbed_output.size += MAX_PRINT_BUFFER;
|
||||
}
|
||||
|
||||
int len = snprintf(g_grabbed_output.ptr + g_grabbed_output.idx, MAX_PRINT_BUFFER, "%s", string);
|
||||
if (len < 0 || len > MAX_PRINT_BUFFER) {
|
||||
// We leave current g_grabbed_output_len untouched
|
||||
@@ -196,24 +197,34 @@ static void fill_grabber(const char *string) {
|
||||
}
|
||||
|
||||
void PrintAndLogOptions(const char *str[][2], size_t size, size_t space) {
|
||||
|
||||
char buff[2000] = "Options:\n";
|
||||
char format[2000] = "";
|
||||
size_t counts[2] = {0, 0};
|
||||
for (size_t i = 0; i < size; i++)
|
||||
for (size_t j = 0 ; j < 2 ; j++)
|
||||
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
for (size_t j = 0 ; j < 2 ; j++) {
|
||||
if (counts[j] < strlen(str[i][j])) {
|
||||
counts[j] = strlen(str[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
|
||||
for (size_t j = 0; j < 2; j++) {
|
||||
if (j == 0)
|
||||
if (j == 0) {
|
||||
snprintf(format, sizeof(format), "%%%zus%%%zus", space, counts[j]);
|
||||
else
|
||||
} else {
|
||||
snprintf(format, sizeof(format), "%%%zus%%-%zus", space, counts[j]);
|
||||
}
|
||||
|
||||
snprintf(buff + strlen(buff), sizeof(buff) - strlen(buff), format, " ", str[i][j]);
|
||||
}
|
||||
if (i < size - 1)
|
||||
|
||||
if (i < size - 1) {
|
||||
strncat(buff, "\n", sizeof(buff) - strlen(buff) - 1);
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "%s", buff);
|
||||
}
|
||||
@@ -223,12 +234,14 @@ static uint8_t PrintAndLogEx_spinidx = 0;
|
||||
void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||
|
||||
// skip debug messages if client debugging is turned off i.e. 'DATA SETDEBUG -0'
|
||||
if (g_debugMode == 0 && level == DEBUG)
|
||||
if (g_debugMode == 0 && level == DEBUG) {
|
||||
return;
|
||||
}
|
||||
|
||||
// skip HINT messages if client has hints turned off i.e. 'HINT 0'
|
||||
if (g_session.show_hints == false && level == HINT)
|
||||
if (g_session.show_hints == false && level == HINT) {
|
||||
return;
|
||||
}
|
||||
|
||||
char prefix[40] = {0};
|
||||
char buffer[MAX_PRINT_BUFFER] = {0};
|
||||
@@ -242,17 +255,19 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||
};
|
||||
switch (level) {
|
||||
case ERR:
|
||||
if (g_session.emoji_mode == EMO_EMOJI)
|
||||
if (g_session.emoji_mode == EMO_EMOJI) {
|
||||
strncpy(prefix, "[" _RED_("!!") "] :rotating_light: ", sizeof(prefix) - 1);
|
||||
else
|
||||
} else {
|
||||
strncpy(prefix, "[" _RED_("!!") "] ", sizeof(prefix) - 1);
|
||||
}
|
||||
stream = stderr;
|
||||
break;
|
||||
case FAILED:
|
||||
if (g_session.emoji_mode == EMO_EMOJI)
|
||||
if (g_session.emoji_mode == EMO_EMOJI) {
|
||||
strncpy(prefix, "[" _RED_("-") "] :no_entry: ", sizeof(prefix) - 1);
|
||||
else
|
||||
} else {
|
||||
strncpy(prefix, "[" _RED_("-") "] ", sizeof(prefix) - 1);
|
||||
}
|
||||
break;
|
||||
case DEBUG:
|
||||
strncpy(prefix, "[" _BLUE_("#") "] ", sizeof(prefix) - 1);
|
||||
@@ -264,10 +279,11 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||
strncpy(prefix, "[" _GREEN_("+") "] ", sizeof(prefix) - 1);
|
||||
break;
|
||||
case WARNING:
|
||||
if (g_session.emoji_mode == EMO_EMOJI)
|
||||
if (g_session.emoji_mode == EMO_EMOJI) {
|
||||
strncpy(prefix, "[" _CYAN_("!") "] :warning: ", sizeof(prefix) - 1);
|
||||
else
|
||||
} else {
|
||||
strncpy(prefix, "[" _CYAN_("!") "] ", sizeof(prefix) - 1);
|
||||
}
|
||||
break;
|
||||
case INFO:
|
||||
strncpy(prefix, "[" _YELLOW_("=") "] ", sizeof(prefix) - 1);
|
||||
@@ -276,13 +292,15 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||
if (g_session.emoji_mode == EMO_EMOJI) {
|
||||
strncpy(prefix, spinner_emoji[PrintAndLogEx_spinidx], sizeof(prefix) - 1);
|
||||
PrintAndLogEx_spinidx++;
|
||||
if (PrintAndLogEx_spinidx >= ARRAYLEN(spinner_emoji))
|
||||
if (PrintAndLogEx_spinidx >= ARRAYLEN(spinner_emoji)) {
|
||||
PrintAndLogEx_spinidx = 0;
|
||||
}
|
||||
} else {
|
||||
strncpy(prefix, spinner[PrintAndLogEx_spinidx], sizeof(prefix) - 1);
|
||||
PrintAndLogEx_spinidx++;
|
||||
if (PrintAndLogEx_spinidx >= ARRAYLEN(spinner))
|
||||
if (PrintAndLogEx_spinidx >= ARRAYLEN(spinner)) {
|
||||
PrintAndLogEx_spinidx = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NORMAL:
|
||||
@@ -306,8 +324,9 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||
const char delim[2] = "\n";
|
||||
|
||||
// line starts with newline
|
||||
if (buffer[0] == '\n')
|
||||
if (buffer[0] == '\n') {
|
||||
fPrintAndLog(stream, "");
|
||||
}
|
||||
|
||||
token = strtok_r(buffer, delim, &tmp_ptr);
|
||||
|
||||
@@ -315,16 +334,21 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||
|
||||
size_t size = strlen(buffer2);
|
||||
|
||||
if (strlen(token))
|
||||
if (strlen(token)) {
|
||||
snprintf(buffer2 + size, sizeof(buffer2) - size, "%s%s\n", prefix, token);
|
||||
else
|
||||
} else {
|
||||
snprintf(buffer2 + size, sizeof(buffer2) - size, "\n");
|
||||
}
|
||||
|
||||
token = strtok_r(NULL, delim, &tmp_ptr);
|
||||
}
|
||||
|
||||
fPrintAndLog(stream, "%s", buffer2);
|
||||
|
||||
} else {
|
||||
|
||||
snprintf(buffer2, sizeof(buffer2), "%s%s", prefix, buffer);
|
||||
|
||||
if (level == INPLACE) {
|
||||
// ignore INPLACE if rest of output is grabbed
|
||||
if (!(g_printAndLog & PRINTANDLOG_GRAB)) {
|
||||
@@ -354,6 +378,7 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
||||
if (logging && g_session.incognito) {
|
||||
logging = 0;
|
||||
}
|
||||
|
||||
if ((g_printAndLog & PRINTANDLOG_LOG) && logging && !logfile) {
|
||||
char *my_logfile_path = NULL;
|
||||
char filename[40];
|
||||
@@ -361,11 +386,15 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
||||
time_t now = time(NULL);
|
||||
timenow = gmtime(&now);
|
||||
strftime(filename, sizeof(filename), PROXLOG, timenow);
|
||||
|
||||
if (searchHomeFilePath(&my_logfile_path, LOGS_SUBDIR, filename, true) != PM3_SUCCESS) {
|
||||
|
||||
printf(_YELLOW_("[-]") " Logging disabled!\n");
|
||||
my_logfile_path = NULL;
|
||||
logging = 0;
|
||||
|
||||
} else {
|
||||
|
||||
logfile = fopen(my_logfile_path, "a");
|
||||
if (logfile == NULL) {
|
||||
printf(_YELLOW_("[-]") " Can't open logfile %s, logging disabled!\n", my_logfile_path);
|
||||
@@ -411,13 +440,16 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
||||
linefeed = false;
|
||||
buffer[strlen(buffer) - 1] = 0;
|
||||
}
|
||||
|
||||
bool filter_ansi = !g_session.supports_colors;
|
||||
memcpy_filter_ansi(buffer2, buffer, sizeof(buffer), filter_ansi);
|
||||
if (g_printAndLog & PRINTANDLOG_PRINT) {
|
||||
|
||||
if ((g_printAndLog & PRINTANDLOG_PRINT) == PRINTANDLOG_PRINT) {
|
||||
memcpy_filter_emoji(buffer3, buffer2, sizeof(buffer2), g_session.emoji_mode);
|
||||
fprintf(stream, "%s", buffer3);
|
||||
if (linefeed)
|
||||
if (linefeed) {
|
||||
fprintf(stream, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RL_STATE_READCMD
|
||||
@@ -433,33 +465,44 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
||||
|
||||
if (((g_printAndLog & PRINTANDLOG_LOG) && logging && logfile) ||
|
||||
(g_printAndLog & PRINTANDLOG_GRAB)) {
|
||||
|
||||
memcpy_filter_emoji(buffer3, buffer2, sizeof(buffer2), EMO_ALTTEXT);
|
||||
|
||||
if (filter_ansi == false) {
|
||||
memcpy_filter_ansi(buffer, buffer3, sizeof(buffer3), true);
|
||||
}
|
||||
}
|
||||
|
||||
if ((g_printAndLog & PRINTANDLOG_LOG) && logging && logfile) {
|
||||
|
||||
if (filter_ansi) {
|
||||
fprintf(logfile, "%s", buffer3);
|
||||
} else {
|
||||
fprintf(logfile, "%s", buffer);
|
||||
}
|
||||
if (linefeed)
|
||||
|
||||
if (linefeed) {
|
||||
fprintf(logfile, "\n");
|
||||
}
|
||||
fflush(logfile);
|
||||
}
|
||||
|
||||
if (g_printAndLog & PRINTANDLOG_GRAB) {
|
||||
|
||||
if (filter_ansi) {
|
||||
fill_grabber(buffer3);
|
||||
} else {
|
||||
fill_grabber(buffer);
|
||||
}
|
||||
if (linefeed)
|
||||
|
||||
if (linefeed) {
|
||||
fill_grabber("\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (flushAfterWrite)
|
||||
if (flushAfterWrite) {
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
//release lock
|
||||
pthread_mutex_unlock(&g_print_lock);
|
||||
@@ -478,9 +521,10 @@ void memcpy_filter_rlmarkers(void *dest, const void *src, size_t n) {
|
||||
uint8_t *rsrc = (uint8_t *)src;
|
||||
uint16_t si = 0;
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
if ((rsrc[i] == '\001') || (rsrc[i] == '\002'))
|
||||
if ((rsrc[i] == '\001') || (rsrc[i] == '\002')) {
|
||||
// skip readline special markers
|
||||
continue;
|
||||
}
|
||||
rdest[si++] = rsrc[i];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user