55 lines
1.6 KiB
Python
Executable file
55 lines
1.6 KiB
Python
Executable file
#!/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"<p>(− )?(\d+)<i>x</i><sup>2</sup> (−)?\+? (\d+)<i>x</i> (−)?\+? (\d+) = 0\.</p>", 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 <hiring@katherina.rocks>"
|
|
message = """\
|
|
From: step-3@jobs.mythic-beasts.com
|
|
To: Katherina Walshe-Grey <hiring@katherina.rocks>
|
|
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)
|