feat: mvp

This commit is contained in:
root
2024-10-31 18:11:10 +03:00
parent 88e75e848a
commit d7f2db8780
2 changed files with 15 additions and 13 deletions

View File

@ -14,9 +14,7 @@ struct user_regs_struct regs;
void continue_execution(pid_t pid) void continue_execution(pid_t pid)
{ {
ptrace(PTRACE_CONT, pid, DONT_CARE, DONT_CARE); ptrace(PTRACE_CONT, pid, DONT_CARE, DONT_CARE);
int wait_status; waitpid(pid, &stats, 0);
int options = 0;
waitpid(pid, &wait_status, options);
return; return;
} }
@ -30,6 +28,7 @@ void print_rax(pid_t pid)
void step(pid_t pid) void step(pid_t pid)
{ {
ptrace(PTRACE_SINGLESTEP, pid, DONT_CARE, DONT_CARE); ptrace(PTRACE_SINGLESTEP, pid, DONT_CARE, DONT_CARE);
waitpid(pid, &stats, 0);
return; return;
} }
@ -49,16 +48,18 @@ int main()
{ {
char buff; char buff;
printf(" -- parrent\n"); printf(" -- parrent\n");
continue_execution(pid); // to start app
continue_execution(pid); continue_execution(pid);
do { if (stats & SIGTRAP)
waitpid(pid, &stats, 0); {
printf("stats - %d", stats); while (stats != 0)
print_rax(pid); {
ptrace(PTRACE_SINGLESTEP, pid, DONT_CARE, DONT_CARE); read(0, &buff, 1);
printf("enter any: "); print_rax(pid);
read(0, &buff, 1); step(pid);
printf("\n"); }
} while(stats); }
printf("____AFTER_TRACE_PARRENT____\n"); printf("____AFTER_TRACE_PARRENT____\n");
} }
return 0; return 0;

View File

@ -8,7 +8,7 @@ section .text
_start: _start:
xor rax, rax, xor rax, rax,
add rax, 1 add rax, 1
int3 ;int3
add rax, 12 add rax, 12
;int3 ;int3
mov rax, 33 mov rax, 33
@ -19,6 +19,7 @@ _start:
mov rsi, msg mov rsi, msg
mov rdx, msg_len mov rdx, msg_len
syscall syscall
int3
mov rax, 60 mov rax, 60
mov rdi, 0 mov rdi, 0