2024-02-14 10:37:05 +00:00
|
|
|
#ifndef WOODY_H
|
2024-03-19 16:20:11 +00:00
|
|
|
#define WOODY_H
|
2024-02-14 10:37:05 +00:00
|
|
|
|
|
|
|
#include "../ft_printf/includes/ft_printf.h"
|
2024-03-19 16:20:11 +00:00
|
|
|
#include <stdbool.h>
|
2024-02-14 10:37:05 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <elf.h>
|
2024-02-21 12:13:17 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2024-04-17 10:14:08 +00:00
|
|
|
|
2024-02-23 13:17:23 +00:00
|
|
|
#define JUMP "\xe9"
|
2024-04-17 13:08:56 +00:00
|
|
|
#define WOODY "....WOODY...."
|
|
|
|
#define JUMP_VALUE "\xda\xda\xda"
|
|
|
|
|
2024-04-11 21:15:15 +00:00
|
|
|
#define TEXT_OFFSET "\xba\xba\xba\xba\xba\xba\xba\xba"
|
|
|
|
#define SECTION_SIZE "\xca\xca\xca\xca\xca\xca\xca\xca"
|
2024-06-12 11:40:57 +00:00
|
|
|
|
2024-03-21 14:44:29 +00:00
|
|
|
typedef struct payload
|
|
|
|
{
|
|
|
|
char *payload;
|
2024-06-18 16:11:20 +00:00
|
|
|
int len;
|
2024-03-21 14:44:29 +00:00
|
|
|
} t_payload;
|
|
|
|
|
2024-06-19 13:21:28 +00:00
|
|
|
typedef struct elf32
|
|
|
|
{
|
|
|
|
Elf32_Ehdr *Ehdr;
|
|
|
|
Elf32_Phdr *Phdr;
|
|
|
|
Elf32_Shdr *Shdr;
|
2024-06-19 15:12:30 +00:00
|
|
|
Elf32_Shdr *text_section;
|
2024-06-19 13:21:28 +00:00
|
|
|
} t_elf32;
|
|
|
|
|
|
|
|
typedef struct elf64
|
|
|
|
{
|
|
|
|
Elf64_Ehdr *Ehdr;
|
|
|
|
Elf64_Phdr *Phdr;
|
|
|
|
Elf64_Shdr *Shdr;
|
2024-06-19 15:12:30 +00:00
|
|
|
Elf64_Shdr *text_section;
|
2024-06-19 13:21:28 +00:00
|
|
|
} t_elf64;
|
|
|
|
|
2024-04-09 08:30:12 +00:00
|
|
|
typedef struct elf_content
|
2024-02-14 10:37:05 +00:00
|
|
|
{
|
|
|
|
long unsigned int file_size;
|
2024-03-19 16:20:11 +00:00
|
|
|
char *file_path;
|
|
|
|
char *file;
|
2024-06-19 13:21:28 +00:00
|
|
|
t_elf32 *elf32;
|
|
|
|
t_elf64 *elf64;
|
2024-04-09 08:30:12 +00:00
|
|
|
} t_elf_content;
|
2024-02-14 10:37:05 +00:00
|
|
|
|
|
|
|
// utils.c
|
2024-03-19 16:20:11 +00:00
|
|
|
void *fetch(char *file, unsigned long file_size, unsigned long offset_to_data, unsigned long supposed_data_size);
|
|
|
|
int ft_put_error(char *str);
|
2024-04-11 10:20:44 +00:00
|
|
|
char *get_string(char *str, char *end_file);
|
|
|
|
int get_symbols_count(int sh_size, int sh_entsize);
|
2024-06-17 17:28:54 +00:00
|
|
|
char *get_section_name(t_elf_content *woody, int section_index);
|
2024-06-19 13:21:28 +00:00
|
|
|
int elf_magic_numbers(char *str);
|
|
|
|
|
|
|
|
// payload.c
|
|
|
|
t_payload *get_payload();
|
|
|
|
int insert_payload(t_elf_content *woody, t_payload *payload, size_t payload_position, unsigned int e_entry, unsigned int p_offset, unsigned int p_memsz);
|
|
|
|
|
|
|
|
// woody32.c
|
|
|
|
int get_elf_sections32(t_elf_content *woody);
|
|
|
|
int inject32(t_elf_content *woody);
|
2024-02-14 10:37:05 +00:00
|
|
|
|
2024-06-19 13:21:28 +00:00
|
|
|
// woody64.c
|
|
|
|
int get_elf_sections64(t_elf_content *woody);
|
|
|
|
int inject64(t_elf_content *woody);
|
2024-06-18 16:11:20 +00:00
|
|
|
|
2024-02-21 12:54:33 +00:00
|
|
|
|
|
|
|
// encrypt.c
|
2024-03-19 16:20:11 +00:00
|
|
|
void encrypt(char *file, unsigned long int offset, unsigned long int size);
|
2024-02-14 10:37:05 +00:00
|
|
|
|
2024-04-15 04:17:31 +00:00
|
|
|
#endif
|
|
|
|
|