Skip to content

Latest commit

 

History

History

sherlock

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Sherlock (crypto)

Sherlock has a mystery in front of him. Help him to find the flag. 

###ENG PL

In the task we get a book. We figured we could compare it to the original text from Project Gutenberg.

We had to make it lowercase and remove the ToC but other than that the comparison was simple:

import codecs


def main():
    with codecs.open("sherlock.txt", "r") as input_file:
        task_data = input_file.read()
        task_data.replace("\n\n", "\n")
    with codecs.open("sherlock.txt", "r") as input_file:
        original_data = input_file.read()
        original_data = original_data.lower()
        original_data.replace("\n\n", "\n")
    result = "".join([task_data[i] for i in range(len(task_data)) if task_data[i] != original_data[i]])
    print(result)


main()

This gave us a long string with ZEROONEZERO.... We changed this into a number and interpreted as text:

from crypto_commons.generic import long_to_bytes

    result = result.replace("ZERO", "0")
    result = result.replace("ONE", "1")
    print(long_to_bytes(int(result, 2)))

And we got BITSCTF{h1d3_1n_pl41n_5173}

###PL version

W zadaniu dostajemy książkę. Postanowiliśmy porównać ją z oryginalnym tekstem z Project Gutenberg.

Musieliśmy zmienić ją na lowercase i usunąć spis treści, ale cała reszta była prosta:

import codecs


def main():
    with codecs.open("sherlock.txt", "r") as input_file:
        task_data = input_file.read()
        task_data.replace("\n\n", "\n")
    with codecs.open("sherlock.txt", "r") as input_file:
        original_data = input_file.read()
        original_data = original_data.lower()
        original_data.replace("\n\n", "\n")
    result = "".join([task_data[i] for i in range(len(task_data)) if task_data[i] != original_data[i]])
    print(result)


main()

To dało nam długi string ZEROONEZERO.... Po zmianie tego na liczbę a następnie zinterpretowaniu jako tekst:

from crypto_commons.generic import long_to_bytes

    result = result.replace("ZERO", "0")
    result = result.replace("ONE", "1")
    print(long_to_bytes(int(result, 2)))

Dostaliśmy BITSCTF{h1d3_1n_pl41n_5173}