woody-woodpacker/includes/woody.h

51 lines
1.1 KiB
C
Raw Normal View History

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-02-23 13:17:23 +00:00
#define JUMP "\xe9"
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-02-14 10:37:05 +00:00
2024-03-21 14:44:29 +00:00
typedef struct payload
{
char *payload;
size_t len;
} t_payload;
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;
Elf64_Ehdr *Ehdr;
Elf64_Phdr *Phdr;
Elf64_Shdr *Shdr;
2024-04-11 10:20:44 +00:00
Elf64_Shdr *text_section;
2024-03-19 16:20:11 +00:00
char *extra_data;
} 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-02-14 10:37:05 +00:00
// woody.c
int prepare_injection(t_elf_content *woody);
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
#endif