from pwn import *

context.arch = 'amd64'

open("map_shared_x86_64", "wb").write(asm("""
mov r10, rcx
mov rcx, rdx
mov rax, 4
int 3
//validate_handle rax = address
mov rbx, rax
mov rcx, r10                                          
xchg rcx, rdx
xchg rdx, rbx
mov rax, 5                                                                                                                                                              
int 3
// map_address
mov rbx,rax                                                                                    
"""))
open("memprot_x86_64", "wb").write(asm("""
mov rax, 11                                       
mov r10, rbx
mov r11, rdx                                       
mov rbx, rdi
//confirm password
int3
cmp eax,0
je continue
mov ebx, 0xffff
jmp done                                                                              
continue:                                                                                                                     
mov rbx, r10
mov rdx, r11                                       
mov rax, 12
int3                                        
done:
nop                                                                                                                                                                                                                                           
"""))
