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
+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()