Commit graph

1904 commits

Author SHA1 Message Date
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
Paul I
263e103fee Remove optional <addr> argument for afb commands 2022-01-05 11:30:16 +01:00
Rot127
63a3fbde2d
Search RzAnalysisOp.analysis_vals[] for xrefs. (#2067)
* Add documentation for 'rz_core_analysis_search_xrefs'

* Search RzAnalysisOp.analysis_vals for references as well.

* Add test case for string search in RzAnalysisOp.analysis_vals.

* Replace int with RzOutputMode to indicate the output mode of the commands.

* Let `rz_core_analysis_refs()` use the `RzOutputMode` enum.

* Split `found_xref()` to `is_valid_xref()` and `print_xref()`.
2022-01-04 18:09:16 +08:00
Florian Märkl
5ddb19c692 [RzIL] Clarify what append actually does
high/low is more descriptive than x/y. Test has also been added.
2022-01-03 17:18:33 +01:00
Florian Märkl
b338949dd4 [RzIL] Fix PC initialization and instruction fetch
Intruction was fetched from possibly outdated RzIL PC.
2022-01-03 17:18:33 +01:00
Dhruv Maroo
386008482f
[RzIL] Implement effects: BLK and REPEAT (#2119) 2022-01-03 12:41:52 +00:00
Giovanni
3e9598d298
RzDiff optimizations and fix #1770 (#2156)
* Added infinite scroll
* Avoid analyzing the whole bin when graph diffing functions
2022-01-03 13:10:44 +01:00
Florian Märkl
c34ae1a7b5
Rename RZIL occurences to RZ_IL 2022-01-03 10:20:11 +01:00
Florian Märkl
9938a85c4b
[RzIL] Add RzReg/Variable Binding (#2155)
Plugins do not create register-based variables themselves anymore, but
they are derived from the register profile. However not all registers
may be bound and not all variables may be actual registers. The concrete
relations between an RzILVM and registers is described by an
RzILRegBinding object. It is simply a list of register names and
variables are created of the same names. When stepping with aezs, the
registers are synchronized automatically. From now on, aezv is primarily
useful for debugging, but interacting with emulation from the user side
should be done with ar.
2022-01-02 17:56:19 +00:00
Anton Kochkov
9c18ea0dc6
Port ft commands to the rzshell (#2162) 2022-01-03 00:33:01 +08:00
Khairul Azhar Kasmiran
e0fe262360
Show error if no-arg macro is called with args (#2161) 2022-01-03 00:26:36 +08:00
Pedro-Bernardo
4f9fe46b34
Fix optype-to-string conversion (#2158) 2022-01-01 01:35:29 +08:00
Florian Märkl
7a8d5af180 [RzIL] Add rz_il_op_new_(unsigned|signed)() 2021-12-30 10:21:45 +01:00
Paul I
f8d222e138
Convert ah commands to rzshell (#2130) 2021-12-30 12:44:51 +08:00
Florian Märkl
86a7439519
Add IO/Map-based RzBuffer Implementation (#2147)
This adds an RzBuffer implementation that binds against RzIO's
rz_io_read_at/rz_io_write_at in order to access the mapped memory. This
is in contrast to the previous io RzBuffer, which has been renamed to
..._io_fd and which reads directly from a single file descriptor without
mapping.
To keep bf working, bin_bf now maps an area of zeroes because
otherwise the initial memory contents in RzIL would read as 0xff.
2021-12-29 10:28:55 +01:00
Florian Märkl
5d93ca3330
[RzIL] Flatten out all RzILOpArgs* structs (#2151)
This reduces heap usage and indirection.
2021-12-28 20:47:10 +00:00
Florian Märkl
aa80d2870f
[RzIL] Make cast work as in BAP (#2152) 2021-12-28 21:22:30 +01:00
Florian Märkl
d556d57d3f [RzIL] Fix minor leaks 2021-12-28 13:37:54 +01:00
Florian Märkl
6a09385746 [RzIL] Remove vector-oplists in favor of seq
The root type of a lifted op is now simply a single RzILOpEffect, which
can be for example a chain of seq ops. This is in line with what BAP
uses.
For convenient creation of sequences, `rz_il_op_new_seqn(ut32 n, ...)`
is a drop-in replacement for `rz_il_make_oplist(ut32 n, ...)`.
2021-12-28 13:37:54 +01:00
Paul I
6fca51c6cb
Convert afn commands to rzshell (#2139)
* Convert afn commands to rzshell
* Remove oldshell help for afn
2021-12-27 18:19:01 +01:00
Florian Märkl
78025648ea
[RzIL] Make RzILOp statically typed (#2140) 2021-12-27 00:13:24 +08:00
Florian Märkl
1a2afca338
Fix Double Free in Cs without a Bin File 2021-12-26 15:23:31 +08:00
Anton Angelov
00fe25867b
Fix x86 disassembly issues related to MASM syntax (#2123) 2021-12-24 16:58:12 +01:00
Giovanni
5963da2bba
[RzIL] Add loadw/storew and bind memories against RzBuffer (#2105)
* [RzIL] Load/Store via RzIO and RzBuffer
* [RzIL] LoadW/StorWe via RzIO and RzBuffer
Co-authored-by: Florian Märkl <info@florianmaerkl.de>
2021-12-24 16:53:20 +01:00
Anton Kochkov
89d61756c1
Fix self-referential typedef format (#2134) 2021-12-24 00:53:36 +08:00
wargio
e80968f031 [FLIRT] verify the name is always unique. 2021-12-23 17:06:55 +01:00
wargio
d92a708541 [FLIRT] add info extraction 2021-12-23 17:06:55 +01:00
Riccardo Schirone
6f40dfe493
Move remaining things from shlr/ to meson subprojects (#2126)
* Move binrz meson directives to binrz/ dir

* Move rizin-shell-parser to a subproject

* Move bochs to a meson subproject

* Move rzqnx to meson subproject

* Move winkd to a meson subproject

* Move rzar to a meson subproject

* Move rzw32dbg_wrap to a meson subproject

* Move ptrace-wrap to a meson subproject

* Move rzgdb to a meson subproject

* Rename w32dbg_wrap to rzw32dbg_wrap

* Update CODEOWNERS

* Remove old references to shlr

* Move shlr/heap stuff in core and remove shlr/arm

* Move spp to a meson subproject

* Remove last references to shlr

* Remove use_webui option

* Move include files directives to librz/include/meson.build

* Move librz meson directives into librz/meson.build

* Handle d/ directories inside the specific module meson.build

* Move plugins listing to specific module meson.build

* Move rzheap to its own subproject

* Fix js linter and licenses

* Use meson.override_dependency for all rz_ modules
2021-12-22 09:20:39 +08:00
wargio
5dafbf7e67 [core] aezv - modify variables in RzIL VM 2021-12-21 19:50:17 +01:00
wargio
869a36d55b [core] Add aezsu - RzIL step until addr 2021-12-21 19:50:17 +01:00
Florian Märkl
9b60670013 Prepare various RzReg accesses for splitting
Common accesses for both debug and analysis must not use
debug->reg or analysis->reg, but go through rz_core_reg_default().
2021-12-21 13:14:08 +01:00
Florian Märkl
affe8c89e1 Make fs+ trim whitespace of the arg
Previously, `fs+ myname` would use the flagspace " myname" with a
leading space. This made .arf inconsistent with setting regs-flags from
C and the syntax `fs+myname` would not be allowed in the future with
newshell anyway.
2021-12-21 13:14:08 +01:00
Florian Märkl
a7c076c56c Add basic tests for de (ESIL watchpoints) 2021-12-21 13:14:08 +01:00
Giovanni
84b226e895
[Core] Integration of Rizin SigDB in aaa and add aaF (#2120) 2021-12-20 23:47:32 +01:00
Florian Märkl
544905631c
[RzIL] Fix concept of Effects and Effect ops (#2109)
This brings our concept of effects in line with BAP and fixes issues
like values being evaluated prematurely in seq. The main point is that
ops themselves are the effects, rather than returning them to be
evaluated later.
2021-12-20 14:21:40 +00:00
Giovanni
d6625126d5
[FLIRT] pac to pat (#2116) 2021-12-19 13:42:00 +01:00
Florian Märkl
17ef95aed8
Make rz_strbuf_slice() truncate on excessive len (#2115)
It is often useful to get a slice of some maximum len, also accepting
smaller results if the source is not large enough.
This also makes the function always operate on byte indices. Before,
it was inconsistently skipping ansi codes sometimes.
This also fixes potential oob writes in panels.c
2021-12-18 23:16:24 +01:00
Giovanni
bd7854d297
Fix multidex and open_many loading using proper base address (#2104) 2021-12-18 09:54:42 +01:00
Khairul Azhar Kasmiran
b1c3595c6b
newshell help: Remove brackets from list tail (#2114) 2021-12-18 09:54:10 +01:00
Riccardo Schirone
9465cca0f5 Replace AES code with Nettle one which is LGPLv3
Code taken from https://git.lysator.liu.se/nettle/nettle and placed in
its own subproject.
2021-12-17 09:18:47 +01:00
Riccardo Schirone
27e135b5d5 Replace RSA-MD licenses-code for MD5 with LGPL one
Get the MD5 code from
https://github.com/FreeRADIUS/freeradius-server/blob/v1.1.x/src/lib/md5.c
which is LGPL and it has fewer integration problems with the other
licenses.
2021-12-17 09:18:47 +01:00
Paul I
d2302facd6
Remove oldshell handlers from cmd_analysis.c (#2106)
* Remove oldshell handlers for `afb` commands
* Remove oldshell handlers for `afB` command
* Remove oldshell handlers for `afs` commands
* Remove oldshell handlers for `afu` command
* Remove oldshell handlers for `afx` commands
* Remove oldshell handlers for `afS` command
* Remove oldshell handlers for `afv` commands
* Add missing `afvb-*`/`afvr-*` and update tests
* Move <delete all> feature out from `analysis_function_vars_del()`
2021-12-16 11:18:40 +08:00
Giovanni
57f83bd657
[FLIRT] Create signatures from RzAnalysis data (#2036)
Add pac and sig creation with options & compression via commands and via new rz-sign
Add missing arch (arc, pic, riscv, spc700 xtensa, and more)

Side note:
on other tools public functions and references are generated in a sequential 
way besides the first one which is the first to be assigned.
since we do not search for sequential references, then we can avoid to
add extra public or referenced functions

Extra:
* Refactoring rz_analysis_mask definition
* Add rz_str_startswith_const and rz_list_iter_get_next_data
2021-12-15 19:08:16 +01:00
Khairul Azhar Kasmiran
298f92cf56
newshell help: Start arg numbering from 1 (#2107) 2021-12-15 23:53:04 +08:00
Dhruv Maroo
4cb187cf42
Add test to check whether DWARF attribute type is checked or not (#2103) 2021-12-14 20:19:30 +01:00
wargio
8c2cb05af8 [RzIL] Add let, rewrite using RzPVector and various bugfixes 2021-12-14 12:34:55 +01:00
wargio
d288a24726 [RzIL] Refactor definitions and VM 2021-12-14 12:34:55 +01:00
Paul I
5914b79982
Convert afl/afi commands to rzhell (#2040)
* Convert afl/afi commands to rzhell
* Reuse code
* Update tests
2021-12-14 17:49:16 +08:00
Florian Märkl
96a85e573e Remove ESIL Pins (#2096)
ESIL Pins were an untested feature to run a command when emulation hit a
specific address. This can be solved in other ways, e.g. scripting.
Project version 7 has been introduced for this change.
2021-12-12 18:27:34 +01:00
Giovanni
bda1e9cfca
Disable GPL code and Add RISC-V support via Capstone 5 (#2087)
* -Duse_gpl=false is supported by rizin and added riscv_cs for capstone v5
* Added GPL build workflow in CI
2021-12-11 13:30:01 +01:00
Anton Angelov
2d1f1a74ed
Fix crash due to null pointer dereference in rz_analysis_block_recurse_depth_first() (#2093) 2021-12-11 10:14:37 +00:00
Giovanni
c1c1fe05ec
[RzIL] refactored rz_il_op to expand new methods to rz_il_op_new_* (#2092) 2021-12-11 17:27:13 +08:00
Florian Märkl
79a17ef482
Remove RzAnalysisPlugin.set_reg_profile (#2091)
Refactored all plugins to use get_reg_profile instead, which simply
returns the register profile instead of applying it as a side-effect.
2021-12-11 10:18:31 +01:00
Anton Kochkov
8c1ef7672b
Remove unused and untested PPC GNU target (#2090) 2021-12-10 19:40:22 +01:00
Anton Kochkov
715dd14811
Remove unused, unupdated and largely untested ARM WineDBG and GNU (Binutils) plugins (#2085)
* Remove WineDBG ARM RzAsm plugin
* Remove unused and untested ARM GNU target
2021-12-10 16:40:58 +01:00
Florian Märkl
aa6917772d
Fix oob write for dwarf with abbrev with count 0 (Fix #2083) (#2086) 2021-12-10 15:43:12 +01:00
Khairul Azhar Kasmiran
5b6aaed68d
Fix optional brackets termination of newshell help (#2077) 2021-12-09 10:58:54 +01:00
Khairul Azhar Kasmiran
3ff8effa4c
Improve slightly dte test (#2075) 2021-12-07 22:30:05 +08:00
Florian Märkl
3c2e4bf63a
Rewrite ar and dr with newshell (#2006)
* Show group-level details of commands

Details can be defined at either a group command or its subcommand of
the same name. If define on group-level it will also be shown in the
group help without needing ??.

* Fix > $ redirection for errored command and leak

* Rewrite ar and dr commands with newshell

Breaking changes:
ar* => arf, ar- => arf-, ar. => ar*
ar, => art, ar? => arq
ar0 => ara0, arb => arab, ars => araS
arC => arpC
arn => arR
art => arT
arf => arF
Removed: drm, aer
2021-12-06 19:02:43 +01:00
Florian Märkl
4cb13c3183
Add rz_bv_set_from_bytes_le() (#2068)
Also make rz_bv_as_hex_string() always pad with the same number of 0s if
len % 4 != 0.
2021-12-06 12:28:26 +08:00
Luca Borzacchiello
cd6bde4aeb
Fix REL relocations in ARM binaries (#2053)
* Fixed REL relocations in ARM binaries
* Integration of ARMv7 part of PR #1699
2021-12-01 21:14:02 +08:00
Dhruv Maroo
648c267bc7
Rename and refactor to use RzBitVector instead of RzILBitVector (#2048) 2021-12-01 14:28:04 +05:30
Riccardo Schirone
64469f2811
Changes in how paths are handled (#1997)
* Remove `RIZIN_EXTRAS` because useless

Extras plugin should be treated as any other regular plugin, they should
not have their own directory. I believe we did not have anyway any
plugin using that directory.

* Do not use `<version>` in `/usr/share`

Users can only install one version of Rizin at a time anyway, thus
splitting the `/usr/share/rizin` directories does not really bring
multi-version install possible. At the same time, we stick to what's
common for other tools, which do not use version in `/usr/share`

* Move plugin directory to `/usr/lib64/rizin/plugins`
* Remove `RZ_HOME_BIN` env var because not useful anymore
* Introduce `rz_util/rz_path` to provide rizin paths
* Use `rz_path_system_sdb_types` whenever it makes sense
* Use some others `rz_path_*` functions instead of custom ones
* Use `rz_path` APIs for themes, fortunes and signatures
* Remove `rz_sys_prefix`
* Reduce the number of defines needed to handle home and system paths
* Reduce the number of `rz_path` functions
* Make the lib debug depending on log level and `RZ_LOG_DEBUG`
* Refactor a bit how directory of plugins are loaded
* Keep supporting old plugins directory for at least 0.4.0
2021-11-30 13:36:38 +08:00
Rot127
26103ee383
Update Hexagon asm and analysis plugins (#1614)
* Add support for: v5-v68+HVX, System instructions/register; Change plugin design to monolithic; Basic ELF-reloc patching.

- Update instruction set to v5-v67 + HVX.
- Introduce monolithic plugin architecture to reverse opcodes in the same functions.
  - Analysis and Asm functionality was previously seperated and let to inconsistensies and incorrectly reversed opcodes.
- Add missing system instructions and registers.
- Enable search for immediates.
- Mark packets of instructions.
- Set more analysis data in RzAnalysisOp.
- Add basic ELF-reloc patching.
- Fix several disassembly and analysis bugs.
  - Jumps were not aligned to packet begin.
  - Endloop packets were not marked as such.
  - Rs.New registers were incorrectly disassembled.
  - Calling convention was out of date.
- Add several formatting configs for the produced disassembly.
  - Dis/Enable UTF-8.
  - Print or omit # prefix of immediates.
  - Print signed immediates as signed or unsigned integers.
2021-11-28 01:40:04 +08:00
Rot127
40ca3d7672
Check for plugin ESIL support before running ESIL code in aaa. (#2039)
* Check for plugin ESIL support before running ESIL code.
* Set ESIL flag for riscv analysis plugin.
2021-11-27 23:22:14 +08:00
GustavoLCR
ba5adf0045 Fix wrong buffer size reporting with shm:// 2021-11-26 13:21:34 +08:00
GustavoLCR
8a1e58db82 Fix #1758: Add support for shm:// on Windows
* Move `shm://` test out of `not-windows-any`
2021-11-26 13:21:34 +08:00
Dhruv Maroo
3d6b7f0235
Cleanup dbl command handler; Remove rz_bp_list (#2012) 2021-11-25 22:33:24 +05:30
Dhruv Maroo
0801f7adf6
Port c commands to newshell (#1854)
Co-authored-by: Riccardo Schirone <ret2libc@users.noreply.github.com>
2021-11-25 17:55:08 +05:30
Dhruv Maroo
34d345d884 Format according to clang-format-13 2021-11-25 15:44:28 +08:00
billow
46533d41eb
EBCDIC character support (#1643) 2021-11-22 09:48:57 +08:00
Florian Märkl
b2386f5983
Fix aae overwriting registers of debuggee (#2004) 2021-11-21 12:12:00 +00:00
Khairul Azhar Kasmiran
d6ba6b1ce8
Revert test/unit/cpp/meson.build (#2003) 2021-11-21 19:39:34 +08:00
Florian Märkl
5757c37cee
Use rz_analysis_get_address_bits() in pxr and fix asserts (#2002) 2021-11-21 12:19:33 +01:00
Florian Märkl
7e1415bc83
Add support for DYLD_CHAINED_PTR_64_OFFSET (#1996) 2021-11-19 14:54:35 +01:00
Giovanni
446a56929b
[FLIRT] Improvements and added pac support & tests (#1992)
* Enforce architecture type on sig, files
* Added terminal output when calling zfs to display the number of matches 
* Added pac support
* Added tests
2021-11-18 18:47:29 +01:00
Khairul Azhar Kasmiran
906ece4211
Add asan build for clang (#1910) 2021-11-17 21:02:02 +08:00
Florian Märkl
289536cc04
Unscramble Register Printing and Flags Logic (#1920)
* Added rz_analysis_get_address_bits() instead of arch-specific hacks in core
* flags are only set for address-sized registers
* dr/ar show registers of any size by default, but hiding registers that are entirely
  covered by others
2021-11-17 11:44:14 +01:00
Florian Märkl
fd8d84b475
Remove rX_rY Hacks in AVR ESIL (#1988) 2021-11-16 23:07:05 +01:00
Florian Märkl
a96edeb0c6
Disambiguate cmd_b/cmd_B for case-insensitive fs (#1987) 2021-11-16 10:56:58 +00:00
Florian Märkl
86e4df8655
Remove r1_r0 Hack from AVR (#1985) 2021-11-16 02:52:10 +01:00
Giovanni
87311c3759
Basefind (#1966)
Co-authored-by: gnole <olegbouchin@gmail.com>
2021-11-15 22:33:38 +01:00
OGRE
dfb6900366
[RzIL] Add concat, append handlers etc. (#1936) 2021-11-15 19:57:14 +01:00
wargio
5f7d85de8e Avoid heap for < 65 bits and simplified rz_il_bv_new_from_* methods 2021-11-15 14:56:15 +01:00
Giovanni
9c830435d6
Fix #1952 - Implement iR <hashes> (#1979) 2021-11-15 14:30:48 +01:00
Florian Märkl
081ebe728f
Rewrite and fix AVR DES ESIL (#1975) 2021-11-14 15:43:03 +01:00
Giovanni
8f4620d043
Add thread pool and physical core number (#1973) 2021-11-14 12:06:19 +01:00
Riccardo Schirone
9ee830054b
RzShell: convert wh command to shell/which (#1964) 2021-11-12 11:42:58 +01:00
Giovanni
f41ea3c284
[FLIRT] Refactoring and create rz_sign library (#1960) 2021-11-11 20:29:59 +01:00
Khairul Azhar Kasmiran
58fd79be91
Fix first line of db/esil/x86_64 (#1958) 2021-11-10 23:03:26 +08:00
Riccardo Schirone
589ab9299c Fix tests after more rigid wx 2021-11-09 12:01:41 +01:00
Riccardo Schirone
9ea989f58d Document rz_hex_str2bin and add unit tests 2021-11-09 12:01:41 +01:00
Riccardo Schirone
824ce9b8ac Fix db/formats/ar test 2021-11-09 09:46:04 +01:00
Riccardo Schirone
b9382426ee RzCmd: print RzCmdStateOutput only if command returns OK 2021-11-05 11:58:24 +01:00
Riccardo Schirone
a1ce0f8dd7 RzShell: convert o- commands to rzshell
* Remove o-*h because it was the same as o--
* Remove o-! because not used
* Remove unread test case because it was not doing anything (o-fd did
  not work)
2021-11-05 11:58:24 +01:00
Giovanni
712f6cdabe
[RzIL] Refactoring, added bool xor and added bitv carry/borrow (#1930) 2021-11-04 19:48:10 +01:00
Giovanni
0d8d08951e
[RzIL] fix jmp & added bitvector type due limitation of int type (#1924)
Adds RZIL_OP_BITV and removes RZIL_OP_INT due host limitation
Fixed type RZIL_OP_JMP to work and apply effect.
Implemented rz_il_bv_new_from_st32 rz_il_bv_new_from_st64
2021-11-02 17:36:47 +01:00
Giovanni
d68aa4517c
[RzIL] Print events on single/multi step aezse/aezsej (#1912)
* implemented aezse and aezsej to see RW events
* Added rzil.step.events.read and rzil.step.events.write to filter events
2021-11-01 12:19:19 +01:00
Giovanni
4ca140a97b
[RzIL] implemented ao statement output (#1901)
* RzIL implemented il string and json representation
* Added json representation
* Fixed some memleaks on rz_il_free_op
* Implemented rz_il_op_stringify and rz_il_op_json
* RzIL Fixed memory leaks
2021-10-30 11:41:30 +08:00
Aswin C
4ec188d219
Refactor APIs related to themes and remove global variables from cmd_eval (#1879)
* Refactor `rz_core_theme_nextpal()`

* Add tests for `ecp`, `ecn` and `ecoj`

* Add braces to avoid declaration after the label

* Use `RzCmdStateOutput` in `eco`

* Fix the output of the test for `ecoj`

* Introduce `RzConsPalSeekMode` and refactor `nextpal_item`

* Rename the APIs related to themes

* Rename `rz_core_get_theme` to `rz_core_theme_get`
* Rename `rz_core_load_theme` to `rz_core_theme_load`
* Rename `rz_core_list_themes` to `rz_core_theme_list`

* Add `curtheme` to `RzCore`

* Eliminate all global variables in cmd_eval.c

* Put the loop outside the `switch` in
  `rz_cmd_eval_color_load_theme_handler`
* Remove `getNext` variable and use the `RzListIter`'s `p` variable

* Sort the list of loadable themes

* Use a normal `strcmp` as the comparator function while sorting themes
2021-10-29 20:25:00 +08:00
Giovanni
8a036858df
[RzIL] Improvements (#1898)
Refactors the brainfuck RzIL code.
Implements aezv which returns the RzIL VM status and the output can be changed via rzil.status.compact=true/false
Refactors the oldshell help messages to clean some useless code
Refactors and optimize RzILBitVector methods
Fixes rz_il_bv_as_string, rz_il_bv_hash and implements rz_il_bv_as_hex_string and rz_il_bv_set_from_ut32/ut64
Assigns all the handlers to op_handler_table to avoid null derefs and to notify which operations are unimplemented
Implements rz_il_handler_logical_and, rz_il_handler_logical_or, rz_il_handler_logical_xor and rz_il_handler_cast
2021-10-28 19:02:19 +02:00
Riccardo Schirone
3e4660650c
RzShell: add autocompletion for @@ iterator operators, @@., @@=, etc. (#1896)
* RzShell: add autocompletion for @@ iterator operators, @@., @@=, etc.
* Update help for @@ii
* Fix test for @@?~?
2021-10-29 00:11:45 +08:00
Riccardo Schirone
6819d04bed Fix all db/archos tests 2021-10-27 09:31:50 +02:00
Riccardo Schirone
ea6d8e37c5 Fix all db/formats tests 2021-10-27 09:31:50 +02:00
Riccardo Schirone
1be3d02a36 Fix all db/esil tests 2021-10-27 09:31:50 +02:00
Riccardo Schirone
2a90781e7f Fix all db/analysis tests 2021-10-27 09:31:50 +02:00
Riccardo Schirone
0a5b00edd2 Fix all db/cmd tests 2021-10-27 09:31:50 +02:00
Riccardo Schirone
9c3e6c15b4 Add few unit tests for @ autocompletion 2021-10-27 09:31:50 +02:00
Florian Märkl
3e7cdf58ed Remove strnlen() calls and replace by rz_str_nlen() 2021-10-26 10:50:22 +02:00
Anton Kochkov
8fab461328
Port g (egg/shellcode) commands to the rzshell (#1744) 2021-10-25 22:15:38 +08:00
Florian Märkl
8de3870d5c
Rewrite most of the bFLT bin plugin (#1863) 2021-10-23 17:45:54 +00:00
Khairul Azhar Kasmiran
0932fd1f75
Fix #1864: Find main() of Fedora 35 x86_64 /bin/ls (#1880) 2021-10-23 19:16:58 +02:00
Aswin C
54b6e53feb
Convert ec to the rzshell (#1809)
* Convert `ec` to the rzshell
* Port the `echo` command
* Make the `color` argument optional for `ecHw`
* Remove `rz_core_echo`
* Make `echo` a part of `e` commands
* Add tests for `eco` and `ecHw`
* Move the definition of `bool2status` to `cmd_eval.c`
* Fix `ecHj` and add a test for it
2021-10-22 13:33:35 +08:00
Riccardo Schirone
75fc447873
Fix some memleaks in unit tests (#1869)
* Cleanup RzAnalysisRzil when freeing RzAnalysis

* Fix str leaking in rz_core_write_string_at

* Fix buf leaking in rz_core_yank_paste

* Fix memleak in json unit tests

* Fix features leaking in RzBinInfo

* Fix features leaking in RzAsm

* Fix memleaks in RzTable

* Fix test_str_search memleaks

* Fix memleak in test_io.c

* Fix memleaks in RzBuf and test_buf.c

* Fix memleaks in test_cmd.c

* Fix memleaks in test_config.c

* Fix memleaks in RzCons

* Fix hashes leaking in test_bin.c

* Fix memleaks in test_id_storage.c

* Fix memleaks in test_il*.c and adjust APIs
2021-10-22 09:33:20 +08:00
Anton Kochkov
514f9fa75b
Remove unused RzBinheap API (#1865) 2021-10-21 15:14:57 +02:00
Anton Kochkov
c14a09f946 Remove unused RzFList 2021-10-21 16:45:09 +08:00
Anton Kochkov
8f66775a0d Add shm:// rzpipe test 2021-10-20 09:57:33 +02:00
Anton Kochkov
1e53cb7f8a Add few missing Windows types 2021-10-20 09:57:33 +02:00
Riccardo Schirone
1172c4085c Re-design the way ? and ?? are used in rzshell
* `<cmd>?` allows to list the sub-commands of <cmd>. If <cmd> has no
  sub-commands, the full help of <cmd> is printed instead.
* `<cmd>??` allows to always list the full help of <cmd>. Useful when
  <cmd> is both the name of a group and a command itself.
* output modes are only listed as part of the full help and not
  considered as sub-commands.
* fix a bug where `<cmd><mode>?` was just printing the list of
  sub-commands of <cmd> instead of the full help of <cmd><mode>.
2021-10-18 11:57:17 +02:00
Khairul Azhar Kasmiran
637c192145
bin.str.enc: Rename latin1 to the more generic 8bit (#1847)
* Rename `rz_str_escape_latin1()` to `rz_str_escape_8bit()`
* test_serialize_analysis.c: Change string from "latin1" to "8bit"
* `bin.str.enc`: Rename `latin1` to the more generic `8bit`
2021-10-18 12:07:52 +08:00
Khairul Azhar Kasmiran
cb46249098
Rename Csa to Csb (#1844) 2021-10-16 15:50:59 +08:00
Anton Kochkov
9ac3e8f263 Add Csp command to add Pascal strings 2021-10-16 11:33:48 +08:00
Anton Kochkov
39613b5c16
Port C (metainformation) commands to the rzshell (#1752)
* Do not escape strings during the search
* Port `C` (metainformation) commands to the rzshell
* Improve string autodetection
* Remove `Cr` and RZ_META_TYPE_RUN
* Escape `\x1b` as `\e` character in strings
* Move string encoding options to `RzStrEncOptions` struct
* Add `esc_double_quotes` option to `RzStrEncOptions`
* Do not filter out unprintable characters for uppercase check
* Use `esc_double_quotes` when printing the string between '"' in disasm
* Use signed chars on all platforms/architectures

Co-authored-by: Riccardo Schirone <sirmy15@gmail.com>
2021-10-15 16:48:18 +08:00
Giovanni
92c4ec0141
Adding timeouts to long tests (#1822)
* Update sections
* Update mdmp
2021-10-14 09:19:56 +00:00
Giovanni
215113b49e
Fixed build warning (#1832) 2021-10-13 17:38:08 +02:00
Theofilos Pechlivanis
2f181b9053
Fix #469 by checking the value of analysis.jmp.cref (#1594) 2021-10-13 14:32:47 +02:00
Giovanni
75aa120c90
Added -e option to rz-diff (#1817) 2021-10-11 17:52:59 +02:00
Heersin
e0d3d6bc66
New RZIL integration (#1663)
The new intermediate language is based on the BAP (Binary Analysis Platform) Core Theory.
It operates on SMT-like bitvectors and their arrays to represent values and memory.
Apart from that, it has also representation for the data and code side effects.
2021-10-09 18:14:44 +08:00
Basstorm
19a6a929f9
Rewrite PDB parser ##bin (#1517)
* Rewrite PDB parser to become endianess-independent
* Use type pretty-printing API
* Use `RzCmdStateOutput` instead of `RzOutputMode` to solve invalid JSON issue
* Move PDB-related print functions to `cpdb.c`
* Use flag API instead of calling commands from the code
* Separate printing from parsing and applying the type information
* Delete useless `main.c`
2021-10-09 16:57:29 +08:00
Dhruv Maroo
afd1bab3c0
Port db commands to newshell (#1777)
* Add `db` commands in `cmd_debug.yaml`

* Use bool instead of int as return value

* Port `db` commands to newshell

* Fix integration tests. Use `db- <addr>`, instead of `db-<addr>`

* Fix `dbW` handler and update `rz_w32_add_winmsg_breakpoint`

* Remove checks for `argc` in `cmd_debug.c` (from review)

* Fix failing Windows tests

* Change control flow in conditional expressions

* Use `RzCmdStateOutput` in handler for `dbt` to print backtrace in various formats

* Use forward slash (/) instead of pipe (|) for command descriptions

* Use output modes for printing breakpoints in `db` handler

* Remove extra newline while printing breakpoints in JSON format

* Change description for `dbc` command

* Update descriptions and handlers; Remove <addr> argument wherever necessary

* Use `RZ_CMD_ARG_TYPE_CHOICES` for perm in `dbw`

* Add details for `dbC` and `dbw`

* Add quiet printing mode for breakpoints

* Remove unnecessary <addr> argument for `db` commands

 * Also add a quiet output mode for `dbl` and `dbt`

* Return if no breakpoint found in function `add_breakpoint`

* Update tests for new `db` commands

* Update `db` command descriptions

 * Remove `dbi.` redundant command
 * Add details for iterating through the list of breakpoints

* Extract `rz_debug_bp_add_noreturn_func` into `debug.c` as RZ_API

* Fix `dbil` handler and `dbg_bps` test

* Shift the noreturn function breakpoint to `cdebug.c`

* Format according to clang-format

* Fix failing integration tests

 * TODO: Find why `db- @@c:dblq` is failing, and fix the bug

* Update `db` commands

* Use `db- @@c:dblq` instead of `db-*`

 * This will also work as a test for command edits (see https://github.com/rizinorg/rizin/pull/1806)
2021-10-08 21:40:51 +05:30
Riccardo Schirone
64be19f082 Move TSLanguage initialization into new rz_core_cmd_new API 2021-10-08 15:38:16 +02:00
Riccardo Schirone
291c6e9e9a
Add RzBinResource type and use it to print resources (#1804) 2021-10-08 16:47:04 +08:00
Khairul Azhar Kasmiran
db0fdffc4e
archos/: Support <os>-any test categories (#1795) 2021-10-05 17:33:42 +08:00
Dhruv Maroo
d6ac6b93ef
Fix changing rflags register using dr (#1794)
* Use the numerical value string as parameter of `rz_core_debug_reg_set()`
* Add test for changing rflags using dr
* Add test for changing rflags using ar
2021-10-04 17:51:38 +08:00
Khairul Azhar Kasmiran
bf847a5db1
Add pt-boundaries test (#1791) 2021-10-03 17:31:35 +08:00
Dhruv Maroo
4f8100cd97
Extend the pretty printing API for base types and other printers (#1781)
* Replace `rz_type_db_base_type_as_string` with `rz_type_db_base_type_as_pretty_string`

 * Use the new type pretty printing API to pretty print base types

* Add option to return newline terminated string by pretty printing API

 * Add `RZ_TYPE_PRINT_END_NEWLINE` option to RzTypePrintOpts

* Improve printing in cases of empty structs/unions/enums

 * Initially, the separator was printed between the curly breaces
   irrespective of whether the struct/union/enum is empty. Now the
   separator is not printed if the given type is empty

* Add pretty printing support for typedefs

 * Also, add another type printing option to show typedefs. To be used in
   `rz_cores_types_typedef_as_c`

* Refactor `.*_as_c` functions to use the new type pretty printing API

* Add tests for typedef and `unknown_t` for pretty printing API

* Add `rz_type_db_base_type_as_string` back. Update tests.

 * Use ternary operator to make expression more concise

* Add doxygen documentation for `rz_type_db_base_type_as_string`

* Use `rz_vector_len` to determine if empty, instead of convoluted logic

* Remove redundant `RZ_NONNULL` for RzTypeDB

* Fix integration tests for type printing

* Update Doxygen documentation

* Fix failint enum printing itegration tests

* Fix according to clang-format
2021-10-02 13:51:01 +05:30
Anton Kochkov
458095d7a0
Fix afvd command for compound types (#1786) 2021-10-02 11:00:14 +08:00