Skip to content

Commit 3563cc3

Browse files
Fix shellcode path customization (#16384) ##egg
1 parent 011a49c commit 3563cc3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

libr/egg/p/egg_exec.c

+20
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,26 @@ static RBuffer *build (REgg *egg) {
9696
break;
9797
case 64:
9898
sc = x86_64_linux_binsh;
99+
if (shell && *shell) {
100+
int len = strlen (shell);
101+
if (len > sizeof (st64) - 1) {
102+
*shell = 0;
103+
eprintf ("Unsupported CMD length\n");
104+
break;
105+
}
106+
st64 b = 0;
107+
memcpy (&b, shell, strlen (shell));
108+
b = -b;
109+
shell = realloc (shell, sizeof (st64) + 1);
110+
if (!shell) {
111+
break;
112+
}
113+
r_str_ncpy (shell, &b, sizeof (st64) + 1);
114+
cd = 4;
115+
r_buf_set_bytes (buf, sc, strlen ((const char *)sc));
116+
r_buf_write_at (buf, cd, (const ut8 *)shell, sizeof (st64));
117+
sc = 0;
118+
}
99119
break;
100120
default:
101121
eprintf ("Unsupported arch %d bits\n", egg->bits);

0 commit comments

Comments
 (0)