2022-04-26 08:23:08 +00:00
|
|
|
/* radare - LGPL - Copyright 2009-2022 - pancake */
|
2016-05-03 02:52:41 +00:00
|
|
|
|
2018-08-01 03:10:54 +00:00
|
|
|
#include <string.h>
|
2016-05-03 02:52:41 +00:00
|
|
|
#include "r_config.h"
|
|
|
|
#include "r_cons.h"
|
|
|
|
#include "r_core.h"
|
2014-07-30 20:12:48 +00:00
|
|
|
|
2022-04-26 08:23:08 +00:00
|
|
|
bool rasm2_list(RCore *core, const char *arch, int fmt);
|
|
|
|
|
|
|
|
static const char *help_msg_La[] = {
|
|
|
|
"Usage:", "La[qj]", " # asm/anal plugin list",
|
|
|
|
"La", "", "List asm/anal pluginsh (See rasm2 -L)",
|
|
|
|
"Laq", "", "Only list the plugin name",
|
|
|
|
"Laj", "", "Full list, but in JSON format",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2017-07-26 13:08:48 +00:00
|
|
|
// TODO #7967 help refactor: move to another place
|
|
|
|
static const char *help_msg_L[] = {
|
2018-08-01 03:10:54 +00:00
|
|
|
"Usage:", "L[acio]", "[-name][ file]",
|
|
|
|
"L", "", "show this help",
|
|
|
|
"L", " blah."R_LIB_EXT, "load plugin file",
|
|
|
|
"L-", "duk", "unload core plugin by name",
|
2022-04-26 08:23:08 +00:00
|
|
|
"La", "[qj]", "list asm/anal plugins (see: aL, e asm.arch=" "??" ")",
|
|
|
|
"Lc", "", "list core plugins (see",
|
2021-12-21 21:15:26 +00:00
|
|
|
"Ld", "", "list debug plugins (dL)",
|
2022-05-30 18:23:47 +00:00
|
|
|
"LD", "[j]", "list supported decompilers (e cmd.pdc=?)",
|
2021-06-04 12:43:18 +00:00
|
|
|
"Le", "", "list esil plugins",
|
|
|
|
"Lg", "", "list egg plugins",
|
2021-12-21 21:15:26 +00:00
|
|
|
"Lh", "", "list hash plugins (ph)",
|
2022-05-30 18:29:07 +00:00
|
|
|
"Li", "[j]", "list bin plugins (iL)",
|
|
|
|
"Lt", "[j]", "list color themes (eco)",
|
2022-05-30 18:54:18 +00:00
|
|
|
"Ll", "[j]", "list lang plugins (#!)",
|
2021-06-04 12:43:18 +00:00
|
|
|
"LL", "", "lock screen",
|
2022-05-30 18:39:18 +00:00
|
|
|
"Lm", "[j]", "list fs plugins (mL)",
|
2021-12-21 21:15:26 +00:00
|
|
|
"Lo", "", "list io plugins (oL)",
|
2022-05-30 18:39:18 +00:00
|
|
|
"Lp", "[j]", "list parser plugins (e asm.parser=?)",
|
2017-07-26 13:08:48 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *help_msg_T[] = {
|
|
|
|
"Usage:", "T", "[-][ num|msg]",
|
2018-08-01 03:10:54 +00:00
|
|
|
"T", "", "list all Text log messages",
|
|
|
|
"T", " message", "add new log message",
|
|
|
|
"T", " 123", "list log from 123",
|
|
|
|
"T", " 10 3", "list 3 log messages starting from 10",
|
|
|
|
"T*", "", "list in radare commands",
|
|
|
|
"T-", "", "delete all logs",
|
|
|
|
"T-", " 123", "delete logs before 123",
|
|
|
|
"Tl", "", "get last log message id",
|
|
|
|
"Tj", "", "list in json format",
|
|
|
|
"Tm", " [idx]", "display log messages without index",
|
|
|
|
"Ts", "", "list files in current directory (see pwd, cd)",
|
|
|
|
"TT", "", "enter into the text log chat console",
|
2022-04-11 09:09:41 +00:00
|
|
|
"T=", "[.]", "pull logs from remote r2 instance specified by http.sync",
|
|
|
|
"T=&", "", "start background thread syncing with the remote server",
|
2017-07-26 13:08:48 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2018-10-31 00:52:08 +00:00
|
|
|
static void screenlock(RCore *core) {
|
|
|
|
// char *pass = r_cons_input ("Enter new password: ");
|
|
|
|
char *pass = r_cons_password (Color_INVERT "Enter new password:"Color_INVERT_RESET);
|
|
|
|
if (!pass || !*pass) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
char *again = r_cons_password (Color_INVERT "Type it again:"Color_INVERT_RESET);
|
|
|
|
if (!again || !*again) {
|
2020-01-17 04:58:29 +00:00
|
|
|
free (pass);
|
2018-10-31 00:52:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (strcmp (pass, again)) {
|
2022-09-05 23:43:44 +00:00
|
|
|
R_LOG_ERROR ("Password mismatch!");
|
2020-01-17 04:58:29 +00:00
|
|
|
free (pass);
|
|
|
|
free (again);
|
2018-10-31 00:52:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
bool running = true;
|
|
|
|
r_cons_clear_buffer ();
|
2020-08-12 16:54:49 +00:00
|
|
|
ut64 begin = r_time_now ();
|
2018-10-31 00:52:08 +00:00
|
|
|
ut64 last = UT64_MAX;
|
2020-10-21 09:27:17 +00:00
|
|
|
int tries = 0;
|
2018-10-31 00:52:08 +00:00
|
|
|
do {
|
|
|
|
r_cons_clear00 ();
|
|
|
|
r_cons_printf ("Retries: %d\n", tries);
|
|
|
|
r_cons_printf ("Locked ts: %s\n", r_time_to_string (begin));
|
|
|
|
if (last != UT64_MAX) {
|
|
|
|
r_cons_printf ("Last try: %s\n", r_time_to_string (last));
|
|
|
|
}
|
|
|
|
r_cons_newline ();
|
|
|
|
r_cons_flush ();
|
|
|
|
char *msg = r_cons_password ("radare2 password: ");
|
|
|
|
if (msg && !strcmp (msg, pass)) {
|
|
|
|
running = false;
|
|
|
|
} else {
|
2022-09-05 23:43:44 +00:00
|
|
|
R_LOG_ERROR ("Invalid password");
|
2020-08-12 16:54:49 +00:00
|
|
|
last = r_time_now ();
|
2018-10-31 00:52:08 +00:00
|
|
|
tries++;
|
|
|
|
}
|
|
|
|
free (msg);
|
|
|
|
int n = r_num_rand (10) + 1;
|
|
|
|
r_sys_usleep (n * 100000);
|
|
|
|
} while (running);
|
|
|
|
r_cons_set_cup (true);
|
|
|
|
free (pass);
|
2022-09-05 23:43:44 +00:00
|
|
|
R_LOG_INFO ("Unlocked!");
|
2018-10-31 00:52:08 +00:00
|
|
|
}
|
|
|
|
|
2017-03-25 01:30:00 +00:00
|
|
|
static int textlog_chat(RCore *core) {
|
2014-08-28 01:11:13 +00:00
|
|
|
char prompt[64];
|
|
|
|
char buf[1024];
|
|
|
|
int lastmsg = 0;
|
|
|
|
const char *me = r_config_get (core->config, "cfg.user");
|
2018-06-26 16:05:31 +00:00
|
|
|
char msg[2048];
|
2014-08-28 01:11:13 +00:00
|
|
|
|
|
|
|
eprintf ("Type '/help' for commands:\n");
|
2017-03-25 01:30:00 +00:00
|
|
|
snprintf (prompt, sizeof (prompt) - 1, "[%s]> ", me);
|
2014-08-28 01:11:13 +00:00
|
|
|
r_line_set_prompt (prompt);
|
|
|
|
for (;;) {
|
|
|
|
r_core_log_list (core, lastmsg, 0, 0);
|
|
|
|
lastmsg = core->log->last;
|
2020-02-29 19:47:10 +00:00
|
|
|
if (r_cons_fgets (buf, sizeof (buf), 0, NULL) < 0) {
|
2014-08-28 01:11:13 +00:00
|
|
|
return 1;
|
2017-03-25 01:30:00 +00:00
|
|
|
}
|
|
|
|
if (!*buf) {
|
|
|
|
continue;
|
|
|
|
}
|
2014-08-28 01:11:13 +00:00
|
|
|
if (!strcmp (buf, "/help")) {
|
|
|
|
eprintf ("/quit quit the chat (same as ^D)\n");
|
|
|
|
eprintf ("/name <nick> set cfg.user name\n");
|
|
|
|
eprintf ("/log show full log\n");
|
|
|
|
eprintf ("/clear clear text log messages\n");
|
|
|
|
} else if (!strncmp (buf, "/name ", 6)) {
|
2017-03-25 01:30:00 +00:00
|
|
|
snprintf (msg, sizeof (msg) - 1, "* '%s' is now known as '%s'", me, buf + 6);
|
2014-08-28 01:11:13 +00:00
|
|
|
r_core_log_add (core, msg);
|
2017-03-25 01:30:00 +00:00
|
|
|
r_config_set (core->config, "cfg.user", buf + 6);
|
2014-08-28 01:11:13 +00:00
|
|
|
me = r_config_get (core->config, "cfg.user");
|
2017-03-25 01:30:00 +00:00
|
|
|
snprintf (prompt, sizeof (prompt) - 1, "[%s]> ", me);
|
2014-08-28 01:11:13 +00:00
|
|
|
r_line_set_prompt (prompt);
|
|
|
|
return 0;
|
|
|
|
} else if (!strcmp (buf, "/log")) {
|
|
|
|
r_core_log_list (core, 0, 0, 0);
|
|
|
|
return 0;
|
|
|
|
} else if (!strcmp (buf, "/clear")) {
|
2017-03-25 01:30:00 +00:00
|
|
|
// r_core_log_del (core, 0);
|
2014-08-28 01:11:13 +00:00
|
|
|
r_core_cmd0 (core, "T-");
|
|
|
|
return 0;
|
|
|
|
} else if (!strcmp (buf, "/quit")) {
|
|
|
|
return 0;
|
2017-03-25 01:30:00 +00:00
|
|
|
} else if (*buf == '/') {
|
2022-09-05 23:43:44 +00:00
|
|
|
R_LOG_ERROR ("Unknown command: %s", buf);
|
2014-08-28 01:11:13 +00:00
|
|
|
} else {
|
2018-06-26 16:05:31 +00:00
|
|
|
snprintf (msg, sizeof (msg), "[%s] %s", me, buf);
|
2014-08-28 01:11:13 +00:00
|
|
|
r_core_log_add (core, msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-03 10:33:23 +00:00
|
|
|
static int getIndexFromLogString(const char *s) {
|
|
|
|
int len = strlen (s);
|
|
|
|
const char *m = s + len;
|
|
|
|
int nlctr = 2;
|
|
|
|
const char *nl = NULL;
|
|
|
|
while (m > s) {
|
|
|
|
if (*m == '\n') {
|
|
|
|
nl = m;
|
|
|
|
if (--nlctr < 1) {
|
|
|
|
return atoi (m + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m--;
|
|
|
|
}
|
|
|
|
return atoi (nl?nl + 1: s);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-12-21 18:52:17 +00:00
|
|
|
static char *expr2cmd(RCoreLog *log, const char *line) {
|
2019-01-03 10:33:23 +00:00
|
|
|
if (!line || !*line) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
line++;
|
|
|
|
if (!strncmp (line, "add-comment", 11)) {
|
|
|
|
line += 11;
|
|
|
|
if (*line == ' ') {
|
|
|
|
char *sp = strchr (line + 1, ' ');
|
|
|
|
if (sp) {
|
|
|
|
char *msg = sp + 1;
|
|
|
|
ut64 addr = r_num_get (NULL, line);
|
|
|
|
return r_str_newf ("CCu base64:%s @ 0x%"PFMT64x"\n", msg, addr);
|
|
|
|
}
|
|
|
|
}
|
2022-09-05 23:43:44 +00:00
|
|
|
R_LOG_ERROR ("Cannot parse add-comment expression");
|
2019-01-03 10:33:23 +00:00
|
|
|
}
|
|
|
|
if (!strncmp (line, "del-comment", 11)) {
|
|
|
|
if (line[11] == ' ') {
|
|
|
|
return r_str_newf ("CC-%s\n", line + 12);
|
|
|
|
}
|
2022-09-05 23:43:44 +00:00
|
|
|
R_LOG_ERROR ("Cannot parse add-comment expression");
|
2019-01-03 10:33:23 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-12-21 18:52:17 +00:00
|
|
|
static int log_callback_r2(RCore *core, int count, const char *line) {
|
2019-01-03 10:33:23 +00:00
|
|
|
if (*line == ':') {
|
|
|
|
char *cmd = expr2cmd (core->log, line);
|
|
|
|
if (cmd) {
|
|
|
|
r_cons_printf ("%s\n", cmd);
|
|
|
|
r_core_cmd (core, cmd, 0);
|
|
|
|
free (cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-12-21 18:52:17 +00:00
|
|
|
static int log_callback_all(RCore *log, int count, const char *line) {
|
2019-01-03 10:33:23 +00:00
|
|
|
r_cons_printf ("%d %s\n", count, line);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-07-30 20:12:48 +00:00
|
|
|
static int cmd_log(void *data, const char *input) {
|
2017-03-25 01:30:00 +00:00
|
|
|
RCore *core = (RCore *) data;
|
2015-04-19 11:39:10 +00:00
|
|
|
const char *arg, *input2;
|
2015-04-19 02:32:48 +00:00
|
|
|
int n, n2;
|
|
|
|
|
2017-03-25 01:30:00 +00:00
|
|
|
if (!input) {
|
2015-04-19 02:32:48 +00:00
|
|
|
return 1;
|
2017-03-25 01:30:00 +00:00
|
|
|
}
|
2015-04-19 02:32:48 +00:00
|
|
|
|
2017-03-25 01:30:00 +00:00
|
|
|
input2 = (input && *input)? input + 1: "";
|
2015-04-19 02:32:48 +00:00
|
|
|
arg = strchr (input2, ' ');
|
|
|
|
n = atoi (input2);
|
2017-03-25 01:30:00 +00:00
|
|
|
n2 = arg? atoi (arg + 1): 0;
|
2014-07-30 20:12:48 +00:00
|
|
|
|
|
|
|
switch (*input) {
|
2019-01-08 22:40:19 +00:00
|
|
|
case 'e': // "Te" shell: less
|
2019-01-03 10:33:23 +00:00
|
|
|
{
|
|
|
|
char *p = strchr (input, ' ');
|
|
|
|
if (p) {
|
|
|
|
char *b = r_file_slurp (p + 1, NULL);
|
|
|
|
if (b) {
|
|
|
|
r_cons_less_str (b, NULL);
|
|
|
|
free (b);
|
|
|
|
} else {
|
2022-09-05 23:43:44 +00:00
|
|
|
R_LOG_ERROR ("File not found");
|
2019-01-03 10:33:23 +00:00
|
|
|
}
|
2017-03-25 01:30:00 +00:00
|
|
|
} else {
|
2019-01-03 10:33:23 +00:00
|
|
|
eprintf ("Usage: less [filename]\n");
|
2017-03-25 01:30:00 +00:00
|
|
|
}
|
2014-07-30 20:12:48 +00:00
|
|
|
}
|
2019-01-03 10:33:23 +00:00
|
|
|
break;
|
2019-01-08 22:40:19 +00:00
|
|
|
case 'l': // "Tl"
|
2017-03-25 01:30:00 +00:00
|
|
|
r_cons_printf ("%d\n", core->log->last - 1);
|
2014-07-30 20:12:48 +00:00
|
|
|
break;
|
2019-01-08 22:40:19 +00:00
|
|
|
case '-': // "T-"
|
2014-07-30 20:12:48 +00:00
|
|
|
r_core_log_del (core, n);
|
|
|
|
break;
|
2019-01-08 22:40:19 +00:00
|
|
|
case '?': // "T?"
|
2017-07-26 13:08:48 +00:00
|
|
|
r_core_cmd_help (core, help_msg_T);
|
|
|
|
break;
|
2019-01-13 02:31:40 +00:00
|
|
|
case 'T': // "TT" Ts ? as ms?
|
2019-02-18 05:20:01 +00:00
|
|
|
if (r_cons_is_interactive ()) {
|
2015-02-12 16:23:30 +00:00
|
|
|
textlog_chat (core);
|
2017-03-25 01:30:00 +00:00
|
|
|
} else {
|
2022-09-05 23:43:44 +00:00
|
|
|
R_LOG_ERROR ("The TT command needs scr.interactive=true");
|
2017-03-25 01:30:00 +00:00
|
|
|
}
|
2014-08-28 01:11:13 +00:00
|
|
|
break;
|
2019-01-08 22:40:19 +00:00
|
|
|
case '=': // "T="
|
|
|
|
if (input[1] == '&') { // "T=&"
|
|
|
|
if (input[2] == '&') { // "T=&&"
|
2019-01-04 11:15:53 +00:00
|
|
|
r_cons_break_push (NULL, NULL);
|
|
|
|
while (!r_cons_is_breaked ()) {
|
|
|
|
r_core_cmd0 (core, "T=");
|
|
|
|
void *bed = r_cons_sleep_begin();
|
2019-01-08 22:40:19 +00:00
|
|
|
r_sys_sleep (1);
|
2019-01-04 11:15:53 +00:00
|
|
|
r_cons_sleep_end (bed);
|
2019-01-03 10:33:23 +00:00
|
|
|
}
|
2019-01-04 11:15:53 +00:00
|
|
|
r_cons_break_pop ();
|
|
|
|
} else {
|
|
|
|
// TODO: Sucks that we can't enqueue functions, only commands
|
2022-09-05 23:43:44 +00:00
|
|
|
R_LOG_INFO ("Background thread syncing with http.sync started");
|
2019-01-04 11:15:53 +00:00
|
|
|
RCoreTask *task = r_core_task_new (core, true, "T=&&", NULL, core);
|
2019-11-26 07:52:17 +00:00
|
|
|
r_core_task_enqueue (&core->tasks, task);
|
2019-01-04 11:15:53 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (atoi (input + 1) > 0 || (input[1] == '0')) {
|
|
|
|
core->sync_index = 0;
|
2019-01-03 10:33:23 +00:00
|
|
|
} else {
|
2019-01-04 11:15:53 +00:00
|
|
|
RCoreLogCallback log_callback = (input[1] == '*')
|
|
|
|
? log_callback_all: log_callback_r2;
|
|
|
|
char *res = r_core_log_get (core, core->sync_index);
|
|
|
|
if (res) {
|
|
|
|
int idx = getIndexFromLogString (res);
|
|
|
|
if (idx != -1) {
|
|
|
|
core->sync_index = idx + 1;
|
|
|
|
}
|
|
|
|
r_core_log_run (core, res, log_callback);
|
|
|
|
free (res);
|
|
|
|
} else {
|
|
|
|
r_cons_printf ("Please check e http.sync\n");
|
|
|
|
}
|
2019-01-03 10:33:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-01-08 22:40:19 +00:00
|
|
|
case ' ': // "T "
|
2019-01-03 10:33:23 +00:00
|
|
|
if (n > 0 || *input == '0') {
|
2014-07-31 03:20:48 +00:00
|
|
|
r_core_log_list (core, n, n2, *input);
|
|
|
|
} else {
|
2017-03-25 01:30:00 +00:00
|
|
|
r_core_log_add (core, input + 1);
|
2014-07-30 20:12:48 +00:00
|
|
|
}
|
2014-07-31 03:20:48 +00:00
|
|
|
break;
|
2019-01-08 22:40:19 +00:00
|
|
|
case 'm': // "Tm"
|
2017-03-25 01:30:00 +00:00
|
|
|
if (n > 0) {
|
2014-07-31 03:20:48 +00:00
|
|
|
r_core_log_list (core, n, 1, 't');
|
|
|
|
} else {
|
|
|
|
r_core_log_list (core, n, 0, 't');
|
|
|
|
}
|
|
|
|
break;
|
2019-01-08 22:40:19 +00:00
|
|
|
case 'j': // "Tj"
|
2014-07-30 20:12:48 +00:00
|
|
|
case '*':
|
|
|
|
case '\0':
|
|
|
|
r_core_log_list (core, n, n2, *input);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2017-05-28 23:37:54 +00:00
|
|
|
|
|
|
|
static int cmd_plugins(void *data, const char *input) {
|
|
|
|
RCore *core = (RCore *) data;
|
|
|
|
switch (input[0]) {
|
|
|
|
case 0:
|
2018-08-01 03:10:54 +00:00
|
|
|
r_core_cmd_help (core, help_msg_L);
|
|
|
|
// return r_core_cmd0 (core, "Lc");
|
2017-05-28 23:37:54 +00:00
|
|
|
break;
|
|
|
|
case '-':
|
2020-03-02 20:39:37 +00:00
|
|
|
r_lib_close (core->lib, r_str_trim_head_ro (input + 1));
|
2017-05-28 23:37:54 +00:00
|
|
|
break;
|
|
|
|
case ' ':
|
2020-03-02 20:39:37 +00:00
|
|
|
r_lib_open (core->lib, r_str_trim_head_ro (input + 1));
|
2017-05-28 23:37:54 +00:00
|
|
|
break;
|
|
|
|
case '?':
|
2017-07-26 13:08:48 +00:00
|
|
|
r_core_cmd_help (core, help_msg_L);
|
2017-05-28 23:37:54 +00:00
|
|
|
break;
|
2021-12-21 21:15:26 +00:00
|
|
|
case 't': // "Lt"
|
2022-05-30 18:29:07 +00:00
|
|
|
if (input[1] == 'j') {
|
|
|
|
r_core_cmd0 (core, "ecoj");
|
|
|
|
} else {
|
|
|
|
r_core_cmd0 (core, "eco");
|
|
|
|
}
|
2021-12-21 21:15:26 +00:00
|
|
|
break;
|
2019-05-05 00:02:06 +00:00
|
|
|
case 'm': // "Lm"
|
2022-05-30 18:33:48 +00:00
|
|
|
if (input[1] == 'j') {
|
|
|
|
r_core_cmd0 (core, "mLj");
|
|
|
|
} else {
|
|
|
|
r_core_cmd0 (core, "mL");
|
|
|
|
}
|
2019-05-05 00:02:06 +00:00
|
|
|
break;
|
2021-01-24 15:39:45 +00:00
|
|
|
case 'e': // "Le"
|
|
|
|
r_core_cmdf (core, "aeL%s", input + 1);
|
|
|
|
break;
|
2018-08-01 03:10:54 +00:00
|
|
|
case 'd': // "Ld"
|
2019-06-17 09:18:37 +00:00
|
|
|
r_core_cmdf (core, "dL%s", input + 1);
|
2018-08-01 03:10:54 +00:00
|
|
|
break;
|
|
|
|
case 'h': // "Lh"
|
2022-05-30 18:29:07 +00:00
|
|
|
if (input[1] == 'j') { // "Lhj"
|
|
|
|
r_core_cmd0 (core, "phj");
|
|
|
|
} else {
|
|
|
|
r_core_cmd0 (core, "ph");
|
|
|
|
}
|
2018-08-01 03:10:54 +00:00
|
|
|
break;
|
|
|
|
case 'a': // "La"
|
2022-04-26 08:23:08 +00:00
|
|
|
if (input[1] == '?') {
|
|
|
|
r_core_cmd_help (core, help_msg_La);
|
|
|
|
} else {
|
|
|
|
// r_core_cmd0 (core, "e asm.arch=??");
|
|
|
|
rasm2_list (core, NULL, input[1]);
|
|
|
|
}
|
2018-08-01 03:10:54 +00:00
|
|
|
break;
|
2020-10-10 09:38:01 +00:00
|
|
|
case 'p': // "Lp"
|
2022-05-30 18:39:18 +00:00
|
|
|
if (input[1] == 'j') { // "Lpj"
|
|
|
|
RConfigNode *node = r_config_node_get (core->config, "asm.parser");
|
|
|
|
if (node && node->options) {
|
|
|
|
char *opt;
|
|
|
|
RListIter *iter;
|
|
|
|
PJ *pj = r_core_pj_new (core);
|
|
|
|
pj_a (pj);
|
|
|
|
r_list_foreach (node->options, iter, opt) {
|
|
|
|
pj_s (pj, opt);
|
|
|
|
}
|
|
|
|
pj_end (pj);
|
|
|
|
char *s = pj_drain (pj);
|
|
|
|
r_cons_printf ("%s\n", s);
|
|
|
|
free (s);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
r_core_cmd0 (core, "e asm.parser=?");
|
|
|
|
}
|
2020-10-10 09:38:01 +00:00
|
|
|
break;
|
2019-06-17 09:18:37 +00:00
|
|
|
case 'D': // "LD"
|
|
|
|
if (input[1] == ' ') {
|
2020-03-02 20:39:37 +00:00
|
|
|
r_core_cmdf (core, "e cmd.pdc=%s", r_str_trim_head_ro (input + 2));
|
2022-05-30 18:23:47 +00:00
|
|
|
} else if (input[1] == 'j') {
|
|
|
|
char *deco;
|
|
|
|
RListIter *iter;
|
|
|
|
char *decos = r_core_cmd_str (core, "e cmd.pdc=?");
|
|
|
|
RList *list = r_str_split_list (decos, "\n", 0);
|
|
|
|
PJ *pj = r_core_pj_new (core);
|
|
|
|
pj_o (pj);
|
|
|
|
pj_ka (pj, "decompilers");
|
|
|
|
r_list_foreach (list, iter, deco) {
|
|
|
|
if (*deco) {
|
|
|
|
pj_s (pj, deco);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pj_end (pj);
|
|
|
|
pj_end (pj);
|
|
|
|
char *s = pj_drain (pj);
|
|
|
|
r_cons_printf ("%s\n", s);
|
|
|
|
free (s);
|
|
|
|
r_list_free (list);
|
|
|
|
free (decos);
|
2019-06-17 09:18:37 +00:00
|
|
|
} else {
|
|
|
|
r_core_cmd0 (core, "e cmd.pdc=?");
|
|
|
|
}
|
|
|
|
break;
|
2019-01-11 13:07:01 +00:00
|
|
|
case 'l': // "Ll"
|
2022-05-30 18:54:18 +00:00
|
|
|
if (input[1] == 'j') {
|
|
|
|
r_core_cmd0 (core, "#!?j");
|
|
|
|
} else {
|
|
|
|
r_core_cmd0 (core, "#!");
|
|
|
|
}
|
2019-01-11 13:07:01 +00:00
|
|
|
break;
|
2018-10-31 00:52:08 +00:00
|
|
|
case 'L': // "LL"
|
2022-08-19 22:02:00 +00:00
|
|
|
if (r_config_get_b (core->config, "scr.interactive")) {
|
|
|
|
screenlock (core);
|
|
|
|
} else {
|
|
|
|
R_LOG_ERROR ("lock screen requires scr.interactive");
|
|
|
|
}
|
2018-10-31 00:52:08 +00:00
|
|
|
break;
|
2021-06-04 12:43:18 +00:00
|
|
|
case 'g': // "Lg"
|
2022-05-30 18:57:59 +00:00
|
|
|
if (input[1] == 'j') {
|
|
|
|
r_core_cmd0 (core, "gLj");
|
|
|
|
} else {
|
|
|
|
r_core_cmd0 (core, "gL");
|
|
|
|
}
|
2021-06-04 12:43:18 +00:00
|
|
|
break;
|
2018-08-01 03:10:54 +00:00
|
|
|
case 'o': // "Lo"
|
|
|
|
case 'i': // "Li"
|
2022-05-06 07:41:08 +00:00
|
|
|
r_core_cmdf (core, "%cL%s", input[0], input + 1);
|
2018-08-01 03:10:54 +00:00
|
|
|
break;
|
|
|
|
case 'c': { // "Lc"
|
2018-03-09 08:01:16 +00:00
|
|
|
RListIter *iter;
|
|
|
|
RCorePlugin *cp;
|
|
|
|
switch (input[1]) {
|
|
|
|
case 'j': {
|
2021-01-21 23:51:33 +00:00
|
|
|
PJ *pj = r_core_pj_new (core);
|
|
|
|
if (!pj) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
pj_a (pj);
|
2018-03-09 08:01:16 +00:00
|
|
|
r_list_foreach (core->rcmd->plist, iter, cp) {
|
2021-01-21 23:51:33 +00:00
|
|
|
pj_o (pj);
|
|
|
|
pj_ks (pj, "Name", cp->name);
|
|
|
|
pj_ks (pj, "Description", cp->desc);
|
|
|
|
pj_end (pj);
|
2018-03-09 08:01:16 +00:00
|
|
|
}
|
2021-01-21 23:51:33 +00:00
|
|
|
pj_end (pj);
|
|
|
|
r_cons_println (pj_string (pj));
|
|
|
|
pj_free (pj);
|
2018-03-09 08:01:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-09-01 10:47:41 +00:00
|
|
|
case ' ':
|
|
|
|
r_lib_open (core->lib, r_str_trim_head_ro (input + 2));
|
|
|
|
break;
|
2018-08-01 03:10:54 +00:00
|
|
|
case 0:
|
|
|
|
r_lib_list (core->lib);
|
2017-11-22 14:25:34 +00:00
|
|
|
r_list_foreach (core->rcmd->plist, iter, cp) {
|
|
|
|
r_cons_printf ("%s: %s\n", cp->name, cp->desc);
|
|
|
|
}
|
|
|
|
break;
|
2018-03-09 08:01:16 +00:00
|
|
|
default:
|
2021-09-01 10:47:41 +00:00
|
|
|
r_core_cmd_help (core, help_msg_L);
|
2018-08-01 03:10:54 +00:00
|
|
|
break;
|
2018-03-09 08:01:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2017-05-28 23:37:54 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|