Obedient Cat:

This file has a flag in plain sight (aka “in-the-clear”).

Files given:
https://mercury.picoctf.net/static/2d24d50b4ebed90c704575627f1f57b2/flag
File Name:
flag

Solution:

Windows:
1. Open the folder containing the flag file in windows explorer
2. Right click the file and click “Open with”
3. Select “Notepad” From all the specified options
4. Congratulations!!! You have the flag

Linux:
1. Open a terminal instance
2. Navigate to the folder containing the flag file using cd and ls commands
3. Use the “cat” command in linux to open the flag
4. The exact format of using the cat command is “cat <file_name>”, in this case: “cat flag”
5. Congratulations!!! You have the flag

More resources to check:
https://maker.pro/linux/tutorial/basic-linux-commands-for-beginners

Python Wrangling:

Python scripts are invoked kind of like programs in the Terminal… Can you run this Python script using this password to get the flag?

Files given:
https://mercury.picoctf.net/static/0bf545252b5120845e3b568b9ad0277e/ende.py
https://mercury.picoctf.net/static/0bf545252b5120845e3b568b9ad0277e/pw.txt
https://mercury.picoctf.net/static/0bf545252b5120845e3b568b9ad0277e/flag.txt.en
File Names:
ende.py
pw.txt
flag.txt.en

Solution:

So Open the ende.py file in either python IDLE or Pycharm. I opened it in Python IDLE for now. The contents of the ende.py file are as follows:

import sys
import base64
from cryptography.fernet import Fernet

usage_msg = “Usage: “+ sys.argv[0] +” (-e/-d) [file]“
help_msg = usage_msg + “\n” +\
“Examples:\n” +\
“ To decrypt a file named ‘pole.txt’, do: “ +\
“‘$ python “+ sys.argv[0] +” -d pole.txt’\n“

if len(sys.argv) < 2 or len(sys.argv) > 4:
print(usage_msg)
sys.exit(1)

if sys.argv[1] == “-e”:
if len(sys.argv) < 4:
sim_sala_bim = input(“Please enter the password:”)
else:
sim_sala_bim = sys.argv[3]

ssb_b64 = base64.b64encode(sim_sala_bim.encode())  
c = Fernet(ssb_b64)  

with open(sys.argv[2], "rb") as f:  
    data = f.read()  
    data_c = c.encrypt(data)  
    sys.stdout.write(data_c.decode())  

elif sys.argv[1] == “-d”:
if len(sys.argv) < 4:
sim_sala_bim = input(“Please enter the password:”)
else:
sim_sala_bim = sys.argv[3]

ssb_b64 = base64.b64encode(sim_sala_bim.encode())  
c = Fernet(ssb_b64)  

with open(sys.argv[2], "r") as f:  
    data = f.read()  
    data_c = c.decrypt(data.encode())  
    sys.stdout.buffer.write(data_c)  

elif sys.argv[1] == “-h” or sys.argv[1] == “–help”:
print(help_msg)
sys.exit(1)

else:
print(“Unrecognized first argument: “+ sys.argv[1])
print(“Please use ‘-e’, ‘-d’, or ‘-h’.”)

But to be honest the solution is not so complex. So the next thing you do is have a look at the pw.txt file. The contents of this file are as follows:

6008014f6008014f6008014f6008014f

Just some random characters. Let’s have a look at the flag.txt.en file (Note just rename the file to “flag.txt” because .en in there is just to represent that it contains encrypted text nothing else):

gAAAAABgUAIVI-r3OTKrDSgUJ8i3N9OzjacXZ1w4Hua00I_-Bg7gZu9Fld-TFYRiUiZlkLkChceqqpL9XnGOMO-W2-lRXpFhTkrqk9fHAvDfNkZHuZcjGPpG4xaR4mPnagzSNIrtL9tK

After having a overview of all the files… I think we should do what the challenge instructed. Run the python file (Make sure to run the file with python2 and not python3). Oooops! So we got an “Usage Error”

So basically it tells us that we have to specify either -e or -d option along with a file to successfully run the file. In this use case “-e” means encrypt and “-d” means decrypt and the file parameter is the flag file so the python file tells us that we can either encrypt the flag file or decrypt it and we have to decrypt the flag file we have because it is encrypted. So we have to run the python file with the -d option and specify the flag file so the complete command to run in linux is “python ende.py -d flag.txt.en” or “python ende.py -d flag.txt” if you renamed the file to flag.txt. After doing this you will be asked to enter the password which we already have. After you enter the password, You have the flag!!! Congratulations!!!!

More resources to check:
https://www.python.org/about/gettingstarted/