misc/pw_crack_2

This commit is contained in:
Oystein Kristoffer Tveit 2024-09-03 17:13:28 +02:00
parent b29a826c6a
commit 3c4cc86337
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
3 changed files with 33 additions and 0 deletions

Binary file not shown.

29
misc/pw_crack_2/level2.py Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env python3
### THIS FUNCTION WILL NOT HELP YOU FIND THE FLAG --LT ########################
def str_xor(secret, key):
#extend key to secret length
new_key = key
i = 0
while len(new_key) < len(secret):
new_key = new_key + key[i]
i = (i + 1) % len(key)
return "".join([chr(ord(secret_c) ^ ord(new_key_c)) for (secret_c,new_key_c) in zip(secret,new_key)])
###############################################################################
flag_enc = open('level2.flag.txt.enc', 'rb').read()
def level_2_pw_check():
user_pw = input("Please enter correct password for flag: ")
if( user_pw == chr(0x34) + chr(0x65) + chr(0x63) + chr(0x39) ):
print("Welcome back... your flag, user:")
decryption = str_xor(flag_enc.decode(), user_pw)
print(decryption)
return
print("That password is incorrect")
level_2_pw_check()

View File

@ -0,0 +1,4 @@
$ ./level2.py
Please enter correct password for flag: 4ec9
Welcome back... your flag, user:
picoCTF{tr45h_51ng1ng_9701e681}