level04: code refactorized

This commit is contained in:
0x35c 2025-05-06 14:13:42 +02:00
parent c6db5f49cd
commit 6fee805bf3

View File

@ -7,31 +7,23 @@
int main(void)
{
int stat_loc;
char s[128];
int v6;
int v7;
int v8;
pid_t v9;
int wstatus;
pid_t pid;
v9 = fork();
pid = fork();
memset(s, 0, sizeof(s));
v8 = 0;
stat_loc = 0;
if (v9) {
if (pid) {
do {
wait(&stat_loc);
v6 = stat_loc;
if ((stat_loc & 0x7F) == 0 ||
(v7 = stat_loc,
(char)((stat_loc & 0x7F) + 1) >> 1 > 0)) {
wait(&wstatus);
if (WIFSIGNALED(wstatus) ||
((char)(WIFSIGNALED(wstatus) + 1) >> 1 > 0)) {
puts("child is exiting...");
return 0;
}
v8 = ptrace(PTRACE_PEEKUSER, v9, 44, 0);
} while (v8 != 11);
} while (ptrace(PTRACE_PEEKUSER, pid, 44, 0) != 11);
puts("no exec() for you");
kill(v9, 9);
kill(pid, 9);
} else {
prctl(1, 1);
ptrace(PTRACE_TRACEME, 0, 0, 0);