#!/usr/bin/env python3

import subprocess
import os
import mmap
import struct


symbol = b'_bootstrap'
terminator = b"#MAGIC#\x00"
placeholder = '1#REPLACE_HERE'


def asm(template, assembly):
    line = sys.stdin.readline()
    offset, *_ = line.split()
    offset = int(offset, 16)

    with open(template, 'r') as fin, open(assembly, 'w') as fout:
        assembly = fin.read().replace(placeholder, str(offset))
        fout.write(assembly)


def truncate(payload):
    # magic = struct.pack('<Q', 0xAAAABBBBCCCCDDDD)
    magic = b'#REALSHIT#\x00'
    with open(payload, 'rb+') as fout:
        buf = fout.read()
        length = buf.find(magic)
        fout.truncate(length)


if __name__ == '__main__':
    import sys
    _, action, *tail = sys.argv

    if action == 'asm':
        asm(*tail)
    elif action == 'truncate':
        truncate(*tail)
    else:
        raise RuntimeError('invalid action %s' % action)


f71232e0bf3d5b33c1e2fc0a57a1e6f610dc4554
<mask token>


def asm(template, assembly):
    line = sys.stdin.readline()
    offset, *_ = line.split()
    offset = int(offset, 16)
    with open(template, 'r') as fin, open(assembly, 'w') as fout:
        assembly = fin.read().replace(placeholder, str(offset))
        fout.write(assembly)


def truncate(payload):
    magic = b'#REALSHIT#\x00'
    with open(payload, 'rb+') as fout:
        buf = fout.read()
        length = buf.find(magic)
        fout.truncate(length)


<mask token>

<mask token>


def asm(template, assembly):
    line = sys.stdin.readline()
    offset, *_ = line.split()
    offset = int(offset, 16)
    with open(template, 'r') as fin, open(assembly, 'w') as fout:
        assembly = fin.read().replace(placeholder, str(offset))
        fout.write(assembly)


def truncate(payload):
    magic = b'#REALSHIT#\x00'
    with open(payload, 'rb+') as fout:
        buf = fout.read()
        length = buf.find(magic)
        fout.truncate(length)


if __name__ == '__main__':
    import sys
    _, action, *tail = sys.argv
    if action == 'asm':
        asm(*tail)
    elif action == 'truncate':
        truncate(*tail)
    else:
        raise RuntimeError('invalid action %s' % action)

<mask token>
symbol = b'_bootstrap'
terminator = b'#MAGIC#\x00'
placeholder = '1#REPLACE_HERE'


def asm(template, assembly):
    line = sys.stdin.readline()
    offset, *_ = line.split()
    offset = int(offset, 16)
    with open(template, 'r') as fin, open(assembly, 'w') as fout:
        assembly = fin.read().replace(placeholder, str(offset))
        fout.write(assembly)


def truncate(payload):
    magic = b'#REALSHIT#\x00'
    with open(payload, 'rb+') as fout:
        buf = fout.read()
        length = buf.find(magic)
        fout.truncate(length)


if __name__ == '__main__':
    import sys
    _, action, *tail = sys.argv
    if action == 'asm':
        asm(*tail)
    elif action == 'truncate':
        truncate(*tail)
    else:
        raise RuntimeError('invalid action %s' % action)

import subprocess
import os
import mmap
import struct
symbol = b'_bootstrap'
terminator = b'#MAGIC#\x00'
placeholder = '1#REPLACE_HERE'


def asm(template, assembly):
    line = sys.stdin.readline()
    offset, *_ = line.split()
    offset = int(offset, 16)
    with open(template, 'r') as fin, open(assembly, 'w') as fout:
        assembly = fin.read().replace(placeholder, str(offset))
        fout.write(assembly)


def truncate(payload):
    magic = b'#REALSHIT#\x00'
    with open(payload, 'rb+') as fout:
        buf = fout.read()
        length = buf.find(magic)
        fout.truncate(length)


if __name__ == '__main__':
    import sys
    _, action, *tail = sys.argv
    if action == 'asm':
        asm(*tail)
    elif action == 'truncate':
        truncate(*tail)
    else:
        raise RuntimeError('invalid action %s' % action)

#!/usr/bin/env python3

import subprocess
import os
import mmap
import struct


symbol = b'_bootstrap'
terminator = b"#MAGIC#\x00"
placeholder = '1#REPLACE_HERE'


def asm(template, assembly):
    line = sys.stdin.readline()
    offset, *_ = line.split()
    offset = int(offset, 16)

    with open(template, 'r') as fin, open(assembly, 'w') as fout:
        assembly = fin.read().replace(placeholder, str(offset))
        fout.write(assembly)


def truncate(payload):
    # magic = struct.pack('<Q', 0xAAAABBBBCCCCDDDD)
    magic = b'#REALSHIT#\x00'
    with open(payload, 'rb+') as fout:
        buf = fout.read()
        length = buf.find(magic)
        fout.truncate(length)


if __name__ == '__main__':
    import sys
    _, action, *tail = sys.argv

    if action == 'asm':
        asm(*tail)
    elif action == 'truncate':
        truncate(*tail)
    else:
        raise RuntimeError('invalid action %s' % action)

