Rizin
unix-like reverse engineering framework and cli tools
cmd_flirt.c File Reference
#include <rz_core.h>
#include <rz_cons.h>
#include <rz_flirt.h>

Go to the source code of this file.

Functions

RZ_IPI RzCmdStatus rz_flirt_create_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flirt_dump_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flirt_scan_handler (RzCore *core, int argc, const char **argv)
 

Function Documentation

◆ rz_flirt_create_handler()

RZ_IPI RzCmdStatus rz_flirt_create_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 9 of file cmd_flirt.c.

9  {
10  const char *filename = argv[1];
11  ut32 written_nodes = 0;
12  if (!rz_core_flirt_create_file(core, filename, &written_nodes)) {
13  RZ_LOG_ERROR("failed to create FLIRT file '%s'\n", filename);
14  return RZ_CMD_STATUS_ERROR;
15  }
16  rz_cons_printf("%u FLIRT signatures were written in '%s'\n", written_nodes, filename);
17  return RZ_CMD_STATUS_OK;
18 }
RZ_API int rz_cons_printf(const char *format,...)
Definition: cons.c:1202
RZ_API bool rz_core_flirt_create_file(RZ_NONNULL RzCore *core, RZ_NONNULL const char *output_file, RZ_NULLABLE ut32 *written_nodes)
Generates a new FLIRT file from a given RzCore structure.
Definition: csign.c:431
uint32_t ut32
const char * filename
Definition: ioapi.h:137
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
@ RZ_CMD_STATUS_OK
command handler exited in the right way
Definition: rz_cmd.h:24
@ RZ_CMD_STATUS_ERROR
command handler had issues while running (e.g. allocation error, etc.)
Definition: rz_cmd.h:26
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58

References argv, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_printf(), rz_core_flirt_create_file(), and RZ_LOG_ERROR.

Referenced by rzshell_cmddescs_init().

◆ rz_flirt_dump_handler()

RZ_IPI RzCmdStatus rz_flirt_dump_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 20 of file cmd_flirt.c.

20  {
22  return RZ_CMD_STATUS_OK;
23 }
RZ_API bool rz_core_flirt_dump_file(RZ_NONNULL const char *flirt_file)
Dumps the contents of a FLIRT file.
Definition: csign.c:372

References argv, RZ_CMD_STATUS_OK, and rz_core_flirt_dump_file().

Referenced by rzshell_cmddescs_init().

◆ rz_flirt_scan_handler()

RZ_IPI RzCmdStatus rz_flirt_scan_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 25 of file cmd_flirt.c.

25  {
26  int new, old;
27  int depth = rz_config_get_i(core->config, "dir.depth");
28  const char *arch = rz_config_get(core->config, "asm.arch");
29  char *file = NULL;
30  RzListIter *iter = NULL;
31  RzList *files = rz_file_globsearch(argv[1], depth);
33 
34  old = rz_flag_count(core->flags, "flirt");
35  rz_list_foreach (files, iter, file) {
36  rz_sign_flirt_apply(core->analysis, file, arch_id);
37  }
39  new = rz_flag_count(core->flags, "flirt");
40 
41  rz_cons_printf("Found %d FLIRT signatures via %s\n", new - old, argv[1]);
42  return RZ_CMD_STATUS_OK;
43 }
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:119
RZ_API RZ_BORROW const char * rz_config_get(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:75
#define NULL
Definition: cris-opc.c:27
RZ_API ut8 rz_core_flirt_arch_from_name(RZ_NONNULL const char *arch)
Returns the FLIRT arch id from a given arch name Returns RZ_FLIRT_SIG_ARCH_ANY if name is not found.
Definition: csign.c:148
cs_arch arch
Definition: cstool.c:13
checking print the parsed form of the magic use in n conjunction with m to debug a new magic file n before installing it n output MIME type special files
Definition: file_opts.h:46
RZ_API int rz_flag_count(RzFlag *f, const char *glob)
Definition: flag.c:776
uint8_t ut8
Definition: lh5801.h:11
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
RZ_API RzList * rz_file_globsearch(const char *globbed_path, int maxdepth)
Definition: file.c:1263
RZ_API bool rz_sign_flirt_apply(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL const char *flirt_file, ut8 expected_arch)
Parses the FLIRT file and applies the signatures.
Definition: flirt.c:1289
Definition: gzappend.c:170
RzAnalysis * analysis
Definition: rz_core.h:322
RzFlag * flags
Definition: rz_core.h:330
RzConfig * config
Definition: rz_core.h:300

References rz_core_t::analysis, arch, argv, rz_core_t::config, files, rz_core_t::flags, NULL, RZ_CMD_STATUS_OK, rz_config_get(), rz_config_get_i(), rz_cons_printf(), rz_core_flirt_arch_from_name(), rz_file_globsearch(), rz_flag_count(), rz_list_free(), and rz_sign_flirt_apply().

Referenced by rzshell_cmddescs_init().