Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • D dynamorio
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,467
    • Issues 1,467
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 44
    • Merge requests 44
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • DynamoRIO
  • dynamorio
  • Issues
  • #4576
Closed
Open
Issue created Dec 01, 2020 by Administrator@rootContributor

[APP CRASH] Missing EIP in SEH Context when application sets trap flag to 1

Created by: dcdelia

Describe the bug DynamoRIO provides a zero EIP value in the SEH Context for the application handler when the program sets TF=1 using popf, while Windows provides the address of the instruction after the one that follows popf.

To Reproduce I have attached both ASM source and EXE (compiled with MASM32 with Console target) of a PoC that saves the EIP value available in the SEH Context and prints to screen the provided and the expected one. To run the program just use drrun.exe -- trapflag.exe. No difference observed when -debug enabled.

trapflag.zip

Expected behavior DynamoRIO should be providing in Context->EIP the address of the instruction next to the one after popf (it is different to the int 2d anti-debugger trick that expects a simple +1 in Context->EIP, so I used a longer instruction here). The detection works also without setting also IF=1 but just TF=1 (i.e. constant 102h for pushf).

PUSH @SehExit
PUSH DWORD PTR fs:[0]
MOV DWORD PTR fs:[0], esp
MOV [SavedESP], esp

PUSH 302h ; or 102h 
POPF
MOV eax, 0abcdefh ; any instruction is good here
@AfterInt:
JMP @AfterSeh

NOP
@SehExit:
MOV eax, DWORD PTR ds:[esp + 0ch]
MOV eax, DWORD PTR ds:[eax + 0b8h]
MOV [ContextEIP], eax
CMP eax, @AfterInt
JNZ @AfterSeh

Versions I have used v.8.0.0 build 1 as well as the latest build 18585. 32-bit application executed on Windows 7 SP1 x64.

Additional context I did not try to see if the general purpose registers are exposed correctly, but I can easily extend the detection program to track and print some of those too if this may help you. Issue #3783 references a simpler version of this anti-debug trick that is documented for instance here. That PoC just looks for a single-step exception being fired, while the one I wrote validates the context as suggested in a detection method proposed by corkami.

Assignee
Assign to
Time tracking