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"))