Guest User

Untitled

a guest
Jul 6th, 2026
517
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.41 KB | None | 1 0
  1. import { createRequire } from "node:module";
  2. import { randomUUID, randomBytes } from "node:crypto";
  3.  
  4. try {
  5. const perf = require("node:perf_hooks") as Record<string, unknown>;
  6. const stub = () => ({
  7. count: 0, min: 0, max: 0, mean: 0, stddev: 0, exceeds: 0,
  8. percentiles: new Map<number, number>(),
  9. record() {}, recordDelta() {}, reset() {}, percentile() { return 0; },
  10. });
  11. let broken = false;
  12. try { (perf.createHistogram as () => unknown)?.(); } catch { broken = true; }
  13. if (typeof perf.createHistogram !== "function" || broken) {
  14. perf.createHistogram = () => stub();
  15. }
  16. } catch {}
  17.  
  18. try {
  19. const req = createRequire(import.meta.url);
  20. const mod = req("piscina") as any;
  21. const Piscina: any = mod.Piscina ?? mod.default ?? mod;
  22. const proto = Piscina?.prototype;
  23. if (proto?.run && !proto.__certCompressionPatched) {
  24. const orig = proto.run;
  25. proto.run = function (task: unknown, opts?: { name?: string }) {
  26. if (opts?.name === "request" && typeof task === "string" && task.includes('"certCompressionAlgo":')) {
  27. task = task.replace(/"certCompressionAlgo":"(\w+)"/, '"certCompressionAlgos":["$1"]');
  28. }
  29. return orig.call(this, task, opts);
  30. };
  31. proto.__certCompressionPatched = true;
  32. }
  33. } catch {}
  34.  
  35. import { Session, initTLS, type SessionOptions } from "node-tls-client";
  36. import { NoneCap } from "nonecap";
  37.  
  38. const NONECAP_API_KEY = process.env.NONECAP_API_KEY ?? "YOUR_NONECAP_API_KEY";
  39. const PROXY_URL =
  40. process.env.PROXY_URL ?? "http://user:[email protected]:12321";
  41. const COUNT = Math.max(1, Number(process.env.COUNT ?? 1));
  42. const CONCURRENCY = Math.max(1, Number(process.env.CONCURRENCY ?? COUNT));
  43. const NONECAP_MAX_CONCURRENCY = Math.max(1, Number(process.env.NONECAP_MAX_CONCURRENCY ?? 5));
  44.  
  45. const API = "https://discord.com/api/v9";
  46. const USER_AGENT =
  47. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36";
  48. const CLIENT_LAUNCH_ID = randomUUID();
  49. const LAUNCH_SIGNATURE = randomUUID();
  50.  
  51. const SUPER_PROPERTIES = Buffer.from(JSON.stringify({
  52. os: "Mac OS X",
  53. browser: "Chrome",
  54. device: "",
  55. system_locale: "en-US",
  56. has_client_mods: false,
  57. browser_user_agent: USER_AGENT,
  58. browser_version: "149.0.0.0",
  59. os_version: "10.15.7",
  60. referrer: "",
  61. referring_domain: "",
  62. referrer_current: "",
  63. referring_domain_current: "",
  64. release_channel: "stable",
  65. client_build_number: 573410,
  66. client_event_source: null,
  67. client_launch_id: CLIENT_LAUNCH_ID,
  68. launch_signature: LAUNCH_SIGNATURE,
  69. client_app_state: "focused",
  70. }), "utf8").toString("base64");
  71.  
  72. const CHROME_149_TLS: SessionOptions = {
  73. ja3string:
  74. "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,35-11-13-16-65281-10-45-18-5-17613-27-23-0-65037-51-43,4588-29-23-24,0",
  75. h2Settings: {
  76. HEADER_TABLE_SIZE: 65536,
  77. ENABLE_PUSH: 0 as unknown as boolean,
  78. INITIAL_WINDOW_SIZE: 6291456,
  79. MAX_HEADER_LIST_SIZE: 262144,
  80. },
  81. h2SettingsOrder: ["HEADER_TABLE_SIZE", "ENABLE_PUSH", "INITIAL_WINDOW_SIZE", "MAX_HEADER_LIST_SIZE"],
  82. supportedSignatureAlgorithms: [
  83. "ECDSAWithP256AndSHA256", "PSSWithSHA256", "PKCS1WithSHA256",
  84. "ECDSAWithP384AndSHA384", "PSSWithSHA384", "PSSWithSHA512", "PKCS1WithSHA512",
  85. ],
  86. supportedVersions: ["GREASE", "1.3", "1.2"],
  87. keyShareCurves: ["GREASE", "X25519MLKEM768" as unknown as "X25519", "X25519"],
  88. certCompressionAlgo: "brotli",
  89. pseudoHeaderOrder: [":method", ":authority", ":scheme", ":path"],
  90. alpnProtocols: ["h2", "http/1.1"],
  91. alpsProtocols: ["h2"],
  92. connectionFlow: 15663105,
  93. randomTlsExtensionOrder: false,
  94. };
  95.  
  96. let tlsInit: Promise<void> | undefined;
  97. const ensureTls = () => (tlsInit ??= initTLS());
  98.  
  99. function generateProxySessionId(): string {
  100. return randomBytes(4).toString("hex");
  101. }
  102.  
  103. function stickyProxy(baseUrl: string): string {
  104. try {
  105. const parsed = new URL(baseUrl);
  106. const password = parsed.password ? decodeURIComponent(parsed.password) : "";
  107. if (!password.includes("_session-")) {
  108. parsed.password = encodeURIComponent(
  109. `${password}_session-${generateProxySessionId()}_lifetime-30m`,
  110. );
  111. }
  112. return parsed.toString();
  113. } catch {
  114. return baseUrl;
  115. }
  116. }
  117.  
  118. class Agent {
  119. private readonly session: Session;
  120. private readonly defaults: Record<string, string>;
  121.  
  122. constructor(proxyUrl: string) {
  123. this.session = new Session({ ...CHROME_149_TLS, timeout: 60_000, proxy: proxyUrl });
  124. this.defaults = {
  125. "User-Agent": USER_AGENT,
  126. Accept: "*/*",
  127. "Accept-Language": "en-US",
  128. "Accept-Encoding": "gzip, deflate, br, zstd",
  129. Origin: "https://discord.com",
  130. Referer: "https://discord.com/register",
  131. "X-Discord-Locale": "en-US",
  132. "X-Discord-Timezone": "Europe/Stockholm",
  133. "X-Debug-Options": "bugReporterEnabled",
  134. "X-Super-Properties": SUPER_PROPERTIES,
  135. "sec-ch-ua": '"Not)A;Brand";v="24", "Chromium";v="149", "Google Chrome";v="149"',
  136. "sec-ch-ua-mobile": "?0",
  137. "sec-ch-ua-platform": '"macOS"',
  138. "Sec-Fetch-Dest": "empty",
  139. "Sec-Fetch-Mode": "cors",
  140. "Sec-Fetch-Site": "same-origin",
  141. };
  142. }
  143.  
  144. set(key: string, value: string): void {
  145. this.defaults[key] = value;
  146. }
  147.  
  148. private async request(
  149. method: "GET" | "POST",
  150. url: string,
  151. body?: unknown,
  152. headers?: Record<string, string>,
  153. ): Promise<{ status: number; body: any }> {
  154. await ensureTls();
  155. const merged = { ...this.defaults, ...headers };
  156. const opts: Record<string, unknown> = { headers: merged, followRedirects: false };
  157. if (method === "POST") {
  158. merged["Content-Type"] = "application/json";
  159. opts.body = JSON.stringify(body ?? {});
  160. }
  161. const r = method === "GET"
  162. ? await this.session.get(url, opts)
  163. : await this.session.post(url, opts);
  164. let parsed: any = r.body;
  165. if (typeof r.body === "string" && (r.body[0] === "{" || r.body[0] === "[")) {
  166. try { parsed = JSON.parse(r.body); } catch {}
  167. }
  168. return { status: r.status, body: parsed };
  169. }
  170.  
  171. get(url: string, headers?: Record<string, string>) {
  172. return this.request("GET", url, undefined, headers);
  173. }
  174. post(url: string, body: unknown, headers?: Record<string, string>) {
  175. return this.request("POST", url, body, headers);
  176. }
  177.  
  178. close(): Promise<void> {
  179. return this.session.close().catch(() => {});
  180. }
  181. }
  182.  
  183. class Semaphore {
  184. private active = 0;
  185. private readonly waiters: Array<() => void> = [];
  186. constructor(private readonly max: number) {}
  187.  
  188. async run<T>(fn: () => Promise<T>): Promise<T> {
  189. if (this.active >= this.max) {
  190. await new Promise<void>((resolve) => this.waiters.push(resolve));
  191. } else {
  192. this.active++;
  193. }
  194. try {
  195. return await fn();
  196. } finally {
  197. const next = this.waiters.shift();
  198. if (next) next();
  199. else this.active--;
  200. }
  201. }
  202. }
  203.  
  204. const solveLimiter = new Semaphore(NONECAP_MAX_CONCURRENCY);
  205.  
  206. interface Challenge {
  207. sitekey: string;
  208. sessionId: string;
  209. rqdata: string;
  210. rqtoken: string;
  211. }
  212.  
  213. function challengeFrom(status: number, body: any): Challenge | null {
  214. if (status !== 400 || !body || typeof body !== "object") return null;
  215. const keys = Array.isArray(body.captcha_key) ? body.captcha_key : [];
  216. if (!keys.includes("captcha-required") && !keys.includes("invalid-response")) return null;
  217. if (!body.captcha_sitekey || !body.captcha_session_id || !body.captcha_rqtoken) return null;
  218. return {
  219. sitekey: body.captcha_sitekey,
  220. sessionId: body.captcha_session_id,
  221. rqdata: body.captcha_rqdata,
  222. rqtoken: body.captcha_rqtoken,
  223. };
  224. }
  225.  
  226. async function solveCaptcha(client: NoneCap, proxyUrl: string, chal: Challenge): Promise<string> {
  227. return solveLimiter.run(async () => {
  228. const solve = await client.solve(
  229. {
  230. type: "hcaptcha_enterprise",
  231. sitekey: chal.sitekey,
  232. url: "https://discord.com/verify",
  233. rqdata: chal.rqdata,
  234. user_agent: USER_AGENT,
  235. proxy: proxyUrl,
  236. },
  237. { timeout: 120_000 },
  238. );
  239. if (!solve.token) throw new Error(`nonecap solve ${solve.status}: no token`);
  240. return solve.token;
  241. });
  242. }
  243.  
  244. async function register(
  245. agent: Agent,
  246. client: NoneCap,
  247. proxyUrl: string,
  248. input: { username: string; password: string; email: string; dateOfBirth: string },
  249. ): Promise<string> {
  250. const exp = await agent.get(`${API}/experiments`);
  251. const fingerprint = exp.body?.fingerprint as string | undefined;
  252. if (!fingerprint) throw new Error(`no fingerprint (status ${exp.status})`);
  253. agent.set("X-Fingerprint", fingerprint);
  254.  
  255. const avail = await agent.post(`${API}/unique-username/username-attempt-unauthed`, {
  256. username: input.username,
  257. });
  258. if (avail.body?.taken !== false) throw new Error(`username "${input.username}" is taken`);
  259.  
  260. const body = {
  261. fingerprint,
  262. email: input.email,
  263. username: input.username,
  264. global_name: input.username,
  265. password: input.password,
  266. invite: null,
  267. consent: true,
  268. date_of_birth: input.dateOfBirth,
  269. gift_code_sku_id: null,
  270. promotional_email_opt_in: false,
  271. };
  272.  
  273. let res = await agent.post(`${API}/auth/register`, body);
  274. for (let attempt = 0; attempt < 2; attempt++) {
  275. const chal = challengeFrom(res.status, res.body);
  276. if (!chal) break;
  277. const token = await solveCaptcha(client, proxyUrl, chal);
  278. res = await agent.post(`${API}/auth/register`, body, {
  279. "X-Captcha-Key": token,
  280. "X-Captcha-Rqtoken": chal.rqtoken,
  281. "X-Captcha-Session-Id": chal.sessionId,
  282. });
  283. }
  284.  
  285. if (res.status === 201 && typeof res.body?.token === "string") return res.body.token;
  286. throw new Error(`register failed (status ${res.status}): ${JSON.stringify(res.body)}`);
  287. }
  288.  
  289. async function oneAttempt(index: number): Promise<string | null> {
  290. const tag = `#${index + 1}`;
  291. const proxyUrl = stickyProxy(PROXY_URL);
  292. const agent = new Agent(proxyUrl);
  293. const client = new NoneCap({ apiKey: NONECAP_API_KEY });
  294. const rand = Math.random().toString(36).slice(2, 9) + Date.now().toString(36).slice(-4);
  295. const t0 = Date.now();
  296. try {
  297. const token = await register(agent, client, proxyUrl, {
  298. username: `lum${rand}`,
  299. password: `Lun!um_${rand}_xZ`,
  300. email: `james.miller.${rand}@your-catchall-domain.com`,
  301. dateOfBirth: "1998-01-12",
  302. });
  303. console.log(`${tag} created in ${((Date.now() - t0) / 1000).toFixed(1)}s — ${token.slice(0, 24)}…`);
  304. return token;
  305. } catch (e) {
  306. console.log(`${tag} failed after ${((Date.now() - t0) / 1000).toFixed(1)}s — ${(e as Error).message}`);
  307. return null;
  308. } finally {
  309. await agent.close();
  310. }
  311. }
  312.  
  313. function fail(message: string): never {
  314. console.error(`preflight failed — ${message}`);
  315. process.exit(1);
  316. }
  317.  
  318. async function preflight(): Promise<void> {
  319. console.log("running preflight checks…");
  320.  
  321. if (!NONECAP_API_KEY || NONECAP_API_KEY === "YOUR_NONECAP_API_KEY") {
  322. fail("NONECAP_API_KEY is not set (edit the file or pass NONECAP_API_KEY=…). Get a key at nonecap.com.");
  323. }
  324.  
  325. if (!PROXY_URL || PROXY_URL.includes("user:pass")) {
  326. fail("PROXY_URL is not set (edit the file or pass PROXY_URL=…). Use a sticky residential proxy.");
  327. }
  328. let proxy: URL;
  329. try {
  330. proxy = new URL(PROXY_URL);
  331. } catch {
  332. fail(`PROXY_URL is not a valid URL: ${PROXY_URL}`);
  333. }
  334. if (!/^https?:$|^socks[45]?:$/.test(proxy.protocol)) {
  335. fail(`unsupported proxy scheme "${proxy.protocol.replace(/:$/, "")}" (use http, https, socks4 or socks5)`);
  336. }
  337. if (!proxy.hostname || !proxy.port) fail("PROXY_URL must include an explicit host and port");
  338. if (!proxy.username || !proxy.password) fail("PROXY_URL must include credentials (user:pass@host:port)");
  339.  
  340. const client = new NoneCap({ apiKey: NONECAP_API_KEY });
  341. try {
  342. const account = await client.me();
  343. if (account.credits_balance <= 0) {
  344. fail(`NoneCap account has no credits (balance ${account.credits_balance}). Top up at nonecap.com.`);
  345. }
  346. console.log(` nonecap ok — ${account.credits_balance} credits`);
  347. } catch (e) {
  348. fail(`could not reach NoneCap / invalid API key: ${(e as Error).message}`);
  349. }
  350.  
  351. const agent = new Agent(stickyProxy(PROXY_URL));
  352. try {
  353. const res = await agent.get(`${API}/experiments`);
  354. if (res.status === 0) {
  355. fail("proxy could not reach discord.com (connection failed) — check the proxy host/port/credentials");
  356. }
  357. if (!res.body?.fingerprint) {
  358. fail(`discord /experiments returned status ${res.status} without a fingerprint — proxy IP may be blocked`);
  359. }
  360. console.log(` proxy + discord ok — exit reachable, fingerprint issued`);
  361. } catch (e) {
  362. fail(`proxy connectivity test threw: ${(e as Error).message}`);
  363. } finally {
  364. await agent.close();
  365. }
  366.  
  367. console.log("preflight passed\n");
  368. }
  369.  
  370. const results = new Array<string | null>(COUNT);
  371. let nextIndex = 0;
  372. async function worker(): Promise<void> {
  373. while (true) {
  374. const i = nextIndex++;
  375. if (i >= COUNT) break;
  376. results[i] = await oneAttempt(i);
  377. }
  378. }
  379.  
  380. await preflight();
  381. console.log(`creating ${COUNT} account(s), ${Math.min(CONCURRENCY, COUNT)} at a time\n`);
  382. await Promise.all(Array.from({ length: Math.min(CONCURRENCY, COUNT) }, () => worker()));
  383. const tokens = results.filter((t): t is string => t !== null);
  384. console.log(`\ndone · ${tokens.length}/${COUNT} created`);
  385. process.exit(tokens.length > 0 ? 0 : 1);
  386.  
Add Comment
Please, Sign In to add comment