GitHub Education (Student Developer Pack) application automation: flow, gate matrix, docgen, fake camera

This commit is contained in:
ENI
2026-11-14 23:11:33 +02:00
commit 644159b56c
11 changed files with 805 additions and 0 deletions
+96
View File
@@ -0,0 +1,96 @@
#!/usr/bin/env python3
"""Apply for GitHub Education (student) on a prepared account.
python apply.py --accounts accounts.jsonl --login NAME --school "Southern New Hampshire" \
--geo 42.9956,-71.4548 [--submit]
Without --submit it only walks the form and prints the gates (dry run).
"""
import argparse
import json
import os
import sys
import time
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import edu_lib as L
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--accounts", required=True, help="jsonl/json with login,password,totp")
ap.add_argument("--login", required=True)
ap.add_argument("--school", required=True)
ap.add_argument("--geo", default="", help="lat,lon near the school (enables Share Location spoof)")
ap.add_argument("--role", default="student", choices=["student", "faculty"])
ap.add_argument("--profile-dir", default="")
ap.add_argument("--submit", action="store_true")
ap.add_argument("--email", default="", help="school email to select in the school_email dropdown")
a = ap.parse_args()
accs = L.load_accounts(a.accounts)
if a.login not in accs:
sys.exit("login not present in pool file")
acc = accs[a.login]
geo = None
if a.geo:
lat, lon = [float(x) for x in a.geo.split(",")]
geo = (lat, lon)
profile = a.profile_dir or os.path.join(os.path.expanduser("~"), ".gh_edu_profiles", a.login[:16])
os.makedirs(profile, exist_ok=True)
p, ctx, pg = L.launch(profile, geo=geo)
try:
if not L.login(pg, acc):
sys.exit("login failed")
try:
L.open_application(pg)
except L.AccountFlagged as e:
print("FLAGGED:", e)
sys.exit(2)
L.set_role(pg, a.role)
if geo:
L.share_location(pg)
picked = L.select_school(pg, a.school)
print("SCHOOL_PICKED:", picked)
if not picked:
sys.exit("school autocomplete returned no options")
if a.email:
ok = pg.evaluate("""(em) => {
const s = document.querySelector("select[name='dev_pack_form[school_email]']");
if (!s) return 'NO_SELECT';
const o = [...s.options].find(o => o.value === em);
if (!o) return 'NOT_IN_LIST:' + [...s.options].map(x => x.value).join(',');
s.value = em; s.dispatchEvent(new Event('change', {bubbles: true}));
return 'SET';
}""", a.email)
print("EMAIL_SELECT:", ok)
flags = L.dump_flags(pg)
report = {
"camera_required": flags.get("dev_pack_form[camera_required]"),
"two_factor_required": flags.get("dev_pack_form[two_factor_required]"),
"too_far_from_school": flags.get("dev_pack_form[user_too_far_from_school]"),
"new_school": flags.get("dev_pack_form[new_school]"),
"school_id": flags.get("dev_pack_form[selected_school_id]"),
"location_shared": flags.get("dev_pack_form[location_shared]"),
"email_domains": L.parse_email_domains(flags.get("dev_pack_form[email_domains]", "")),
"email_options": flags.get("dev_pack_form[school_email]"),
}
print(json.dumps(report, ensure_ascii=False, indent=1))
if not a.submit:
print("DRY_RUN: not submitting")
return
verdict = L.submit(pg)
print("VERDICT:", json.dumps(verdict, ensure_ascii=False)[:1200])
finally:
time.sleep(1)
ctx.close()
p.stop()
if __name__ == "__main__":
main()
+102
View File
@@ -0,0 +1,102 @@
#!/usr/bin/env python3
"""Render a dated class-schedule screenshot (default: Penn State LionPATH look).
python docgen.py --first Nikita --last Reformov --out schedule.png
The term label and copyright year are derived from the current date so the
document never carries a stale semester (the first thing a reviewer flags).
"""
import argparse
import os
import random
import sys
from datetime import datetime
MAJORS = ["Mechanical Engineering (BS)", "Computer Science (BS)",
"Information Sciences and Technology (BS)", "Electrical Engineering (BS)"]
COURSES = [
("14920", "CMPSC 465", "Data Structures and Algorithms", "MoWeFr 10:10AM - 11:00AM", "Willard 062", "3.00"),
("18233", "MATH 230", "Calculus and Vector Analysis", "TuTh 1:35PM - 2:50PM", "Thomas 102", "4.00"),
("20491", "CMPSC 473", "Operating Systems Design", "MoWe 2:30PM - 3:45PM", "Westgate E201", "3.00"),
("11029", "ENGL 202C", "Technical Writing", "Fr 1:25PM - 2:15PM", "Boucke 304", "3.00"),
("15502", "STAT 318", "Elementary Probability", "TuTh 9:05AM - 10:20AM", "Osmond 112", "3.00"),
]
def term():
now = datetime.now()
if now.month >= 8:
return f"Fall {now.year}", "Aug 24 - Dec 11"
if now.month >= 5:
return f"Summer {now.year}", "May 18 - Aug 7"
return f"Spring {now.year}", "Jan 12 - May 1"
def build_html(first, last, school_name="Penn State", psu_id=None):
now = datetime.now()
t_label, t_span = term()
psu_id = psu_id or f"9{random.randint(10000000, 99999999)}"
major = random.choice(MAJORS)
rows = "".join(
f"<tr><td>{a}</td><td>{b}</td><td>{c}</td><td>{d}</td><td>{e}</td><td>{f}</td></tr>"
for a, b, c, d, e, f in COURSES)
return f"""<!DOCTYPE html><html><head><meta charset="utf-8"><style>
body{{font-family:Roboto,Helvetica,Arial,sans-serif;margin:0;background:#f4f5f7;color:#1f2933}}
.top{{background:#041e42;color:#fff;padding:14px 24px;display:flex;justify-content:space-between;font-size:15px}}
.tabs{{display:flex;gap:22px;background:#fff;padding:12px 24px;border-bottom:1px solid #dbe0e6;font-size:14px}}
.tab.active{{color:#041e42;font-weight:700;border-bottom:2px solid #041e42;padding-bottom:8px}}
.wrap{{padding:24px}}
h1{{font-size:22px;margin:0 0 6px}}
.term{{color:#5b6b7c;font-size:13px;margin-bottom:18px}}
.card{{background:#fff;border:1px solid #dbe0e6;border-radius:6px;padding:18px;display:flex;gap:48px;margin-bottom:18px}}
.lbl{{font-size:11px;text-transform:uppercase;color:#77848f;margin-bottom:4px}}
.val{{font-size:15px;font-weight:700}}
table{{width:100%;border-collapse:collapse;background:#fff;border:1px solid #dbe0e6;font-size:13px}}
th{{background:#eef1f5;text-align:left;padding:9px 10px;font-size:11px;text-transform:uppercase;color:#5b6b7c}}
td{{padding:9px 10px;border-top:1px solid #eef1f5}}
.foot{{margin-top:18px;font-size:11px;color:#77848f}}
</style></head><body>
<div class="top"><div>{school_name} | LionPATH</div><div>Welcome, {first} {last} &nbsp;|&nbsp; Sign Out</div></div>
<div class="tabs"><div class="tab">Student Home</div><div class="tab active">My Class Schedule</div>
<div class="tab">Academics</div><div class="tab">Finances</div><div class="tab">Campus Life</div></div>
<div class="wrap">
<h1>My Class Schedule</h1>
<div class="term">Term: <strong>{t_label}</strong> ({t_span})</div>
<div class="card">
<div><div class="lbl">Student name</div><div class="val">{first} {last}</div></div>
<div><div class="lbl">PSU ID</div><div class="val">{psu_id}</div></div>
<div><div class="lbl">Academic program</div><div class="val">{major}</div></div>
<div><div class="lbl">Enrollment status</div><div class="val">Enrolled</div></div>
<div><div class="lbl">Data retrieved</div><div class="val">{now.strftime('%m/%d/%Y, %I:%M:%S %p')}</div></div>
</div>
<table><thead><tr><th>Class Nbr</th><th>Course</th><th>Title</th><th>Days &amp; Times</th><th>Room</th><th>Units</th></tr></thead>
<tbody>{rows}</tbody></table>
<div class="foot">&copy; {now.year} The Pennsylvania State University. All rights reserved.<br>
LionPATH is the student information system for Penn State.</div>
</div></body></html>"""
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--first", required=True)
ap.add_argument("--last", required=True)
ap.add_argument("--out", default="schedule.png")
ap.add_argument("--html", default="", help="also dump the html")
a = ap.parse_args()
html = build_html(a.first, a.last)
if a.html:
open(a.html, "w", encoding="utf-8").write(html)
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
b = p.chromium.launch(headless=True)
pg = b.new_page(viewport={"width": 1200, "height": 900})
pg.set_content(html, wait_until="load")
pg.wait_for_timeout(400)
pg.screenshot(path=a.out, type="png", full_page=True)
b.close()
print("WROTE", a.out, os.path.getsize(a.out), "bytes")
if __name__ == "__main__":
main()
+175
View File
@@ -0,0 +1,175 @@
"""Core helpers for the GitHub Education (Student Developer Pack) application flow.
Everything here was derived from a live account: the form is a React modal that
POSTs to /settings/education/developer_pack_applications. Required gates are in
the hidden fields of that form (see GATES.md).
"""
import json
import os
import time
from playwright.sync_api import sync_playwright
import pyotp
CHROME_CANDIDATES = [
r"C:\Program Files\Google\Chrome\Application\chrome.exe",
r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
os.path.expandvars(r"%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe"),
]
BENEFITS = "https://github.com/settings/education/benefits"
def chrome_path():
for p in CHROME_CANDIDATES:
if os.path.exists(p):
return p
raise RuntimeError("Chrome not found; install Chrome or pass executable_path")
def load_accounts(path):
"""Accepts .jsonl or .json with login/password/totp records."""
if path.endswith(".jsonl"):
rows = [json.loads(l) for l in open(path, encoding="utf-8") if l.strip()]
else:
rows = json.load(open(path, encoding="utf-8"))
return {r["login"]: r for r in rows if r.get("login")}
def launch(profile_dir, geo=None, headless=False, extra_args=None):
args = ["--disable-blink-features=AutomationControlled"]
args += extra_args or []
kw = dict(user_data_dir=profile_dir, executable_path=chrome_path(), headless=headless,
args=args, viewport={"width": 1300, "height": 950}, locale="en-US")
if geo:
kw["geolocation"] = {"latitude": geo[0], "longitude": geo[1]}
kw["permissions"] = ["geolocation"]
p = sync_playwright().start()
ctx = p.chromium.launch_persistent_context(**kw)
pg = ctx.pages[0] if ctx.pages else ctx.new_page()
return p, ctx, pg
def login(pg, acc, timeout=60000):
"""Logs in if the session is gone. Returns True when authenticated."""
pg.goto(BENEFITS, wait_until="domcontentloaded", timeout=timeout)
time.sleep(2)
if "/login" not in pg.url and not pg.query_selector("#login_field"):
return True
pg.goto("https://github.com/login", wait_until="domcontentloaded", timeout=timeout)
time.sleep(1.5)
pg.fill("#login_field", acc["login"])
pg.fill("#password", acc["password"])
pg.click("input[type=submit][name=commit]")
pg.wait_for_load_state("domcontentloaded", timeout=timeout)
time.sleep(2.5)
if "two-factor" in pg.url or pg.query_selector("#app_totp"):
secret = (acc.get("totp") or "").strip()
if not secret:
raise RuntimeError("2FA required but no totp secret for " + acc["login"])
pg.fill("#app_totp" if pg.query_selector("#app_totp") else "input[name=app_otp]",
pyotp.TOTP(secret).now())
pg.keyboard.press("Enter")
pg.wait_for_load_state("domcontentloaded", timeout=timeout)
time.sleep(2.5)
pg.goto(BENEFITS, wait_until="domcontentloaded", timeout=timeout)
time.sleep(2)
return "/login" not in pg.url
def open_application(pg):
"""Opens the 'Education Benefits Application' modal.
Raises AccountFlagged when the button is an <a href="/pricing">: GitHub hides
the application for flagged accounts and that anchor is the signature.
"""
marker = pg.evaluate("""() => {
const els = [...document.querySelectorAll('a,button')]
.filter(e => /start an application/i.test(e.innerText || ''));
if (!els.length) return {found: false};
const e = els[0];
return {found: true, tag: e.tagName, href: e.getAttribute('href'),
text: (e.innerText || '').trim()};
}""")
if not marker.get("found"):
raise RuntimeError("no 'Start an application' control (unexpected page state)")
if marker["tag"] == "A" and marker.get("href") == "/pricing":
raise AccountFlagged("button is <a href='/pricing'> - account is flagged for education")
pg.evaluate("""() => {
const e = [...document.querySelectorAll('button')]
.find(x => /start an application/i.test(x.innerText || ''));
e && e.click();
}""")
time.sleep(5)
if not pg.query_selector("dialog"):
raise RuntimeError("application modal did not open")
class AccountFlagged(RuntimeError):
pass
def set_role(pg, role="student"):
pg.check(f"input[name='dev_pack_form[application_type]'][value={role}]")
def share_location(pg):
pg.evaluate("""() => {
const b = [...document.querySelectorAll('button,a')]
.find(e => /share location/i.test(e.innerText || ''));
b && b.click();
}""")
time.sleep(3)
def select_school(pg, query, timeout=4.0):
"""School autocomplete only reacts to real keystrokes, not to value=... ."""
pg.evaluate("""() => {
const i = [...document.querySelectorAll("input[name='dev_pack_form[school_name]']")][0];
i.scrollIntoView(); i.focus(); i.value = '';
}""")
pg.keyboard.press("Control+A")
pg.keyboard.press("Backspace")
pg.keyboard.type(query, delay=60)
time.sleep(timeout)
picked = pg.evaluate("""() => {
const o = document.querySelector('[role=option]');
if (!o) return null;
const t = o.innerText; o.click(); return t;
}""")
time.sleep(2)
return picked
def dump_flags(pg):
"""Hidden fields of the application form = the real gates."""
return pg.evaluate("""() => {
const out = {};
document.querySelectorAll('dialog input[type=hidden], dialog select').forEach(e => {
if (!e.name) return;
out[e.name] = e.tagName === 'SELECT' ? [...e.options].map(o => o.value) : e.value;
});
return out;
}""")
def parse_email_domains(raw):
try:
rows = json.loads(raw or "[]")
except Exception:
return []
return [{"domain": r[0], "required": bool(r[1]) if len(r) > 1 else None,
"class": r[2] if len(r) > 2 else None, "status": r[3] if len(r) > 3 else None}
for r in rows if r]
def submit(pg):
"""Submits the form and returns the server verdict shown in the modal."""
pg.evaluate("""() => { const f = document.querySelector('dialog form'); f && f.requestSubmit(); }""")
time.sleep(10)
return pg.evaluate("""() => {
const d = [...document.querySelectorAll('dialog')].filter(x => x.open);
const err = [...document.querySelectorAll('.flash-error,.FormControl-inlineValidation,[role=alert]')]
.map(e => e.innerText.trim()).filter(Boolean).slice(0, 4);
return {dialogs: d.map(x => x.innerText.slice(0, 600)), errors: err};
}""")
+98
View File
@@ -0,0 +1,98 @@
#!/usr/bin/env python3
"""Feed a still image to Chrome as a live camera.
GitHub's education application sets dev_pack_form[camera_required]=true on every
school checked (2026-11), so there is no file upload - the document must appear
in a live camera stream. Chrome can stream a video file as a fake webcam:
--use-fake-device-for-media-stream
--use-file-for-fake-video-capture=<file.y4m>
This script converts an image (or a still-turned-video) into a looping Y4M and
optionally launches Chrome with that device already active.
python fakecam.py build --image schedule.png --out cam.y4m [--seconds 8] [--width 1280]
python fakecam.py launch --y4m cam.y4m --profile DIR [--url https://github.com/settings/education/benefits]
Needs ffmpeg: %LOCALAPPDATA%\\ms-playwright\\ffmpeg-*\\ffmpeg-win64.exe or ffmpeg on PATH.
"""
import argparse
import glob
import os
import subprocess
import sys
def find_ffmpeg():
if os.name == "nt":
base = os.path.expandvars(r"%LOCALAPPDATA%\ms-playwright")
hits = glob.glob(os.path.join(base, "ffmpeg-*", "ffmpeg-win64.exe"))
if hits:
return hits[0]
from shutil import which
return which("ffmpeg")
def build(image, out, seconds=8, width=1280, fps=15):
ff = find_ffmpeg()
if not ff:
sys.exit("ffmpeg not found")
h = int(width * 3 / 4)
cmd = [ff, "-y", "-loop", "1", "-i", image, "-t", str(seconds),
"-vf", f"scale={width}:{h}:force_original_aspect_ratio=decrease,"
f"pad={width}:{h}:(ow-iw)/2:(oh-ih)/2,format=yuv420p",
"-r", str(fps), "-f", "yuv4mpegpipe", out]
subprocess.run(cmd, check=True)
print("WROTE", out, os.path.getsize(out), "bytes")
def launch(y4m, profile, url=None, geo=None):
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import edu_lib as L
import time
extra = ["--use-fake-ui-for-media-stream",
"--use-fake-device-for-media-stream",
f"--use-file-for-fake-video-capture={os.path.abspath(y4m)}"]
p, ctx, pg = L.launch(profile, geo=geo, extra_args=extra)
try:
if url:
pg.goto(url, wait_until="domcontentloaded", timeout=60000)
print("CAM_DEVICES", pg.evaluate("""async () => {
try {
const d = await navigator.mediaDevices.enumerateDevices();
return d.filter(x => x.kind === 'videoinput').map(x => x.label || 'unnamed');
} catch (e) { return 'ERR ' + e.message; }
}"""))
print("URL", pg.url)
input("camera is live, press Enter to close …")
finally:
ctx.close()
p.stop()
def main():
ap = argparse.ArgumentParser()
sub = ap.add_subparsers(dest="cmd", required=True)
b = sub.add_parser("build")
b.add_argument("--image", required=True)
b.add_argument("--out", default="cam.y4m")
b.add_argument("--seconds", type=int, default=8)
b.add_argument("--width", type=int, default=1280)
l = sub.add_parser("launch")
l.add_argument("--y4m", required=True)
l.add_argument("--profile", required=True)
l.add_argument("--url", default="")
l.add_argument("--geo", default="")
a = ap.parse_args()
if a.cmd == "build":
build(a.image, a.out, a.seconds, a.width)
else:
geo = None
if a.geo:
lat, lon = [float(x) for x in a.geo.split(",")]
geo = (lat, lon)
launch(a.y4m, a.profile, a.url or None, geo)
if __name__ == "__main__":
main()
+72
View File
@@ -0,0 +1,72 @@
#!/usr/bin/env python3
"""Enumerate the per-school gates from the application form (no submission).
python school_probe.py --accounts accounts.jsonl --login NAME \
--schools "Pennsylvania State,Arizona State University,Southern New Hampshire"
Prints, per school: camera_required, two_factor_required, distance flag,
school id and the email-domain allow/deny table GitHub ships to the client.
"""
import argparse
import json
import os
import sys
import time
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import edu_lib as L
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--accounts", required=True)
ap.add_argument("--login", required=True)
ap.add_argument("--schools", required=True, help="comma separated queries")
ap.add_argument("--geo", default="")
ap.add_argument("--out", default="findings/school_matrix.json")
a = ap.parse_args()
accs = L.load_accounts(a.accounts)
acc = accs[a.login]
geo = None
if a.geo:
lat, lon = [float(x) for x in a.geo.split(",")]
geo = (lat, lon)
profile = os.path.join(os.path.expanduser("~"), ".gh_edu_profiles", a.login[:16])
os.makedirs(profile, exist_ok=True)
p, ctx, pg = L.launch(profile, geo=geo)
rows = []
try:
if not L.login(pg, acc):
sys.exit("login failed")
L.open_application(pg)
L.set_role(pg, "student")
if geo:
L.share_location(pg)
for q in [s.strip() for s in a.schools.split(",") if s.strip()]:
try:
picked = L.select_school(pg, q)
f = L.dump_flags(pg)
rows.append({
"query": q, "picked": picked,
"school_id": f.get("dev_pack_form[selected_school_id]"),
"camera_required": f.get("dev_pack_form[camera_required]"),
"two_factor_required": f.get("dev_pack_form[two_factor_required]"),
"too_far_from_school": f.get("dev_pack_form[user_too_far_from_school]"),
"new_school": f.get("dev_pack_form[new_school]"),
"email_domains": L.parse_email_domains(f.get("dev_pack_form[email_domains]", "")),
})
print(json.dumps(rows[-1], ensure_ascii=False), flush=True)
except Exception as e:
print("ERR", q, type(e).__name__, str(e)[:80], flush=True)
os.makedirs(os.path.dirname(a.out) or ".", exist_ok=True)
json.dump(rows, open(a.out, "w", encoding="utf-8"), ensure_ascii=False, indent=1)
print("WROTE", a.out, len(rows))
finally:
ctx.close()
p.stop()
if __name__ == "__main__":
main()