Certainly! Here's an example of a Python script for a simple cybersecurity Capture the Flag (CTF) challenge:
python
import hashlib
import base64
def main():
print("Welcome to the Cybersecurity CTF Challenge!")
print("Your mission is to decode the encoded flag and find the hidden message.")
encoded_flag = "WW91IGRpZCBpdCEgVGhlIGZsYWcgaXM6IEN0RntjMGQzX2QzYzBkMW5nX2NoNGxsMW5nM30="
while True:
user_input = input("Enter the decoded flag: ")
if user_input == "exit":
print("Exiting the challenge. Goodbye!")
break
decoded_flag = base64.b64decode(encoded_flag).decode('utf-8')
if user_input == decoded_flag:
print("Congratulations! You have successfully decoded the flag.")
print("The hidden message is:", decoded_flag)
break
else:
print("Oops! The decoded flag is incorrect. Try again.")
print("Thank you for participating in the Cybersecurity CTF Challenge!")
if __name__ == '__main__':
main()
In this example, the script presents a simple CTF challenge where the participant needs to decode an encoded flag to find the hidden message. Here's how the script works:
The script starts by printing a welcome message and instructions for the challenge.
The encoded flag is stored in the encoded_flag variable. In this case, the flag is encoded using Base64 encoding.
The script enters a loop where it prompts the user to enter the decoded flag.
If the user enters "exit", the script terminates and prints a goodbye message.
The script decodes the encoded_flag using Base64 decoding and stores it in the decoded_flag variable.
If the user's input matches the decoded_flag, the script congratulates the user for successfully decoding the flag and reveals the hidden message.
If the user's input does not match the decoded_flag, the script informs the user that the decoded flag is incorrect and prompts them to try again.
The loop continues until the user either enters the correct decoded flag or chooses to exit the challenge.
Finally, the script thanks the participant for participating in the challenge.
In this example, the hidden message is "You did it! The flag is: CtF{c0d3_d3c0d1ng_ch4ll1ng3}", which is encoded using Base64. The participant needs to decode the encoded flag to reveal the hidden message and complete the challenge.
Feel free to modify and expand upon this example to create more complex and challenging CTF tasks based on your specific requirements.