Last active
April 24, 2020 16:01
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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