Commit graph

91 commits

Author SHA1 Message Date
wargio
bbdf3d03bd Fix flirt crc calculation, length and matching 2022-10-26 21:46:22 +02:00
wargio
fbad0b4859 Remove agd and add rz_analysis_similarity/match + refactoring
- Introduce the following new methods:
  * `rz_analysis_similarity_basic_block()`
  * `rz_analysis_similarity_function()`
  * `rz_analysis_similarity_basic_block_2()`
  * `rz_analysis_similarity_function_2()`
  * `rz_analysis_match_basic_blocks()`
  * `rz_analysis_match_functions()`
  * `rz_analysis_match_basic_blocks_2()`
  * `rz_analysis_match_functions_2()`
- Remove `RzAnalysisDiff` and its usages
- Remove `librz/analysis/diff.c` entirely to and adds `librz/analysis/similarity.c`
- Remove a lot of unused structures and simplified the code by a lot
- Fix typo in levenshtein
- Remove `librz/core/gdiff.c` and `gdiff` functions since they were unused or only used in rz-diff
- Remove `difftype` (or "color") from `RzANode` which lead to dead code
- Decrease serialized data in projects.
- Add `RzAnalysisVarKind` and `RzAnalysisVarType` and replaces all the hardcoded values
- Remove command `agd`
- Remove all `rz_core_gdiff` usages from `rz_core.h`
- Refactor `rz_analysis_var_list` and `rz_analysis_var_count` due unused argument (`RzAnalysis` was not used)
- Add new method `rz_analysis_var_count_total` to simplify some usages
- Remove `rz_core_graph_diff`
- Add `typedef RzAnalysisFcnType` on `enum``used for function types
- Remove unused `RZ_ANALYSIS_FCN_VARKIND_LOCAL`
- Remove from `RzAnalysisFunction` the following variables:
  * `fingerprint`
  * `fingerprint_size`
  * `diff`
  * `diff_ops`
  * `diff_thbb`
  * `diff_thfcn`
- Remove from `RzAnalysisBlock` the following variables:
  * `fingerprint`
  * `diff`
- Remove `RZ_ANALYSIS_THRESHOLDBB` and `RZ_ANALYSIS_THRESHOLDFCN`
- Remove the following callbacks from `RzAnalysisPlugin`
  * `RzAnalysisDiffBBCallback`
  * `RzAnalysisDiffFcnCallback`
  * `RzAnalysisDiffEvalCallback`
- Fix fancy table columns/rows when a color string is in a cell
- Bumped project version to 9
2022-10-04 20:02:35 +02:00
Anton Kochkov
52260857b5
Convert some of the a commands to the rzshell (#3025)
* Remove `ap` command
* Convert `ad` commands to rzshell
* Convert `aF` command to the rzshell
2022-09-15 21:09:15 +02:00
Dean
59b38e6efa
Add /*<type>*/ comments everywhere (#2986)
Adds /*<type>*/ comments and a linter check from rz-bindgen to enforce
their existence and consistency

Also includes the following fixes made when adding the annotations:
* removed unused intern_table arguments in pyc_dis.c, pyc_dis.h, asm_pyc.c
* removed unused classes argument from place_nodes in agraph.c
* removed unused recurse and recurse_bb functions in canalysis.c
* removed unused vars field from RzPrint struct
* removed unused RzAnalysisType* structs from rz_analysis.h
* removed unused list field from RzEgg struct
* fixed bug in bp_plugin.c where duplication-checking logic iterates over the wrong list
* removed unused q_regs field from RzDebug struct
* removed unused backtrace field from RzDebugPlugin struct
* removed unused classes_list field from RzBinNXOObj struct
* removed unused methods_list and classes_list fields from RzBinZimgObj struct
2022-09-11 13:04:53 +08:00
Anton Kochkov
9b4a1d1be0 Move ESIL and analysis APIs to the corresponding places 2022-09-08 07:41:18 +08:00
billow
46a1929397
Refactor rz_core_analysis_graph*() functions (#2949)
- fix `ags` and `agl` commands
- add more tests for the `ag` commands
- move graph related code to cgraph.c
- remove APIs `rz_core_print_bb_custom` `rz_core_print_bb_gml`
- exports
    - `rz_graph_drawable_to_json_str`
    - `rz_graph_drawable_to_cmd`
    - `rz_graph_drawable_to_gml`
    - `rz_core_graph`
    - `rz_core_graph_diff`
    - `rz_core_graph_format_from_string`
    - `rz_core_graph_type_from_string`
    - `rz_core_graph_write`
    - `create_agraph_from_graph_at`
- add unit/integration tests for the graph API
2022-08-29 22:48:23 +08:00
Giovanni
c89b12a046
Removed plenty of eprintfs in rz_core (#2950) 2022-08-29 00:32:17 +08:00
billow
4b385978a1
Convert ag to rzshell (#2916)
* `BROKEN=1` for `ag[df]`

Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2022-08-22 08:16:14 +08:00
wargio
25ff470ecd Removing dead code in esil.
Before this fix, rz_analysis_archinfo(RZ_ANALYSIS_ARCHINFO_DATA_ALIGN) always returned -1
because the RZ_ANALYSIS_ARCHINFO_DATA_ALIGN value was not set in the switch;
when the code was refactored, this broke esil because several checks that were always set
as true, now were actually correctly executed.
To resolve this the dead code has been removed.
2022-08-13 22:52:24 +02:00
Riccardo Schirone
4181be2a6f core/cmd: fix afx command JSON output 2022-08-05 15:10:24 +02:00
wingdeans
a6a7a5f530 Fix annotation inconsistencies 2022-08-03 00:29:56 -04:00
Peiwei Hu
4389df1e18
Update embedded fd command (#2838) 2022-07-23 22:29:33 +08:00
Peiwei Hu
56abc5c2b3
Remove command aC (#2793) 2022-07-20 20:46:58 +02:00
billow
3dc58a993e
Expose rz_core_analysis_name() (#2800)
* expose `rz_core_analysis_name()`
* split `rz_core_analysis_name()` as `rz_core_analysis_rename()` and `rz_core_analysis_name()`
* add `addr` arg to `rz_core_analysis_{rename,name}()`
2022-07-12 22:11:43 +08:00
billow
40ca22202b
Refactor rz_core_print_disasm_json (#2746)
* Split `rz_core_print_disasm_json` as: `rz_core_print_disasm_json` and `rz_core_disasm`
* Use `rz_str_enc_string_as_type` in `ds_init`
* Refactor `rz_core_print_disasm` and `rz_core_handle_backwards_disasm`
* Add `rz_core_asm_bb_middle`
* Move global `disasm_texts` to `RzDisasmState`
* Rewrite `core_analysis_bytes_standard` with `rz_core_analysis_bytes`
* Add `test_rz_core_print_disasm` and `test_rz_core_analysis_bytes`
* Rewrite `rz_core_print_disasm` with `RzCmdStateOutput`
* `pdi` -> `pdq` in tests
* `pdi` -> `pDq` in tests
* `pid` -> `pdq` in tests
* `pId` -> `pDq` in tests
* `pij` -> `pdj` in tests
* `pIj` -> `pDj` in tests
* `pdeqq` -> `pdeQ` in tests
* Remove `pDJ` from `test/db/json/`
2022-07-09 08:10:06 +08:00
Peiwei Hu
69399bb1ea
Convert command ai to new shell (#2778) 2022-07-04 18:08:58 +02:00
Peiwei Hu
c9f21da81f Convert command aL(j) to new shell 2022-07-04 23:37:23 +08:00
Peiwei Hu
0fc9c9682e
Fix some checks of rz_analysis_op (#2755)
* Fix some checks of rz_analysis_op
* rm unreachable code
2022-07-01 18:12:14 +08:00
Riccardo Schirone
6f8aec2b3b
CI: install sigdb in static version of rizin (#2689)
* CI: install sigdb in static version of rizin
* RzCore: use bool2status whenever possible
* RzCore: add flirt.sigdb.load vars to select which signatures to load
* test: adjust testing to not consider system/home flirt db
* sign: use a RzSigDb structure instead of a raw list to store signatures
* sign: switch RzSigDb to use a hashtable and avoid duplicates
2022-06-23 10:29:46 +02:00
billow
aaf08869cf
Expose APIs (#2710)
- `rz_core_bin_get_compile_time`
- `rz_core_analysis_coverage_count`
- `rz_core_analysis_code_count`
- `rz_core_analysis_calls_count`
- `rz_core_sym_name_init`
- `rz_core_sym_name_fini`
- `rz_core_sym_is_export`
- `rz_core_bin_whole_strings`
- `rz_core_analysis_coverage_count`
- `rz_core_analysis_code_count`
- `rz_core_analysis_calls_count`
- `rz_core_analysis_esil_deinit`
- `rz_core_analysis_esil_init_mem_del`
- `rz_core_types_as_c`
- `rz_type_list_c_nl_handler`
- `rz_core_file_open_load`
- `rz_core_config_in_space`

-  rename `SymName` -> `RzSymName`
2022-06-21 10:49:42 +08:00
GustavoLCR
efc529cb5e
Allow to set jump table type to a enum (#2706)
* Adds `afbet` command
* In disassembly, try to substitute the switch table case number with the corresponding enum case
2022-06-19 17:29:16 +08:00
GustavoLCR
19bc4705a4 Parse: Change rz_parse_subvar API to accept a RzAnalysisOp
* Kill `get_op_ireg`
2022-06-06 00:02:09 +08:00
Riccardo Schirone
53b0bebcec RzCore: add 'aez' help reference 2022-06-02 11:21:06 +02:00
Anton Kochkov
bb89c771a2 Fix CID 392696 - memory leak 2022-05-19 12:17:53 +08:00
billow
91555f632e
Expose "continue until" API
* Expose `rz_analysis_continue_until_syscall()` as an API
* Expose `rz_analysis_continue_until_call()` as an API
2022-05-17 22:05:22 +08:00
Anton Kochkov
2188b4564d
Various Coverity fixes (#2615)
* Fix CID 392733 - memory leak

* Fix CID 392732 - memory leak

* Fix CID 392730 - memory leak

* Fix CID 392729 - memory leak

* Fix `rz_analysis_diff_free()` API function

* Fix CID 392685 - memory leak

* Fix CID 392012 - use after free

* Fix CID 391968 - uninitialized pointer read

* Fix CID 391966 - memory leak

* Fix CID 391964 - uninitialized pointer read

* Fix CID 390013 - memory leak

* Fix CID 389939 - memory leak

* Fix CID 379249 - memory leak

* Fix CID 378881 - uninitialized scalar variable

* Fix CID 378973 - uninitialized scalar variable

* Fix CID 378850 - uninitialized scalar variable

* Fix CID 371079 - memory leak

* Fix CID 367478 - memory leak

* Fix CID 366821 - memory leak

* Fix CID 366736 - memory leak

* Fix CID 361684 - uninitialized scalar value

* Fix CID 352581 - memory leak

* Fix CID 352557 - memory leak

* Fix CID 348937 - memory leak

* Fix CID 322229 - memory leak

* Fix CID 320122 - memory leak

* Fix CID 317611 - memory leak
2022-05-15 23:15:28 +08:00
billow
e767046197
Convert dL to rzshell (becomes dl) and expose API
- Convert `dL` to rzshell
- `dL` becomes `dl`
- Expose `rz_core_debug_backtraces()` API
- Expose `rz_core_analysis_hint_set_offset()` API
2022-05-13 20:17:56 +08:00
Giovanni
423617930c
[dalvik] handle move-exception after gotos/returns and mid op jumps (#2603)
* Fix dalvik analysis by looking for move-exception after gotos/returns
* Fixed Dalvik analysis due compiler optimizations
2022-05-12 13:16:54 +02:00
Paul I
9db3ed0670 Rename RzAnalysisXRefType enum members 2022-05-12 09:24:12 +02:00
Giovanni
0d4d8f5892
Ported aa* commands under newshell (#2594) 2022-05-10 19:07:20 +02:00
Paul I
df354a4cec
Convert af commands to rzshell (#2586) 2022-05-05 18:19:17 +08:00
wargio
33e8c5b2b8 Resolve 'format not a string literal and no format arguments' 2022-05-03 12:13:22 +02:00
wargio
f8c9634705 allow aang to do the same as aaa 2022-05-03 12:13:22 +02:00
wargio
b74419425a Recover golang strings from x86 mov/lea instructions 2022-05-03 12:13:22 +02:00
wargio
b86cfeb39a Converted rz_core_notify_* to use C format 2022-05-03 12:13:22 +02:00
Anton Kochkov
c42dd5d4bb
Convert as commands to the rzshell (#2323) 2022-05-03 18:06:18 +08:00
billow
b3ca50319d
Expose rz_core_analysis_bytes() API and refactoring (#2565) 2022-04-26 23:44:45 +02:00
Paul I
00676b4e39
Convert afc commands to rzshell (#2559) 2022-04-24 20:55:41 +02:00
Paul I
d24a325df1
Remove afC commands (#2555) 2022-04-22 12:57:11 +02:00
Paul I
8df5d48b95
Convert afM, afm, aft commands to rzshell (#2550) 2022-04-21 13:56:00 +02:00
Peiwei Hu
5fa722efab
Refactor RzTable: change the implementation to RzVector (#2536) 2022-04-13 00:57:52 +08:00
billow
6669f35145
Convert commands to rzshell aes aets (#2534) 2022-04-12 02:06:22 +02:00
billow
68445de6b1
Convert aec aei commands to rzshell (#2515) 2022-04-09 20:49:01 +02:00
Anton Kochkov
d6d214572f
Revert "Refactor RzTable: change the internal storage to RzVector (#2421)" (#2517)
This reverts commit 1748b38ce1.
2022-04-08 18:06:20 +08:00
Riccardo Schirone
6f68175068
RzCore: add afv help under af? (#2516) 2022-04-07 18:46:27 +02:00
Peiwei Hu
1748b38ce1
Refactor RzTable: change the internal storage to RzVector (#2421) 2022-04-07 21:13:34 +08:00
Riccardo Schirone
47b73ca7fa RzUtil/str: remove len argument from rz_str_filter
All uses of rz_str_filter already passed either strlen(..) or -1 or 0,
which was the same as computing strlen(...). The only case where a
different value was passed was in astr.c, where the string was anyway
allocated with rz_str_ndup(). Thus the string passed to rz_str_filter()
is always zero-terminated and we don't need to compute the length in
rz_str_filter() to traverse it all, but we can just stop at the first
NULL byte.
2022-04-06 01:46:18 +08:00
Paul I
5ea3630c35
Convert ab commands to rzshell (#2395) 2022-04-02 21:27:55 +08:00
Florian Märkl
bc8bbf4faf
Convert aae to newshell and remove /re (#2468)
The functionality to analyze only for references that point to a
specific addr, available as `aae <size> <addr>` and `/re` was untested
and at least half broken, so it was removed.
The rest of the code has also been refactored to use less strings and
global state (no core->offset).
2022-03-29 15:32:42 +00:00
Giovanni
d344d29a57
Moved rz_analysis_esil_dumpstack to rz_core_esil_dumpstack (#2460) 2022-03-28 19:55:46 +08:00