From c19e8366f454129525b03c84bc002e2094fb752e Mon Sep 17 00:00:00 2001 From: Jonathan Salwan Date: Fri, 4 Nov 2011 16:34:31 +0100 Subject: [PATCH] Update all core [-file add] [-d deleted] --- Makefile | 5 +- includes/ropgadget.h | 27 +++++---- src/check_arch_supported.c | 17 +++--- src/check_asm_mode.c | 6 +- src/check_bind_mode.c | 5 +- src/check_d_mode.c | 57 ------------------ src/check_elf_format.c | 16 ++--- src/check_file_mode.c | 117 +++++++++++++++++++++++++++++++++++++ src/check_filter_mode.c | 6 +- src/check_g_mode.c | 78 +------------------------ src/check_importsc_mode.c | 4 +- src/check_limit_mode.c | 6 +- src/check_map_mode.c | 10 ++-- src/check_only_mode.c | 6 +- src/check_opcode_mode.c | 8 +-- src/check_option.c | 42 +++++++++++++ src/check_string_mode.c | 4 +- src/check_symtab_mode.c | 2 +- src/check_v_mode.c | 2 +- src/main.c | 3 +- src/syntax.c | 41 ++++++------- 21 files changed, 243 insertions(+), 219 deletions(-) delete mode 100644 src/check_d_mode.c create mode 100644 src/check_file_mode.c create mode 100644 src/check_option.c diff --git a/Makefile b/Makefile index fa7eb23..1c3ac97 100644 --- a/Makefile +++ b/Makefile @@ -57,9 +57,9 @@ SRC = $(SRC_DIR)/main.c \ $(SRC_DIR)/combo_ropmaker1.c \ $(SRC_DIR)/combo_ropmaker2.c \ $(SRC_DIR)/combo_ropmaker_importsc.c \ - $(SRC_DIR)/check_g_mode.c \ - $(SRC_DIR)/check_d_mode.c \ + $(SRC_DIR)/check_file_mode.c \ $(SRC_DIR)/check_v_mode.c \ + $(SRC_DIR)/check_g_mode.c \ $(SRC_DIR)/check_bind_mode.c \ $(SRC_DIR)/check_filter_mode.c \ $(SRC_DIR)/check_only_mode.c \ @@ -75,6 +75,7 @@ SRC = $(SRC_DIR)/main.c \ $(SRC_DIR)/check_limit_mode.c \ $(SRC_DIR)/check_map_mode.c \ $(SRC_DIR)/check_symtab_mode.c \ + $(SRC_DIR)/check_option.c \ $(SRC_DIR)/no_filtered.c \ $(SRC_DIR)/varop.c \ $(SRC_DIR)/onlymode.c \ diff --git a/includes/ropgadget.h b/includes/ropgadget.h index 19e5243..ef556b2 100644 --- a/includes/ropgadget.h +++ b/includes/ropgadget.h @@ -199,13 +199,13 @@ typedef struct s_importsc t_char_importsc *poctet; } t_importsc; -/* file -d or -g option */ -typedef struct s_option +/* -file */ +typedef struct s_filemode { - char *gfile; - char *dfile; - size_t size_file; -} t_option; + char *file; + size_t size; + unsigned char *data; +} t_filemode; /* -syntax (not implemented)*/ typedef struct s_syntaxcode @@ -253,9 +253,10 @@ int flag_sectheader; int flag_progheader; int flag_elfheader; int flag_symtab; +int flag_g; /* flag options */ -t_option pOption; /* -g or -d */ +t_filemode filemode; /* -file */ t_opcode opcode_mode; /* -opcode */ t_stringmode stringmode; /* -string */ t_asm_mode asm_mode; /* -asm */ @@ -272,13 +273,10 @@ char *get_flags(Elf32_Word); char *get_seg(Elf32_Word); void syntax(char *); void display_version(void); -void display_data(unsigned char *, unsigned int); void search_gadgets(unsigned char *, unsigned int); unsigned char *save_bin_data(char *, unsigned int); -int check_elf_format(unsigned char *); -int check_arch_supported(void); -void no_elf_format(void); -void no_arch_supported(void); +void check_elf_format(unsigned char *); +void check_arch_supported(void); int check_exec_maps(t_maps_exec *, Elf32_Addr); void free_add_maps_exec(t_maps_exec *); void display_program_header(void); @@ -292,9 +290,10 @@ void print_real_string(char *str); int check_read_maps(t_maps_read *, Elf32_Addr); void free_add_maps_read(t_maps_read *); void free_var_opcode(t_varop *element); -void check_g_mode(char **); -void check_d_mode(char **); +void check_file_mode(char **); void check_v_mode(char **); +void check_g_mode(char **); +void check_option(); void check_filtre_mode(char **); void check_opcode_mode(char **); void check_string_mode(char **); diff --git a/src/check_arch_supported.c b/src/check_arch_supported.c index fc6057c..cc23223 100644 --- a/src/check_arch_supported.c +++ b/src/check_arch_supported.c @@ -27,19 +27,16 @@ #define ELF_F pElf_Header->e_ident[EI_CLASS] == ELFCLASS32 #define PROC8632 pElf_Header->e_machine == EM_386 -void no_arch_supported(void) -{ - fprintf(stderr, "Error: Architecture isn't supported\n"); - exit(EXIT_FAILURE); -} - -int check_arch_supported(void) +void check_arch_supported(void) { /* supported: - Linux/x86-32bits */ /* supported: - FreeBSD/x86-32bits */ if (ELF_F && (LINUX || FREEBSD) && PROC8632) - return (0); - - return (-1); + return ; + else + { + fprintf(stderr, "%sError%s: Architecture isn't supported\n", RED, ENDC); + exit(EXIT_FAILURE); + } } diff --git a/src/check_asm_mode.c b/src/check_asm_mode.c index 7d3f34e..104126b 100644 --- a/src/check_asm_mode.c +++ b/src/check_asm_mode.c @@ -145,9 +145,9 @@ void check_asm_mode(char **argv) } else { - fprintf(stderr, "Syntax: -asm \n\n"); - fprintf(stderr, "Ex: -asm \"xor %%ebx, %%eax\"\n"); - fprintf(stderr, "Ex: -asm \"int \\$0x80\"\n"); + fprintf(stderr, "%sSyntax%s: -asm \n", RED, ENDC); + fprintf(stderr, "%sEx%s: -asm \"xor %%ebx, %%eax\"\n", RED, ENDC); + fprintf(stderr, " -asm \"int \\$0x80\"\n"); exit(EXIT_FAILURE); } } diff --git a/src/check_bind_mode.c b/src/check_bind_mode.c index 367f00d..bf57c9a 100644 --- a/src/check_bind_mode.c +++ b/src/check_bind_mode.c @@ -35,12 +35,13 @@ void check_bind_mode(char **argv) { if (argv[i + 1] == NULL) { - fprintf(stderr, "Error: syntax -port \n"); + fprintf(stderr, "%sSyntax%s: -port \n", RED, ENDC); + fprintf(stderr, "%sEx%s: -port 8080\n", RED, ENDC); exit(EXIT_FAILURE); } if (atoi(argv[i + 1]) < 1000 || atoi(argv[i + 1]) > 9999) { - fprintf(stderr, "Error port: need to set port between 1000 and 9999 (For stack padding)\n"); + fprintf(stderr, "%sError port%s: need to set port between 1000 and 9999 (For stack padding)\n", RED, ENDC); exit(EXIT_FAILURE); } strcpy(bind_mode.port, argv[i + 1]); diff --git a/src/check_d_mode.c b/src/check_d_mode.c deleted file mode 100644 index e4b7606..0000000 --- a/src/check_d_mode.c +++ /dev/null @@ -1,57 +0,0 @@ -/* -** RopGadget - Dev v3.3 -** Jonathan Salwan - http://twitter.com/JonathanSalwan -** http://shell-storm.org -** 2011-10-18 -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "ropgadget.h" - -void check_d_mode(char **argv) -{ - struct stat filestat; - unsigned char *data; - unsigned int size; - int i = 0; - - while (argv[i] != NULL) - { - if (!strcmp(argv[i], "-d")) - { - if (argv[i + 1] != NULL && argv[i + 1][0] != '\0') - { - pOption.dfile = argv[i + 1]; - if((stat(pOption.dfile, &filestat)) == -1) - { - perror("stat"); - exit(EXIT_FAILURE); - } - size = filestat.st_size; - data = save_bin_data(pOption.dfile, size); - display_data(data, size); - free(data); - exit(EXIT_SUCCESS); - } - else - { - fprintf(stderr, "Syntax: -d \n"); - exit(EXIT_FAILURE); - } - } - i++; - } -} diff --git a/src/check_elf_format.c b/src/check_elf_format.c index 7e8d97c..4620801 100644 --- a/src/check_elf_format.c +++ b/src/check_elf_format.c @@ -22,15 +22,11 @@ #include #include "ropgadget.h" -void no_elf_format(void) +void check_elf_format(unsigned char *data) { - fprintf(stderr, "Error: No elf format\n"); - exit(EXIT_FAILURE); -} - -int check_elf_format(unsigned char *data) -{ - if (!strncmp((const char *)data, MAGIC_ELF, 4)) - return (0); - return (-1); + if (strncmp((const char *)data, MAGIC_ELF, 4)) + { + fprintf(stderr, "%sError%s: No elf format\n", RED, ENDC); + exit(EXIT_FAILURE); + } } diff --git a/src/check_file_mode.c b/src/check_file_mode.c new file mode 100644 index 0000000..3f25aad --- /dev/null +++ b/src/check_file_mode.c @@ -0,0 +1,117 @@ +/* +** RopGadget - Dev v3.3 +** Jonathan Salwan - http://twitter.com/JonathanSalwan +** http://shell-storm.org +** 2011-10-18 +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "ropgadget.h" + +static void set_all_flag(void) +{ + flag_sectheader = 0; + flag_progheader = 0; + flag_elfheader = 0; + flag_symtab = 0; + flag_g = 0; + syntaxcode.flag_pysyn = 1; /* python syntax by default */ + syntaxcode.flag_csyn = 0; + syntaxcode.flag_phpsyn = 0; + syntaxcode.flag_perlsyn = 0; + limitmode.flag = 0; + limitmode.value = -1; /* default unlimited */ + opcode_mode.flag = 0; + stringmode.flag = 0; + bind_mode.flag = 0; + asm_mode.flag = 0; + mapmode.flag = 0; +} + +static void check_all_flag(char **argv) +{ + check_allheader_mode(argv); + check_elfheader_mode(argv); + check_progheader_mode(argv); + check_sectheader_mode(argv); + check_symtab_mode(argv); + check_bind_mode(argv); + check_filtre_mode(argv); + check_only_mode(argv); + check_opcode_mode(argv); + check_asm_mode(argv); + check_importsc_mode(argv); + check_syntax_mode(argv); + check_limit_mode(argv); + check_string_mode(argv); + check_map_mode(argv); + check_g_mode(argv); +} + +static unsigned char *save_bin_in_memory(char *file) +{ + int fd; + unsigned char *data; + struct stat filestat; + + fd = xopen(file, O_RDONLY, 0644); + stat(file, &filestat); + filemode.size = filestat.st_size; + filemode.file = file; + data = xmalloc(filemode.size * sizeof(char)); + read(fd, data, filemode.size); + pMapElf = xmmap(0, filemode.size, PROT_READ, MAP_SHARED, fd, 0); + filemode.data = data; + pElf_Header = (Elf32_Ehdr *)data; + pElf32_Shdr = (Elf32_Shdr *)((char *)data + pElf_Header->e_shoff); + pElf32_Phdr = (Elf32_Phdr *)((char *)data + pElf_Header->e_phoff); + close(fd); + + return (data); +} + +void check_file_mode(char **argv) +{ + unsigned char *data; + int i = 0; + + while (argv[i] != NULL) + { + if (!strcmp(argv[i], "-file")) + { + if (argv[i + 1] != NULL && argv[i + 1][0] != '\0') + { + data = save_bin_in_memory(argv[i + 1]); + check_elf_format(data); + check_arch_supported(); + set_all_flag(); + save_section(); /* save all sections in list_sections */ + save_symbols(data); /* save all symbols in list_symbols */ + check_all_flag(argv); + check_option(); + /*search_gadgets(data, filemode.size);*/ /* let's go */ + free(data); + exit(EXIT_SUCCESS); /* end */ + } + else + { + fprintf(stderr, "%sSyntax%s: -file \n", RED, ENDC); + exit(EXIT_FAILURE); + } + } + i++; + } +} diff --git a/src/check_filter_mode.c b/src/check_filter_mode.c index 7fa8f9c..61739bc 100644 --- a/src/check_filter_mode.c +++ b/src/check_filter_mode.c @@ -50,9 +50,9 @@ void check_filtre_mode(char **argv) } else { - fprintf(stderr, "Syntax: -filtre \n\n"); - fprintf(stderr, "Ex: -filter \"dec %%edx\"\n"); - fprintf(stderr, " -filter \"pop %%eax\" -filter \"dec\"\n"); + fprintf(stderr, "%sSyntax%s: -filtre \n", RED, ENDC); + fprintf(stderr, "%sEx%s: -filter \"dec %%edx\"\n", RED, ENDC); + fprintf(stderr, " -filter \"pop %%eax\" -filter \"dec\"\n"); exit(EXIT_FAILURE); } } diff --git a/src/check_g_mode.c b/src/check_g_mode.c index 245e29d..07870b9 100644 --- a/src/check_g_mode.c +++ b/src/check_g_mode.c @@ -21,88 +21,16 @@ #include "ropgadget.h" -static void set_all_flag(void) -{ - flag_sectheader = 0; - flag_progheader = 0; - flag_elfheader = 0; - flag_symtab = 0; - syntaxcode.flag_pysyn = 1; /* python syntax by default */ - syntaxcode.flag_csyn = 0; - syntaxcode.flag_phpsyn = 0; - syntaxcode.flag_perlsyn = 0; - limitmode.flag = 0; - limitmode.value = -1; /* default unlimited */ - opcode_mode.flag = 0; - stringmode.flag = 0; - bind_mode.flag = 0; - asm_mode.flag = 0; - mapmode.flag = 0; -} - -static void check_all_flag(char **argv) -{ - check_allheader_mode(argv); - check_elfheader_mode(argv); - check_progheader_mode(argv); - check_sectheader_mode(argv); - check_symtab_mode(argv); - check_bind_mode(argv); - check_filtre_mode(argv); - check_only_mode(argv); - check_opcode_mode(argv); - check_asm_mode(argv); - check_importsc_mode(argv); - check_syntax_mode(argv); - check_limit_mode(argv); - check_string_mode(argv); - check_map_mode(argv); -} - void check_g_mode(char **argv) { - struct stat filestat; - unsigned char *data; - unsigned int size; int i = 0; while (argv[i] != NULL) { - if (!strcmp(argv[i], "-g")) + if (!strcmp(argv[i], "-g") && flag_g == 0) { - if (argv[i + 1] != NULL && argv[i + 1][0] != '\0') - { - pOption.gfile = argv[i + 1]; - if((stat(pOption.gfile, &filestat)) == -1) - { - perror("stat"); - exit(EXIT_FAILURE); - } - set_all_flag(); - size = filestat.st_size; - pOption.size_file = size; - data = save_bin_data(pOption.gfile, size); - pElf_Header = (Elf32_Ehdr *)data; - pElf32_Shdr = (Elf32_Shdr *)((char *)data + pElf_Header->e_shoff); - pElf32_Phdr = (Elf32_Phdr *)((char *)data + pElf_Header->e_phoff); - - if (check_elf_format(data) == -1) - no_elf_format(); - if (check_arch_supported() == -1) - no_arch_supported(); - - save_section(); /* save all sections in list_sections */ - save_symbols(data); /* save all symbols in list_symbols */ - check_all_flag(argv); - search_gadgets(data, size); /* let's go */ - free(data); - exit(EXIT_SUCCESS); - } - else - { - fprintf(stderr, "Syntax: -g \n"); - exit(EXIT_FAILURE); - } + search_gadgets(filemode.data, filemode.size); + flag_g = 1; } i++; } diff --git a/src/check_importsc_mode.c b/src/check_importsc_mode.c index a3ace41..6cea65e 100644 --- a/src/check_importsc_mode.c +++ b/src/check_importsc_mode.c @@ -80,8 +80,8 @@ void check_importsc_mode(char **argv) } else { - fprintf(stderr, "Syntax: -importsc \n\n"); - fprintf(stderr, "Ex: -importsc \"\\x6a\\x0b\\x58\\x99\\x52\\x68\\x2f\\x2f\\x73\\x68\\x68\\x2f\\x62\\x69\\x6e\\x89\\xe3\\x31\\xc9\\xcd\\x80\"\n"); + fprintf(stderr, "%sSyntax%s: -importsc \n", RED, ENDC); + fprintf(stderr, "%sEx%s: -importsc \"\\x6a\\x02\\x58\\xcd\\x80\\xeb\\xf9\"\n", RED, ENDC); exit(EXIT_FAILURE); } } diff --git a/src/check_limit_mode.c b/src/check_limit_mode.c index 2783587..e931a21 100644 --- a/src/check_limit_mode.c +++ b/src/check_limit_mode.c @@ -35,14 +35,14 @@ void check_limit_mode(char **argv) limitmode.value = atoi(argv[i + 1]); if (limitmode.value < 0 || limitmode.value > 0xfffe) { - fprintf(stderr, "Error value\n"); + fprintf(stderr, "%sError%s: limit value\n", RED, ENDC); exit(EXIT_FAILURE); } } else { - fprintf(stderr, "Syntax: -limit \n\n"); - fprintf(stderr, "Ex: -limit 100\n"); + fprintf(stderr, "%sSyntax%s: -limit \n", RED, ENDC); + fprintf(stderr, "%sEx%s: -limit 100\n", RED, ENDC); exit(EXIT_FAILURE); } } diff --git a/src/check_map_mode.c b/src/check_map_mode.c index 0c147b5..9b9300f 100644 --- a/src/check_map_mode.c +++ b/src/check_map_mode.c @@ -51,7 +51,7 @@ static Elf32_Addr get_start(char *str) addr = (Elf32_Addr)strtol(str, NULL, 16); base_addr = (pElf32_Phdr->p_vaddr - pElf32_Phdr->p_offset); - end_addr = (pElf32_Phdr->p_vaddr - pElf32_Phdr->p_offset) + pOption.size_file; + end_addr = (pElf32_Phdr->p_vaddr - pElf32_Phdr->p_offset) + filemode.size; if (addr < base_addr) { fprintf(stderr, "Error value for -map option\n"); @@ -75,7 +75,7 @@ static Elf32_Addr get_end(char *str) addr = (Elf32_Addr)strtol(str, NULL, 16); base_addr = (pElf32_Phdr->p_vaddr - pElf32_Phdr->p_offset); - end_addr = (pElf32_Phdr->p_vaddr - pElf32_Phdr->p_offset) + pOption.size_file; + end_addr = (pElf32_Phdr->p_vaddr - pElf32_Phdr->p_offset) + filemode.size; if (addr > end_addr) { fprintf(stderr, "Error value for -map option\n"); @@ -92,7 +92,7 @@ static void check_error_value(void) Elf32_Addr end_addr; base_addr = (pElf32_Phdr->p_vaddr - pElf32_Phdr->p_offset); - end_addr = (pElf32_Phdr->p_vaddr - pElf32_Phdr->p_offset) + pOption.size_file; + end_addr = (pElf32_Phdr->p_vaddr - pElf32_Phdr->p_offset) + filemode.size; if (mapmode.addr_start > mapmode.addr_end) { fprintf(stderr, "Error value for -map option\n"); @@ -118,8 +118,8 @@ void check_map_mode(char **argv) } else { - fprintf(stderr, "Syntax: -map \n\n"); - fprintf(stderr, "Ex: -map 0x08040000-0x08045000\n"); + fprintf(stderr, "%sSyntax%s: -map \n", RED, ENDC); + fprintf(stderr, "%sEx%s: -map 0x08040000-0x08045000\n", RED, ENDC); exit(EXIT_FAILURE); } } diff --git a/src/check_only_mode.c b/src/check_only_mode.c index 2bb360f..28b7323 100644 --- a/src/check_only_mode.c +++ b/src/check_only_mode.c @@ -50,9 +50,9 @@ void check_only_mode(char **argv) } else { - fprintf(stderr, "Syntax: -only \n\n"); - fprintf(stderr, "Ex: -only \"dec %%edx\"\n"); - fprintf(stderr, " -only \"pop %%eax\" -only \"dec\"\n"); + fprintf(stderr, "%sSyntax%s: -only \n", RED, ENDC); + fprintf(stderr, "%sEx%s: -only \"dec %%edx\"\n", RED, ENDC); + fprintf(stderr, " -only \"pop %%eax\" -only \"dec\"\n"); exit(EXIT_FAILURE); } } diff --git a/src/check_opcode_mode.c b/src/check_opcode_mode.c index f889300..a89c137 100644 --- a/src/check_opcode_mode.c +++ b/src/check_opcode_mode.c @@ -33,8 +33,8 @@ int size_opcode(char *str) } if (cpt == 0) { - fprintf(stderr, "Syntax: -opcode \n\n"); - fprintf(stderr, "Ex: -opcode \"\\xcd\\x80\"\n"); + fprintf(stderr, "%sSyntax%s: -opcode \n", RED, ENDC); + fprintf(stderr, "%sEx%s: -opcode \"\\xcd\\x80\"\n", RED, ENDC); exit(EXIT_FAILURE); } return (cpt); @@ -98,8 +98,8 @@ void check_opcode_mode(char **argv) } else { - fprintf(stderr, "Syntax: -opcode \n\n"); - fprintf(stderr, "Ex: -opcode \"\\xcd\\x80\"\n"); + fprintf(stderr, "%sSyntax%s: -opcode \n", RED, ENDC); + fprintf(stderr, "%sEx%s: -opcode \"\\xcd\\x80\"\n", RED, ENDC); exit(EXIT_FAILURE); } } diff --git a/src/check_option.c b/src/check_option.c new file mode 100644 index 0000000..2529e6e --- /dev/null +++ b/src/check_option.c @@ -0,0 +1,42 @@ +/* +** RopGadget - Dev v3.3 +** Jonathan Salwan - http://twitter.com/JonathanSalwan +** http://shell-storm.org +** 2011-10-18 +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "ropgadget.h" + +static void help_option(void) +{ + fprintf(stderr, "%sError%s: No options found\n", RED, ENDC); + fprintf(stderr, " Please use the following options\n\n"); + fprintf(stderr, " %s-g%s Search gadgets and make payload\n", RED, ENDC); + fprintf(stderr, " %s-elfheader%s Display ELF Header\n", RED, ENDC); + fprintf(stderr, " %s-progheader%s Display Program Header\n", RED, ENDC); + fprintf(stderr, " %s-sectheader%s Display Section Header\n", RED, ENDC); + fprintf(stderr, " %s-symtab%s Display Symbols Table\n", RED, ENDC); + fprintf(stderr, " %s-allheader%s Display ELF/Program/Section/Symbols Header\n", RED, ENDC); + exit(EXIT_FAILURE); +} + +void check_option() +{ + if (flag_sectheader == 0 && flag_progheader == 0 && + flag_elfheader == 0 && flag_symtab == 0 && flag_g == 0) + help_option(); +} diff --git a/src/check_string_mode.c b/src/check_string_mode.c index 373544a..2cb4bbf 100644 --- a/src/check_string_mode.c +++ b/src/check_string_mode.c @@ -37,8 +37,8 @@ void check_string_mode(char **argv) } else { - fprintf(stderr, "Syntax: -string \n\n"); - fprintf(stderr, "Ex: -string \"key\"\n"); + fprintf(stderr, "%sSyntax%s: -string \n", RED, ENDC); + fprintf(stderr, "%sEx%s: -string \"key\"\n", RED, ENDC); exit(EXIT_FAILURE); } } diff --git a/src/check_symtab_mode.c b/src/check_symtab_mode.c index e2fbc05..203b80c 100644 --- a/src/check_symtab_mode.c +++ b/src/check_symtab_mode.c @@ -32,7 +32,7 @@ void display_symtab(void) fprintf(stdout, "%sSymbols Table\n", YELLOW); fprintf(stdout, "============================================================%s\n\n", ENDC); if (tmp == NULL) - fprintf(stderr, "%s/!\\ no symbols in %s%s\n", RED, pOption.gfile, ENDC); + fprintf(stderr, "%s/!\\ no symbols in %s%s\n", RED, filemode.file, ENDC); else { fprintf(stderr, "%sidx addr\tsize\t name%s\n", GREEN, ENDC); diff --git a/src/check_v_mode.c b/src/check_v_mode.c index e4c961f..519293a 100644 --- a/src/check_v_mode.c +++ b/src/check_v_mode.c @@ -29,7 +29,7 @@ void check_v_mode(char **argv) { if (!strcmp(argv[i], "-v")) { - fprintf(stdout, "RopGadget - Dev v3.3\n"); + fprintf(stdout, "%sRopGadget%s - Dev v3.3\n", RED, ENDC); fprintf(stdout, "Jonathan Salwan - twitter @JonathanSalwan\n"); fprintf(stdout, "http://www.shell-storm.org\n"); exit(EXIT_SUCCESS); diff --git a/src/main.c b/src/main.c index 9a3c1ca..c50871f 100644 --- a/src/main.c +++ b/src/main.c @@ -24,8 +24,7 @@ int main(__attribute__ ((unused))int argc, char **argv) { check_v_mode(argv); - check_g_mode(argv); - check_d_mode(argv); + check_file_mode(argv); syntax(argv[0]); return(0); diff --git a/src/syntax.c b/src/syntax.c index 18245da..46e010f 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -23,12 +23,18 @@ void syntax(char *str) { - fprintf(stderr, "Syntax : %s