I've been battling with one school task for couple days and can't seem to find any idea how to solve it. The task is pretty simple:
Log in to the server using SSH. The answer to the task is in encrypted network traffic, which you have the ability to eavesdrop on, which a running web application can help with. HINT: HTTPS private key has been forgotten in Git
So I log in. Only tool I have sudo privileges is tcpdump
. Quick use of ps aux
returns the application which is in my interest.
/usr/bin/python3 /usr/local/bin/flask run --cert=/root/archive//cert.pem --key=/root//key.pem --host=0.0.0.0 --port=443
I do not have access to the root folder. Quick grab of network traffic with tcpdump
allows me to save it to .pcap
file. I check it with Wireshark and everything is in order, I see which message contains the answer—but obviously it's encrypted. So I try to open the app with my browser:
https://school_server_address:443
And it's an Apache server with two files and couple generic Git folders.
One file is cert.pem, which seems to be the public key, since it starts with
-----BEGIN CERTIFICATE-----
. So there is no use for me from it, since I can't use it to decrypt the network traffic in Wireshark.The second file is a Python app which I don't quite understand. Here is the code:
import os from flask import Flask, request from flask_autoindex import AutoIndex ppath = os.path.dirname(os.path.realpath(__file__)) app = Flask(__name__) AutoIndex(app, browse_root=ppath, show_hidden=True) @app.route("/secret", methods=["POST"]) def hello(): # fetch password and compare with open("../password.txt", "r") as pfh, \ open("../secret.txt", "r") as sfh: password = pfh.read().strip().split('=')[1] secret = sfh.read() if password == request.form.get('password', None): return secret return "Wrong password" return "Internal error" if __name__ == "__main__": app.run()
I've tried opening the address in my browser:
https://server_address:443/secret
It just returns 404.
I know the information may not be easy to digest, since I'm trying to explain a task on a system only I can see, but do any of you have any idea how should I proceed with looking for the private HTTPS key? Are there more ideas I could deduce from the task description that I lack experience to do so? Thank you for any clues!