Skip to content

Commit

Permalink
koekeishiya#725 set protection for stack segment
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Nov 23, 2020
1 parent 4d1b220 commit d290835
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/osax/mach_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ bool mach_loader_inject_payload(pid_t pid)
return false;
}

if (vm_protect(task, stack, stack_size, 0, VM_PROT_READ | VM_PROT_WRITE) != KERN_SUCCESS) {
fprintf(stderr, "could not change protection for stack segment\n");
return false;
}

if (mach_vm_allocate(task, &code, image_size, VM_FLAGS_ANYWHERE) != KERN_SUCCESS) {
fprintf(stderr, "could not allocate code segment\n");
return false;
Expand Down

0 comments on commit d290835

Please sign in to comment.