Rizin
unix-like reverse engineering framework and cli tools
|
Go to the source code of this file.
Classes | |
struct | rz_flirt_tail_byte_t |
struct | rz_flirt_function_t |
struct | rz_flirt_module_t |
struct | rz_flirt_node_t |
struct | rz_flirt_sig_info_t |
struct | rz_flirt_pat_info_t |
struct | rz_flirt_info_t |
struct | rz_flirt_compressed_options_t |
struct | rz_signature_database_entry_t |
struct | rz_signature_db_t |
Typedefs | |
typedef struct rz_flirt_tail_byte_t | RzFlirtTailByte |
typedef struct rz_flirt_function_t | RzFlirtFunction |
typedef struct rz_flirt_module_t | RzFlirtModule |
typedef struct rz_flirt_node_t | RzFlirtNode |
typedef enum rz_flirt_file_type_t | RzFlirtFileType |
typedef struct rz_flirt_sig_info_t | RzFlirtSigInfo |
typedef struct rz_flirt_pat_info_t | RzFlirtPatInfo |
typedef struct rz_flirt_info_t | RzFlirtInfo |
typedef struct rz_flirt_compressed_options_t | RzFlirtCompressedOptions |
typedef struct rz_signature_database_entry_t | RzSigDBEntry |
typedef struct rz_signature_db_t | RzSigDb |
#define RZ_FLIRT_LIBRARY_NAME_DFL "Built with rizin " RZ_VERSION |
Definition at line 19 of file rz_flirt.h.
#define RZ_FLIRT_LIBRARY_NAME_MAX 0xFF |
Definition at line 18 of file rz_flirt.h.
#define RZ_FLIRT_MAX_PRELUDE_SIZE (32) |
Definition at line 20 of file rz_flirt.h.
#define RZ_FLIRT_NAME_MAX 1024 |
Definition at line 17 of file rz_flirt.h.
#define RZ_FLIRT_SIG_APP_16_BIT 0x0080 |
Definition at line 147 of file rz_flirt.h.
#define RZ_FLIRT_SIG_APP_32_BIT 0x0100 |
Definition at line 148 of file rz_flirt.h.
#define RZ_FLIRT_SIG_APP_64_BIT 0x0200 |
Definition at line 149 of file rz_flirt.h.
#define RZ_FLIRT_SIG_APP_ALL 0xFFFF |
Definition at line 150 of file rz_flirt.h.
#define RZ_FLIRT_SIG_APP_CONSOLE 0x0001 |
Definition at line 140 of file rz_flirt.h.
#define RZ_FLIRT_SIG_APP_DLL 0x0008 |
Definition at line 143 of file rz_flirt.h.
#define RZ_FLIRT_SIG_APP_DRV 0x0010 |
Definition at line 144 of file rz_flirt.h.
#define RZ_FLIRT_SIG_APP_EXE 0x0004 |
Definition at line 142 of file rz_flirt.h.
#define RZ_FLIRT_SIG_APP_GRAPHICS 0x0002 |
Definition at line 141 of file rz_flirt.h.
#define RZ_FLIRT_SIG_APP_MULTI_THREADED 0x0040 |
Definition at line 146 of file rz_flirt.h.
#define RZ_FLIRT_SIG_APP_SINGLE_THREADED 0x0020 |
Definition at line 145 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_AIXAR 0x01000000 |
Definition at line 127 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_ALL 0xFFFFFFFF |
Definition at line 128 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_AOUT 0x00100000 |
Definition at line 123 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_AR 0x00010000 |
Definition at line 119 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_BIN 0x00000004 |
Definition at line 105 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_COFF 0x00000400 |
Definition at line 113 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_DOS_COM 0x00800000 |
Definition at line 126 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_DOS_COM_OLD 0x00000002 |
Definition at line 104 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_DOS_EXE 0x00400000 |
Definition at line 125 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_DOS_EXE_OLD 0x00000001 |
Definition at line 103 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_DOSDRV 0x00000008 |
Definition at line 106 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_ELF 0x00040000 |
Definition at line 121 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_INTELHEX 0x00000020 |
Definition at line 108 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_LE 0x00000100 |
Definition at line 111 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_LOADER 0x00020000 |
Definition at line 120 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_LX 0x00000080 |
Definition at line 110 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_MOSHEX 0x00000040 |
Definition at line 109 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_NE 0x00000010 |
Definition at line 107 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_NLM 0x00000200 |
Definition at line 112 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_OMF 0x00001000 |
Definition at line 115 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_OMFLIB 0x00008000 |
Definition at line 118 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_PE 0x00000800 |
Definition at line 114 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_PILOT 0x00200000 |
Definition at line 124 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_SREC 0x00002000 |
Definition at line 116 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_W32RUN 0x00080000 |
Definition at line 122 of file rz_flirt.h.
#define RZ_FLIRT_SIG_FILE_ZIP 0x00004000 |
Definition at line 117 of file rz_flirt.h.
#define RZ_FLIRT_SIG_OS_ALL 0xFFFF |
Definition at line 137 of file rz_flirt.h.
#define RZ_FLIRT_SIG_OS_MSDOS 0x0001 |
Definition at line 131 of file rz_flirt.h.
#define RZ_FLIRT_SIG_OS_NETWARE 0x0008 |
Definition at line 134 of file rz_flirt.h.
#define RZ_FLIRT_SIG_OS_OS2 0x0004 |
Definition at line 133 of file rz_flirt.h.
#define RZ_FLIRT_SIG_OS_OTHER 0x0020 |
Definition at line 136 of file rz_flirt.h.
#define RZ_FLIRT_SIG_OS_UNIX 0x0010 |
Definition at line 135 of file rz_flirt.h.
#define RZ_FLIRT_SIG_OS_WIN 0x0002 |
Definition at line 132 of file rz_flirt.h.
typedef struct rz_flirt_compressed_options_t RzFlirtCompressedOptions |
typedef enum rz_flirt_file_type_t RzFlirtFileType |
typedef struct rz_flirt_function_t RzFlirtFunction |
typedef struct rz_flirt_info_t RzFlirtInfo |
typedef struct rz_flirt_module_t RzFlirtModule |
typedef struct rz_flirt_node_t RzFlirtNode |
typedef struct rz_flirt_pat_info_t RzFlirtPatInfo |
typedef struct rz_flirt_sig_info_t RzFlirtSigInfo |
typedef struct rz_flirt_tail_byte_t RzFlirtTailByte |
typedef struct rz_signature_db_t RzSigDb |
typedef struct rz_signature_database_entry_t RzSigDBEntry |
enum rz_flirt_file_type_t |
Enumerator | |
---|---|
RZ_FLIRT_FILE_TYPE_UNKNOWN | unknown type |
RZ_FLIRT_FILE_TYPE_SIG |
|
RZ_FLIRT_FILE_TYPE_PAT |
|
Definition at line 191 of file rz_flirt.h.
Definition at line 185 of file rz_flirt.h.
enum rz_flirt_sig_arch_t |
Definition at line 23 of file rz_flirt.h.
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.
analysis | The RzAnalysis structure |
flirt_file | The FLIRT file to parse |
Definition at line 1289 of file flirt.c.
References node_match_functions(), NULL, rz_buf_free(), rz_buf_new_slurp(), RZ_FLIRT_NODE_OPTIMIZE_MAX, RZ_FLIRT_SIG_ARCH_ANY, RZ_LOG_ERROR, rz_return_val_if_fail, rz_sign_flirt_node_free(), rz_sign_flirt_parse_compressed_pattern_from_buffer(), rz_sign_flirt_parse_string_pattern_from_buffer(), RZ_STR_ISEMPTY, RZ_STR_ISNOTEMPTY, and rz_str_lchr().
Referenced by rz_core_analysis_sigdb_apply(), and rz_flirt_scan_handler().
RZ_API void rz_sign_flirt_info_fini | ( | RZ_NULLABLE RzFlirtInfo * | info | ) |
Frees an RzFlirtInfo struct elements without freeing the pointer.
RzFlirtInfo | The RzFlirtInfo elements to be freed |
Definition at line 315 of file flirt.c.
References free(), info(), memset(), RZ_FLIRT_FILE_TYPE_SIG, and rz_bin_info_t::type.
Referenced by rz_core_flirt_dump_file(), and sigdb_signature_resolve_details().
RZ_API ut32 rz_sign_flirt_node_count_nodes | ( | RZ_NONNULL const RzFlirtNode * | node | ) |
Counts the number of FLIRT signatures in the node.
flirt_file | The FLIRT node to use to count |
Definition at line 1334 of file flirt.c.
References count, rz_list_length(), rz_return_val_if_fail, and rz_sign_flirt_node_count_nodes().
Referenced by rz_core_flirt_create_file(), rz_sign_flirt_node_count_nodes(), rz_sign_flirt_parse_compressed_pattern_from_buffer(), rz_sign_flirt_parse_string_pattern_from_buffer(), and rz_sign_flirt_write_compressed_pattern_to_buffer().
RZ_API void rz_sign_flirt_node_free | ( | RZ_NULLABLE RzFlirtNode * | node | ) |
Frees an RzFlirtNode struct.
RzFlirtNode | The RzFlirtNode to be freed |
Definition at line 299 of file flirt.c.
References free(), and rz_list_free().
Referenced by flirt_create_child(), flirt_create_child_from_analysis(), flirt_node_optimize(), flirt_node_shorten_and_insert(), flirt_pat_parse_line(), parse_tree(), rz_core_flirt_convert_file(), rz_core_flirt_create_file(), rz_core_flirt_dump_file(), rz_sign_flirt_apply(), rz_sign_flirt_node_new(), rz_sign_flirt_parse_string_pattern_from_buffer(), and sigdb_signature_resolve_details().
RZ_API RZ_OWN RzFlirtNode* rz_sign_flirt_node_new | ( | RZ_NONNULL RzAnalysis * | analysis, |
ut32 | optimization | ||
) |
Generates the FLIRT signatures and returns an RzFlirtNode.
analysis | The RzAnalysis structure to derive the signatures. |
optimization | Optimization to apply after creation of the flatten nodes. |
Definition at line 355 of file create.c.
References rz_analysis_function_t::addr, fail, flirt_compare_node(), flirt_create_child_from_analysis(), flirt_node_optimize(), free(), i, is_valid_mask_prelude(), malloc(), mask, rz_analysis_function_t::name, NULL, PFMT64x, root, RZ_ANALYSIS_FCN_TYPE_FCN, RZ_ANALYSIS_FCN_TYPE_LOC, RZ_ANALYSIS_FCN_TYPE_SYM, rz_analysis_function_linear_size(), rz_analysis_mask(), RZ_FLIRT_NODE_OPTIMIZE_MAX, RZ_FLIRT_NODE_OPTIMIZE_NONE, RZ_FREE, rz_list_append(), rz_list_length(), rz_list_newf(), rz_list_sort(), RZ_LOG_ERROR, RZ_LOG_WARN, RZ_NEW0, rz_return_val_if_fail, rz_sign_flirt_node_free(), ST32_MAX, starts_with_flag, rz_analysis_function_t::type, and ut64().
Referenced by rz_core_flirt_create_file().
RZ_API RZ_OWN RzFlirtNode* rz_sign_flirt_parse_compressed_pattern_from_buffer | ( | RZ_NONNULL RzBuffer * | flirt_buf, |
ut8 | expected_arch, | ||
RZ_NULLABLE RzFlirtInfo * | info | ||
) |
Parses the RzBuffer containing a FLIRT structure and returns an RzFlirtNode.
Parses the RzBuffer containing a FLIRT structure and returns an RzFlirtNode if expected_arch matches the id or RZ_FLIRT_SIG_ARCH_ANY is set.
flirt_buf | The buffer to read |
expected_arch | The expected arch to be used for the buffer |
info | Pointer to a RzFlirtInfo that can be used to get info about the sig file |
Definition at line 1136 of file flirt.c.
References parse_status_t::buffer, test-lz4-list::exit, flirt_parse_version(), free(), header, IDASIG_FEATURE_COMPRESSED, info(), malloc(), NULL, parse_tree(), parse_v10_header(), parse_v5_header(), parse_v6_v7_header(), parse_v8_v9_header(), rz_buf_free(), rz_buf_new_with_pointers(), rz_buf_read(), rz_buf_size(), rz_buf_tell(), RZ_FLIRT_FILE_TYPE_SIG, RZ_FLIRT_SIG_ARCH_ANY, RZ_FREE, rz_inflate(), rz_inflate_ignore_header(), RZ_LOG_ERROR, RZ_NEW0, rz_return_val_if_fail, rz_sign_flirt_node_count_nodes(), rz_bin_info_t::type, and parse_status_t::version.
Referenced by rz_core_flirt_convert_file(), rz_core_flirt_dump_file(), and rz_sign_flirt_apply().
RZ_API RZ_OWN bool rz_sign_flirt_parse_header_compressed_pattern_from_buffer | ( | RZ_NONNULL RzBuffer * | flirt_buf, |
RZ_NONNULL RzFlirtInfo * | info | ||
) |
Parses the RzBuffer containing a FLIRT structure and returns an RzFlirtInfo.
Parses the RzBuffer containing a FLIRT structure and returns an RzFlirtNode if expected_arch matches the id or RZ_FLIRT_SIG_ARCH_ANY is set.
flirt_buf | The buffer to read |
expected_arch | The expected arch to be used for the buffer |
info | Pointer to a RzFlirtInfo that can be used to get info about the sig file |
Definition at line 1062 of file flirt.c.
References idasig_v5_t::arch, test-lz4-list::exit, free(), info(), idasig_v5_t::library_name_len, idasig_v5_t::magic, malloc(), idasig_v6_v7_t::n_functions, NULL, idasig_v5_t::old_n_functions, parse_v10_header(), parse_v5_header(), parse_v6_v7_header(), parse_v8_v9_header(), rz_buf_read(), RZ_FLIRT_FILE_TYPE_SIG, RZ_LOG_ERROR, rz_return_val_if_fail, rz_bin_info_t::type, and idasig_v5_t::version.
Referenced by sigdb_signature_resolve_details().
RZ_API RZ_OWN RzFlirtNode* rz_sign_flirt_parse_string_pattern_from_buffer | ( | RZ_NONNULL RzBuffer * | flirt_buf, |
ut32 | optimization, | ||
RZ_NULLABLE RzFlirtInfo * | info | ||
) |
Parses the RzBuffer containing a FLIRT signature in string format and returns an RzFlirtNode.
flirt_buf | The buffer to read |
optimization | Optimization to apply after creation of the flatten nodes. |
info | Pointer to a RzFlirtInfo that can be used to get info about the pat file |
Definition at line 356 of file pat.c.
References flirt_compare_node(), flirt_node_optimize(), flirt_pat_parse_line(), free(), info(), setup::line, memset(), NULL, p, pat_dbg, PAT_LINE_BUFFER_SIZE, read(), root, rz_buf_read(), RZ_FLIRT_FILE_TYPE_PAT, RZ_FLIRT_NODE_OPTIMIZE_MAX, RZ_FLIRT_NODE_OPTIMIZE_NONE, rz_list_newf(), rz_list_sort(), RZ_LOG_ERROR, RZ_NEW0, rz_return_val_if_fail, rz_sign_flirt_node_count_nodes(), rz_sign_flirt_node_free(), rz_strbuf_append(), rz_strbuf_fini(), rz_strbuf_free(), rz_strbuf_get(), rz_strbuf_init(), rz_strbuf_length(), rz_strbuf_new(), st64, and rz_bin_info_t::type.
Referenced by rz_core_flirt_convert_file(), rz_core_flirt_dump_file(), rz_sign_flirt_apply(), and sigdb_signature_resolve_details().
RZ_API bool rz_sign_flirt_write_compressed_pattern_to_buffer | ( | RZ_NONNULL const RzFlirtNode * | node, |
RZ_NONNULL RzBuffer * | buffer, | ||
RzFlirtCompressedOptions * | options | ||
) |
Writes in the the RzBuffer the FLIRT signatures in compressed format.
node | The FLIRT node to use as input |
buffer | The buffer to write to |
Definition at line 1580 of file flirt.c.
References flirt_write_node(), IDASIG_FEATURE_COMPRESSED, IDASIG_FEATURE_NONE, memset(), NULL, options, rz_buf_append_bytes(), rz_buf_append_le_bits, rz_buf_append_string(), rz_buf_free(), rz_buf_new_empty(), rz_deflatew_buf(), RZ_FLIRT_LIBRARY_NAME_MAX, RZ_FLIRT_SIG_ARCH_ANY, RZ_LOG_ERROR, rz_return_val_if_fail, rz_sign_flirt_node_count_nodes(), RZ_STR_ISEMPTY, autogen_x86imm::tmp, and ut64().
Referenced by rz_core_flirt_convert_file(), and rz_core_flirt_create_file().
RZ_API bool rz_sign_flirt_write_string_pattern_to_buffer | ( | RZ_NONNULL const RzFlirtNode * | root, |
RZ_NONNULL RzBuffer * | buffer | ||
) |
Writes in the the RzBuffer the FLIRT signatures in string format.
root | The FLIRT root node to use as input |
buffer | The buffer to write to |
Definition at line 529 of file pat.c.
References flirt_pat_write_line(), root, rz_buf_append_string(), rz_return_val_if_fail, rz_strbuf_fini(), rz_strbuf_init(), and sb.
Referenced by rz_core_flirt_convert_file(), and rz_core_flirt_create_file().
RZ_API bool rz_sign_sigdb_add_entry | ( | RZ_NONNULL RzSigDb * | db, |
RZ_NONNULL const RzSigDBEntry * | entry | ||
) |
Add a new signature entry to a database.
db | Database of signatures |
entry | Single signature entry to add to the database |
Definition at line 158 of file sigdb.c.
References NULL, and rz_return_val_if_fail.
Referenced by rz_sign_sigdb_load_database(), and sigdb_move_entry().
Definition at line 277 of file sigdb.c.
References rz_signature_db_t::entries, and free().
Referenced by analysis_sigdb_add(), and rz_sign_sigdb_load_database().
Return the signature database as a list of entries.
Definition at line 294 of file sigdb.c.
References NULL, rz_list_new(), rz_list_sort(), rz_return_val_if_fail, sigdb_signature_cmp(), and sigdb_to_list().
Referenced by rz_core_analysis_sigdb_list().
RZ_API RZ_OWN RzSigDb* rz_sign_sigdb_load_database | ( | RZ_NONNULL const char * | sigdb_path, |
bool | with_details | ||
) |
Returns a database of signatures loaded from the signature database path.
sigdb_path | The signature database path/location |
with_details | When true, opens each signature within the db for extra details |
Definition at line 105 of file sigdb.c.
References fail, rz_signature_database_entry_t::file_path, files, NULL, rz_file_globsearch(), rz_file_is_directory(), RZ_JOIN_2_PATHS, rz_list_free(), RZ_LOG_ERROR, RZ_NEW0, rz_return_val_if_fail, rz_sign_sigdb_add_entry(), rz_sign_sigdb_free(), rz_sign_sigdb_new(), rz_sign_sigdb_signature_free(), rz_str_endswith(), RZ_STR_ISNOTEMPTY, rz_strf, sigdb_signature_resolve_details(), and strdup().
Referenced by analysis_sigdb_add().
RZ_API bool rz_sign_sigdb_merge | ( | RZ_NONNULL RzSigDb * | db, |
RZ_NONNULL RzSigDb * | db2 | ||
) |
Merge the signatures from db2
into db
.
Data within db2
is moved into db
, making it empty.
db | Database of signatures to extend |
db2 | Database of signatures that need to be merged into db |
Definition at line 184 of file sigdb.c.
References rz_signature_db_t::entries, NULL, rz_return_val_if_fail, sigdb_move_entry(), and sigdb_move_data_t::src.
Referenced by analysis_sigdb_add().
Create a new empty RzSigDb
instance.
Definition at line 260 of file sigdb.c.
References rz_signature_db_t::entries, free(), ht_pu_sigdb_freekv(), NULL, RZ_NEW0, sigdb_entry_cmp(), and sigdb_entry_hash().
Referenced by rz_core_analysis_sigdb_list(), and rz_sign_sigdb_load_database().
RZ_API void rz_sign_sigdb_signature_free | ( | RZ_NULLABLE RzSigDBEntry * | entry | ) |
Frees a RzSigDBEntry structure.
[in] | entry | The RzSigDBEntry to free |
Definition at line 12 of file sigdb.c.
References free().
Referenced by ht_pu_sigdb_freekv(), and rz_sign_sigdb_load_database().