Skip to content

Add .NET Environment.TickCount timing anti-debug rule#1137

Open
aryanyk wants to merge 2 commits intomandiant:masterfrom
aryanyk:rule-dotnet-tickcount-antidebug
Open

Add .NET Environment.TickCount timing anti-debug rule#1137
aryanyk wants to merge 2 commits intomandiant:masterfrom
aryanyk:rule-dotnet-tickcount-antidebug

Conversation

@aryanyk
Copy link

@aryanyk aryanyk commented Mar 12, 2026

This PR adds a rule to detect timing-based anti-debug checks in .NET binaries that rely on repeated reads of Environment.TickCount around Thread.Sleep.

Issue #596

The technique appears in the .NET-Anti-Debug project. A minimal sample implementing the behavior was compiled, features were inspected using scripts/show-features.py, and the rule was verified to trigger correctly with capa.

Example detection:

  • md5: e842958188274d5ffee7fbeffb803b2e
  • function: 0x6000001

Additional rules for other techniques in the same project (e.g., WMI-based VM detection and process enumeration) will be submitted in follow-up PRs after validating samples.

Copy link
Collaborator

@mike-hunhoff mike-hunhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aryanyk there appears to be unrelated rules included in this pull request. Please remove these unrelated rules. Also, please build the referenced anti-debug .NET project and open a pull request to https://github.com/mandiant/capa-testfiles for the resulting binary so we can ground all related rules, thank you.

@aryanyk aryanyk force-pushed the rule-dotnet-tickcount-antidebug branch from 3c0d9f8 to 783cb04 Compare March 21, 2026 12:16
@aryanyk
Copy link
Author

aryanyk commented Mar 21, 2026

Thanks for the feedback @mike-hunhoff

I've removed the unrelated rules from this PR.

I have also created a minimal .NET sample implementing the timing-based anti-debug technique and opened a PR to capa-testfiles to include this sample: mandiant/capa-testfiles#304 .

Please let me know if any further adjustments are needed.

@aryanyk aryanyk requested a review from mike-hunhoff March 21, 2026 12:28
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

Successfully merging this pull request may close these issues.

2 participants