Guest User

Untitled

a guest
Sep 15th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. proc _ScanPattern,ProcessHandle,pattern,pSize,mask,modname
  2.      invoke CreateToolhelp32Snapshot,8,[pID]
  3.      mov    [mSnapshot],eax
  4.      mov    [module.dwSize],sizeof.MODULEENTRY32
  5.      invoke Module32First,[mSnapshot],module
  6. check_module:
  7.      invoke StrStrI,module.szModule,[modname]
  8.      test   eax,eax
  9.      jz     next_module
  10. ;-------------------------------------------------------------------------------------------------------------
  11. push       ecx esi edi
  12.      invoke VirtualAlloc,0,[module.modBaseSize],MEM_COMMIT,PAGE_EXECUTE_READWRITE
  13.      mov    [AllocAddress],eax
  14.      add    eax,[module.modBaseSize]
  15.      dec    eax
  16.      mov    [EndofAlloc],eax
  17.      invoke ReadProcessMemory,[phandle],[module.modBaseAddr],[AllocAddress],[module.modBaseSize],0
  18.      mov    edi,[AllocAddress]
  19.      mov    esi,[pattern]
  20. ;.while 1
  21. ;.endw
  22. MainLoop:
  23.      xor    ecx,ecx
  24.      jmp    Loop2
  25. Search:
  26.      mov    eax,[mask]
  27.      mov    al,[eax+ecx]
  28.      cmp    al,"x"
  29.      jne    AB
  30.      mov    al,[esi+ecx]
  31.      mov    ah,[edi+ecx]
  32.      cmp    al,ah
  33.      jne    Bdnm
  34. AB:
  35.      inc    ecx
  36. Loop2:
  37.      cmp    ecx,[pSize]
  38.      jne    Search
  39.      mov    eax,edi
  40.      sub    eax,[AllocAddress]
  41.      add    eax,[module.modBaseAddr]
  42.      push   eax
  43.      invoke VirtualFree,[AllocAddress],[module.modBaseSize],MEM_DECOMMIT
  44.      pop    eax
  45.      ret
  46. Bdnm:
  47.      cmp    edi,[EndofAlloc]
  48.      jnb    OutOfScanRange
  49.      inc    edi
  50.      jmp    MainLoop
  51. OutOfScanRange:
  52.      mov    eax,-1
  53.      push   eax
  54.      invoke VirtualFree,[AllocAddress],[module.modBaseSize],MEM_DECOMMIT
  55.      pop    eax
  56.      pop    ecx esi edi
  57.      ret
  58. ;-------------------------------------------------------------------------------------------------------------
  59. next_module:
  60.      invoke Module32Next,[mSnapshot],module
  61.      test   eax,eax
  62.      jnz    check_module
  63.      invoke CloseHandle,[mSnapshot]
  64.      ret
  65. endp
Add Comment
Please, Sign In to add comment