Hack This Site - Basic 6

Tue, Jan 05, 21

Welcome back to my walkthrough of hackthissite.org’s CTF missions. I will be going through my thought process of how I solved these missions, and therefore also giving away the solutions. If you came across this to give you hints, watch out for spoilers! Good luck, have fun.

Similarly to the previous challenges we must discover a password to continue to the following challenge. Our hint is that Sam has encrypted his password but the encryption system is publicly available through this webpage; enter a string and it outputs the encrypted string.

Somehow, like magic, we have been given the encrypted password - being b768j887. What we must do is figure out how the encryption algorithm works. The only way to do this? Well its to start typing random inputs to see what it would output. I begin with the input aaa, which outputs abc. Hmm… This seems like it takes the char index of the string (starting at 0) and just adds said index to the char at that index. To make sure that this is the case, we will try the input aaaaa and I expect the oupt abcde. Indeed, my hypothesis was correct and the output is abcde. Therefore this is a simple shift cipher. We can make a quick python script (this is really not needed since the password is so short and you can do it manually) to decipher the password for us in reverse.

import sys

def decipher(ct):
    pt = ""
    for i in range(0,len(ct)):
        pt += chr(ord(ct[i])-i)
    return pt

if __name__ == "__main__":
    ct = sys.argv[1] # expecting input of text to decipher as an argument
    print(decipher(ct))

Now that we have a decipher algorithm, we can easily decipher the given string and input it into the password form. Voila! We have solved this challenge.