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

Injection vs Extraction #468

Closed
tsarpaul opened this issue Dec 31, 2019 · 4 comments
Closed

Injection vs Extraction #468

tsarpaul opened this issue Dec 31, 2019 · 4 comments

Comments

@tsarpaul
Copy link

tsarpaul commented Dec 31, 2019

Hi, I couldn't find documentation regarding those two modules but from reading source it seems that Injection tracks injected code (duh, e.g. WriteProcessMemory) and Extraction seems to track interesting regions (e.g. NtProtectVirtualMemory).
I want to be able to extract as much malicious code as possible so I'm wondering whether it's possible to merge both modules and perhaps hear the considerations why these modules were developed into separate branches in the monitor.

To this end I'm weighing on using the old procmem feature (which I'm patching to meet ends) to just dump the whole process's code.

@kevoreilly
Copy link
Contributor

I've recently been combining these two modules into the base capemon - I'm still testing them but I've attached them in case you would like to try too. You can enable injection with the option injection=1 and extraction is just extraction=1. The distinction between them is basically inter-process vs 'intra-process' but the real reason they have been separated until now is that extraction uses debugger breakpoints and so was much more complex and error-prone to develop.

I am hoping soon to make the default to have all these enabled so as to minimise the need for multiple executions - I just need to see that they are stable enough to rely upon to work on the majority of samples without hindering the baseline analysis.

I wouldn't recommend the procmemdump feature as it's so crude but it's worth noting that this has been reimplemented and is now done in-monitor as opposed to by a separate process as in spender. I'd therefore be interested to know what you are patching to improve it.

There is a lot of power in the new 'DumpInterestingRegions' function, a lot of which can be tested with the option: verbose-dumping=1, so give that a try too.
capemon.zip

@tsarpaul
Copy link
Author

tsarpaul commented Jan 1, 2020

I actually noticed at DumpInterestingRegions (https://github.com/kevoreilly/capemonv2/blob/master/CAPE/CAPE.c#L1657) the verbose_dumping check is done incorrectly:

 else if (!g_config.verbose_dumping && MemInfo.BaseAddress == CallerBase)
      {
          DoOutputDebugString("DumpInterestingRegions: Dumping calling region at 0x%p.\n", MemInfo.BaseA  ddress);

The condition should be "g_config.verbose_dumping && .." instead no?

@kevoreilly
Copy link
Contributor

Ah this is intended as it's assumed that if verbose_dumping is set the calling region will already have been dumped with the first api call originating there, in hooking.c.

@kevoreilly
Copy link
Contributor

The injection and extraction features have now been integrated into capemon and can be switched on with injection=1 and extraction=1 options respectively, and of course simultaneously. This should take care of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants