GeminiBot commited on
Commit ·
387c337
1
Parent(s): 2e170a0
Reinforce JSDOM browser simulation to solve challenge
Browse files5 unmodified lines67891011121314151617181920212223242552 unmodified lines787980815 unmodified linesprivate async solveChallenge(vqdHash: string, ua: string): Promise<string> {try {const jsScript = Buffer.from(vqdHash, 'base64').toString('utf-8');const dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, { runScripts: 'dangerously' });dom.window.top.__DDG_BE_VERSION__ = 1;dom.window.top.__DDG_FE_CHAT_HASH__ = 1;const result = await dom.window.eval(jsScript) as any;result.client_hashes[0] = ua;result.client_hashes = result.client_hashes.map((t: string) => {const hash = createHash('sha256');hash.update(t);return hash.digest('base64');});return btoa(JSON.stringify(result));} catch (e: any) {throw new Error("Challenge Solver Error: " + e.message);}}52 unmodified linesreturn `⚠️ Ошибка бэкенда: ${error.message}`;}}}5 unmodified lines6789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525352 unmodified lines1061071081095 unmodified linesprivate async solveChallenge(vqdHash: string, ua: string): Promise<string> {try {const jsScript = Buffer.from(vqdHash, 'base64').toString('utf-8');// Создаем максимально детальную симуляцию браузераconst dom = new JSDOM(`<!DOCTYPE html><html><head></head><body><div id="app"></div></body></html>`, {url: "https://duckduckgo.com/",referrer: "https://duckduckgo.com/",contentType: "text/html",runScripts: "dangerously",resources: "usable"});// Эмулируем Navigator и другие свойстваObject.defineProperty(dom.window, 'navigator', {value: {userAgent: ua,platform: 'Win32',languages: ['en-US', 'en'],deviceMemory: 8,hardwareConcurrency: 8}});// Установка обязательных переменных DDGdom.window.top.__DDG_BE_VERSION__ = 1;dom.window.top.__DDG_FE_CHAT_HASH__ = 1;// Выполняем скриптconst result = await dom.window.eval(jsScript) as any;if (!result || !result.client_hashes) {throw new Error("Challenge script returned invalid result");}result.client_hashes[0] = ua;result.client_hashes = result.client_hashes.map((t: string) => {const hash = createHash('sha256');hash.update(t);return hash.digest('base64');});return btoa(JSON.stringify(result));} catch (e: any) {throw new Error(`Challenge Solver Error: ${e.message}`);}}52 unmodified linesreturn `⚠️ Ошибка бэкенда: ${error.message}`;}}}
src/duckai.ts+31-3