Commit graph

1904 commits

Author SHA1 Message Date
Anton Kochkov
9f6e13f364
Remove rz-agent (#3087) 2022-10-12 10:34:46 +02:00
Anton Kochkov
4a037c2f2a
Convert dk commands to the rzshell (#3078) 2022-10-11 18:02:52 +08:00
Giovanni
171612c5e1
Add ssdeep hash (#3084) 2022-10-10 17:03:26 +02:00
Anton Kochkov
24503df48b
Convert pF commands to the rzshell (#3071)
* Convert `pF` commands to the rzshell
* Add json output for PKCS7 and x509 and rename test due FS issues

Co-authored-by: wargio <wargio@libero.it>
2022-10-09 19:18:05 +02:00
wargio
5ecc9b8a36 Added pF tests 2022-10-09 08:09:00 +08:00
Khairul Azhar Kasmiran
4cdad14ccd
Remove dk 9 from debug tests (#3070)
* Add `dk 9` test
2022-10-08 16:44:22 +08:00
Khairul Azhar Kasmiran
137d376f54
Kill debugged process on exit if non-interactive and dbg.exitkills is true (#3068) 2022-10-07 22:46:36 +08:00
wargio
fbad0b4859 Remove agd and add rz_analysis_similarity/match + refactoring
- Introduce the following new methods:
  * `rz_analysis_similarity_basic_block()`
  * `rz_analysis_similarity_function()`
  * `rz_analysis_similarity_basic_block_2()`
  * `rz_analysis_similarity_function_2()`
  * `rz_analysis_match_basic_blocks()`
  * `rz_analysis_match_functions()`
  * `rz_analysis_match_basic_blocks_2()`
  * `rz_analysis_match_functions_2()`
- Remove `RzAnalysisDiff` and its usages
- Remove `librz/analysis/diff.c` entirely to and adds `librz/analysis/similarity.c`
- Remove a lot of unused structures and simplified the code by a lot
- Fix typo in levenshtein
- Remove `librz/core/gdiff.c` and `gdiff` functions since they were unused or only used in rz-diff
- Remove `difftype` (or "color") from `RzANode` which lead to dead code
- Decrease serialized data in projects.
- Add `RzAnalysisVarKind` and `RzAnalysisVarType` and replaces all the hardcoded values
- Remove command `agd`
- Remove all `rz_core_gdiff` usages from `rz_core.h`
- Refactor `rz_analysis_var_list` and `rz_analysis_var_count` due unused argument (`RzAnalysis` was not used)
- Add new method `rz_analysis_var_count_total` to simplify some usages
- Remove `rz_core_graph_diff`
- Add `typedef RzAnalysisFcnType` on `enum``used for function types
- Remove unused `RZ_ANALYSIS_FCN_VARKIND_LOCAL`
- Remove from `RzAnalysisFunction` the following variables:
  * `fingerprint`
  * `fingerprint_size`
  * `diff`
  * `diff_ops`
  * `diff_thbb`
  * `diff_thfcn`
- Remove from `RzAnalysisBlock` the following variables:
  * `fingerprint`
  * `diff`
- Remove `RZ_ANALYSIS_THRESHOLDBB` and `RZ_ANALYSIS_THRESHOLDFCN`
- Remove the following callbacks from `RzAnalysisPlugin`
  * `RzAnalysisDiffBBCallback`
  * `RzAnalysisDiffFcnCallback`
  * `RzAnalysisDiffEvalCallback`
- Fix fancy table columns/rows when a color string is in a cell
- Bumped project version to 9
2022-10-04 20:02:35 +02:00
Florian Märkl
2e8ec8ac75
Always detach when quitting from -q or -Q (#3058)
Previously, on macOS we were detaching properly when the user quit rizin
after an interactive `rz -d <file>` session, but not on
`rz -d -Qc <cmd> <file>`, which would leave behind a zombie process.
Now, the process is detached and keeps running, which also matches the
behavior on Linux. Hence the `dk 9` additions in the tests, to not
spoil the output with whatever the processes print.
2022-10-01 17:38:01 +02:00
Anton Kochkov
4bf6b67212
Convert dd commands to rzshell (#3049)
* Convert `dd` command to rzshell
* Remove unimplemented `dH` command
* Remove `ddt` command
* Move `date` command to the "shell" category
2022-09-29 08:24:50 +08:00
Giovanni
5b1e5e6762
Support blake3 hash algo (#3030) 2022-09-17 18:38:21 +02:00
wargio
8f40517990 Refactor rz_float_new_from_utXX_as_fXX 2022-09-16 21:55:58 +08:00
Anton Kochkov
52260857b5
Convert some of the a commands to the rzshell (#3025)
* Remove `ap` command
* Convert `ad` commands to rzshell
* Convert `aF` command to the rzshell
2022-09-15 21:09:15 +02:00
Heersin
b13202b934
RzUtil: softfloat support based on bitvector (#2784) 2022-09-14 14:38:22 +02:00
Giovanni
e3f72d8e72
Add nim lang support (#3015) 2022-09-10 18:20:05 +02:00
Giovanni
008363fcc4
Fix #2851 - wrong AVR analysis jump value for rjmp/rcall (#3012) 2022-09-07 23:00:23 +02:00
Giovanni
ade374378e
Add free-pascal demangling support (#3011)
* Add free-pascal demangling support
* Fixed tests
2022-09-06 10:39:58 +08:00
Dhruv Maroo
dee7baca00
Use correct enum for MOD and SMOD (#2988)
* Use correct rnum for `MOD` and `SMOD`

* Update `db/asm/ppc_64` to use `mod` instead of `smod`
2022-08-30 19:30:46 +02:00
billow
46a1929397
Refactor rz_core_analysis_graph*() functions (#2949)
- fix `ags` and `agl` commands
- add more tests for the `ag` commands
- move graph related code to cgraph.c
- remove APIs `rz_core_print_bb_custom` `rz_core_print_bb_gml`
- exports
    - `rz_graph_drawable_to_json_str`
    - `rz_graph_drawable_to_cmd`
    - `rz_graph_drawable_to_gml`
    - `rz_core_graph`
    - `rz_core_graph_diff`
    - `rz_core_graph_format_from_string`
    - `rz_core_graph_type_from_string`
    - `rz_core_graph_write`
    - `create_agraph_from_graph_at`
- add unit/integration tests for the graph API
2022-08-29 22:48:23 +08:00
Giovanni
c89b12a046
Removed plenty of eprintfs in rz_core (#2950) 2022-08-29 00:32:17 +08:00
Giovanni
3752e24b98
Update rz-libdemangle (#2984) 2022-08-27 02:35:07 +02:00
Riccardo Schirone
9ba89d8116 core/cmd: rewrite rz_cmd_macro API 2022-08-26 07:53:43 +08:00
Riccardo Schirone
02a0b7a1ad core/cmd: just store RzCore reference instead of void *data 2022-08-26 07:53:43 +08:00
wargio
0eef58115b Rewritten (partially) rz_run_parseline 2022-08-22 13:50:39 +02:00
billow
4b385978a1
Convert ag to rzshell (#2916)
* `BROKEN=1` for `ag[df]`

Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2022-08-22 08:16:14 +08:00
Florian Märkl
c542bfcb4a Make cb use cfg.bigendian instead of host one
Fixes the remaining test in test/db/cmd/cmd_c on big endian hosts,
tested on OpenBSD/sparc64.
The mask calculation was removed because it was unnecessary (only
comparing selected bytes anyway) and wrong by a factor of 8 (bits vs.
bytes confusion).
2022-08-19 16:10:54 +02:00
Florian Märkl
e4182a6123 Make cu[1248] use cfg.bigendian instead of host one
Fixes the respective test in test/db/cmd/cmd_c on big endian hosts,
tested on OpenBSD/sparc64.
2022-08-19 16:10:54 +02:00
Riccardo Schirone
ac1b0e4d94
core/cmd: fix CHOICES argument selection between choices_cb/choices (#2932) 2022-08-18 20:10:13 +08:00
GustavoLCR
d25dff702a
Fix pg with fewer than 5 arguments (#2921) 2022-08-15 11:23:37 +08:00
Giovanni
eedfde9e97
Ensure RZ_ANALYSIS_ARCHINFO_MIN_OP_SIZE always return at least 1 (#2917) 2022-08-15 01:15:31 +08:00
wargio
a73e8ecd4d Add references and flags to constant pointers to data maps 2022-08-13 22:52:24 +02:00
karliss
32ef171354
Fix reset followed by color change in rz_cons_html_filter (#2912) 2022-08-13 09:43:18 +02:00
Giovanni
5655350535
Resolve golang string structures in data section (#2878) 2022-08-11 18:00:38 +08:00
Rot127
b46e7bd4f2
PPC uplifting to RzIL (#2823)
* Print a warning if config for VM was NULL.
* Add warning if register is not added to VM due to overlap.
* Update PPC register profile.
* Add vector and float registers. As well as some control and system registers.
* Enable to write values 4bit registers.
* PPC: Uplift most common instructions.
* Print warning if reserved SPR instruction is encountered.
* Update PC/LR addresses and add ca32 writes.
* Write cache needs to get flushed so load and store tests don't share the same memory.
* Add missing T/F branch mnemonics.
* Add Move to/from CR/CR0-7
* Fix TA address calculation for branch instructions.
* Add branch tests for branch mnemonics.
* Add XNOP
* NOP cache touch instructions.
* Add undocumented ATTN instruction to the not_implemented group.
* Add isel instruction.
* Implement CRCLR, CRSET, CROR.
* Add CNTLZ instructions.
* Add mcrf instructions.
* Add inacive test for cmpb.
* Add Load bytes reverse instructions.
* Add test and add address alignment to dcbz.
* Add eqv test
* Correct DIV and MUL operations
* Add div tests.
* Add tests and correct MT/MFXER
* Remove register ca32, ov32
* Remove explici setting of cr register because QEMU does not do it. Otherwise we get a mismatch in the trace
* Simplify carry set for add and sub. Sub instructions are exclusivly defined with addition. Hence no sub case needed.
* Unify BD and fix branch instructions. Fix: Check the single bit not the cr reg
* Document Conditional branches and replace NOPs with EMPTY
* Add mulli instruction to double word instructions.
* Fix ca set for shift instructions:
* ca value had to be determined before the shift happened. The wrong ca value was calculated if the src and target reg were the same.
* Replace NOP wit EMPTY.
* Use MSB isntead of SLT.
* Brought fixup of ADD and SUB instructions: The add and sub instructions had several issues which let to incorrect execution.
* The carry was incorrectly if three add operations happened (only the last add were checked, not both).
* The carry was incorrectly set if the src and target register matched.
* Same applies for the CR bit.
* It was too complex. Several local variables were introduced for this.
* Set result in local var, since it would change if src and target reg are the same.
* Remove MTMSR and MFMSR since it is too complex and untestable currently.
* Use unsigned int for shift. Otherwise the 0x1c shift produces a runtime error since 0xf is int as default.
* Fix mtxer: Only write flag bits.
* Let NOT_IMPLEMENTED macro return NULL.
* Mark st[wd]cx and l[wd]cx as not implemented.
* Increase dcache_line_size to 128 bytes.
* Fix cntlz for ppc32. m was set incorrectly, since it is 0 not 32 for 32bit cpus.
* Fix isel: Use op.crx reg instead of imm.
* Unify helper function names: Prependnig `ppc_` mark as IPI
* Add more "Move to SPR" cases.
* MULLI opeartes only on double word on 64bit CPUs.
* Most registers are now assigned the control register type and no longer show up in the ar command.
* Fix xor if dest and src registers match by saving result in local var.
* Fix BE/LE issue for Load BRX instructions.
* Fix shifts: Use only lower 6bits of n.
* User Pure local variables for ROT macros.
* Fix rldimi instructions.
* n was not inverted.
* more than 6 bits of n could be used
* Add 32bit emulateme tests.
* Add 64bit emulateme tests.
* Determine lg(v) in inline function.
* Calculate CR bit in C not in the VM.
* Check if `~mask = 0` and skip mask calculation if yes.
* Check for `sh == 0` and skip rotations where possible.
* Remove `la` instruction. `la` is a mnemonic for `addi`.
* Remove SPR instructions which are not supported by QEMU or not traced yet. For most set/read SPR instructions QEMU segfaults.


In case of SPR 1 (xer), 8 (lr) and 9 (ctr) the assembler resolves them to their mnemonics (mtxer, mtlr etc.). This means the code here is never reached.
To test the get_xer code MFXER was added again. The rz-tracetests will fail for this instructions (due to missing ca32, ov32). But this case is covert in an issue.
2022-08-11 08:41:15 +08:00
Heersin
a9c59ce1dd
Add rz_bv_range_set and rz_bv_is_all_one to bitvector lib (#2891) 2022-08-10 08:20:16 +08:00
Rot127
9f64b41766
Disassemble invalid duplex instructions to invalid ; invalid. (#2889) 2022-08-08 21:05:50 +08:00
Rot127
720598f1f0
[Hexagon] Resolve duplex instructions dynamically (#2882)
* Chane HexInsn -> HexInsnContainer in asm plugin.

* Make HexInsn -> HexInsnContainer in hexagon_disas.c

* Add function to set concatinate textual disassembly parts.

* Switch expressions, fix segfault.

* Print number of unhandle ops, if they can not be added to RzAnalysisOp.

* Add lookup function to determine sub-instructions for duplex iclass.

* Fix asm tests.

* Add memcpy for instruction containers

* Fix off by one.

* Fix segfault if the packet held only the instruction which is currently resolved. `hic->bin.insn` would be NULL in this case.

* Remove duplicate index name.

* Set instruction address.

* Clean up hic->parse_bits use

* Fix: .new registers were not resolved dur to too early return.

* Fix rebase mistakes.
* Add missing code

* Fix build error: Use sizeof(`text_infix`) since it is way smaller than `text`

* Initialize `HexInsn` inside `setup_new_hic`. Fixes NULL access.

* Mark RzAsm/RzAnalysis members as deprecated and fix typo.
2022-08-08 08:12:53 +08:00
Anton Kochkov
f8def2f0f5
Remove reduntant license entries and READMEs (#2875)
* Remove reduntant license entries and READMEs
* Do not use `make`
2022-08-08 08:04:26 +08:00
Florian Märkl
e893d2fb66 Fix arm64 register access in xnu debugger
ARM_THREAD_STATE64 fetches arm_thread_state64_t but our struct was
arm_unified_thread_state_t, which adds a header. The pc in the register
profile was hacked to account for the shift, but all the x-regs were
not, so x7 had the value of x8 for example. Now we just use the specific
state for 32 or 64.
2022-08-07 19:22:40 +02:00
Florian Märkl
8681cdc43b Use cpu_type_t for checking xnu debuggee's arch
This fixes basic single-stepping on macOS/arm64.
dbg->bits is affected by all kinds of things going on in rizin, in
particular it currently randomly switches to 16 when calling pd during
an arm64 debug session, causing the stepping code to break.
We now fetch the cpu type of the process once during attach, similar to
how lldb does it. They also use 0 for the "invalid" value, so we do that
as well.
2022-08-07 19:22:40 +02:00
Florian Märkl
2525507152 Add tests for stepping and breakpoints on macOS/x86_64 2022-08-07 19:22:40 +02:00
billow
1054e6295f
Export pcA as rz_core_print_bytes_with_inst (#2880)
* export `rz_core_print_bytes_with_inst`
* move `pcA` to rzshell
2022-08-07 00:28:01 +08:00
Florian Märkl
5f97d93327 Rewrite and fix non-libuv tcp server (Rt command)
The non-libuv tcp server implementation had several issues:
* Relied on EINTR or self-connect through global vars for breaking,
  which did not work during recv() for example.
* Never retried on EINTR
* Called recv() only once, thus subject to fragmentation issues

To support breaking otherwise blocking socket calls, RzStopPipe has been
imported from chiaki (I am the sole author so I can relicense).

rz_socket_block_time() was also detected to be doing the exact opposite
than it should on Windows through the tests, and fixed.
2022-08-06 13:20:52 +02:00
billow
0908b65bc3
Convert px[ dDhHwWqQol] to rzshell
* `pxd` -> `pxd 4`
* `pxd<N> [len]` -> `pxd <N> [len]`
* expose APIs:
- `rz_core_print_cmp`
- `rz_core_print_dump`
- `rz_core_print_hexdump_`
- `rz_core_print_hexdump_byline`
* test for `pxW` `pxH`
* move `void rz_print_section` -> `const char *rz_print_section`
* `pxd` -> `pxd[ hwq]`
* `pxc`
* `pxAv` -> `pxAl`
* `pxt.` -> removed ?
* `px/` -> keep
* `pxf` -> TODO: not found old code ?
2022-08-04 09:11:22 +08:00
Dhruv Maroo
d44b5748eb
[RzIL] IL lifting of SuperH ISA (#2518)
* Add an assembler for the SuperH ISA
	* Rewrite GPL GNU disassembler code
2022-08-02 02:37:03 +05:30
Rot127
b9fa2be193
Asm tokens fixes (#2855)
* Replace on s390x failing tms320 c55x test with c55x+ test.

* Fix resource leaks of parse paramters.

* Revive unreachable code.

* Raplace test with one which has not a different asm string in Capstone v3.

* Rename `new` to `newt` since `new` is a keyword and should not be used as var name.
2022-07-30 21:24:49 +08:00
Peiwei Hu
7f02a45dc3
Port command pb/B to new shell (#2828) 2022-07-29 00:20:10 +08:00
Florian Märkl
05a01569ac
Move warning from rz_reg_type_by_name to profile parsing (#2850)
The warning about non-existent register types is useful for register
profile parsing errors, but this function is also used by e.g.
`ar`/`dr`, so the overloaded `ar` would print a warning when given a
specific register name for example.
2022-07-28 15:22:04 +02:00
Florian Märkl
1d88af3c56
Refactor and replace .dm* calls with pure C (#2847)
This fixes the following minor issues:
* Errors like "Cannot create flag (...) because there is already (...)
  flag" during debug startup
* Unnecessary seeks during .dm* causing io reads and e.g. delays of up
  to 5s on x86 macOS during debug startup
* Flags are now created in the "maps" flagspace, rather than globally,
  making them easier to clean up later
* Flags now have the same size as the maps and not +1
2022-07-28 13:40:44 +02:00
Rot127
c009f8d7a3
Tokenize and colorize asm strings (#2417)
This introduces the ability to split asm strings into tokens and assign a type to them.

This means:
* Each asm strings is assigned a list of tokens. Each token points to a sub-string.
* A token has a type attached which describes it (e.g. register token, operator token, mnemonic token etc.)
* A generic parsing method is introduced which splits an asm string into tokens. The pattern it parses is `<mnem> <op> <op> ...`.
* Instead of the generic method, plugins can create the token strings on their own.
* An API method was introduced to help plugins implement their own parsing methods via regex patterns.
* Custom token strings are stored in `RzAsmOp.asm_toks`

Additionally the coloring of asm strings is now exclusively done via the token strings.
* For this a function was added to colorize tokenized asm strings according to their token types.
2022-07-27 08:52:01 -04:00
Florian Märkl
bd076fa6bc
Fix endian issues and libs in xbe and extend tests (#2843)
Apart from obvious big endian parsing bugs, this also tests `il` with
xbe, since that had endianness issues too and was previously untested.
To be able to have meaningful tests there, extra entries for the
explicit kernel and xapi pointers found in the xbe header have been
removed, since these always seem to point into the regular library array
anyway and would thus result in duplicates.

This fixes test/db/formats/xbe on OpenBSD/sparc64.
2022-07-27 08:24:14 +08:00
GustavoLCR
0f69192562
Fixes for the regex engine (#2839)
* Fix some UTF8 not being considered characters
* Fix broken selection between `smatcher()` and `lmatcher()`
* Fix broken regex maching for `lmatcher()` (big state machines) engine
* Use `long long` for short state machine type
* Add tests
2022-07-25 10:29:32 +08:00
pluswave
68f6f71fd2
ARM esil32: ldr reg, [pc, reg] correct (#2826)
* ARM esil32: ldr reg, [pc, reg] correct
* Fix test for db/esil/apple
2022-07-22 09:23:40 +08:00
Zhang Zengbo
3b9e823db7 ARM pseudo subvar: don't substitude [pc, reg] 2022-07-21 22:24:06 +02:00
Riccardo Schirone
a689f0a86e librz: refactor a bit how plugins are built
Rely on RZ_ARRAY_SIZE to add librz plugins instead of NULL terminators.
2022-07-20 22:04:02 +02:00
Riccardo Schirone
503b3baeeb reg: remove x86-linux.regs unused file 2022-07-20 22:04:02 +02:00
Riccardo Schirone
fd3a79f9e3 bin: remove Ldr plugins
RzBinLdrPlugins were not used. There was just one for Linux, but it was
not doing anything.
2022-07-20 22:04:02 +02:00
Peiwei Hu
7001e81336
Port command pa to new shell (#2824) 2022-07-20 17:55:30 +00:00
Peiwei Hu
9a75679626
Port command p6 to new shell (#2819) 2022-07-19 18:11:00 +08:00
GustavoLCR
a6bd48f98b
Fixes for tests (#2818)
* Close files before trying to delete them
* Add `-N` to not load the rizinrc in `read from stdin` test to avoid overwriting the color setting
* Make sure `.tmp` exists for `idpx` test
2022-07-19 18:09:33 +08:00
Rot127
2e48303443
TMS320 and TMS320c64x register profile (#2805) 2022-07-19 18:08:43 +08:00
Riccardo Schirone
faac2436b1 Move SDB into RzUtil
* Make SDB code SPDX compliant
* Use some RzUtil functions inside SDB

util: compile natively without any extra dependency
2022-07-19 08:45:20 +02:00
Khairul Azhar Kasmiran
a58538d387
Fix rz_str_split_list_regex() (#2815) 2022-07-18 22:26:55 +08:00
Rot127
5a38df5294
Fix: register profile comments parsing (#2806)
Parse comments in register profile definitions correctly.
2022-07-18 19:36:56 +08:00
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