commit 457187097b9a56993ec42f3556e90cd54ccd34d5 Author: Katherina Walshe-Grey Date: Wed Feb 26 11:21:17 2025 +0000 Commit solution diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..4a4726a --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use_nix diff --git a/mythic-beasts-jobs.py b/mythic-beasts-jobs.py new file mode 100755 index 0000000..f539cb3 --- /dev/null +++ b/mythic-beasts-jobs.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python + +### STEP 2 + +import requests +import re +import math + +url = "http://jobs.mythic-beasts.com/ukaig6ua6yieHo4o" + +r1 = requests.get(url) + +# This is inelegant, but meh, it works and regexes are inherently cursed anyway. Especially regexes for scraping HTML. +# It's not like this is being used for a job application or anything. +vals = re.search(r"

(− )?(\d+)x2 (−)?\+? (\d+)x (−)?\+? (\d+) = 0\.

", r1.text).groups() + +a = int(vals[1]) +if vals[0] != None: + a *= -1 +b = int(vals[3]) +if vals[2] != None: + b *= -1 +c = int(vals[5]) +if vals[4] != None: + c *= -1 + +x0 = (-b + math.sqrt(b**2 - 4*a*c))/(2*a) +x1 = (-b - math.sqrt(b**2 - 4*a*c))/(2*a) +secret = re.search(r'value="([0-9a-z]{64})"/>', r1.text).groups()[0] + +r2 = requests.post(url, data = {'x0': x0, 'x1': x1, 'secret': secret, 'submit': "Submit"}) + +### STEP 3 + +import dns.resolver +import smtplib + +password = re.search(r'password ([0-9a-z]{64})', r2.text).groups()[0] + +rdata = dns.resolver.resolve('_submission._tcp.jobs.mythic-beasts.com', 'SRV')[0] + +from_email = "step-3@jobs.mythic-beasts.com" +to_email = "Katherina Walshe-Grey " +message = """\ +From: step-3@jobs.mythic-beasts.com +To: Katherina Walshe-Grey +Date: whenever Now is. please don't make me script this. +Subject: Hello, me! + +this is a fun little challenge. don't know if anyone is actually reading these, but if so, thank you! greatly enjoying myself!""" + +with smtplib.SMTP(rdata.target, rdata.port) as server: + server.login("step-3@jobs.mythic-beasts.com", password) + server.sendmail(from_email, to_email, message) diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..8b321ec --- /dev/null +++ b/shell.nix @@ -0,0 +1,11 @@ +let + pkgs = import { }; +in +pkgs.mkShell { + packages = with pkgs; [ + (python3.withPackages (subpkgs: with subpkgs; [ + requests + dnspython + ])) + ]; +}