mirror of
https://github.com/JonathanSalwan/ROPgadget
synced 2026-06-08 11:25:23 +00:00
Update all core [-file add] [-d deleted]
This commit is contained in:
@@ -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 \
|
||||
|
||||
+13
-14
@@ -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 **);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,9 +145,9 @@ void check_asm_mode(char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Syntax: -asm <instructions>\n\n");
|
||||
fprintf(stderr, "Ex: -asm \"xor %%ebx, %%eax\"\n");
|
||||
fprintf(stderr, "Ex: -asm \"int \\$0x80\"\n");
|
||||
fprintf(stderr, "%sSyntax%s: -asm <instructions>\n", RED, ENDC);
|
||||
fprintf(stderr, "%sEx%s: -asm \"xor %%ebx, %%eax\"\n", RED, ENDC);
|
||||
fprintf(stderr, " -asm \"int \\$0x80\"\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,12 +35,13 @@ void check_bind_mode(char **argv)
|
||||
{
|
||||
if (argv[i + 1] == NULL)
|
||||
{
|
||||
fprintf(stderr, "Error: syntax -port <port>\n");
|
||||
fprintf(stderr, "%sSyntax%s: -port <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]);
|
||||
|
||||
@@ -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 <binaire>\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
+6
-10
@@ -22,15 +22,11 @@
|
||||
#include <stdio.h>
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <binary>\n", RED, ENDC);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -50,9 +50,9 @@ void check_filtre_mode(char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Syntax: -filtre <word>\n\n");
|
||||
fprintf(stderr, "Ex: -filter \"dec %%edx\"\n");
|
||||
fprintf(stderr, " -filter \"pop %%eax\" -filter \"dec\"\n");
|
||||
fprintf(stderr, "%sSyntax%s: -filtre <word>\n", RED, ENDC);
|
||||
fprintf(stderr, "%sEx%s: -filter \"dec %%edx\"\n", RED, ENDC);
|
||||
fprintf(stderr, " -filter \"pop %%eax\" -filter \"dec\"\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-75
@@ -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 <binaire>\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
search_gadgets(filemode.data, filemode.size);
|
||||
flag_g = 1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@ void check_importsc_mode(char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Syntax: -importsc <shellcode>\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 <shellcode>\n", RED, ENDC);
|
||||
fprintf(stderr, "%sEx%s: -importsc \"\\x6a\\x02\\x58\\xcd\\x80\\xeb\\xf9\"\n", RED, ENDC);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <value>\n\n");
|
||||
fprintf(stderr, "Ex: -limit 100\n");
|
||||
fprintf(stderr, "%sSyntax%s: -limit <value>\n", RED, ENDC);
|
||||
fprintf(stderr, "%sEx%s: -limit 100\n", RED, ENDC);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <start-end>\n\n");
|
||||
fprintf(stderr, "Ex: -map 0x08040000-0x08045000\n");
|
||||
fprintf(stderr, "%sSyntax%s: -map <start-end>\n", RED, ENDC);
|
||||
fprintf(stderr, "%sEx%s: -map 0x08040000-0x08045000\n", RED, ENDC);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ void check_only_mode(char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Syntax: -only <keyword>\n\n");
|
||||
fprintf(stderr, "Ex: -only \"dec %%edx\"\n");
|
||||
fprintf(stderr, " -only \"pop %%eax\" -only \"dec\"\n");
|
||||
fprintf(stderr, "%sSyntax%s: -only <keyword>\n", RED, ENDC);
|
||||
fprintf(stderr, "%sEx%s: -only \"dec %%edx\"\n", RED, ENDC);
|
||||
fprintf(stderr, " -only \"pop %%eax\" -only \"dec\"\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ int size_opcode(char *str)
|
||||
}
|
||||
if (cpt == 0)
|
||||
{
|
||||
fprintf(stderr, "Syntax: -opcode <opcode>\n\n");
|
||||
fprintf(stderr, "Ex: -opcode \"\\xcd\\x80\"\n");
|
||||
fprintf(stderr, "%sSyntax%s: -opcode <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 <opcode>\n\n");
|
||||
fprintf(stderr, "Ex: -opcode \"\\xcd\\x80\"\n");
|
||||
fprintf(stderr, "%sSyntax%s: -opcode <opcode>\n", RED, ENDC);
|
||||
fprintf(stderr, "%sEx%s: -opcode \"\\xcd\\x80\"\n", RED, ENDC);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -37,8 +37,8 @@ void check_string_mode(char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Syntax: -string <string>\n\n");
|
||||
fprintf(stderr, "Ex: -string \"key\"\n");
|
||||
fprintf(stderr, "%sSyntax%s: -string <string>\n", RED, ENDC);
|
||||
fprintf(stderr, "%sEx%s: -string \"key\"\n", RED, ENDC);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+1
-2
@@ -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);
|
||||
|
||||
+21
-20
@@ -23,12 +23,18 @@
|
||||
|
||||
void syntax(char *str)
|
||||
{
|
||||
fprintf(stderr, "Syntax : %s <option> <binary> [FLAGS]\n\n", str);
|
||||
fprintf(stderr, "Options: \n");
|
||||
fprintf(stderr, " -d Dump Hexadecimal\n");
|
||||
fprintf(stderr, "%sSyntax%s: %s <option> <binary> [FLAGS]\n\n", RED, ENDC, str);
|
||||
fprintf(stderr, "%sOptions%s: \n", RED, ENDC);
|
||||
fprintf(stderr, " -file Load file\n");
|
||||
fprintf(stderr, " -g Search gadgets and make payload\n");
|
||||
fprintf(stderr, " -v Version\n");
|
||||
fprintf(stderr, "Flags: \n");
|
||||
fprintf(stderr, " -elfheader Display ELF Header\n");
|
||||
fprintf(stderr, " -progheader Display Program Header\n");
|
||||
fprintf(stderr, " -sectheader Display Section Header\n");
|
||||
fprintf(stderr, " -symtab Display Symbols Table\n");
|
||||
fprintf(stderr, " -allheader Display ELF/Program/Section/Symbols Header\n");
|
||||
fprintf(stderr, " -v Version\n\n");
|
||||
|
||||
fprintf(stderr, "%sFlags%s: \n", RED, ENDC);
|
||||
fprintf(stderr, " -bind Set this flag for make a bind shellcode (optional) (Default local exploit)\n");
|
||||
fprintf(stderr, " -port <port> Set a listen port, optional (Default 1337)\n");
|
||||
fprintf(stderr, " -importsc <shellcode> Make payload and convert your shellcode in ROP payload\n");
|
||||
@@ -38,22 +44,17 @@ void syntax(char *str)
|
||||
fprintf(stderr, " -string <string> Search a specific hard string on read segment ('?' any char)\n");
|
||||
fprintf(stderr, " -asm <instructions> Search a specific instructions on exec segment\n");
|
||||
fprintf(stderr, " -limit <value> Limit the display of gadgets\n");
|
||||
fprintf(stderr, " -map <start-end> Search gadgets on exec segment between two address\n");
|
||||
fprintf(stderr, " -elfheader Display ELF Header before searching gadgets\n");
|
||||
fprintf(stderr, " -progheader Display Program Header before searching gadgets\n");
|
||||
fprintf(stderr, " -sectheader Display Section Header before searching gadgets\n");
|
||||
fprintf(stderr, " -symtab Display Symbols Table before searching gadgets\n");
|
||||
fprintf(stderr, " -allheader Display ELF/Program/Section/Symbols Header before searching gadgets\n\n");
|
||||
fprintf(stderr, " -map <start-end> Search gadgets on exec segment between two address\n\n");
|
||||
|
||||
fprintf(stderr, "Ex: %s -g ./smashme.bin -bind -port 8080\n", str);
|
||||
fprintf(stderr, " %s -g ./smashme.bin -importsc \"\\x6a\\x0b\\x58\\x99\\x52\\x68\\x2f\\x2f\\x73\\x68\\x68\\x2f\\x62\\x69\\x6e\\x89\\xe3\\x31\\xc9\\xcd\\x80\"\n", str);
|
||||
fprintf(stderr, " %s -g ./smashme.bin -filter \"add %%eax\" -filter \"dec\" -bind -port 8080\n", str);
|
||||
fprintf(stderr, " %s -g ./smashme.bin -only \"pop\" -filter \"eax\"\n", str);
|
||||
fprintf(stderr, " %s -g ./smashme.bin -opcode \"\\xcd\\x80\"\n", str);
|
||||
fprintf(stderr, " %s -g ./smashme.bin -asm \"xor %%eax,%%eax ; ret\"\n", str);
|
||||
fprintf(stderr, " %s -g ./smashme.bin -asm \"int \\$0x80\"\n", str);
|
||||
fprintf(stderr, " %s -g ./smashme.bin -string \"main\"\n", str);
|
||||
fprintf(stderr, " %s -g ./smashme.bin -string \"m?in\"\n", str);
|
||||
fprintf(stderr, "%sEx%s: %s -file ./smashme.bin -g -bind -port 8080\n", RED, ENDC, str);
|
||||
fprintf(stderr, " %s -file ./smashme.bin -g -importsc \"\\x6a\\x02\\x58\\xcd\\x80\\xeb\\xf9\"\n", str);
|
||||
fprintf(stderr, " %s -file ./smashme.bin -g -filter \"add %%eax\" -filter \"dec\" -bind -port 8080\n", str);
|
||||
fprintf(stderr, " %s -file ./smashme.bin -g -only \"pop\" -filter \"eax\"\n", str);
|
||||
fprintf(stderr, " %s -file ./smashme.bin -g -opcode \"\\xcd\\x80\"\n", str);
|
||||
fprintf(stderr, " %s -file ./smashme.bin -g -asm \"xor %%eax,%%eax ; ret\"\n", str);
|
||||
fprintf(stderr, " %s -file ./smashme.bin -g -asm \"int \\$0x80\"\n", str);
|
||||
fprintf(stderr, " %s -file ./smashme.bin -g -string \"main\"\n", str);
|
||||
fprintf(stderr, " %s -file ./smashme.bin -g -string \"m?in\"\n", str);
|
||||
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
Reference in New Issue
Block a user