Skip to content

Instantly share code, notes, and snippets.

@intrd
Last active May 24, 2024 23:15
Show Gist options
  • Save intrd/c63db7bd3d0951f0653d6fdf7ea169d6 to your computer and use it in GitHub Desktop.
Save intrd/c63db7bd3d0951f0653d6fdf7ea169d6 to your computer and use it in GitHub Desktop.
base64x50 decoder used in misc100-base3200 @ 3dsctf-2k16
## base64x50 decoder used in misc100-base3200 @ 3dsctf-2k16
# @author intrd - http://dann.com.br/
# @license Creative Commons Attribution-ShareAlike 4.0 International License - http://creativecommons.org/licenses/by-sa/4.0/
import base64
# 3200/64 = 50
pontfile='msg.txt'
for x in range(0, 50):
with open(pontfile, 'r') as f:
de = f.readline()
f.close()
with open(pontfile,"w") as xx:
xx.write(base64.b64decode(de))
@andersonhowever
Copy link

andersonhowever commented May 24, 2024

resolved error:

Traceback (most recent call last):
File "/home/kali/base3200.py", line 10, in
xx.write(base64.b64decode(de))
TypeError: write() argument must be str, not bytes

import base64

pontfile = 'msg.txt'

# Read the content of the file once
with open(pontfile, 'r') as f:
    content = f.read()

# Decode the content 50 times
for _ in range(50):
    content = base64.b64decode(content)

# Write the decoded content back to the file
with open(pontfile, 'wb') as f:
    f.write(content)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment