5
$\begingroup$

Greg, our Server Security Admin, was locked up today in his own Server Room. (Yeah, quite crazy I know). The guy had forgotten the password to unlock his door. Fortunately he had saved the password on his laptop. He takes a sigh of relief and sits down on his chair, opens up his laptop and gets into the folder which has 6 files.

Now, he has a bad memory and is unable to recollect how to find the password. He has emailed me those 6 files. Can you help me find the password so that I can help our dear friend get out of the room?

Leaving the files right here for you -

unused_1.txt

f = 10
s = 20
a = 30
d = 40

sum = f + a + d

print(sum)

unused_2.txt

public class Main {
  public static void main(String[] args) {
    
    int m = "hello";
    int a = "how are";
    int y = "you";
    int t = "world";

    String txt = m + a + y;

    System.out.println(txt);
  }
}

unused_3.txt

const e = "Hello, world!";
const a = "Hello, planet!";
const parts = a.split(", ");

console.log(parts);

unused_4.txt

fun main() {
    val a = "Help help!"
    val b = "Dont help!"
    val c = "Please help!"
    val bCount = b.length
    val cCount = c.length

    println("The string '$b' has $bCount characters.")
    println("The string '$c' has $cCount characters.")
}

unused_5.txt

using System;
using System.Net.NetworkInformation;

class Program {
    static void Main(string[] args) {
        string hostName = "www.google.com";
        Ping ping = new Ping();
        PingReply reply = ping.Send(hostName);
        
        if (reply.Status == IPStatus.Success) {
            string l = 0;
            Console.WriteLine("Ping to " + hostName + " was successful. Response time: " + reply.RoundtripTime + "ms.");
        } else {
            Console.WriteLine("Ping to " + hostName + " failed. Status: " + reply.Status);
        }
    }
}

get_password.py

def decrypt(msg: str, password: str) -> str:
    key = generate_key(password)
    decrypted = ""
    for i in range(len(msg)):
        char = msg[i]
        key_c = key[i % len(key)]
        decrypted += chr((ord(char) - ord(key_c) + 256) % 256)
    return decrypted

def generate_key(password: str) -> str:
    key = ""
    for i in range(len(password)):
        key += chr(ord(password[i]) % 256)
    return key

encrypted_message = "ÇÜÊÜ™“ÞÔæ„‚àÞƒÚÕÉá”ÙÉÑ@ŠÖ×”‰ÕŒ“ÓÚÔʼâÌ®¬ƒŽiÕ˜"
key = "enter_the_key_you_found_here" + " & get blocked"

decrypted_message = decrypt(encrypted_message, key)
print("Decrypted message:", decrypted_message)

Update:

So, I called back Greg and told him that the puzzling stack exchange is having hard time interpreting the ASCII codes in his file. Well, he did have a backup for situations like these and have send me another file. I guess this should help us getting him out.

get_password_backup.py

CHARACTER_SET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+-=[]{}|;':\",.<>/?\\ "

def generate_key(password: str) -> str:
    key = ""
    for i in range(len(password)):
        key += CHARACTER_SET[ord(password[i]) % len(CHARACTER_SET)]
    return key

def encrypt(msg: str, password: str) -> str:
    key = generate_key(password)
    encrypted = ""
    for i in range(len(msg)):
        char = msg[i]
        key_c = key[i % len(key)]
        char_index = CHARACTER_SET.index(char)
        key_c_index = CHARACTER_SET.index(key_c)
        encrypted_index = (char_index + key_c_index) % len(CHARACTER_SET)
        encrypted += CHARACTER_SET[encrypted_index]
    return encrypted

def decrypt(msg: str, password: str) -> str:
    key = generate_key(password)
    decrypted = ""
    for i in range(len(msg)):
        char = msg[i]
        key_c = key[i % len(key)]
        char_index = CHARACTER_SET.index(char)
        key_c_index = CHARACTER_SET.index(key_c)
        decrypted_index = (char_index - key_c_index) % len(CHARACTER_SET)
        decrypted += CHARACTER_SET[decrypted_index]
    return decrypted

print (decrypt("^EmdEG4YGwOJoLunCuHLkooZTKjlLUGroGh_J=8jxT(S+kEOCW","enter the key you found here" + " & get locked"))
$\endgroup$

1 Answer 1

6
$\begingroup$

After hearing back from Greg about the unfortunate encoding issues, we now have the solution:

The names of the unused variables in each of the 5 "unused_" files spell out "steal".

Using that as the key in the 6th file and running it in an online Python interpreter reveals that

The password to unlock the door is $n00finGm@chinE

I hope Greg gets to take the rest of Friday off for the trouble!

(for specifics, I have used this one here, but any would work I think:

https://www.programiz.com/python-programming/online-compiler/)

$\endgroup$
3
  • 1
    $\begingroup$ Well, you are almost there. But lol, looks like Stackexchange is bad at handling ASCII as well. I realized it only after posting when it ate up lot of characters from the string while the preview mode was just fine. I have communicated the same to Greg and we have an update :) $\endgroup$
    – Techidiot
    Mar 23, 2023 at 19:16
  • $\begingroup$ @Techidiot yes, after running the latest file with the key the password is revealed :-) $\endgroup$ Mar 24, 2023 at 9:23
  • $\begingroup$ Yay! Greg sends his best regards :) $\endgroup$
    – Techidiot
    Mar 24, 2023 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.