Compare commits

..

No commits in common. "a0e9ccb0e31f97ec9e7d11a1e1fc150a7f275d13" and "d1c86e7165b04e01efe13e93761502769b9cdfec" have entirely different histories.

6 changed files with 12 additions and 18 deletions

View File

@ -18,8 +18,7 @@ void ft_lstdelone(t_list *lst, void (*del)(void *))
return ;
if (del)
{
del(lst->content);
free(lst);
del(lst->content);
}
}

View File

@ -1 +0,0 @@
nasm -f elf64 -o print.o print.s && ld -o print print.o && nasm -f bin -o payload print.s && hexdump -v -e '"\\\x\" 1/1 "%02x"' payload

View File

@ -49,4 +49,3 @@ int prepare_injection(t_elf_content *woody);
void encrypt(char *file, unsigned long int offset, unsigned long int size);
#endif

View File

@ -9,7 +9,7 @@ _start:
mov rdi, 1
lea rsi, [rel msg]
mov rdx, 14
mov rdx, 10
mov rax, 1
syscall
pop rdx
@ -17,7 +17,6 @@ _start:
pop rdi
pop rax
jmp 0x00000000
msg db "....WOODY....",10
msg db "..WOODY..",10
text_section dq 0xbabababababababa
section_sisze dq 0xcacacacacacacaca

View File

@ -43,4 +43,3 @@ int main(int ac, char **av)
return ret;
return prepare_injection(&woody);
}

View File

@ -1,5 +1,6 @@
#include "../includes/woody.h"
int elf_magic_numbers(char *str)
{
return (!ft_strncmp(str, ELFMAG, SELFMAG));
@ -110,7 +111,7 @@ int insert_payload(t_elf_content *woody, t_payload *payload, size_t payload_posi
printf("the jump = %ld\n", payload->len - 16);
int32_t jmp_index = ptr_jmp - payload->payload;
int32_t jump_value = ((payload_position + jmp_index + 5) - woody->Ehdr->e_entry) * -1; // 5 = JUMP SIZE (OPCODE + 4 bytes operand)
int32_t jump_value = (payload_position - woody->Ehdr->e_entry + jmp_index - 1) * -1;
ft_memcpy(&payload->payload[jmp_index + 1], &jump_value, sizeof(jump_value));
int64_t text_index = ptr_text_section - payload->payload;
@ -126,7 +127,7 @@ int insert_payload(t_elf_content *woody, t_payload *payload, size_t payload_posi
printf("Old entry : %ld (%lx)\n", woody->Ehdr->e_entry, woody->Ehdr->e_entry);
printf("Code cave start = %ld (%lx)\n", payload_position, payload_position);
printf("Payload size = %ld (%lx)\n", payload->len, payload->len);
printf("Backward offset = %d (%x)(%x)\n", jump_value, jump_value, -jump_value);
printf("Backwar d offset = %d (%x)(%x)\n", jump_value, jump_value, -jump_value);
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
@ -204,7 +205,6 @@ int get_elf_sections(t_elf_content *woody)
break;
}
}
return EXIT_SUCCESS;
}
@ -224,4 +224,3 @@ int prepare_injection(t_elf_content *woody)
free(woody_file);
return EXIT_SUCCESS;
}