Compare commits
5 Commits
fa004f3a6a
...
d1c86e7165
Author | SHA1 | Date |
---|---|---|
pbonilla | d1c86e7165 | |
pbonilla | 8a5bfae528 | |
pbonilla | fba60ca76e | |
gbrochar | 2a20011050 | |
gbrochar | f83b053fcb |
|
@ -1,4 +1,7 @@
|
||||||
*.o
|
*.o
|
||||||
*.a
|
*.a
|
||||||
woody_woodpacker
|
woody_woodpacker
|
||||||
woody
|
woody
|
||||||
|
asm
|
||||||
|
payload
|
||||||
|
print
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
{
|
|
||||||
"files.associations": {
|
|
||||||
"stdio.h": "c",
|
|
||||||
"mman.h": "c",
|
|
||||||
"stdint.h": "c",
|
|
||||||
"compare": "c"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,6 +15,8 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define JUMP "\xe9"
|
#define JUMP "\xe9"
|
||||||
|
#define TEXT_OFFSET "\xba\xba\xba\xba\xba\xba\xba\xba"
|
||||||
|
#define SECTION_SIZE "\xca\xca\xca\xca\xca\xca\xca\xca"
|
||||||
|
|
||||||
typedef struct payload
|
typedef struct payload
|
||||||
{
|
{
|
||||||
|
@ -22,7 +24,7 @@ typedef struct payload
|
||||||
size_t len;
|
size_t len;
|
||||||
} t_payload;
|
} t_payload;
|
||||||
|
|
||||||
typedef struct efl_content
|
typedef struct elf_content
|
||||||
{
|
{
|
||||||
long unsigned int file_size;
|
long unsigned int file_size;
|
||||||
char *file_path;
|
char *file_path;
|
||||||
|
@ -30,15 +32,18 @@ typedef struct efl_content
|
||||||
Elf64_Ehdr *Ehdr;
|
Elf64_Ehdr *Ehdr;
|
||||||
Elf64_Phdr *Phdr;
|
Elf64_Phdr *Phdr;
|
||||||
Elf64_Shdr *Shdr;
|
Elf64_Shdr *Shdr;
|
||||||
|
Elf64_Shdr *text_section;
|
||||||
char *extra_data;
|
char *extra_data;
|
||||||
} t_efl_content;
|
} t_elf_content;
|
||||||
|
|
||||||
// utils.c
|
// utils.c
|
||||||
void *fetch(char *file, unsigned long file_size, unsigned long offset_to_data, unsigned long supposed_data_size);
|
void *fetch(char *file, unsigned long file_size, unsigned long offset_to_data, unsigned long supposed_data_size);
|
||||||
int ft_put_error(char *str);
|
int ft_put_error(char *str);
|
||||||
|
char *get_string(char *str, char *end_file);
|
||||||
|
int get_symbols_count(int sh_size, int sh_entsize);
|
||||||
|
|
||||||
// woody.c
|
// woody.c
|
||||||
int prepare_injection(t_efl_content *woody);
|
int prepare_injection(t_elf_content *woody);
|
||||||
|
|
||||||
// encrypt.c
|
// encrypt.c
|
||||||
void encrypt(char *file, unsigned long int offset, unsigned long int size);
|
void encrypt(char *file, unsigned long int offset, unsigned long int size);
|
||||||
|
|
9
print.s
9
print.s
|
@ -7,21 +7,16 @@ _start:
|
||||||
push rsi
|
push rsi
|
||||||
push rdx
|
push rdx
|
||||||
|
|
||||||
mov rdi, 1
|
|
||||||
mov rdi, 1
|
|
||||||
mov rdi, 1
|
|
||||||
mov rdi, 1
|
|
||||||
mov rdi, 1
|
|
||||||
mov rdi, 1
|
mov rdi, 1
|
||||||
lea rsi, [rel msg]
|
lea rsi, [rel msg]
|
||||||
mov rdx, 10
|
mov rdx, 10
|
||||||
mov rax, 1
|
mov rax, 1
|
||||||
syscall
|
syscall
|
||||||
|
|
||||||
pop rdx
|
pop rdx
|
||||||
pop rsi
|
pop rsi
|
||||||
pop rdi
|
pop rdi
|
||||||
pop rax
|
pop rax
|
||||||
jmp 0x00000000
|
jmp 0x00000000
|
||||||
|
|
||||||
msg db "..WOODY..",10
|
msg db "..WOODY..",10
|
||||||
|
text_section dq 0xbabababababababa
|
||||||
|
section_sisze dq 0xcacacacacacacaca
|
|
@ -5,7 +5,7 @@ void encrypt(char *file, unsigned long int offset, unsigned long int size)
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
while (i < size)
|
while (i < size)
|
||||||
{
|
{
|
||||||
file[offset + i] = 0;
|
file[offset + i] = file[offset + i] + 1;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
#include "../includes/woody.h"
|
#include "../includes/woody.h"
|
||||||
|
|
||||||
int get_elf_file(t_efl_content *woody)
|
int get_elf_file(t_elf_content *woody)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
off_t off;
|
off_t off;
|
||||||
|
@ -20,7 +20,7 @@ int get_elf_file(t_efl_content *woody)
|
||||||
}
|
}
|
||||||
woody->file_size = off;
|
woody->file_size = off;
|
||||||
woody->file = mmap(NULL, woody->file_size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
|
woody->file = mmap(NULL, woody->file_size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
|
||||||
if (woody->file == MAP_FAILED)
|
if (woody->file == MAP_FAILED)
|
||||||
{
|
{
|
||||||
close(fd);
|
close(fd);
|
||||||
ft_printf("Error: Failed to map file \'%s\'\n", woody->file_path);
|
ft_printf("Error: Failed to map file \'%s\'\n", woody->file_path);
|
||||||
|
@ -32,7 +32,7 @@ int get_elf_file(t_efl_content *woody)
|
||||||
|
|
||||||
int main(int ac, char **av)
|
int main(int ac, char **av)
|
||||||
{
|
{
|
||||||
t_efl_content woody;
|
t_elf_content woody;
|
||||||
if (ac != 2)
|
if (ac != 2)
|
||||||
{
|
{
|
||||||
return ft_put_error("Woody_woodpacker take 1 argument\n");
|
return ft_put_error("Woody_woodpacker take 1 argument\n");
|
||||||
|
|
20
srcs/utils.c
20
srcs/utils.c
|
@ -7,6 +7,26 @@ void *fetch(char *file, unsigned long file_size, unsigned long offset_to_data, u
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_symbols_count(int sh_size, int sh_entsize)
|
||||||
|
{
|
||||||
|
if (sh_size <= 0 || sh_entsize <= 0)
|
||||||
|
return 0;
|
||||||
|
return (sh_size / sh_entsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *get_string(char *str, char *end_file)
|
||||||
|
{
|
||||||
|
char *search_end = str;
|
||||||
|
while (search_end < end_file)
|
||||||
|
{
|
||||||
|
if (*search_end == 0)
|
||||||
|
return str;
|
||||||
|
++search_end;
|
||||||
|
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int ft_put_error(char *str)
|
int ft_put_error(char *str)
|
||||||
{
|
{
|
||||||
ft_putstr_fd("Error: ", STDERR_FILENO);
|
ft_putstr_fd("Error: ", STDERR_FILENO);
|
||||||
|
|
124
srcs/woody.c
124
srcs/woody.c
|
@ -6,7 +6,7 @@ int elf_magic_numbers(char *str)
|
||||||
return (!ft_strncmp(str, ELFMAG, SELFMAG));
|
return (!ft_strncmp(str, ELFMAG, SELFMAG));
|
||||||
}
|
}
|
||||||
|
|
||||||
int save_elf(char *path, char *file, unsigned long int size)
|
int save_elf(char *path, char *file, unsigned long int size)
|
||||||
{
|
{
|
||||||
int fd = open(path, O_CREAT | O_WRONLY | O_TRUNC, 0755);
|
int fd = open(path, O_CREAT | O_WRONLY | O_TRUNC, 0755);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
|
@ -27,7 +27,7 @@ int save_elf(char *path, char *file, unsigned long int size)
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_load_segment(t_efl_content *woody, int start, bool executable)
|
int get_load_segment(t_elf_content *woody, int start, bool executable)
|
||||||
{
|
{
|
||||||
for (int i = start; i < woody->Ehdr->e_phnum; i++)
|
for (int i = start; i < woody->Ehdr->e_phnum; i++)
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ int get_load_segment(t_efl_content *woody, int start, bool executable)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void offset_sections(t_efl_content *woody, unsigned int from, unsigned int offset_ammount)
|
void offset_sections(t_elf_content *woody, unsigned int from, unsigned int offset_ammount)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < woody->Ehdr->e_phnum; i++)
|
for (int i = 0; i < woody->Ehdr->e_phnum; i++)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,7 @@ void offset_sections(t_efl_content *woody, unsigned int from, unsigned int offse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t create_codecave(t_efl_content *woody, Elf64_Phdr *load_segment, t_payload *payload)
|
size_t create_codecave(t_elf_content *woody, Elf64_Phdr *load_segment, t_payload *payload)
|
||||||
{
|
{
|
||||||
const unsigned int page_size = 4096; // getpagesize(); not authorized
|
const unsigned int page_size = 4096; // getpagesize(); not authorized
|
||||||
unsigned int padding_size = ((payload->len / page_size) + 1) * page_size;
|
unsigned int padding_size = ((payload->len / page_size) + 1) * page_size;
|
||||||
|
@ -87,37 +87,55 @@ t_payload *get_payload()
|
||||||
return NULL;
|
return NULL;
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
int fd = open("payload", O_RDONLY);
|
int fd = open("payload", O_RDONLY);
|
||||||
|
if (fd == -1) {
|
||||||
|
perror("error opening payload");
|
||||||
|
free(payload);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
payload->len = read(fd, buffer, 1024);
|
payload->len = read(fd, buffer, 1024);
|
||||||
payload->payload = malloc(sizeof(char) * payload->len);
|
payload->payload = malloc(sizeof(char) * payload->len);
|
||||||
ft_memcpy(payload->payload, buffer, payload->len);
|
ft_memcpy(payload->payload, buffer, payload->len);
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
int insert_payload(t_efl_content *woody, t_payload *payload, size_t payload_position)
|
int insert_payload(t_elf_content *woody, t_payload *payload, size_t payload_position)
|
||||||
{
|
{
|
||||||
char *ptr = ft_strnstr_nullterminated(payload->payload, JUMP, payload->len);
|
char *ptr_jmp = ft_strnstr_nullterminated(payload->payload, JUMP, payload->len);
|
||||||
if (ptr)
|
char *ptr_text_section = ft_strnstr_nullterminated(payload->payload, TEXT_OFFSET, payload->len);
|
||||||
|
char *ptr_section_size = ft_strnstr_nullterminated(payload->payload, SECTION_SIZE, payload->len);
|
||||||
|
if (ptr_jmp && ptr_text_section && ptr_section_size)
|
||||||
{
|
{
|
||||||
int32_t jmp_index = ptr - payload->payload;
|
printf("test a jumo = %ld\n", ptr_jmp - payload->payload);
|
||||||
int32_t jump_value = ((payload_position + payload->len) - woody->Ehdr->e_entry) * -1;
|
printf("test a jumo = %ld\n", ptr_jmp - payload->payload + sizeof(JUMP));
|
||||||
|
printf("jump base = %ld\n", payload->len);
|
||||||
|
printf("the jump = %ld\n", payload->len - 16);
|
||||||
|
|
||||||
|
int32_t jmp_index = ptr_jmp - payload->payload;
|
||||||
|
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));
|
ft_memcpy(&payload->payload[jmp_index + 1], &jump_value, sizeof(jump_value));
|
||||||
ft_memcpy(woody->file + payload_position, payload->payload, payload->len);
|
|
||||||
|
|
||||||
|
int64_t text_index = ptr_text_section - payload->payload;
|
||||||
|
int64_t text_value = (payload_position - woody->text_section->sh_offset + text_index - 1) * -1;
|
||||||
|
text_value = 0;
|
||||||
|
ft_memcpy(&payload->payload[text_index], &text_value, sizeof(text_value));
|
||||||
|
|
||||||
|
int64_t section_index = ptr_section_size - payload->payload;
|
||||||
|
int64_t section_value = (payload_position - woody->text_section->sh_size + section_index - 1) * -1;
|
||||||
|
ft_memcpy(&payload->payload[section_index], §ion_value, sizeof(section_value));
|
||||||
|
|
||||||
|
ft_memcpy(woody->file + payload_position, payload->payload, payload->len);
|
||||||
printf("Old entry : %ld (%lx)\n", woody->Ehdr->e_entry, woody->Ehdr->e_entry);
|
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("Code cave start = %ld (%lx)\n", payload_position, payload_position);
|
||||||
printf("Payload size = %ld (%lx)\n", payload->len, payload->len);
|
printf("Payload size = %ld (%lx)\n", payload->len, payload->len);
|
||||||
printf("Backwar d offset = %d (%x)\n", jump_value, jump_value);
|
printf("Backwar d offset = %d (%x)(%x)\n", jump_value, jump_value, -jump_value);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void inject(t_efl_content *woody)
|
void inject(t_elf_content *woody)
|
||||||
{
|
{
|
||||||
t_payload *payload = get_payload();
|
t_payload *payload = get_payload();
|
||||||
|
|
||||||
int i = get_load_segment(woody, 0, true);
|
int i = get_load_segment(woody, 0, true);
|
||||||
int j = get_load_segment(woody, i + 1, false);
|
int j = get_load_segment(woody, i + 1, false);
|
||||||
|
|
||||||
|
@ -125,7 +143,6 @@ void inject(t_efl_content *woody)
|
||||||
size_t payload_position;
|
size_t payload_position;
|
||||||
printf("load position = : %ld (%lx)\n", woody->Phdr[i].p_offset, woody->Phdr[i].p_offset);
|
printf("load position = : %ld (%lx)\n", woody->Phdr[i].p_offset, woody->Phdr[i].p_offset);
|
||||||
printf("load size = : %ld (%lx)\n", woody->Phdr[i].p_filesz, woody->Phdr[i].p_filesz);
|
printf("load size = : %ld (%lx)\n", woody->Phdr[i].p_filesz, woody->Phdr[i].p_filesz);
|
||||||
|
|
||||||
if (code_cave_size > payload->len) // inverse here to test the other technique
|
if (code_cave_size > payload->len) // inverse here to test the other technique
|
||||||
{
|
{
|
||||||
payload_position = woody->Phdr[i].p_offset + woody->Phdr[i].p_memsz;
|
payload_position = woody->Phdr[i].p_offset + woody->Phdr[i].p_memsz;
|
||||||
|
@ -140,11 +157,20 @@ void inject(t_efl_content *woody)
|
||||||
woody->Ehdr->e_entry = payload_position;
|
woody->Ehdr->e_entry = payload_position;
|
||||||
woody->Phdr[i].p_filesz += payload->len;
|
woody->Phdr[i].p_filesz += payload->len;
|
||||||
woody->Phdr[i].p_memsz += payload->len;
|
woody->Phdr[i].p_memsz += payload->len;
|
||||||
|
woody->Phdr[i].p_flags = PF_X | PF_W | PF_R;
|
||||||
|
woody->text_section->sh_size += payload->len;
|
||||||
printf("New entry = %ld (%lx)\n", woody->Ehdr->e_entry, woody->Ehdr->e_entry);
|
printf("New entry = %ld (%lx)\n", woody->Ehdr->e_entry, woody->Ehdr->e_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_elf_sections(t_efl_content *woody)
|
int is_special_section_indice(uint16_t section_index) {
|
||||||
|
return (section_index == SHN_LOPROC || section_index == SHN_BEFORE ||
|
||||||
|
section_index == SHN_AFTER || section_index == SHN_HIPROC ||
|
||||||
|
section_index == SHN_LOOS || section_index == SHN_HIOS ||
|
||||||
|
section_index == SHN_ABS || section_index == SHN_COMMON ||
|
||||||
|
section_index == SHN_XINDEX || section_index == SHN_HIRESERVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_elf_sections(t_elf_content *woody)
|
||||||
{
|
{
|
||||||
woody->Ehdr = (Elf64_Ehdr *)fetch(woody->file, woody->file_size, 0, sizeof(Elf64_Ehdr));
|
woody->Ehdr = (Elf64_Ehdr *)fetch(woody->file, woody->file_size, 0, sizeof(Elf64_Ehdr));
|
||||||
if (!woody->Ehdr || !elf_magic_numbers(woody->file) || woody->Ehdr->e_ident[EI_CLASS] != ELFCLASS64)
|
if (!woody->Ehdr || !elf_magic_numbers(woody->file) || woody->Ehdr->e_ident[EI_CLASS] != ELFCLASS64)
|
||||||
|
@ -155,60 +181,46 @@ int get_elf_sections(t_efl_content *woody)
|
||||||
woody->Phdr = (Elf64_Phdr *)fetch(woody->file, woody->file_size, woody->Ehdr->e_phoff, sizeof(Elf64_Phdr));
|
woody->Phdr = (Elf64_Phdr *)fetch(woody->file, woody->file_size, woody->Ehdr->e_phoff, sizeof(Elf64_Phdr));
|
||||||
|
|
||||||
woody->Shdr = (Elf64_Shdr *)fetch(woody->file, woody->file_size, woody->Ehdr->e_shoff, sizeof(Elf64_Shdr));
|
woody->Shdr = (Elf64_Shdr *)fetch(woody->file, woody->file_size, woody->Ehdr->e_shoff, sizeof(Elf64_Shdr));
|
||||||
if (woody->Shdr == NULL || !fetch(woody->file, woody->file_size, woody->Ehdr->e_shoff, woody->Ehdr->e_shnum * sizeof(Elf64_Shdr)))
|
if (!woody->Shdr|| !fetch(woody->file, woody->file_size, woody->Ehdr->e_shoff, woody->Ehdr->e_shnum * sizeof(Elf64_Shdr)))
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
if (!fetch(woody->file, woody->file_size, woody->Ehdr->e_shoff + (woody->Ehdr->e_shstrndx * sizeof(Elf64_Shdr)), sizeof(Elf64_Shdr)))
|
||||||
{
|
{
|
||||||
return ft_put_error("Corrupted file");
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
char *Sshstrtab = (char *)fetch(woody->file, woody->file_size, woody->Shdr[woody->Ehdr->e_shstrndx].sh_offset, 0);
|
||||||
|
if (Sshstrtab == NULL)
|
||||||
|
{
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
for (int j = 0; j < woody->Ehdr->e_shnum;j++)
|
||||||
|
{
|
||||||
|
if (woody->Shdr[j].sh_name > woody->Shdr[woody->Ehdr->e_shstrndx].sh_size) return EXIT_FAILURE;
|
||||||
|
if (woody->Shdr[j].sh_type == SHT_PROGBITS && woody->Shdr[j].sh_flags & SHF_EXECINSTR &&
|
||||||
|
woody->Shdr[j].sh_flags & SHF_ALLOC &&
|
||||||
|
Sshstrtab + woody->Shdr[j].sh_name < (char *)woody->file + woody->file_size &&
|
||||||
|
!ft_strncmp(".text\0", Sshstrtab + woody->Shdr[j].sh_name, 6))
|
||||||
|
{
|
||||||
|
woody->text_section = &woody->Shdr[j];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Elf64_Shdr *symbols_table = NULL;
|
|
||||||
// for (int i = 0; i < woody->Ehdr->e_shnum; i++) {
|
|
||||||
// if (Shdr[i].sh_type == SHT_SYMTAB) {
|
|
||||||
// symbols_table = fetch(woody->file, woody->file_size, woody->Ehdr->e_shoff + (i * sizeof(Elf64_Shdr)), sizeof(Elf64_Shdr));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (symbols_table == NULL)
|
|
||||||
// return ft_put_error("No symbols");
|
|
||||||
|
|
||||||
// if (!fetch(woody->file, woody->file_size, woody->Ehdr->e_shoff + (woody->Ehdr->e_shstrndx * sizeof(Elf64_Shdr)), sizeof(Elf64_Shdr)))
|
|
||||||
// return ft_put_error("Corrupted file");
|
|
||||||
|
|
||||||
// char *Sshstrtab = (char *)fetch(woody->file, woody->file_size, Shdr[woody->Ehdr->e_shstrndx].sh_offset, 0);
|
|
||||||
// if (Sshstrtab == NULL)
|
|
||||||
// return ft_put_error("Corrupted file");
|
|
||||||
|
|
||||||
// Elf64_Shdr *strtab_header = (Elf64_Shdr *)fetch(woody->file, woody->file_size, woody->Ehdr->e_shoff + (symbols_table->sh_link * woody->Ehdr->e_shentsize), sizeof(Elf64_Shdr));
|
|
||||||
// if (!strtab_header)
|
|
||||||
// return ft_put_error("Corrupted file");
|
|
||||||
|
|
||||||
// char *strtab = fetch(woody->file, woody->file_size, strtab_header->sh_offset, 0);
|
|
||||||
// if (strtab == NULL)
|
|
||||||
// return ft_put_error("Corrupted file");
|
|
||||||
// Elf64_Sym *symbols = (Elf64_Sym *)fetch(woody->file, woody->file_size, symbols_table->sh_offset, sizeof(Elf64_Sym));
|
|
||||||
// if (symbols == NULL)
|
|
||||||
// return ft_put_error("Corrupted file");
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int prepare_injection(t_efl_content *woody)
|
int prepare_injection(t_elf_content *woody)
|
||||||
{
|
{
|
||||||
int elf_statut = get_elf_sections(woody);
|
int elf_statut = get_elf_sections(woody);
|
||||||
if (elf_statut)
|
if (elf_statut)
|
||||||
return elf_statut;
|
return elf_statut;
|
||||||
|
|
||||||
inject(woody);
|
inject(woody);
|
||||||
|
// encrypt(woody->file, woody->text_section->sh_offset, woody->text_section->sh_size);
|
||||||
char *woody_file;
|
char *woody_file;
|
||||||
if (!(woody_file = malloc(woody->file_size)))
|
if (!(woody_file = malloc(woody->file_size)))
|
||||||
return ft_put_error("Allocation error");
|
return ft_put_error("Allocation error");
|
||||||
|
|
||||||
ft_memcpy(woody_file, woody->file, woody->file_size);
|
ft_memcpy(woody_file, woody->file, woody->file_size);
|
||||||
|
|
||||||
// encrypt(woody_file, strtab_header->sh_offset , strtab_header->sh_size);
|
|
||||||
munmap(woody_file, woody->file_size);
|
munmap(woody_file, woody->file_size);
|
||||||
save_elf("woody", woody_file, woody->file_size);
|
save_elf("woody", woody_file, woody->file_size);
|
||||||
free(woody_file);
|
free(woody_file);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue