Skip to content

Commit

Permalink
Add 'dlopen' & 'dlsym' as a name source for autorenamer;
Browse files Browse the repository at this point in the history
Fix doc
  • Loading branch information
srgblv committed Nov 20, 2024
1 parent c280f99 commit cdecd34
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 4 additions & 1 deletion doc/unflat.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Unflattening
Here is a deep modification of original code of [Rolf Rolles](https://hex-rays.com/blog/hex-rays-microcode-api-vs-obfuscating-compiler) and [Takahiro Haruyama](https://blogs.vmware.com/security/2019/02/defeating-compiler-level-obfuscations-used-in-apt10-malware.html) to deal with nested flattening used in FinSpy (FinFisher) malware. As well it should be useful in RE other flattened malware.
Here is a deep modification of original code by [Rolf Rolles](https://hex-rays.com/blog/hex-rays-microcode-api-vs-obfuscating-compiler)
and [Takahiro Haruyama](https://blogs.vmware.com/security/2019/02/defeating-compiler-level-obfuscations-used-in-apt10-malware.html)
to deal with nested flattening and jg/jle instead jz/jnz comparing were used in FinSpy (FinFisher) malware.
As well it should be useful in RE other flattened malware.

Unflattener may be disabled/enabled in decompiler's context menu. Current state of unflattener reported in a comment in the first line of pseudocode.

Expand Down
2 changes: 1 addition & 1 deletion src/hrtng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4386,7 +4386,7 @@ plugmod_t*
addon.producer = "Sergey Belov and Milan Bohacek, Rolf Rolles, Takahiro Haruyama," \
" Karthik Selvaraj, Ali Rahbar, Ali Pezeshk, Elias Bachaalany, Markus Gaasedelen";
addon.url = "https://github.com/KasperskyLab/hrtng";
addon.version = "1.1.5";
addon.version = "1.1.6";
register_addon(&addon);

return PLUGIN_KEEP;
Expand Down
9 changes: 4 additions & 5 deletions src/rename.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,16 @@ static bool getCallName(cfunc_t *func, cexpr_t* call, qstring* name)
if (!args.size())
return false;

if (!namecmp(funcname.c_str(), "LoadLibrary") ||
!namecmp(funcname.c_str(), "GetModuleHandle")) {
if (!namecmp(funcname.c_str(), "LoadLibrary") || !namecmp(funcname.c_str(), "GetModuleHandle") || !namecmp(funcname.c_str(), "dlopen")) {
qstring argName;
if (args.size() == 1 && getExpName(func, &args[0], &argName)) {
if (args.size() >= 1 && getExpName(func, &args[0], &argName)) {
*name = "h";
*name += argName;
return true;
}
}
else if (!namecmp(funcname.c_str(), "GetProcAddress")) {
if (args.size() == 2 && getExpName(func, &args[1], name))
else if (!namecmp(funcname.c_str(), "GetProcAddress") || !namecmp(funcname.c_str(), "dlsym")) {
if (args.size() >= 2 && getExpName(func, &args[1], name))
return true;
}
else if (!namecmp(funcname.c_str(), "strdup") || !namecmp(funcname.c_str(), "wcsdup")) {
Expand Down

0 comments on commit cdecd34

Please sign in to comment.