gpa.asm 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. BITS 64
  2. ; https://dennisbabkin.com/blog/?t=how-to-implement-getprocaddress-in-shellcode
  3. GetKernel32ModuleHandle:
  4. mov rax, gs:[60h]
  5. mov rax, [rax + 18h]
  6. mov rax, [rax + 20h]
  7. mov rax, [rax]
  8. mov rax, [rax]
  9. mov rax, [rax + 20h]
  10. ret
  11. GetAddressOf_GetProcAddress:
  12. mov eax, [rcx + 3ch]
  13. add rax, rcx
  14. lea rax, [rax + 88h]
  15. mov edx, [rax]
  16. lea rax, [rcx + rdx]
  17. mov edx, [rax + 18h]
  18. mov r8d, [rax + 20h]
  19. lea r8, [rcx + r8]
  20. mov r10, 41636f7250746547h ; "GetProcA"
  21. mov r11, 0073736572646441h ; "Address\0"
  22. .1:
  23. mov r9d, [r8]
  24. lea r9, [rcx + r9]
  25. ; Function name comparision
  26. cmp r10, [r9]
  27. jnz .2
  28. cmp r11, [r9 + 7]
  29. jnz .2
  30. ; Found GetProcAddress
  31. neg rdx
  32. mov r10d, [rax + 18h]
  33. lea rdx, [r10 + rdx]
  34. mov r10d, [rax + 24h]
  35. lea r10, [rcx + r10]
  36. movzx rdx, word [r10 + rdx * 2]
  37. mov r10d, [rax + 1ch]
  38. lea r10, [rcx + r10]
  39. mov r10d, [r10 + rdx * 4]
  40. lea rax, [rcx + r10] ; Function address
  41. jmp .end
  42. .2:
  43. add r8, 4
  44. dec rdx
  45. jnz .1
  46. .end:
  47. ret