2020.06.27 redpwn

Redpwn 2020 Crypto - base646464

CTF writeup: redpwnCTF 2020's base646464 applies Base64 25 times. A Python decode loop respectfully declines to call that encryption.

Event
redpwn
Category
crypto
Topic
Encoding
Published
Markdown source Attached files Read article
Cite

Copy this citation into your bibliography, or download the BibTeX file.

Download .bib

base646464

Description

Plain text
Encoding something multiple times makes it exponentially more secure!

Files

Lets take a look at generate.js, which reads

JavaScript
const btoa = str => Buffer.from(str).toString('base64');

const fs = require("fs");
const flag = fs.readFileSync("flag.txt", "utf8").trim();

let ret = flag;
for(let i = 0; i < 25; i++) ret = btoa(ret);

fs.writeFileSync("cipher.txt", ret);

The function btoa is basically string to its base64 encoding.
The flag is encoded repetitively 25 times in a for loop.
We just need to base64 decode it 25 times and we will get the flag.

Python
from base64 import b64decode

with open('cipher.txt','r') as cipher_file:
    data = cipher_file.read()

for i in range(25):
    data = b64decode(data)

print(data)

A cool sarcasm on bad crypto challenges in CTFs :)

flag{l00ks_l1ke_a_l0t_of_64s}