Advertisement
Guest User

Untitled

a guest
Apr 29th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. push %rbx
  2. mov 8(%rsp),%rbx
  3. xor %r12,%rbx
  4. ...
  5. xor %r12,%rbx
  6. cmp %rbx,8(%rsp)
  7. jnz .error
  8. pop %rbx
  9. retn
  10. .error:
  11. ud2
  12.  
  13. ; store the old value of rbx
  14. push %rbx
  15. ; read the top value on the stack (the return pointer) and put it in rbx
  16. mov 8(%rsp),%rbx
  17. ; xor rbx with a random value stored in r12
  18. ; rbx now contains the RAP canary
  19. xor %r12,%rbx
  20.  
  21. ; xor the RAP canary in rbx with the random value in r12
  22. ; this "decrypts" the stack pointer from the RAP canary
  23. xor %r12,%rbx
  24. ; compare the top value on the stack (the return pointer)
  25. ; with the value decrypted from the RAP canary
  26. cmp %rbx,8(%rsp)
  27. ; if the comparison fails, jump to error
  28. jnz .error
  29. ; restore the original value of rbx
  30. pop %rbx
  31. ; return
  32. retn
  33. .error:
  34. ; an error occured, quit the process
  35. ud2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement