Guest User

Untitled

a guest
Apr 26th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. global call_64_from_64
  2. global call_32_from_64
  3. global call_32_from_32
  4.  
  5. section .text
  6.  
  7. call_64_from_64:
  8. push rsi
  9. push rdi
  10. mov rax, 1
  11. mov rdi, 1
  12. mov rsi, rcx
  13. mov rdx, 44
  14. syscall
  15. pop rdi
  16. pop rsi
  17. ret
  18.  
  19. call_32_from_64:
  20. push rbx
  21. mov rax, 4
  22. mov rbx, 1
  23. ; mov rcx, rcx
  24. mov rdx, 44
  25. int 0x80
  26. pop rbx
  27. ret
  28.  
  29. call_32_from_32:
  30. push rbx
  31. ; Stash stack
  32. mov [_stack_stash], rsp
  33. lea rsp, [rdi + 0x80]
  34. ; Stash "how to get back"
  35. mov r9, 0x3300000000
  36. or r9, _call32_return_64
  37. push r9
  38. push _call32_return_32
  39. ; Set up far return/jump
  40. push 0x23
  41. push _call_32_from_32
  42. db 0x48 ; REX
  43. retf
  44.  
  45. _call32_return_64:
  46. mov rsp, [_stack_stash]
  47. pop rbx
  48. ret
  49.  
  50. section .bss
  51. _stack_stash: resq 1
  52.  
  53. BITS 32
  54.  
  55. section .text
  56.  
  57. _call32_return_32:
  58. add esp, 4
  59. retf
  60.  
  61. _call_32_from_32:
  62. mov eax, 4
  63. mov ebx, 1
  64. ; mov ecx, ecx
  65. mov edx, 44
  66. int 0x80
  67. ret
Add Comment
Please, Sign In to add comment