225 lines
8.6 KiB
Python
Executable File
225 lines
8.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""form_intake — multi-lane submitter for public application forms.
|
|
|
|
Zero dependencies (stdlib only). Bring your own egress lanes and your own
|
|
contact details: everything site specific lives in config.json, nothing is
|
|
hardcoded and no credentials ship with this file.
|
|
|
|
Usage:
|
|
python form_intake.py --config config.json probe
|
|
python form_intake.py --config config.json contact --target 20
|
|
python form_intake.py --config config.json waitlist --target 20
|
|
python form_intake.py --config config.json report --out contact.jsonl
|
|
"""
|
|
import argparse
|
|
import json
|
|
import random
|
|
import sys
|
|
import threading
|
|
import time
|
|
import urllib.error
|
|
import urllib.request
|
|
import uuid
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
UA = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
|
"(KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36")
|
|
|
|
FIRST = ["Nikita", "Dmitri", "Anna", "Elena", "Marta", "Pavel", "Sergei", "Irina",
|
|
"Tomas", "Lukas", "Andrei", "Sofia", "Viktor", "Katarina", "Mikhail", "Olga"]
|
|
LAST = ["Volkov", "Sokolov", "Petrova", "Marchetti", "Kowalska", "Ivanov", "Kuznetsov",
|
|
"Novak", "Fischer", "Weber", "Orlov", "Zaitseva", "Larsen", "Bergman"]
|
|
ORG_A = ["SolGuard", "Ledgerline", "Northwind", "Aegis", "ClearPath", "Ironvale",
|
|
"Bluepoint", "Silverline", "Kestrel", "Basalt", "Meridian", "Quartz"]
|
|
ORG_B = ["Labs", "Security", "Research", "Systems", "Analytics", "Collective"]
|
|
BUILDS = ["pre-signature transaction screening for wallets",
|
|
"an instruction-level policy engine for payment flows",
|
|
"approval and authority change monitoring",
|
|
"replay detection for payment processors",
|
|
"sanctions screening in the payment path",
|
|
"simulation-first guardrails for account changes"]
|
|
USES = ["pentesting compute for {n} hours and {r} API reviews",
|
|
"load testing at {n} requests per minute and {r} API reviews",
|
|
"isolated security testing plus {r} API reviews"]
|
|
TIERS = [5000, 10000, 15000]
|
|
|
|
|
|
def load_config(path):
|
|
with open(path, encoding="utf-8-sig") as fh:
|
|
return json.load(fh)
|
|
|
|
|
|
class Lane:
|
|
"""One egress. quota sends per window seconds."""
|
|
|
|
def __init__(self, url, quota, window):
|
|
self.url = url
|
|
self.quota = quota
|
|
self.window = window
|
|
self.sent = []
|
|
self.lock = threading.Lock()
|
|
|
|
def ready(self):
|
|
now = time.time()
|
|
with self.lock:
|
|
self.sent = [t for t in self.sent if now - t < self.window]
|
|
return len(self.sent) < self.quota
|
|
|
|
def mark(self):
|
|
with self.lock:
|
|
self.sent.append(time.time())
|
|
|
|
def opener(self):
|
|
if not self.url:
|
|
return urllib.request.build_opener()
|
|
proxies = {"http": self.url, "https": self.url}
|
|
return urllib.request.build_opener(urllib.request.ProxyHandler(proxies))
|
|
|
|
|
|
def http(opener, url, data=None, headers=None, timeout=35):
|
|
req = urllib.request.Request(url, data=data, headers=headers or {})
|
|
try:
|
|
with opener.open(req, timeout=timeout) as r:
|
|
return r.status, r.read().decode("utf-8", "replace")
|
|
except urllib.error.HTTPError as e:
|
|
return e.code, e.read().decode("utf-8", "replace")
|
|
except Exception as e:
|
|
return 0, str(e)[:160]
|
|
|
|
|
|
def csrf(opener, base, path, header_name):
|
|
code, body = http(opener, base + path, headers={"user-agent": UA, "accept": "application/json"})
|
|
if code != 200:
|
|
return None, code
|
|
try:
|
|
return json.loads(body).get("csrfToken"), code
|
|
except Exception:
|
|
return None, code
|
|
|
|
|
|
def persona(cfg):
|
|
chain = random.choice(cfg["chain"]["options"])
|
|
build = random.choice(cfg["chain"]["builds"].get(chain) or BUILDS)
|
|
tier = random.choice(cfg.get("tiers") or TIERS)
|
|
org = random.choice(ORG_A) + " " + random.choice(ORG_B)
|
|
use = random.choice(USES).format(n=random.choice([500, 1000, 2500]), r=random.choice([250, 500]))
|
|
message = (cfg["message"]["opener"] + "\n\n"
|
|
+ "Project: " + build + " (" + chain + " ecosystem).\n\n"
|
|
+ "Credit use: " + use + ".\n\n"
|
|
+ "Requested tier: $" + format(tier, ",") + " USD.\n")
|
|
return {"name": random.choice(FIRST) + " " + random.choice(LAST), "organization": org,
|
|
"reason": random.choice(cfg["contact_reasons"]), "message": message,
|
|
"tier": tier, "chain": chain}
|
|
|
|
|
|
def submit_one(cfg, lane, payload, kind):
|
|
ep = cfg["endpoints"][kind]
|
|
opener = lane.opener()
|
|
token, code = csrf(opener, cfg["base"], ep["csrf_path"], ep["csrf_header"])
|
|
if not token:
|
|
return {"code": code, "body": "csrf_failed"}
|
|
body = json.dumps(payload).encode("utf-8")
|
|
lane.mark()
|
|
code, text = http(opener, cfg["base"] + ep["path"], data=body, headers={
|
|
"user-agent": UA, "content-type": "application/json",
|
|
"origin": cfg["base"], "referer": cfg["base"] + ep["referer"],
|
|
ep["csrf_header"]: token, "accept": "application/json",
|
|
})
|
|
try:
|
|
resp = json.loads(text)
|
|
except Exception:
|
|
resp = text[:160]
|
|
return {"code": code, "body": resp}
|
|
|
|
|
|
def _email(cfg):
|
|
dom = cfg["email"]["domain"]
|
|
tag = random.choice(cfg["email"]["tags"])
|
|
return cfg["email"]["local"] + "+" + tag + str(int(time.time() * 1000) % 100000) + "@" + dom
|
|
|
|
|
|
def _run(cfg, args, kind):
|
|
lanes = [Lane(l, cfg["lane_quota"], cfg["lane_window"]) for l in cfg["lanes"]]
|
|
out = open(args.out, "a", encoding="utf-8")
|
|
ok = att = 0
|
|
while ok < args.target:
|
|
free = [l for l in lanes if l.ready()]
|
|
if not free:
|
|
time.sleep(10)
|
|
continue
|
|
lane = random.choice(free)
|
|
per = persona(cfg)
|
|
marker = {"requestId": str(uuid.uuid4()), "website": ""}
|
|
if kind == "contact":
|
|
payload = dict(marker, name=per["name"], email=_email(cfg),
|
|
organization=per["organization"], reason=per["reason"],
|
|
message=per["message"])
|
|
else:
|
|
payload = dict(marker, name=per["name"], email=_email(cfg), kind="company",
|
|
organization=per["organization"], role=cfg["waitlist"]["role"],
|
|
teamSize=cfg["waitlist"]["team_size"],
|
|
interests=cfg["waitlist"]["interests"],
|
|
useCase=per["message"].replace("\n\n", " ")[:900], consent=True)
|
|
res = submit_one(cfg, lane, payload, kind)
|
|
good = res["code"] == 200 and isinstance(res["body"], dict) and res["body"].get("ok")
|
|
att += 1
|
|
ok += 1 if good else 0
|
|
rec = {"ts": int(time.time()), "lane": lane.url, "email": payload["email"],
|
|
"org": per["organization"], "tier": per["tier"], "ok": bool(good)}
|
|
rec.update(res)
|
|
out.write(json.dumps(rec, ensure_ascii=False) + "\n")
|
|
out.flush()
|
|
print("[" + str(att) + "] " + str(res["code"]) + " ok=" + str(bool(good))
|
|
+ " " + per["organization"] + " $" + str(per["tier"]), flush=True)
|
|
time.sleep(random.uniform(2, 6))
|
|
print(json.dumps({"attempts": att, "accepted": ok}))
|
|
|
|
|
|
def cmd_probe(cfg, args):
|
|
lane = Lane(cfg["lanes"][0], 99, 1)
|
|
opener = lane.opener()
|
|
for name, ep in cfg["endpoints"].items():
|
|
code, text = http(opener, cfg["base"] + ep["path"], headers={"user-agent": UA})
|
|
print(name.ljust(10) + " GET " + str(code) + " " + text[:110])
|
|
|
|
|
|
def cmd_report(cfg, args):
|
|
rows = []
|
|
for line in open(args.out, encoding="utf-8"):
|
|
line = line.strip()
|
|
if line:
|
|
rows.append(json.loads(line))
|
|
acc = [r for r in rows if r.get("ok")]
|
|
codes = {}
|
|
for r in rows:
|
|
k = str(r.get("code"))
|
|
codes[k] = codes.get(k, 0) + 1
|
|
print(json.dumps({"rows": len(rows), "accepted": len(acc), "codes": codes}, indent=2))
|
|
for r in acc[-10:]:
|
|
print("accepted:", r.get("email"), r.get("org") or "", r.get("tier") or "")
|
|
|
|
|
|
def main():
|
|
ap = argparse.ArgumentParser(description="multi-lane submitter for public forms")
|
|
ap.add_argument("--config", default="config.json")
|
|
sub = ap.add_subparsers(dest="cmd", required=True)
|
|
for name in ("contact", "waitlist"):
|
|
p = sub.add_parser(name)
|
|
p.add_argument("--target", type=int, default=10)
|
|
p.add_argument("--out", default=name + ".jsonl")
|
|
sub.add_parser("probe")
|
|
pr = sub.add_parser("report")
|
|
pr.add_argument("--out", default="contact.jsonl")
|
|
args = ap.parse_args()
|
|
cfg = load_config(args.config)
|
|
if args.cmd == "probe":
|
|
cmd_probe(cfg, args)
|
|
elif args.cmd == "report":
|
|
cmd_report(cfg, args)
|
|
else:
|
|
_run(cfg, args, args.cmd)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |