Skip to content

Instantly share code, notes, and snippets.

@Darth-Carrotpie
Created June 25, 2020 14:55
Show Gist options
  • Save Darth-Carrotpie/195d475e02ddba051c43bd8ad8500014 to your computer and use it in GitHub Desktop.
Save Darth-Carrotpie/195d475e02ddba051c43bd8ad8500014 to your computer and use it in GitHub Desktop.
import binascii
import base64
def __decode_flag(encodedFlag, startChar):
decodedBytes = bytearray(binascii.unhexlify(encodedFlag))
print(len(decodedBytes))
output_bytes = []
i = 0
baseChar = base64.b64encode(startChar.encode('utf-8'))[0]
while i < len(decodedBytes):
nextItem = decodedBytes[((i + 1) % len(decodedBytes))]
newChar = baseChar ^ nextItem
output_bytes.append(newChar)
i = i + 1
baseChar = newChar
print(len(output_bytes))
b64dencoded = base64.b64decode(bytearray(output_bytes))#, altchars="-_")
output = b64dencoded.decode('utf-8')
return output
print('You are suppose to work a bit')
def main():
input = b"646a310e2d261f1121013717516236040e01161b183b2a0a0f54095126112f300e1d231b500705690e20103e01163423010e251727775331112f000c27013b200e1d2308390c3d0e2d2616330e1567570f2b3215390a3e202b5a006b"
alphanums = r'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
for num in alphanums:
print("char: "+str(num))
decoded = __decode_flag(input, num)
print(decoded)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment