Created
January 10, 2026 20:42
-
-
Save tomrockdsouza/25663df77606c3fb161796cb8e284e00 to your computer and use it in GitHub Desktop.
this is a library that can take the secret link and passphrase as inputs and return the viewable secret as a raw string from ess.sessionm.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urllib.request | |
| import urllib.parse | |
| import json | |
| import html | |
| class EssRequestFailureError(Exception): | |
| pass | |
| class EssParseFailureError(Exception): | |
| pass | |
| class EssSecretAlreadyViewedError(Exception): | |
| pass | |
| def extract_between(text): | |
| start = text.find("<code>") + 1 | |
| end = text.find("</code>", start) | |
| return text[start+5:end] | |
| def get_secret(passphrase, secret_id): | |
| url = f"https://ess.sessionm.com/secret/{secret_id}" | |
| # Encode form data as application/x-www-form-urlencoded | |
| data = urllib.parse.urlencode({ | |
| "passphrase": passphrase | |
| }).encode("utf-8") | |
| req = urllib.request.Request( | |
| url, | |
| data=data, | |
| headers={"Content-Type": "application/x-www-form-urlencoded"}, | |
| method="POST" | |
| ) | |
| with urllib.request.urlopen(req) as response: | |
| resp_data = response.read().decode("utf-8") | |
| # Try to parse as JSON, otherwise return raw text | |
| try: | |
| return json.loads(resp_data) | |
| except json.JSONDecodeError: | |
| return resp_data | |
| def parse_text(input_text): | |
| try: | |
| url, passphrase, *_=input_text.strip().split("\n") | |
| except ValueError: | |
| raise EssParseFailureError | |
| url=url.strip() | |
| passphrase=passphrase.strip() | |
| if not ( | |
| url.startswith('https://ess.sessionm.com/secret/') | |
| and passphrase.startswith('passphrase: ') | |
| ): | |
| raise EssParseFailureError | |
| return url[32:], passphrase[12:] | |
| def ess_process_text(input_text): | |
| url, passphrase = parse_text(input_text) | |
| try: | |
| html_response = get_secret(passphrase=passphrase,secret_id=url) | |
| except Exception: | |
| raise EssRequestFailureError | |
| x_secret = extract_between(html_response) | |
| if x_secret.__contains__('<h1>Secret has either already been viewed<br />or your passphrase is incorrect.</h1>'): | |
| raise EssSecretAlreadyViewedError | |
| return html.unescape(x_secret) | |
| if __name__=="__main__": | |
| print(ess_process_text("""https://ess.sessionm.com/secret/ABCDEFGHIJKLMNOPQRSTUVWXYZ | |
| passphrase: ABCDEFGHIJKLMNOPQRSTUVWXYZ""")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment