在调试器中,拙劣的debugger是用0xcc 来跟踪代码,但od就是用标志位进行单步跟踪,简单的说就是把TF置位,如果我们有自己的单步跟踪代码,od如果同时也跟踪了,就会“无视”我们自己的代码....达到anti的目的
代码如下:
;===============================cut==============================
;Author:Comic.Liu
  .386
  .model  flat,stdcall
  option  casemap  :none

  include    windows.inc
  include    user32.inc
  includelib  user32.lib
  include    kernel32.inc
  includelib  kernel32.lib
  .const

  .data
    szT    db  'Title',0
    szM    db  'You Are Passed',0
  .code
SEH  proc  pExcept:DWORD,pFrame:DWORD,pContext:DWORD,pDispatch:DWORD
    pushad
    assume  esi:ptr EXEPTION_RECORD,edi:ptr CONTEXT

    mov  esi,[pExcept]
    mov  edi,[pContext]

    mov  ebx,[edi].regEip
    inc  ebx
    cmp  byte ptr[ebx],0
    org  $-1
    popfd
    jz  fin
    or  [edi].regFlag,100h
    jmp  fin1
fin:    inc  [edi].regEip
fin1:    popad
    mov  eax,ExceptionContinueExecution
    ret



SEH  endp

start:
    assume  fs:nothing
    push  offset SEH
    push  fs:[0]
    mov  fs:[0],esp

    pushfd
    pushfd
    or  dword ptr[esp],100h
    popfd
    ;进入这一段代码就翘翘了
    nop
    ret
    ;=======End============
    ;不过可以用OD里的F4直接跳过上面那一段,到下面
    popfd
    invoke  MessageBox,NULL,offset szM,offset szT,NULL

    pop  fs:[0]
    add  esp,4
    invoke  ExitProcess,0
  
  end  start
;==========================finish===========================
程序在nop处以Single Step事件进入seh
在seh里面,修改eip跳过代码:ret

如果od跟踪,就截断了single step,seh就不会运行了,然后就出错

  • 标 题: 答复
  • 作 者:forgot
  • 时 间:2006-08-22 10:21

这个太普通了,有经验的遇到popfd会不由自主看一下[esp+1]里面那个是不是奇数。