Skip to content
This repository was archived by the owner on Jun 29, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ _mmap_data(int pid, size_t len, void *base_address, int protections, int flags,
long shellcode_len = ftell(f);
CHECK(shellcode_len > 0, "ftell error");
// align shellcode size to 32/64-bit boundary
long shellcode_len_aligned = shellcode_len + (sizeof(void*) - (shellcode_len % sizeof(void*)));
long shellcode_len_aligned = shellcode_len;
if (shellcode_len % sizeof(void*) != 0) {
shellcode_len_aligned += sizeof(void*) - shellcode_len % sizeof(void*);
}
CHECK(fseek(f, 0, SEEK_SET) == 0, "fseek error");
shellcode = malloc(shellcode_len_aligned);
memset(shellcode, 0x90, shellcode_len_aligned); // fill with NOPs
Expand Down Expand Up @@ -242,7 +245,7 @@ _launch_payload(int pid, void *code_cave, size_t code_cave_size, void *stack_add
int
inject_code(int pid, unsigned char *payload, size_t payload_len)
{
int ret = 0, status = 0;
int ret = 0;
void *payload_addr = NULL,
*stack = NULL,
*code_cave = NULL,
Expand Down