Skip to content

Instantly share code, notes, and snippets.

@sugayaa
Last active April 24, 2020 16:01
Show Gist options
  • Save sugayaa/9c28e7bf369cb1be7832dd716891e6ea to your computer and use it in GitHub Desktop.
Save sugayaa/9c28e7bf369cb1be7832dd716891e6ea to your computer and use it in GitHub Desktop.
Script mainly intended for CTF's. Script create binaries from raw hex text.
def sanitize(content):
return content.replace(" ","").replace("\n","").replace("\r","")
def main():
with open("binary_as_text", "r") as f:
content = f.read()
content = sanitize(content)
bin_content = b''
for i in range(len(content)//2):
byte = content[i*2:i*2+2]
bin_content += bytes([int(byte, 16)])
with open("generated_binary", "wb") as dest:
dest.write(bin_content)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment