Advertisement
Madmouse

examples from my paper for breakpoint detection as an introd

Feb 15th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; intel x86_64
  2.     mov rcx, rsi    ; move size argument into rcx for the loop
  3.     mov rsi, rdi    ; move the the text pointer to rsi for printing
  4.     xor rax, rax    ; clear out registers
  5.     xor rdi, rdi
  6. scan:               ; scan for breakpoints
  7.     cmp byte [rsi], 0xCC
  8.     je fuck_you
  9.     inc rsi
  10. loop scan
  11.     xor rdi, rdi
  12.     ret
  13. fuck_you:
  14.     xor rdi, rdi
  15.     mov al, 1
  16.     ret
  17.  
  18.  
  19.  
  20. @ ARM
  21. scan:
  22.         .code 32
  23.         ldr r3, =0xE7F00000     @ load breakpoint constant
  24.         ldr r4, =0xFFFF0000     @ mask
  25. loop:
  26.         ldr r2, [r0]    @ load byte code into r2
  27.         and r2, r4      @ clear out extra data in bytecode with mask
  28.         cmp r2, r3      @ is it a breakpoint?
  29.         beq fuck        @ if so FUCK
  30.         cmp r1, #0      @ are we at the end?
  31.         beq safe        @ if so we are safe
  32.         sub r1, #1      @ decrement the counter
  33.         add r0, #1      @ increment our pointer
  34.         bne loop        @ if we are still looping, loop
  35. safe:
  36.         mov r0, #0      @ return false
  37.         mov r1, r0
  38.         bx lr
  39. fuck:
  40.         mov r0, #0x1    @ return true
  41.         mov r1, #0
  42.         bx lr
  43.  
  44.  
  45.  
  46. # MIPS
  47. scan:
  48.         li $t0, 0x5000D                 # breakpoint constant
  49. loop:
  50.         lw $t3, ($a0)                   # load bytecode
  51.         beq $t3, $t0, fuck              # if this is a breakpoint fucked
  52.         beq $t3, 0, safe                # if the counter is 0 we are safe
  53.         subu $a1, 1                     # decrement counter
  54.         addu $a0, 1                     # increment our pointer
  55.         j loop                          # if we are looping loop
  56.  
  57. safe:
  58.         li $v0, 0x0     # return false
  59.         li $v1, 0x0
  60.         jr $ra
  61.  
  62. fuck:
  63.         li $v0, 0x1     # return true
  64.         li $v1, 0x0
  65.         jr $ra
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement