Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ropchain constraint syntax parser #4552

Merged
merged 30 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c3ff183
Ropchain constraint syntax parser
giridharprasath Jun 13, 2024
0c3e27b
Refactor cmd_search.c and add unit tc
giridharprasath Jun 14, 2024
15d55ca
Initial commit for RzILOpEffect rop APIs
giridharprasath Jun 17, 2024
0d2c190
WIP: Add RzILOpEffect ROP gadget analysis APIs
giridharprasath Jun 18, 2024
27836e2
tiny rop.c cleanup
giridharprasath Jun 18, 2024
ac87493
WIP: Add rop gadget semantics
giridharprasath Jun 24, 2024
7af1118
Nit change
giridharprasath Jun 24, 2024
0d0331e
Cleanup and add memory rw support
giridharprasath Jun 25, 2024
8e6400e
fix dependency function flags
giridharprasath Jun 25, 2024
d3e820c
Generate accurate Rop gadgets
giridharprasath Jun 27, 2024
d8f5489
Regression tc fix
giridharprasath Jun 27, 2024
2445faf
Fix regression and add doc
giridharprasath Jun 28, 2024
b7bdc65
fix sanity
giridharprasath Jun 28, 2024
d315965
Fix sanity switch/case
giridharprasath Jun 28, 2024
c2b19f0
Tiny rop gadget print fix
giridharprasath Jun 28, 2024
4b26743
fix Linter comments
giridharprasath Jun 29, 2024
74a8ccb
Initial refactoring
giridharprasath Jul 4, 2024
070cbab
Final refactoring and test case
giridharprasath Jul 6, 2024
6cdd9bc
Refactoring and doxygen fixes
giridharprasath Jul 7, 2024
5d28f4a
Migration test fix
giridharprasath Jul 7, 2024
5993781
Fix migration intergration issues
giridharprasath Jul 7, 2024
51de827
Linter fixes
giridharprasath Jul 7, 2024
bbfaaa3
Linter fixes
giridharprasath Jul 8, 2024
15cb8ed
Ignore test sync db
giridharprasath Jul 8, 2024
583406e
Review fixes
giridharprasath Jul 9, 2024
5314e3f
Review comment fixes
giridharprasath Jul 9, 2024
e9d3fc7
Moved around lines for readability
wargio Jul 10, 2024
69f5a30
Fixed copyright in librz/core/cmd/cmd_search_rop.c
wargio Jul 10, 2024
bdb8efe
Rename var in function librz/arch/analysis.c
wargio Jul 10, 2024
267adbe
Fix definition in librz/include/rz_analysis.h
wargio Jul 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ peda-session-*
/.vs
.cache/
test/.tmp/*
test/.sync_disk_db
subprojects/capstone-*/
subprojects/pcre2*/
subprojects/libzip-*/
Expand Down
28 changes: 28 additions & 0 deletions librz/arch/analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <rz_util/rz_path.h>
#include <rz_arch.h>
#include <rz_lib.h>
#include <rz_rop.h>

/**
* \brief Returns the default size byte width of memory access operations.
Expand Down Expand Up @@ -129,6 +130,7 @@ RZ_API RzAnalysis *rz_analysis_new(void) {
}
}
analysis->ht_global_var = ht_sp_new(HT_STR_DUP, NULL, (HtSPFreeValue)rz_analysis_var_global_free);
analysis->ht_rop = NULL;
analysis->global_var_tree = NULL;
analysis->il_vm = NULL;
analysis->hash = rz_hash_new();
Expand Down Expand Up @@ -185,6 +187,7 @@ RZ_API RzAnalysis *rz_analysis_free(RzAnalysis *a) {
rz_list_free(a->imports);
rz_str_constpool_fini(&a->constpool);
ht_sp_free(a->ht_global_var);
ht_up_free(a->ht_rop);
rz_list_free(a->plugins);
rz_analysis_debug_info_free(a->debug_info);
free(a);
Expand Down Expand Up @@ -240,6 +243,31 @@ RZ_API char *rz_analysis_get_reg_profile(RzAnalysis *analysis) {
: NULL;
}

/**
* \brief Check if a register is in the analysis profile.
* \param analysis Pointer to the RzAnalysis object.
* \param str The register name to check.
* \return true if the register name is found, false otherwise.
*
* This function checks if the given register name is present
* in the register profile of the given RzAnalysis.
*/
RZ_API bool rz_analysis_is_reg_in_profile(RzAnalysis *analysis, const char *str) {
giridharprasath marked this conversation as resolved.
Show resolved Hide resolved
rz_return_val_if_fail(analysis && str, false);

char *reg_prof = rz_analysis_get_reg_profile(analysis);
if (!reg_prof) {
return false;
}

if (strstr(reg_prof, str)) {
free(reg_prof);
return true;
}
free(reg_prof);
return false;
}
wargio marked this conversation as resolved.
Show resolved Hide resolved

RZ_API bool rz_analysis_set_reg_profile(RzAnalysis *analysis) {
bool ret = false;
char *p = rz_analysis_get_reg_profile(analysis);
Expand Down
3 changes: 1 addition & 2 deletions librz/core/cconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -3735,8 +3735,7 @@ RZ_API int rz_core_config_init(RzCore *core) {

/* rop */
SETI("rop.len", 5, "Maximum ROP gadget length");
SETBPREF("rop.sdb", "false", "Cache results in sdb (experimental)");
SETBPREF("rop.db", "true", "Categorize rop gadgets in sdb");
SETBPREF("rop.cache", "false", "Cache rop gadget results(experimental)");
wargio marked this conversation as resolved.
Show resolved Hide resolved
SETBPREF("rop.subchains", "false", "Display every length gadget from rop.len=X to 2 in /Rl");
SETBPREF("rop.conditional", "false", "Include conditional jump, calls and returns in ropsearch");
SETBPREF("rop.comments", "false", "Display comments in rop search output");
Expand Down
Loading
Loading