Skip to content

Instantly share code, notes, and snippets.

@AndyNovo AndyNovo/encodehexflag Secret
Created Mar 6, 2019

Embed
What would you like to do?
jimmys_crypto
468a4376450df466cd200e20c8d62d9c7e62b982a3625f7017ec97fec4b7f38f4d3fe2e60439f1b8316bf96a7b64e2fbb2fcb5179cca6001c14794e74a5df146ad9fe58fb5091ee8bce96e245a6a6c9b19886a9d3ec1c12c7c07bf99cb8d1351d38491e4e2c4d2c8bd526d94cd
6c9b4570450ce630c9201f20ceca68892b70b881b42505411cbcd1e2d3f4f5825062e2d10e34a4a96566d95a595c84ed8fec8826a0ed5646ed3dfc9d732ebc64ebe0cfce897634b781dd53020e155edb74cf5db97eb2f4715751eec7c48d125d818492f0f785c8cea51d3eb3a8905e7853a11a1a6ec89542c3b174c30ae78013714e7f4cdabf79b50536554976c67899ef1faf3471d1ed3ed591314ae674da3ccd9df7523afa451f8bbbf4825fa75a01bc564b00ba8b1fe450b90334e8ecd57d3a8a00935332c5ad90ce198a6620cdfe773d025ba546a90d89f2a4198858879ac35826fa6a6b30232929cc29bde4888d7b7d45fdf30e213821282da13837da2dc906df76a218eff5ef19eea7169d0ff73e54b1c4a853bdaa92b5e16fa953db9b8e57890f793441c8fea94764f0e98591b368e1be60b779bf800a7614fc431147abcd7faa54bd9eab95ce025e321d44330371fdff0f9f81434b1f6e6d149794ab4f760f7dfd538d2d34d1b2773376b3dd6e6db23de9792df1
#!/usr/bin/env python2
import random
def do_xor(p, k):
out = ''
for i in xrange(len(p)):
out += chr(ord(p[i]) ^ ord(k[i]))
return out
with open('flag_plaintext', 'rb') as f1:
p1 = ''.join(f1.readlines())
with open('secret_plaintext', 'rb') as f2:
p2 = ''.join(f2.readlines())
l = max(len(p1), len(p2))
key = ''.join([chr(random.randint(0, 256)) for i in xrange(l)])
c1 = do_xor(p1, key)
c2 = do_xor(p2, key)
#NOTE I AM SHARING THE HEXDIGEST OF FLAG AND SECRET NOT THE RAW FILES THAT ARE INDICATED HERE
with open('flag', 'wb') as f1:
f1.write(c1)
with open('secret', 'wb') as f2:
f2.write(c2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.