From 3c4cc863377e08ecc57223e00035ace0e559b910 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 3 Sep 2024 17:13:28 +0200 Subject: [PATCH] misc/pw_crack_2 --- misc/pw_crack_2/level2.flag.txt.enc | Bin 0 -> 31 bytes misc/pw_crack_2/level2.py | 29 ++++++++++++++++++++++++++++ misc/pw_crack_2/output.txt | 4 ++++ 3 files changed, 33 insertions(+) create mode 100644 misc/pw_crack_2/level2.flag.txt.enc create mode 100755 misc/pw_crack_2/level2.py create mode 100644 misc/pw_crack_2/output.txt diff --git a/misc/pw_crack_2/level2.flag.txt.enc b/misc/pw_crack_2/level2.flag.txt.enc new file mode 100644 index 0000000000000000000000000000000000000000..4c28d25fc78a872303578effb3504fe08d17af9a GIT binary patch literal 31 mcmZ?aVF)WXRCRI?59f)o3gd`k3JMRlisEAlVdLiskplo}(FREX literal 0 HcmV?d00001 diff --git a/misc/pw_crack_2/level2.py b/misc/pw_crack_2/level2.py new file mode 100755 index 0000000..8b05d8d --- /dev/null +++ b/misc/pw_crack_2/level2.py @@ -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() diff --git a/misc/pw_crack_2/output.txt b/misc/pw_crack_2/output.txt new file mode 100644 index 0000000..a5b80c2 --- /dev/null +++ b/misc/pw_crack_2/output.txt @@ -0,0 +1,4 @@ +$ ./level2.py +Please enter correct password for flag: 4ec9 +Welcome back... your flag, user: +picoCTF{tr45h_51ng1ng_9701e681}