Skip to content

Instantly share code, notes, and snippets.

@elongl

elongl/_eval.c Secret

Created June 13, 2021 18:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save elongl/cf5badc6d78721cacbe87dfe59afeef5 to your computer and use it in GitHub Desktop.
The `_eval` function of `libshared.so`.
/* WARNING: Control flow encountered bad instruction data */
void _eval(char **param_1,char *param_2,uint param_3,__pid_t *param_4)
{
__pid_t __pid;
int iVar1;
size_t sVar2;
int *piVar3;
int iVar4;
char *__file;
char local_128 [256];
int local_28 [2];
undefined *local_c;
local_128[0] = '\0';
local_c = &_gp_1;
memset(local_128 + 1,0,0xfd);
__pid = fork();
if (__pid == -1) {
perror("fork");
__errno_location();
}
else {
if (__pid == 0) {
iVar1 = 0;
do {
iVar4 = iVar1 + 1;
signal(iVar1,(__sighandler_t)0x0);
iVar1 = iVar4;
} while (iVar4 < 0x7f);
ioctl(0,0x5471,0);
close(0);
close(1);
__file = "/dev/console";
close(2);
setsid();
iVar1 = open("/dev/console",2);
if (iVar1 < 0) {
__file = "/dev/null";
open("/dev/null",0);
open("/dev/null",1);
}
else {
close(iVar1);
open("/dev/console",0);
open("/dev/console",1);
}
open(__file,1);
if (param_2 != (char *)0x0) {
iVar1 = memcmp(param_2,&DAT_0002a4b0,2);
iVar4 = 0x101;
if (iVar1 == 0) {
iVar4 = 0x109;
param_2 = param_2 + 2;
}
else {
if (*param_2 == '>') {
iVar4 = 0x301;
param_2 = param_2 + 1;
}
}
iVar1 = open(param_2,iVar4,0x1a4);
if (iVar1 < 0) {
perror(param_2);
}
else {
dup2(iVar1,1);
close(iVar1);
}
}
iVar1 = 0;
if (*param_1 != (char *)0x0) {
iVar4 = 0;
do {
sVar2 = strlen(local_128);
iVar1 = iVar1 + 1;
snprintf(local_128 + sVar2,0xfe,"%s ",*(undefined4 *)(iVar4 + (int)param_1));
iVar4 = iVar1 * 4;
} while (param_1[iVar1] != (char *)0x0);
}
setenv("PATH","/sbin:/bin:/usr/sbin:/usr/bin",1);
alarm(param_3);
execvp(*param_1,param_1);
perror(*param_1);
piVar3 = __errno_location();
/* WARNING: Subroutine does not return */
exit(*piVar3);
}
if (param_4 == (__pid_t *)0x0) {
waitpid(__pid,local_28,0);
}
else {
*param_4 = __pid;
}
}
/* WARNING: Bad instruction - Truncating control flow here */
halt_baddata();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment