Commit graph

1840 commits

Author SHA1 Message Date
Rot127
ccdd9f2848
Add UTF-8 friendly strchr (#2809)
* Add utility functions to search for UTF-8 chars in strings.

* Break loop if number of read bytes goes beyond str.

* Add doxygen to `rz_mem_cmp`

* Add NULL checks to functions.
2022-07-18 17:53:58 +08:00
Florian Märkl
91e48624b5 Add very basic debug tests for macOS
The system.privilege.taskport change in CI could also be simplified without
having to manually edit a plist.
2022-07-17 20:31:32 +02:00
Riccardo Schirone
8939fdbd7d
Use add_global_arguments instead of passing cflags/ldflags all around (#2812)
See also 66a0e22293/docs/TESTING_WITH_SANITIZERS.md (clang)
2022-07-17 21:33:51 +08:00
Riccardo Schirone
6c665c6098 Use Rizin specific macros instead of the ones from SDB 2022-07-17 12:11:13 +02:00
Riccardo Schirone
1331474286 test: Use rz_file_tmpdir to have temporary dir 2022-07-17 12:11:13 +02:00
Riccardo Schirone
470e030f19
util: provide rz_time_gettimeofday API (#2811) 2022-07-17 09:57:00 +08:00
Khairul Azhar Kasmiran
b79201b49a
Remove RZ_BIRTH (#2803) 2022-07-13 17:01:42 +08:00
Anton Kochkov
b2d9429129
Remove sdb json (#1118)
* Drop sdb_json in `librz/cons/grep.c`
* Do not print the JSON key in grep
* Use proper JSON paths in tests
* Use signed number in case of RzJson in tests
* Do not add quotes for sole RZ_JSON_STRING
2022-07-12 22:48:33 +08:00
Florian Märkl
c3e9c19109
Fix and test rz_json_as_string() for primitives (#2796)
Allowing converting the primitive json values null, number, string and
bool to be converted to strings is useful, simplifies the code and fixes
crashes when converting otherwise valid RzJson objects.
2022-07-09 15:40:50 +02: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
906fe97252
Add psc command to generate a C/C++ string (#2791) 2022-07-08 19:50:32 +08:00
Peiwei Hu
8e6f7e1a78
Add hints for fe/f commands (#2785) 2022-07-07 22:27:26 +08:00
Giovanni
2e0d490d2f
Add RzBaseFindOpt for custom thread status callback (#2768) 2022-07-06 11:34:00 +02:00
Giovanni
b1f5b5b454
Remove usage of rz_bin_is_big_endian (#2761)
* Remove usage of rz_bin_is_big_endian which changes the endianness set by the user
2022-07-02 18:36:16 +00:00
Riccardo Schirone
32274f6975 Fix tests for .gnu_debugdata 2022-07-02 10:12:26 +02:00
Riccardo Schirone
2f1e39818e Add liblzma subproject 2022-07-02 10:12:26 +02:00
Giovanni
f355dcf557
Add RzBinStrDb and api to interact with it via rz_bin_object_string_* (#2754)
* Add RzBinStrDb and api to interact with it via rz_bin_object_string_*
* use update instead of insert
* check for null deref in rz_analysis_set_stringrefs
* Never delete strings just add them and fixed comments
2022-07-01 06:34:41 +08:00
Peiwei Hu
347d8a72f5
Fix the crash of command fg (#2758) 2022-06-30 16:33:43 +00:00
Giovanni
ea02b0d25f
Remove zignatures and move aaF[l] -> F[al] , zf[sdc] -> F[sdc] (#2682) 2022-06-29 07:49:43 +08:00
Riccardo Schirone
2987e035da hash: use RzHash in most hash APIs 2022-06-28 21:55:26 +08:00
Riccardo Schirone
9ea7c2fa5a RzHash: rename everything in librz/hash to RzHash prefix 2022-06-28 21:55:26 +08:00
Giovanni
648882d544
Add libmspack and add idpx to extracts compressed pdb (#2728)
* Add libmspack, cabextract and add idpx to extracts compressed pdb
* Remove cabextract from CIs since it is not anymore required.
2022-06-27 23:52:07 +02:00
Giovanni
6567e6ba4e
Multithread string search (#2665) 2022-06-27 23:34:08 +02: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
Giovanni
6f6ae6e019
Rename rz_arch to rz_platform (#2708) 2022-06-22 17:22:13 +02:00
Giovanni
a2d23a8e11
Remove RQueue (#2720) 2022-06-22 22:41:05 +08:00
Giovanni
4dfad73567
Remove RZ_BIN_STRING_ENC_* in favor of RZ_STRING_ENC_* (#2716) 2022-06-21 18:45:09 +02:00
Dean
bf2871c7eb
Add dotnet PE support (#2528)
* Add CIL support

* refactor dotnet parsing to pe/dotnet.c
* parse PE CLR metatables (based on yara implementation)
* use CLR methoddefs to add binsymbols (including method namespace/class)
* parse CLR method headers
* CIL disassembler using .NET opcodes.def
* CIL analysis plugin
2022-06-21 09:20:47 +08:00
Rot127
f108873520
Rework register profile parsing
**Register profile parsing**

- Types, sizes, and offsets get now parsed separately in their own functions.
- More logging added.
- The string is first parsed into a list of register definitions and alias (`RzRegProfileDef`, `RzRegProfileAlias`) and afterward applied to `RzReg.regset`.
- Documentation was added on how the register profile needs to be formatted.
- Functions are more consistent with return types (most return `bool` now instead of `Error Msg` + `NULL`).

**New register profile structs**

The register profile of `RzReg` consists of two lists with alias and definitions.
I chose lists over NULL-terminated arrays because they were a little easier to handle during parsing (no memory management).
Please let me know if you would strongly prefer the NULL-terminated version.
2022-06-20 20:54:42 +08:00
Giovanni
a988941bf2
Refactor thread code and add RzThreadQueue (#2683)
* Kill the thread only if is alive.
* Remove rz_th_lock_guard.
* Use rz_sys_usleep since pthread_yield/sched_yield are not portable.
* Kill threads only on error.
* Avoid killing already-dead threads.
* RzThreadFunction now returns void* and added test_thread_queue.
* Removed pthread_exit
2022-06-19 21:07:13 +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
807c64de3e Fix missing rip reg flag for 32-bit binaries on Windows x86-64
* Always add `PC` register flag
* Fix `PC` highlighting when debugging 32-bit binaries in x64 Windows
* Add test
2022-06-17 21:15:59 +08:00
GustavoLCR
23a3468834 Fix register flag address not updating after dc 2022-06-17 21:15:59 +08:00
Dhruv Maroo
3c16afeeb0
Implement empty instruction for RzIL (#2697) 2022-06-14 23:07:57 +04:00
Riccardo Schirone
5e43ea2f97
RzCore: read core block before printing (#2694)
* RzCore: read core block before printing
* Add debug test for pd with dbH
2022-06-14 15:27:27 +00:00
Luca Borzacchiello
2d69ecbb22
Better false-positives detection in rz_scan_strings (#2691)
* Improved false-positive detection in str_search

This commit adds the following features:
- Extend the false-positive check on ASCII frequencies to all UTF strings
- Add a global option to activate/deactivate di check
- Improve the false-positive heuristic by adding a special case for extended-ASCII strings
2022-06-14 22:14:13 +08:00
Dean
9c2c5fa495
Skip floating point numbers during asm name substitution #2688 2022-06-13 22:27:33 +02:00
Ben Demick
49680257af
Fix default ELF arch for x86 binaries 2022-06-13 21:16:47 +08:00
Giovanni
4c81b52f68
Use github as symbol server for the tests (#2686) 2022-06-10 16:35:15 +00:00
BraveBoii
782fcd5257 Updated sflib 2022-06-08 20:50:31 +08:00
guest177
59179ab311 Correct MZ size when bytes_in_last_block = 0 ##bin
Signed-off-by: Riccardo Schirone <sirmy15@gmail.com>
2022-06-06 14:35:25 +02:00
GustavoLCR
951a33c490 WinKD/DMP: Use backtrace_generic() for dbt for arm and x86 2022-06-05 00:27:35 +08:00
Riccardo Schirone
72c29e83d5 RzUtil: fix rz_path_prefix in case of portable build
Before this patch the function was using RZ_PREFIX even when IS_PORTABLE
was set, making the function not working well because RZ_PREFIX might
not exist in the system where the portable build is used (the path was
passed to realpath(), which requires an existing path).

This patch fixes the problem by searching for the BINDIR without using
realpath() on the RZ_PREFIX. Moreover, it avoid retrieving the same
prefix every time by saving it in a global variable.

* Add rz_constructor.h to allow defining constructors/destructors on
  multiple compilers.
2022-05-31 23:32:52 +08:00
Florian Märkl
0950e823a4
Refactor rz_core_analysis_get_stats() and fix edge cases (#2645)
Range is now explicitly inclusive/inclusive to allow generating stats
for the entire 64bit range.
This especially also removes the obscure "Cannot alloc for this range",
which could be observed in Cutter, and adds a more meaningful error to
the p- command whenever no range is available.
2022-05-30 04:59:47 +00:00
Riccardo Schirone
36decf9438 RzCore: move wd function to rz_core_write_duplicate_at API 2022-05-25 14:03:17 +02:00
wargio
df0664b736 Add support for riscv64 string recovery 2022-05-18 19:24:53 +02:00
wargio
0187442d69 Add support for ppc64 string recovery 2022-05-18 19:24:53 +02:00
wargio
53de6e47a1 Add support for mips32/64 BE/LE string recovery 2022-05-18 19:24:53 +02:00
wargio
99985c89dc Refactoring using sigs for x64/x86/arm32/arm64
- initial support for mips32/mips64/riscv64/ppc64
2022-05-18 19:24:53 +02:00
Riccardo Schirone
e36d66abe7 Remove analysis.endsize config
Commit taken from radare2 project:
03afa631ff37ecb7585d3d4bb052f7208e68c25dA ("Kill anal.endsize ##anal")
2022-05-18 10:25:01 +02:00
Riccardo Schirone
cdc80202dd RzCore: add scr.prompt.flag.only config var 2022-05-16 13:16:28 +02:00
Anton Kochkov
5aef0d8a98
Update libdemangle for MSVC fixes (#2556)
Co-authored-by: GustavoLCR <gugulcr@gmail.com>
2022-05-15 20:57:27 +08:00
Rot127
fb665274f4
Fix: Hexagon relocations (#2612)
* Add more relocation types.
* Replace flawed patching algorithm with the `llvm-llds` algorithm.
* Add macros for bitmasks.
* Remove code duplicates.
* Add relocation tests.
2022-05-13 20:26:31 +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
Riccardo Schirone
6f8a59072c test: allow to run unit tests without installation 2022-05-10 16:57:44 +02:00
Giovanni
0dcdc842a2
SDB usage cleanup within rz_bin 2022-05-10 10:27:33 +08:00
Riccardo Schirone
27e0d7ae82
RzBin: improve handling of addresses in ELF (#2591)
* RzBin/ELF: avoid the creation of useless flags at 0

Use UT64_MAX as an error value for addresses like symbols, imports,
sections, etc., and do not create flags for those because they are not
meaningful. This is useful for imports that do not have an address in
the virtual/file space and for non-alloc sections (e.g. .comment).
2022-05-10 10:17:35 +08:00
billow
457105f640
Convert do to rzshell (#2573)
* `doo` -> `ood`
* `doof` -> `oodf`
* expose `rz_core_debug_process_close()` API
2022-05-07 09:07:02 +08:00
Riccardo Schirone
41c9bfc2ae RzBin: fix string scan vaddr/paddr
* Fix convertion of paddr to vaddr by using the new RzBin API
  rz_bin_object_p2v
* Fix locations of strings when RzBinXtr is used (e.g. fatmach)
2022-05-06 18:09:17 +02:00
Riccardo Schirone
474effacc6 RzBin: add APIs to convert paddr/vaddr addresses based on binary info 2022-05-06 18:09:17 +02:00
Paul I
df354a4cec
Convert af commands to rzshell (#2586) 2022-05-05 18:19:17 +08:00
GustavoLCR
71e12433ac
Fix rz_buf_fwd_scan unit test for big endian archs (#2589) 2022-05-05 12:39:25 +08:00
Giovanni
539a12597d
Move rz_bin_file_golang_compiler usage under bobj.c (#2584) 2022-05-03 21:57:31 +08:00
wargio
4a06141377 Fix 2128 - Parse go.buildinfo and set compiler value under iI 2022-05-03 12:13:22 +02:00
wargio
0750370104 Added string checking on golang parsed tests. 2022-05-03 12:13:22 +02:00
wargio
01643ab3e0 Use rz_str_len_utf8_ansi for detecting valid string length 2022-05-03 12:13:22 +02:00
wargio
f9d74c9115 Added tests and fixed some others 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
Theofilos Pechlivanis
e87349f9bc
Refactor afs and afsj (#2578) 2022-05-03 11:08:20 +08:00
Anton Kochkov
564d88c319
Add missing Python magic values (#2522) 2022-05-02 13:22:12 +02:00
Florian Märkl
b40dde5fbf
Move DEBUGGER checks from C to meson.build (#2577)
Entire files are now avoided to be built by checking in meson rather
than using #if DEBUGGER. This now also includes bsd_debug.c, which
is currently slightly broken on OpenBSD/sparc64 and caused compile
errors even with -Ddebugger=false.
2022-05-02 11:22:35 +02:00
Rot127
b65ef05e96
Fix: Allow to setup big endian bitvectors with less than 8bit values. (#2571) 2022-04-29 16:03:42 +02:00
Giovanni
e1b2c3eff5
Remove eprintfs (part 2) (#2563)
* Removed eprintf from librz/bin/format/pyc/marshal.c
* Removed eprintf from librz/bin/format/pyc/pyc_magic.c
* Removed eprintf from librz/bin/format/te/te.c
* Removed eprintf from librz/bin/format/wasm/wasm.c
* Removed eprintf from librz/bin/format/xnu/rz_cf_dict.c
* Removed eprintf from librz/bin/p/bin_bf.c
* Removed eprintf from librz/bin/p/bin_cgc.c
* Removed eprintf from librz/bin/p/bin_elf.inc
* Removed eprintf from librz/bin/p/bin_luac.c
* Removed eprintf from librz/bin/p/bin_mach0.c
* Removed eprintf from librz/bin/p/bin_mdmp.c
* Removed eprintf from librz/bin/p/bin_menuet.c
* Removed eprintf from librz/bin/p/bin_nes.c
* Removed eprintf from librz/bin/p/bin_pe.c
* Removed eprintf from librz/bin/p/bin_pebble.c
* Removed eprintf from librz/bin/p/bin_psxexe.c
* Removed eprintf from librz/bin/p/bin_sfc.c
2022-04-25 17:53:54 +02:00
Paul I
00676b4e39
Convert afc commands to rzshell (#2559) 2022-04-24 20:55:41 +02:00
Giovanni
5e09c02109
Remove eprintfs (part 1) and rz-bin -X (#2558)
* Removed eprintfs from librz/bin/bfile.c
* Removed rz_bin_package and rz-bin -X because untested and not implemented
* Removed eprintfs from librz/bin/bin.c
* Be verbose on clang-format and not on command execution
* Removed eprintfs from librz/bin/bobj.c
* Removed eprintfs from librz/bin/dwarf.c
* Removed eprintfs from librz/bin/format/coff/coff.c
* Removed eprintfs from librz/bin/format/dmp/dmp64.c
* Removed eprintfs from librz/bin/format/luac/luac_bin.c
* Removed eprintf from librz/bin/format/luac/luac_common.c and refactoring
* Removed eprintf from librz/bin/format/luac/v53/parse_53.c
* Removed eprintf from librz/bin/format/mach0/coresymbolication.c
* Removed eprintf from librz/bin/format/mach0/dyldcache.c
* Removed eprintf from librz/bin/format/luac/v54/parse_54.c
* Removed eprintf from librz/bin/format/mach0/dyldcache_rebase.c
* Removed eprintf from librz/bin/format/mach0/fatmach0.c
* Removed eprintf from librz/bin/format/mdmp/mdmp.c
* Removed eprintf from librz/bin/format/mz/mz.c
* Removed eprintf from nso/nxo bin format
* Removed eprintf from librz/bin/format/objc/mach0_classes.c
* Removed eprintf from librz/bin/format/omf/omf.c
* Removed eprintf & bprintf from librz/bin/format/pe/pe.c
* Removed eprintf from librz/bin/format/pe/pemixed.c
* Fixed luac test
2022-04-23 18:43:43 +02:00
Florian Märkl
3cbde10260
Update Hexagon for compact struct conversion (#2548)
This is updating with rz-hexagon 1ca78d073861b6ce66b682d200c7a3fc2734a6a3
2022-04-22 17:50:39 +02:00
Paul I
d24a325df1
Remove afC commands (#2555) 2022-04-22 12:57:11 +02:00
Giovanni
de8a5cac55
Porting pd and subcommands to newshell (#2552)
* pd + pda[jJqi=]
* Added pdb/pdC/pdf/pdk/pdl/pdp/pdr and removed pdi in favour of pdq
* removed pdx since is an alias for 2 other commands.
* Added pdR and pds[fb]
* Added example and fixed bug when cw
* Removed pdx test file since it is the same as cmd_pix
2022-04-21 16:19:48 +02:00
Khairul Azhar Kasmiran
ef7b1a0153
rizin.c: Use RZ_LOG_ERROR instead of eprintf for obvious errors (#2553) 2022-04-19 21:26:50 +08:00
Heersin
2fdb8ac07e
Fix copied bit count in rz_copy_nbits and add unit test (#2547) 2022-04-18 18:47:08 +02:00
GustavoLCR
55fc4dfac1
Implement new rz_buf_fwd_scan() API (#2530) 2022-04-17 15:08:08 +02:00
GustavoLCR
be669a9404
Fix OOB write in unescape_special_chars() (#2543) 2022-04-14 21:21:34 +02:00
wargio
5c8db619f7 Implemented dex/dexs/dexe core cmds for dumping dex info like for java 2022-04-12 22:14:05 +02:00
Peiwei Hu
5fa722efab
Refactor RzTable: change the implementation to RzVector (#2536) 2022-04-13 00:57:52 +08:00
Dhruva Gole
e547fe6720
rz-ax: count set bits in number (#2513)
Signed-off-by: Dhruva Gole <goledhruva@gmail.com>
2022-04-12 17:13:34 +02:00
GustavoLCR
8ff310e62d Add PE SEH tests 2022-04-11 12:27:50 +08:00
Florian Märkl
a1e958f230 Fix radare2 CVE-2022-1240 (out of bounds read) 2022-04-10 16:05:40 +02:00
wargio
21ba6616ce Fix radare2 CVE-2022-1244 (out of bound read)
This this an Out of Bound read caused by missing sanitization of the
parsed dyldcache parsed structure.
Introduced via c19eaa8843
Original r2 commit: 09e20cd53d00a1497bf50349fe6eb812b4f54ac5
2022-04-10 16:05:40 +02:00
Martin M
74c071b071
Fix disassembly of LDD instruction on AVR (#2519) 2022-04-08 21:23:15 +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
30cbd237d3 RzCore: save/restore bits and arch config values while printing 2022-04-07 16:41:54 +02:00
Peiwei Hu
1748b38ce1
Refactor RzTable: change the internal storage to RzVector (#2421) 2022-04-07 21:13:34 +08:00
Rot127
0c4e84cd9d
Add big endian PPC relocs (#2502)
* Add support for big endian PPC relocs.
* Add tests for PPC_RELATIVE and PPC_JMP_SLOT.
2022-04-06 09:18:40 +08:00
Riccardo Schirone
272be57bcd
RzCore: default dbg.verbose to false (#2506)
Some messages printed by Rizin might be hard to decode at times. Just
stick to the basic information by default.
2022-04-06 01:28:15 +02: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
Rot127
10bedc2b00
Add Hexagon register profile (#2490)
Although the reg profile was not really used yet it will be relevant for the RZIL uplifting.
Introduces:
* Double/quadruple registers now properly overlap with their counterparts.
* Registers have correct types assigned (vec, ctr, sys etc. Before, all regs were of type gbr)
* Consistent register names (asm name style: c3:2, r31 etc, alias style: lc1:sa1, lr etc.)
* Adds _tmp registers in the profile. Later used by uplifted instructions (think of .new registers).
2022-04-03 18:26:17 +02:00
Giovanni
348ed19ad6
Dex add support for some imports within direct_methods via super calls (#2491)
* Dex add support for some imports within direct_methods via super calls
* Fixed tests and added test
2022-04-03 20:54:55 +08:00
Rot127
628d04f713
Add RzConfig for asm plugins (#2488)
* Add function to add config node to config by `RzConfigNode*`
* Move `SET<NODE>` macros to `rz_config.h`
* Add un/set functions for plugin specific configs.
* Add RzConfig and node setter to hexagon plugin.
* Use plugins RzConfig to determine sdk syntax setting.
* Use plugins RzConfig to determine if numbers should be signed.
* Use plugins RzConfig to determine if immediate hash should be printed.
* Remove unused parameter `rz_asm`.
* Remove unused variable.
* Remove unused callback.
* Remove unused flags from `RzAsm`
* Fix asm tests: Add NULL check; Set correct sign in asm test.
2022-04-03 20:44:50 +08:00
Anton Kochkov
30a62fb4e3
Fix the build 2022-04-03 01:50:22 +08:00
Giovanni
4fb8c83e94
[DEX] Add relocation support 2022-04-02 16:23:43 +02:00
Paul I
5ea3630c35
Convert ab commands to rzshell (#2395) 2022-04-02 21:27:55 +08:00
Giovanni
b223ed4992
Use method definition as name where possible (#2481) 2022-04-01 21:59:04 +08:00
Khairul Azhar Kasmiran
8f320a474f
Support rizin - on Windows (#2482) 2022-04-01 21:47:19 +08:00
Riccardo Schirone
c2dd9df426 RzCore: print "lib" field in 'is' command also in JSON mode 2022-04-01 11:57:50 +02:00
Khairul Azhar Kasmiran
964d6fbfb2
Allow testing of rizin -qc "..." - on not-windows-any (#2473) 2022-03-31 16:28:20 +02:00
Khairul Azhar Kasmiran
907f296f57
Move "p8|sed -e s,1,x,g>x;cat x;rm x" test back under cmd/feat_redirect (#2463) 2022-03-30 23:23:20 +08:00
GustavoLCR
0c4308d07e
Add module name to PDB flag name (#2435)
* Add PDB flags inside `symbols` flag space
* Use `rz_bin_get_baddr()` in `rz_core_pdb_load_info()`
* Fix tests
2022-03-29 12:49:34 +08:00
GustavoLCR
e945fb0e31 Introduce rz_file_dos_basename() API
Use it whenever we need to interact with paths that can contain `\` as a separator as well
2022-03-29 09:27:51 +08:00
GustavoLCR
77c46e1c9d Fix rz_file_basename on Windows 2022-03-29 09:27:51 +08:00
Giovanni
d344d29a57
Moved rz_analysis_esil_dumpstack to rz_core_esil_dumpstack (#2460) 2022-03-28 19:55:46 +08:00
Giovanni
7b06001ed9
Remove cb_printf() from RzAnalysis (#2454)
* Moved `rz_analysis_var_list_show()` under rz_core as static function
* Removed `cb_printf()` from RzAnalysis and refactoring zignatures
* Removed newline from matches
* Use `stdout` for ESIL traps
* Converted commands to use RzCmdStateOutput
2022-03-28 08:22:19 +08:00
Florian Märkl
1cbd1d7b31
Introduce addr_bits to type db for e.g. thumb (#2457)
This has the same meaning as rz_analysis_get_address_bits(), i.e. the
size of an address, which is often, but not always the same as the
"asm.bits" bitness, especiall in thumb where it has to be 32, rather
than 16. This fixes pointer size calculation for such cases.

Fix #1835
2022-03-27 15:53:42 +02:00
Florian Märkl
8414d224ed
[RzIL] Add lifter for Armv8 AArch64 (#2354) 2022-03-27 10:29:51 +02:00
Giovanni
f87025d1e8
Remove cb_printf() from RzBin (#2446)
* Remove `cb_printf()` from RzBin
* Removed `bin.rawstr` from `rz-bin`
* Dropping `izzz` since does the same as `izz`
* Fix PE one section executables
* Fix behaviour of BFLT, LE, and SMD bin plugins
2022-03-26 20:30:55 +08:00
Khairul Azhar Kasmiran
fc66b66206
Remove .replace("\r\n","\n") from cmd_pipe tests (#2452) 2022-03-26 12:35:21 +08:00
Giovanni
acc339fc2f
Add rz_lang_byte_array and remove rz_print_code (#2444)
* Added rz_lang_byte_array and removed rz_print_code + refactoring cmds
* Added test for big endian
* Removed vlang and sync oldshell with newshell cmd changes
* Fixed in a more portable way conversion on signed byte for Java/Kotlin
* Resolved comments and added examples to help users
2022-03-25 20:45:57 +08:00
Rot127
a1b3332cb2
Move minunit due to compile errors. (#2439) 2022-03-23 20:00:47 +08:00
Riccardo Schirone
7f19c8f867 Split unit and integration tests 2022-03-23 10:34:53 +01:00
GustavoLCR
7e8fc2e97f Move cmd_aO test file to fix git on Windows
Case insensitivity causes all sorts of problems
2022-03-22 09:01:29 +01:00
billow
3632192818
Convert dt commands to rzshell (#2418) 2022-03-22 09:12:12 +08:00
Peiwei Hu
79454cdbe2
Convert a8, aO and ao command to rzshell (#2396) 2022-03-21 16:58:54 +08:00
Riccardo Schirone
86d20b2d16
RzShell: Remove possibility to switch to oldshell (#2420)
Due to some commands/tests still using the legacy "..." commands, we
can't fully remove oldshell code yet, but with this patch we just hide
it from the end users. Rzshell is now the default and only shell and
rzshell autocompletion is the default and only autocompletion engine.
2022-03-17 14:49:34 +01:00
GustavoLCR
170ab3eb3b
Remove windows.h include from rz_types.h (#2410)
* Create `rz_windows.h`
* Move `RzThread` structure definitions to internal header
* Create and use `rz_th_get_user()` API to avoid exposing `RzThread` layout in external header
* Make `rz_th_self()` an IPI
* Use `_wmkdir()` in `rz_sys_mkdir()` on Windows
* Remove unused `winkd_break_read` function
* Remove `RzIORap` definition from `rz_io.h`
* Remove include of `Windows.h` from `rz_types.h`
* Use `rz_windows.h` when necessary
* Remove `RzCoreRtrHost` definition from `rz_core.h`
* Remove `rz_socket.h` include from `rz_core.h`
2022-03-16 13:54:41 +01:00
Riccardo Schirone
d20b026ce2
Finish conversion of w commands to rzshell (#2412)
* Convert 'wz' to rzshell
* Remove 'wt' commands in favour of > operator
* Convert 'ww' command to rzshell
* Convert 'wm' command to rzshell
* Convert 'wd' command to rzshell
* Convert 'wu' command to rzshell
* Convert 'wo' commands to rzshell
* Fix 'w' tests
2022-03-16 11:20:29 +00:00
GustavoLCR
dd81b6629a
Implement getting a backtrace from a Windows Kernel Dump for x64 (#2387)
* PE: Add header to mappings
* PE: Add temp defs for unknown `UNWIND_CODE_OPS`
* Core Bind: Add `RzCoreBinApplyInfo` binding
* DMP/WinKD: Always add kernel modules to mod list
* Implement Windows x64 SEH backtracing
* Fix `ompb` not prioritizing maps
* Optimize `rz_io_map_priorize()`
* DMP: Implement backtrace for x64
2022-03-15 10:45:02 +01:00
Khairul Azhar Kasmiran
934588cfa5
!!: Fix extra \r on Windows (#2401)
* `!!`: Fix extra `\r` on Windows
* Use more efficient algorithm
* "Fix" cmd_pipe test
* "Fix" shared_memory.py
* Move feat_redirect test to archos/not-windows-any
2022-03-14 21:55:12 +08:00
Florian Märkl
88ec019514
Store back-references to core files in RzIOMap (#2408)
This allows tracing an io map back to the RzCoreFile and thus also its
bin file and other info. This is used in rz-ghidra to determine which
memory ranges can be considered readonly to enable constant propagation.
2022-03-14 10:09:14 +01:00
Florian Märkl
bedcf6f354
Add indicator to oml for which map is visible at seek (#2409)
There may be multiple maps containing the current seek. This indicates
only the highest-priority one, which is also the one whose data is
visible at the seek address.
2022-03-14 08:59:40 +01:00
Peiwei Hu
d7cb78879e
Add hint for unexpected type definition (#2393) 2022-03-14 10:46:59 +08:00
Khairul Azhar Kasmiran
7ede9dfd39
Update libc6 and dbg.maps.count.after.map test (#2403)
* Update `dbg.maps.count.after.map` test
* `ci.yml`: Install latest version of libc6
* `tcc.yml`: Update libc
2022-03-12 19:11:22 +08:00
Akihiko Odaki
13edb7440b Fix /a input option parsing when the pattern lacks 2022-03-11 18:28:06 +01:00
Peiwei Hu
babb7bf342
Remove command 0 (alias for s 0x...) 2022-03-09 22:10:13 +08:00
Florian Märkl
298ac10d6e
[RzIL] Fix sbc/sbci and leaks in AVR lifter (#2389)
Leaks detected by running rz-test with asan-built rz-asm. The sbc
instructions didn't do the carry subtraction right and threw away half
of the computation, which is why it was detected through leaks.
2022-03-07 15:50:11 +00:00
Dhruv Maroo
1532342358 Add --print-errorlogs flag meson test for Windows jobs 2022-03-06 16:54:44 +01:00
wargio
f3ad6c8516 Moved rz_print_randomart under rz_hash and removed it from rz-ax 2022-03-06 16:29:03 +01:00
Giovanni
db580beb22
Refactoring for rz_print_2bpp_* and ps<cmd> (#2376)
* Moved rz_print_2bpp_* under rz_core
* Moved rz_print_string to rz_str_stringify_raw_buffer
* Added test for print urlencode and added pu0
* Removed RzCoreString and implemented utf32be/utf16be
2022-03-04 15:30:46 +01:00
Khairul Azhar Kasmiran
3125603f89
Complete prompt cycle in prompt tests (#2381) 2022-03-04 20:33:09 +08:00
Anton Kochkov
da3fe72686 Increase timeout for RZIL test 2022-03-04 00:38:22 +08:00
Khairul Azhar Kasmiran
d525579475
Add tests for Rizin prompt (#2377) 2022-03-03 17:24:22 +01:00
GustavoLCR
ccfde0de98 DMP: Add/fix tests 2022-03-03 21:52:41 +08:00
wargio
0fd8a0d847 removed test 2022-03-03 12:56:12 +01:00
Riccardo Schirone
f745478fde
Improve suggestions when wrong command/args is used (#2365) 2022-03-02 10:39:33 +01:00
Khairul Azhar Kasmiran
9cfcd65d1d
Remove unnecessary aezi from rzil/bf test (#2373) 2022-03-01 22:05:00 +08:00
Khairul Azhar Kasmiran
45bf3677b2
Add double aezi test (#2372) 2022-02-28 22:48:03 +08:00
Florian Märkl
95ff6fd38a
Fix separation of fpu and gpr in arm64 reg profile (#2368)
d/s/h/b regs are in a different file than x/w regs.
2022-02-27 16:46:20 +01:00
Khairul Azhar Kasmiran
f3c77de061
aezsu: Fix outdated pc when checking for completion (#2367)
* aezsu: Fix outdated `pc` when checking for completion
* Check reg pc after stepping as well
2022-02-27 22:04:45 +08:00
Khairul Azhar Kasmiran
b4c716a99d
Fix broken aezi test (#2366) 2022-02-27 18:20:12 +08:00
Riccardo Schirone
37805dd012
RzCmd: add support for dynamic arg choices (#2362) 2022-02-25 11:40:24 +00:00
Riccardo Schirone
9df2994127
RzCmd: add support for dynamically generated details sections (#2361)
So far all the help sections were statically generated from the YAML
files, however sometimes you may want to list things in the help
messages that depend on what is loaded in Rizin (e.g. plugins, etc.).
This patch adds support for a details_cb that provides a dynamically
created RzCmdDescDetail array.
2022-02-25 09:25:15 +00:00
GustavoLCR
ddea0c01e7 PDB: Add/fix tests 2022-02-25 13:17:20 +08:00
Giovanni
63622fa9e6
[RzIL] AVR lifter (#1890)
Added all the ops excluding des and spm due their complexity
Added tests to verify output of each execution cycle.
2022-02-22 18:54:55 +01:00
Florian Märkl
bfb98ed20c
[RzIL] Add lifter for 32-bit Arm, including thumb (#2241) 2022-02-22 12:23:28 +00:00
Florian Märkl
0549b2b5fb
Fix trailing bits in rz_bv_set_to_bytes_le() (#2348)
Any traling bits in the last byte that is to be written should be left
alone.
2022-02-21 23:05:50 +01:00
Florian Märkl
c9d299155c
Fix UB in rz_bv_set_all(..., 64) (#2345)
Shifting a 64-bit value by 64 bits is UB. Restructuring it like this is
fine because the bv len must never be 0.
2022-02-21 13:31:18 +00:00
Florian Märkl
102549102d
Refactor Arm IT handling and fix for 4-byte ops (#2336)
The code was duplicated in both asm and anylsis, so now it's in
arm_it.c.
Previously, conditions were applied to N offsets after an IT instruction
using a fixed stride of 2 bytes. This obviously breaks for 4-byte thumb2
instructions, but whenever we find such an instruction, we can check if
there is a condition inside of it and readjust if necessary.
2022-02-19 17:16:15 +01:00
Khairul Azhar Kasmiran
03feef1396
disasm, scr.utf8=1: Add missing @ to self-loops (#2335) 2022-02-19 10:42:54 +08:00
Florian Märkl
76cec13591
Fix rz_bv_len_bytes() (#2334) 2022-02-18 18:11:33 +01:00
Khairul Azhar Kasmiran
a48068ff8d
Drop scr.interactive requirement for s error (#2333) 2022-02-18 21:25:00 +08:00
Riccardo Schirone
dffc891ff8 Fix tests still using '...' syntax 2022-02-16 16:25:37 +01:00
Riccardo Schirone
2a118ee413
Convert 'we' commands to rzshell (#2325) 2022-02-16 09:31:50 +00:00
Peiwei Hu
9258676789
rz-find: enable search within import and symbol table (#2256)
adds the ability of searching within import and symbol table
command -S has been changed to -w
2022-02-15 13:40:00 +01:00
Giovanni
b1af4e3840
Added test for FLIRT correctness (#2319) 2022-02-15 12:27:13 +08:00
Khairul Azhar Kasmiran
e68a5f785d
Fix #2072: Convert main vaddr to paddr first (#2320)
* Fix #2072: Convert main vaddr to paddr first
* Declare freepascal test as broken
2022-02-15 00:05:09 +08:00
Riccardo Schirone
6ba4e79a4e
Remove BROKEN from few tests about main signature detection (#2318) 2022-02-14 21:04:57 +08:00
Rot127
3d71687d5e
Add Hexagon IDE conforming packet syntax (#2209)
* Add option to print instruction packets syntax in objdump style.
* Add the config `plugins.hexagon.sdk` to toggle syntax.
* Remove unused trimming.
* Trim only newlines from the assembly string.
* Add new trim functions to allow trimming of certain chars.
2022-02-14 02:27:55 +08:00
Florian Märkl
bdd9b20afe Fix rz_bv_div() and rz_bv_mod()
Problems fixed:
* Division by repeated addition is horribly slow, now it's classic
  shift+sub
* a / a = 1, not a
* rz_bv_set_all() was setting too many bits if len % 8 != 0
* Removed print on div by 0 because we define it to all 1s (like BAP)

mod just uses div and we use regular ut64 division when possible.
2022-02-13 17:57:17 +01:00
Florian Märkl
05f47d2397 Add ctz and clz ops to RzBitVector
These are typical "count trailing/leading zeroes" to be used in
division for example.
2022-02-13 17:57:17 +01:00
Florian Märkl
e2751e5c49 Make big bvs store in typical little endian
Previously, bits were stored in the big endian in reversed order, such
that bit 0 of byte 0 would contain the msb. This requires reversing them
for any calculation and becomes even more confusing when the size is not
a multiple of 8, so let's just store them in classic little endian with
bit 0 of byte 0 containing the lsb.
This also fixes rz_bv_as_hex_string() for bvs that have a size not
divisiable by 0.
2022-02-13 17:57:17 +01:00
Florian Märkl
9401c9d67e Fix rz_bv_as_hex_string() for big 0
This was printing `0x` instead of `0x0` for big vectors when padding was
disabled.
2022-02-13 17:57:17 +01:00
GustavoLCR
5eaea7a552
PE x64 SEH fixes (#2310)
* Fix missing SEH scopes in x64 PE
* Fix multiple exception scopes in same address not adding flags
* Also add flags for the exception filter if it exists
* Fix assertion in `rz_analysis_block_update_hash()`
* Add call reference for exception filter
* Update old block's hash when creating a new block in trycatch analysis
* Fix try-catch control flow analysis
* Fix test
2022-02-13 21:32:40 +08:00
Florian Märkl
f729512817
Fix pcalign after changing analysis bits (#2306)
This fixes a bug that showed up after 2bdec10f98
because the bits value was set after cpu, but pcalign was already 4 then
and not updated by bits for example in:

rz-asm -a arm -b 16 -o 0x1059e -A dff81000
2022-02-13 09:28:33 +01:00
Khairul Azhar Kasmiran
f6ea17e1e0
?P: Ignore io.va (#2305) 2022-02-12 22:02:50 +08:00
Florian Märkl
2bdec10f98
Fix cpu in rz-asm -A (#2303)
For analysis info, the cpu also needs to be set on the RzAnalysis, not
only RzAsm.
2022-02-11 22:53:02 +01:00
Khairul Azhar Kasmiran
dbbd4da41a
Fix #2299: ?p ignores io.va (#2302) 2022-02-11 17:36:22 +01:00
Riccardo Schirone
52825a7a02
Convert 'wc' commands to rzshell (#2297)
Remove `wcr` because dup of `wc-*`.
2022-02-10 15:48:57 +01:00
Riccardo Schirone
dea0918afd
Convert wa commands to rzshell (#2293) 2022-02-09 18:49:11 +08:00
Khairul Azhar Kasmiran
04ff3f3af5
Fix #2288: Clear ds->opstr on pdf '..' (#2294)
* Fix #2288: Clear `ds->opstr` on pdf '`..`'
* Base test output
* Fix cmd_pd2 test
* Fix elf/reloc test
* Fix cmd_af test
2022-02-08 18:03:43 +01:00
Florian Märkl
76e776907e
[RzIL] Add remaining comparison aliases and tests (#2295) 2022-02-08 17:29:35 +01:00
Riccardo Schirone
2c02457109
Convert o commands to rzshell (#2281) 2022-02-07 18:23:31 +01:00
chinggg
95be95e89a
Add floating point support to math operations (#2287) 2022-02-07 11:18:22 +01:00
wargio
8d238ddfc8 Fix asm tests 2022-02-06 15:50:50 +01:00
Giovanni
687b8e8fec
Rename functions properly and ensure to remove the old flags. (#2289)
* Rename functions properly and ensure to remove the old flags.
* Rename flag instead of deleting it
* When renamed, the flags are not set in the right flag space.

This reverts commit bf39802452b7545551f52c4c32f8c01764ab2a75.
2022-02-06 22:21:21 +08:00
wargio
3cb17236e2 Wrong esil test 2022-02-06 12:08:16 +01:00
wargio
1b98f63b6c Fixed tests 2022-02-06 12:08:16 +01:00
Florian Märkl
d533276df8 Fix cmn, teq and tst in arm32 assembler 2022-02-06 12:32:22 +08:00
Florian Märkl
bd98b8c28e Add asm.cmt.il and refactor asm.cmt.esil
asm.cmt.esil was handled in a somewhat peculiar way, printing below the
disassembly if asm.cmt.right=0, even though every other comment is
printed above. Now it is more in line with all other commenting and the
new asm.cmt.il works in the same way.
2022-02-05 21:50:48 +01:00
Florian Märkl
325ab7c2bb Extend bitvector and reg unit tests
Some additional tests for bitvector access of single-bit registers.
2022-02-05 21:50:48 +01:00
Anton Kochkov
2f638cad1e Convert f commands to rzshell
* Changed behavior of `f` to only add flag if there is none
* Changed behavior of `f+` to add flag in any case
* Moved listing subcommands from `f` to `fl`
* Moved listing subcommands from `f.` to `f.l`
* Added subcommand `f.l*` to list all local flags in all functions
* Listing flags at the current offset became `fl.`
* Moved `f=` to `fl=`
* Old `fl` (flag length) now became `fL`
* Removed original `fe` commands
* Old `f?` (check if flag exists) now became `fe`
* Removed `fV` commands
* Removed `fn` commands in favor of `fl` and `asm.flags.real=true`
* Removed `fS` commands (`fSo` and `fSn`)
* `fo` became `fortune` and moved from "flags" to "shell" category
* Removed oldshell handlers of the `z` commands
2022-02-03 21:46:42 +08:00
Khairul Azhar Kasmiran
28d8f7d335
Use ar in some rzil bf tests instead of aezv (#2279) 2022-02-03 10:56:44 +01:00
Florian Märkl
00107ea05d
Add patching for R_386_32 and R_386_PC32 (#2278) 2022-02-03 00:12:06 +01:00
Khairul Azhar Kasmiran
2105f87b35
Remove dup 'loopy hello world' test (#2276) 2022-02-02 18:06:24 +01:00
Khairul Azhar Kasmiran
9530186f46
Add rzil bf "repeat-emu-run" test (#2275) 2022-02-02 18:33:13 +08:00
Khairul Azhar Kasmiran
d51df2d46c
Remove -b32 from bf rzil tests (#2274) 2022-02-02 11:38:54 +08:00
Khairul Azhar Kasmiran
2fbaf94d78
bf_syscall_write: Use fflush and don't print NUL 2022-02-01 17:25:54 +08:00
Anton Kochkov
91b414708c Remove unused esil.debug config variable 2022-02-01 17:25:03 +08:00
Florian Märkl
85c00053e0
Enable specifying exact reg bindings in RzAnalysisILConfig (#2261) 2022-01-29 09:14:08 +00:00
Florian Märkl
6af80b33a7
[RzIL] Coalesce nested seq when printing (#2262)
Change printing of
    (seq (...) (seq (...) (...)))
to just
    (seq (...) (...) (...))
2022-01-28 16:58:51 +01:00
Florian Märkl
bbe3c0724d
Add sb (= r9) alias to arm assembler (#2260) 2022-01-28 16:58:35 +01:00
Dhruva Gole
64740dd2d3
Add power/exponent to math operations (#2220) 2022-01-27 14:49:19 +01:00
Florian Märkl
40c35ac5b1
Fix dcu printing regular output as ERROR (#2257) 2022-01-27 09:58:01 +01:00
Khairul Azhar Kasmiran
2db04a55f1
Set bf machine memory size to 30,000 (#2252) 2022-01-26 17:13:06 +01:00
Florian Märkl
06ccd06197 Add unit tests for software breakpoints 2022-01-26 17:12:26 +01:00
Florian Märkl
33cad678c8 Make dcu fail on failed bp instead of blindly continuing 2022-01-26 17:12:26 +01:00
Florian Märkl
490fb69685 Refactor: Replace corebind by need-driven context in RzBreakpoint 2022-01-26 17:12:26 +01:00
Florian Märkl
e2edd9d1ef
Fix many pointer/int conversion warnings on arm32 (#2246)
This is -Wint-to-pointer-cast and -Wpointer-to-int-cast of gcc 10 on
arm32
2022-01-25 11:41:17 +01:00
Khairul Azhar Kasmiran
f50543ca28
Add test for case-insensitivity of #2236 (#2245)
* Add test for case-insensitivity of #2236
* Add `-c core.symlinks=true` to AppVeyor's `git clone rizin-testbins`
2022-01-25 17:25:19 +08:00
billow
6a7cb865b4
Fix OOB in overlapping variables resolution (#2222)
* Fix a crash during variables type propagation
* Fix test int64_t variable overlapping removal

Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2022-01-25 10:14:54 +01:00
GustavoLCR
66d6bb9438
Fix OOB write in rz_str_unescape() if last char is \ (#2238) 2022-01-24 17:06:41 +08:00
Florian Märkl
ab3bd63b6b Move bitmask creation to common rz_num_bitmask() 2022-01-23 18:29:31 +01:00
Florian Märkl
5a2d80c728 [RzIL] Fix sbc V and unused status bit
Detected with rz-tracetest
2022-01-22 20:04:24 +01:00
Florian Märkl
1a3ba85c48 [RzIL] Add rz_il_value_eq()
Needed for rz-tracetest
2022-01-22 18:40:10 +01:00
Florian Märkl
efa41b86d7 [RzIL] Refine events and add tests
* Removed nullability where not needed
* Made events take RzILVal instead of force-converting to RzILBitVector
  for variables
* Added more fine-grained tests for events from specific ops
2022-01-22 18:40:10 +01:00
Khairul Azhar Kasmiran
c4ce21b587
Fix #2218: .bf extension identifies file as bf if contents are not recognized (#2236) 2022-01-23 00:33:33 +08:00
Florian Märkl
a1e7306e2f [RzIL] Fix fill bit in shiftl/shiftr 2022-01-22 09:40:20 +08:00
Florian Märkl
5c4a9aac68 [RzIL] Fix 6502 asl and sbc 2022-01-22 09:40:20 +08:00
Rot127
e9be7afc37
Fix CID 367529 (#2231)
* Remove duplicated branch to determine instruction type.
* Fix test by removing not utilized 0x0.
2022-01-21 14:06:14 +01:00
Florian Märkl
90e4e5cf16
[RzIL] Fix rti and stack behavior in 6502 IL
Detected with rz-tracetest
2022-01-21 09:22:34 +01:00
Giovanni
afe1dc3bae
[FLIRT] Add sigdb details and fixed bugs #2223 2022-01-20 17:19:40 +01:00
Florian Märkl
f9e01ba07d [RzIL] Rewrite RzAnalysisRzil as RzAnalysisILVM with config
RzAnalysisILVM wraps around the low-level RzILVM and enables emulation
of real code from disassembly, rather than raw IL.
Analysis plugins now don't actively initialize the vm anymore, but
return a fully declarative description RzAnalysisILConfig of how to set
up the vm and optionally its initial state.
This also enables multiple IL vms to exist at the same time as plugins
can not mess with the global vm anymore. See the added integration test
for an example.
2022-01-17 16:50:40 +01:00
Florian Märkl
65efe6699c [RzIL] Make aezs and aezse stop on error 2022-01-17 16:50:40 +01:00
Florian Märkl
20777b6e0b
[RzIL] Make bf emulation stateless (#2214) 2022-01-16 14:33:05 +01:00
Florian Märkl
114667a34e [RzIL] Implement 6502 Lifting
This adds RzIL lifting for all legal 6502 ops, except the special bcd
modes of adc and sbc for now. The lifting of every one of these ops is
covered by an asm test, making sure all IL is valid. Some manual
execution tests are available too, including one that runs a simple
real-world xor-"decryption" loop.
The lifting has not been tested against traces yet, so minor mistakes in
the semantics are currently expected.
2022-01-16 03:21:49 +01:00
Khairul Azhar Kasmiran
50638dfb19
Simplify pt boundaries test using ..( (#2213) 2022-01-15 17:19:40 +08:00
Anton Kochkov
538ffe3739 Convert fs commands to rzshell 2022-01-15 09:11:40 +08:00
Riccardo Schirone
0d415bc346
Delete ESIL stack memory after type propagation (#2207) 2022-01-14 16:52:39 +00:00
Florian Märkl
6ba0f3a091 [RzIL] Make aezsu stop on invalid ops 2022-01-14 17:24:35 +08:00
Florian Märkl
5be9fa2f0f [RzIL] Update flags on init and step 2022-01-14 17:24:35 +08:00
Rot127
f40b5ef545
Hexagon v69 update (#2180)
Also new in this commit:
- Uses system registers as defined in LLVM definitions.
- Several new Hexagon v69 (HVX) instructions.
- File header now has the LLVM commit and timestamps of the source file generation.
2022-01-14 16:46:38 +08:00
Riccardo Schirone
6c2ee73fe7
Convert 'ob' commands to rzshell (#2201)
* Use API instead of 'oba' command in rizin.c
* Fix tests and use API instead of 'ob' commands
2022-01-14 08:45:16 +00:00
GustavoLCR
0457d9f5a3
Print path and GUID of the downloaded PDB file in the JSON output (#2199)
* Don't download the file if it's already downloaded
2022-01-14 11:22:23 +08:00
Florian Märkl
1fcf76faf8 [RzIL] Forbid data after ctrl effects by validation
Because there is currently no reason to have non-ctrl effects after a ctrl
effect (because then we have already jumped somewhere else), we reject this
kind of code altogether.
This leaves future semantics of such code open without breaking any
existing IL, in case it will be needed at some point.
2022-01-13 21:35:25 +01:00
Florian Märkl
111cd2c476 [RzIL] Make jumptargets independent of opsize
Previously, after a (jmp x) with opsize y, the jump target would
actually be x + y because the addition happened after the evaluation.
Now we actually jump to the target specified by the op.
2022-01-13 21:35:25 +01:00
Florian Märkl
4f1e4ee6d5 Add asm tests for all legal 6502 ops
Ops with relative addressing now also only pad with 4 leading zeroes.
2022-01-14 00:47:33 +08:00
Khairul Azhar Kasmiran
4a9d3f2438
Fix #2135: Add ..( command (#2184)
* Fix #2135 - Add `..(` command
* Use `RZ_LOG_ERROR` instead of `eprintf` inside `macro_call()`
* Improve `(?`
2022-01-13 18:10:23 +08:00
Florian Märkl
ca301b9a24
Add support for DYLD_CHAINED_PTR_ARM64E_USERLAND24 (#2197)
Original commit: 169c643a7ad7a1978ff39fba0c326bd26c9f1d4c
Original author: Francesco Tamagni <mrmacete@protonmail.ch>
2022-01-12 16:44:12 +01:00
Riccardo Schirone
afc635f6d1
Convert om commands to rzshell (#2192)
* removal of `omo` command
* use of `oml`, `oml.` and `oml=` to list maps instead of `om`
* removal of RIZIN output from `oml`
* removal of `omn.` and just assume `omn` uses core->offset
2022-01-11 17:29:20 +01:00
Florian Märkl
c8a6359d83
Change IL string syntax to s-expressions (#2193)
Before:
	store(key:var(v:ptr), value:add(x:load(key:var(v:ptr), mem:0),
	    y:int(value:1, length:8)), mem:0)
After:
	(store 0 (var ptr) (+ (load 0 (var ptr)) (bv 8 0x1)))

S-Expressions like this are more concise and will be trivial to parse,
in case we want a parser for this later. It is also very similar to what
BAP uses, so it will be easier to compare.
2022-01-11 10:08:41 +01:00
Florian Märkl
7e36f4bd38 Add IL lifting testing to rz-test 2022-01-10 19:27:09 +01:00
Florian Märkl
cd938d2083 Add -I (IL lifting) option to rz-asm
$? is also set to the return value of a command run by ! for testing
this.
2022-01-10 19:27:09 +01:00
Florian Märkl
157e40d65b
[RzIL] Add Validator (Type-checker) (#2182)
This adds the IL validator, which performs static type-checking of both
pure and effect ops among other checks. In particular, assuming the
validator is correctly implemented, if it considers an op to be valid
under some context, evaluating the op in the vm will never yield a
runtime error, that is, an error where the vm itself errors, not an
expected error state of the code being executed. In our case, this
includes for example:

* Any kind of type error: Conditions not being bool, bitvector sizes not
  matching, ...
* Variables not being available when they are accessed Using local
* variables with multiple different types in a single effect etc.

Any code that we lift must obey these rules. Thus, any analysis can rely
on it. The plan for this is to use the validator primarily in testing,
development of lifters and for IL code coming from the outside. If our
lifting code is covered well enough by tests using the validator, we can
omit the validation at runtime.

The only ops that do not have well-defined validation yet are blk and
goto since their semantics, in particular regarding label handling are
still a bit vague. This also removes the concat and unk ops since they
are unimplemented and not needed.
2022-01-10 16:54:13 +01:00
Anton Kochkov
1b2748604e
Fix the RZ_BIN_PREFIX test for Windows (#2189)
* Fix the RZ_BIN_PREFIX test for Windows
* Do not use previous VS2019 image
2022-01-09 13:47:38 +08:00
Anton Kochkov
4487d7e1ac Port fd commands to the rzshell 2022-01-08 10:59:10 +08:00
Anton Kochkov
d80d70a361 Port fz commands to the rzshell 2022-01-08 10:59:10 +08:00
Paul I
dd6de07c96
Convert ac commands to rzshell (#2160) 2022-01-08 10:58:43 +08:00
Rot127
1409025ecf
Adapt basic block analysis for the Hexagon architecture. (#2073)
* Rebase onto branch 'dev' and resolve conflicts.
* Add tests for unmapped jumps.
* Fix test: Flags are correctly detected.
2022-01-05 16:51:44 +00:00
Florian Märkl
54318a2268
[RzIL] Rework Variable Handling (#2174)
There are now three kinds of vars: global, local and local pure. Global
and local pure are exactly like in BAP, local ones are defined by their
initial set op and have the scope of a single lifted instruction.

The set op now handles both global and local vars, let is now pure and
binds only inside its body. Vars have static types, global and local are
always mutable, local pure naturally immutable.

The var op specifies the kind of variable to take from, and the
individual variable sets are separate. This corresponds to BAP's
behavior where the kind of variable is part of the identifier.

Variable content storage has also been rewritten and RzILBag removed.
2022-01-05 11:16:47 +00:00
GustavoLCR
2e065789a7
Fix #1377 - Handle forward definitions in PDB parser 2022-01-05 18:38:02 +08:00