mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-03 10:51:01 +00:00
Enforce sandbox for ko/kd
This commit is contained in:
parent
f798918758
commit
1d5ea4dd56
@ -658,6 +658,7 @@ static int bin_relocs (RCore *r, int mode, ut64 baddr, int va) {
|
||||
if ((mode & R_CORE_BIN_SET)) {
|
||||
int bin_demangle = r_config_get_i (r->config, "bin.demangle");
|
||||
int is_pe = 1; // TODO: optimize
|
||||
int is_sandbox = r_sandbox_enable (0);
|
||||
char *sdb_module = NULL;
|
||||
RFlagItem *fi;
|
||||
char *demname, *symname;
|
||||
@ -668,7 +669,7 @@ static int bin_relocs (RCore *r, int mode, ut64 baddr, int va) {
|
||||
ut64 addr = va? reloc->vaddr: reloc->paddr;
|
||||
demname = NULL;
|
||||
if (reloc->import && reloc->import->name[0]) {
|
||||
if (is_pe && strstr (reloc->import->name, "Ordinal")) {
|
||||
if (is_pe && !is_sandbox && strstr (reloc->import->name, "Ordinal")) {
|
||||
const char *TOKEN = ".dll_Ordinal_";
|
||||
char *module = strdup (reloc->import->name);
|
||||
char *import = strstr (module, TOKEN);
|
||||
@ -687,10 +688,11 @@ static int bin_relocs (RCore *r, int mode, ut64 baddr, int va) {
|
||||
if (r_file_exists (filename)) {
|
||||
db = sdb_new (NULL, filename, 0);
|
||||
} else {
|
||||
filename = sdb_fmt (1,
|
||||
R2_PREFIX"/share/radare2/"
|
||||
R2_VERSION"/format/dll/%s.sdb",
|
||||
module);
|
||||
#if __WINDOWS__
|
||||
filename = sdb_fmt (1, "share/radare2/"R2_VERSION"/format/dll/%s.sdb", module);
|
||||
#else
|
||||
filename = sdb_fmt (1, R2_PREFIX"/share/radare2/" R2_VERSION"/format/dll/%s.sdb", module);
|
||||
#endif
|
||||
if (r_file_exists (filename)) {
|
||||
db = sdb_new (NULL, filename, 0);
|
||||
}
|
||||
|
@ -454,21 +454,27 @@ static int cmd_kuery(void *data, const char *input) {
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
if (r_sandbox_enable (0)) {
|
||||
eprintf ("This command is disabled in sandbox mode\n");
|
||||
return 0;
|
||||
}
|
||||
if (input[1] == ' ') {
|
||||
char *fn = strdup (input+2);
|
||||
char *ns = strchr (fn, ' ');
|
||||
if (ns) {
|
||||
Sdb *db;
|
||||
*ns++ = 0;
|
||||
db = sdb_ns_path (core->sdb, ns, 1);
|
||||
if (db) {
|
||||
Sdb *newdb = sdb_new (NULL, fn, 0);
|
||||
if (newdb) {
|
||||
sdb_drain (db, newdb);
|
||||
} else {
|
||||
eprintf ("Cannot open sdb '%s'\n", fn);
|
||||
}
|
||||
} else eprintf ("Cannot find sdb '%s'\n", ns);
|
||||
if (r_file_exists (fn)) {
|
||||
db = sdb_ns_path (core->sdb, ns, 1);
|
||||
if (db) {
|
||||
Sdb *newdb = sdb_new (NULL, fn, 0);
|
||||
if (newdb) {
|
||||
sdb_drain (db, newdb);
|
||||
} else {
|
||||
eprintf ("Cannot open sdb '%s'\n", fn);
|
||||
}
|
||||
} else eprintf ("Cannot find sdb '%s'\n", ns);
|
||||
} else eprintf ("Cannot open file\n");
|
||||
} else eprintf ("Missing sdb namespace\n");
|
||||
free (fn);
|
||||
} else {
|
||||
@ -476,12 +482,15 @@ static int cmd_kuery(void *data, const char *input) {
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
if (r_sandbox_enable (0)) {
|
||||
eprintf ("This command is disabled in sandbox mode\n");
|
||||
return 0;
|
||||
}
|
||||
if (input[1] == ' ') {
|
||||
char *fn = strdup (input+2);
|
||||
char *ns = strchr (fn, ' ');
|
||||
if (ns) {
|
||||
*ns++ = 0;
|
||||
eprintf ("NS(%s)\n", ns);
|
||||
Sdb *db = sdb_ns_path (core->sdb, ns, 0);
|
||||
if (db) {
|
||||
sdb_file (db, fn);
|
||||
|
Loading…
Reference in New Issue
Block a user