capa icon indicating copy to clipboard operation
capa copied to clipboard

dotnet: characteristics

Open mike-hunhoff opened this issue 2 years ago • 5 comments

most of the characteristics we emit won't apply to dotnet, so, let's collect ideas for new dotnet characteristics here.

mike-hunhoff avatar Apr 04 '22 18:04 mike-hunhoff

- chracteristic: mixed mode

scope: file

Mixed assemblies are capable of containing both unmanaged machine instructions and MSIL instructions. This allows them to call and be called by .NET components, while retaining compatibility with native C++ libraries. Using mixed assemblies, developers can author applications using a mixture of .NET and native C++ code.

mike-hunhoff avatar Apr 04 '22 18:04 mike-hunhoff

- characteristic: invalid token

scope: (instruction, basic block,) call, function, file

often see this used as an anti-analysis technique aimed to break tooling

also: "invalid string"

mike-hunhoff avatar Apr 04 '22 18:04 mike-hunhoff

- characteristic: p/invoke

scope: (instruction, basic block,) call, function, file

P/Invoke is a technology that allows you to access structs, callbacks, and functions in unmanaged libraries from your managed code.

maybe make this more generic e.g. unmanaged call as there appear to be other ways to invoke unmanaged code from managed that does not require p/invoke

mike-hunhoff avatar Apr 04 '22 18:04 mike-hunhoff

is it worth going through all the [method] flags and turning the relevant ones into characteristics?

Originally posted by @williballenthin in https://github.com/mandiant/capa/pull/958#discussion_r845239977

Screen Shot 2022-04-07 at 12 13 47 PM Screen Shot 2022-04-07 at 12 13 00 PM

mike-hunhoff avatar Apr 07 '22 18:04 mike-hunhoff

encountered a protected .NET sample that did not contain a #US stream. This could make for an interesting characteristic used to detect packed/protected/obfuscated .NET but we would need additional research to determine how un/common this is.

something like:

- characteristic: missing user strings

update:

ECMA II.24.2.1: "Each kind of stream shall occur at most once, that is, a meta-data file shall not contain two “#US” streams, or five “#Blob” streams. Streams need not be there if they are empty."

mike-hunhoff avatar Dec 13 '22 17:12 mike-hunhoff