The Safest Encryption
40 points Medium

I intercepted this zip file, the contents seem to be encrypted, but it looks like the key is also in there. Could you try recovering the encrypted file?

CTFlearn.zip
Flag
Rating 4.53
5
4
3
2
1

Discussion

Protected
0

Good one, bro!!! Loved it

0

hey guys! took me a day and a half to solve this.. because the so-called "solutions" all don't work. here we go, ill give you a hint, download this file-xor-er that xors two files you selected FOR YOU! AUTOMATICALLY! no programming, no codes that don't work, only efficiency: https://www.nirsoft.net/utils/xorfiles.html by downloading this zip file and extracting all the content, open the file called "xorfiles" and click on browse, now select the pdf and txt in the zip file of this challenge and then select a blank pdf as a final file so that you can see the flag in the pdf. And voila! The answer will be seen inside of the blank pdf file, hope this helps! and for those of you who solved the challenge thinking im just giving out the answer, i do sincerely apologize because this challenge is way too hard! Beginners will never be able to solve this challenge, as I said, this took me a days and half. Good luck!

0

how i solved this: https://pastebin.com/2u3KhVJe (i dont recommend because it contains the solution)

0

Hint: Use WC command, is there anything interesting?

0

can u explain ?

0

Hi bro, think abt the WC command show the number of bytes and words in each file. Is there a coincidence in somewhere?

0

i solved it my guy, kinda hard, im about to complete all the cryptography section then head back to forensics because i was stuck at the space station, anyway thanks

0

from pwn import xor with open('CTFLearn.pdf', 'rb') as file1, open('CTFLearn.txt', 'rb') as file2: var1 = file1.read() var2 = file2.read() flag = xor(var1, var2) with open('result', 'wb') as result: result.write(flag)

1

import sys

Read two files as byte arrays

file1_b = bytearray(open(sys.argv1, 'rb').read()) file2_b = bytearray(open(sys.argv[2], 'rb').read())

Set the length to be the smaller one

size = len(file1_b) if len(file1_b) < len(file2_b) else len(file2_b)

xord_byte_array = bytearray(size)

XOR between the files

for i in range(size): xord_byte_array[i] = file1_b[i] ^ file2_b[i]

Write the XORd bytes to the output file

open(sys.argv[3], 'wb').write(xord_byte_array)

print("XOR operation completed. Result saved to", sys.argv[3])

Run:python script.py CTFlearn.pdf CTFlearn.txt output.pdf

What i m doing here incorrect i cant understand

-1

i found this challenge very hard first and i didn't find the solution any where in the internet and i decided to include the solution here PLZZZZZZZZZZ if u don't wanna see the solution don't read what i wrote below i don't wanna ruin the challenge to anybody but if u feel u have no way to figure out the solution by yourself read the remaining :

the 2 files given are the same size that means tha we have to think about XOR so first search in the internet about a script that takes 2 files and XOR them and then the output should be in pdf format go to your folders (Graphical user interface) and open that pdf you will see the flag

4

SCRIPT :

import sys

Read two files as byte arrays

file1_b = bytearray(open(sys.argv1, 'rb').read()) file2_b = bytearray(open(sys.argv[2], 'rb').read())

Set the length to be the smaller one

size = len(file1_b) if len(file1_b) < len(file2_b) else len(file2_b) xord_byte_array = bytearray(size)

XOR between the files

for i in range(size): xord_byte_array[i] = file1_b[i] ^ file2_b[i]

Write the XORd bytes to the output file

open(sys.argv[3], 'wb').write(xord_byte_array)

call it whatever you want i called it xor.py then save

in the terminal run this command :

python xor.py CTFlearn.pdf CTFlearn.txt output.pdf

then this file called output.pdf is the one u should open to view the flag remember open it using the GUI not terminal unfortunately i cannot upload images in this comments to show but i hope u could find this helpful

3

There are 2 small errors in this code. The fixed code is : import sys file1_b = bytearray(open(sys.argv1, 'rb').read()) file2_b = bytearray(open(sys.argv[2], 'rb').read()) size = len(file1_b) if len(file1_b) < len(file2_b) else len(file2_b) xord_byte_array = bytearray(size) for i in range(size): xord_byte_array[i] = file1_b[i] ^ file2_b[i] open(sys.argv[3], 'wb').write(xord_byte_array)

1

is this done in nano?

0

its python script so the file should be .py u can write it in whatever you want nano or sublime vscode its the same

1

you can use nano or mousepad and save it as ..py file

2