clean: rename efl_content to elf_content
This commit is contained in:
parent
f83b053fcb
commit
2a20011050
|
@ -22,7 +22,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;
|
||||||
|
@ -31,14 +31,14 @@ typedef struct efl_content
|
||||||
Elf64_Phdr *Phdr;
|
Elf64_Phdr *Phdr;
|
||||||
Elf64_Shdr *Shdr;
|
Elf64_Shdr *Shdr;
|
||||||
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);
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -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");
|
||||||
|
|
14
srcs/woody.c
14
srcs/woody.c
|
@ -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;
|
||||||
|
@ -98,7 +98,7 @@ t_payload *get_payload()
|
||||||
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 = ft_strnstr_nullterminated(payload->payload, JUMP, payload->len);
|
||||||
if (ptr)
|
if (ptr)
|
||||||
|
@ -119,7 +119,7 @@ int insert_payload(t_efl_content *woody, t_payload *payload, size_t payload_posi
|
||||||
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();
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ void inject(t_efl_content *woody)
|
||||||
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 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)
|
||||||
|
@ -197,7 +197,7 @@ int get_elf_sections(t_efl_content *woody)
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue