/** * FastDL Scraper & Signature Generator - Instagram Video Downloader * Target: https://fastdl.app/en3Zu/video * Author: Vamz Spectre * * Fitur: * - Dynamic Chunk & Webpack Loader: Mengambil dan mengeksekusi chunk modul link/signature (link.chunk.js) secara headless via Node.js VM. * - Dynamic Signature Generation: Menghasilkan parameter `_s` (HMAC SHA-256), `_ts`, `_tsc`, `_sv`, dan `ts` secara presisi sesuai engine resmi fastdl. * - Cloudflare Turnstile & Captcha Support: Mendeteksi tantangan Turnstile (siteKey) & support injection token token via header `wh-cf-token` atau `x-token`. * - Parsing Media Respons: Menangani ekstraksi video MP4, foto/slideshow, thumbnail, dan link download direct. */ const vm = require("vm"); const https = require("https"); const FASTDL_BASE_URL = "https://fastdl.app"; const DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"; let cachedSigner = null; /** * Fetch data via HTTPS helper */ function fetchHttps(url, options = {}, postData = null) { return new Promise((resolve, reject) => { const parsed = new URL(url); const opts = { hostname: parsed.hostname, port: parsed.port || 443, path: parsed.pathname + parsed.search, method: options.method || (postData ? "POST" : "GET"), headers: { "User-Agent": DEFAULT_USER_AGENT, ...(options.headers || {}), }, }; if (postData) { opts.headers["Content-Length"] = Buffer.byteLength(postData); } const req = https.request(opts, (res) => { const chunks = []; res.on("data", (chunk) => chunks.push(chunk)); res.on("end", () => { const data = Buffer.concat(chunks).toString("utf-8"); resolve({ status: res.statusCode, headers: res.headers, data, }); }); }); req.on("error", reject); if (postData) req.write(postData); req.end(); }); } /** * Mendapatkan URL chunk link terbaru dari app.js fastdl.app */ async function getLinkChunkUrl() { const pageRes = await fetchHttps(`${FASTDL_BASE_URL}/en3Zu/video`); const appMatch = pageRes.data.match(/\/js\/app\.js\?id=[a-f0-9]+/); const appPath = appMatch ? appMatch[0] : "/js/app.js"; const appRes = await fetchHttps(`${FASTDL_BASE_URL}${appPath}`); const chunkMatch = appRes.data.match(/54:"([a-f0-9]+)"/); const hash = chunkMatch ? chunkMatch[1] : ""; return `${FASTDL_BASE_URL}/js/link.chunk.js${hash ? `?ch=${hash}` : ""}`; } /** * Menginisialisasi VM Node.js untuk mengeksekusi modul signature generator FastDL */ async function getFastDlSigner() { if (cachedSigner) return cachedSigner; const chunkUrl = await getLinkChunkUrl(); const chunkRes = await fetchHttps(chunkUrl); const chunkSrc = chunkRes.data; const mockWindow = { location: { hostname: "fastdl.app" }, top: null, document: { referrer: "" }, setInterval: () => {}, clearInterval: () => {}, setTimeout: (fn, ms) => setTimeout(fn, ms), clearTimeout: (id) => clearTimeout(id), atob: (s) => Buffer.from(s, "base64").toString("binary"), btoa: (s) => Buffer.from(s, "binary").toString("base64"), Uint8Array, TextDecoder, TextEncoder, AbortController, crypto: require("crypto").webcrypto, }; mockWindow.top = mockWindow; let pushedModules = null; const webpackChunk = []; webpackChunk.push = (args) => { pushedModules = args[1]; }; const sandbox = { window: mockWindow, globalThis: mockWindow, self: mockWindow, location: mockWindow.location, document: mockWindow.document, setInterval: mockWindow.setInterval, clearInterval: mockWindow.clearInterval, setTimeout: mockWindow.setTimeout, clearTimeout: mockWindow.clearTimeout, atob: mockWindow.atob, btoa: mockWindow.btoa, Uint8Array, TextDecoder, TextEncoder, AbortController, console, fetch: async () => ({ json: async () => ({ msec: Date.now() / 1000 }) }), crypto: mockWindow.crypto, }; mockWindow.webpackChunk = webpackChunk; sandbox.webpackChunk = webpackChunk; vm.createContext(sandbox); vm.runInContext(chunkSrc, sandbox); const installedModules = {}; function __webpack_require__(moduleId) { if (installedModules[moduleId]) return installedModules[moduleId].exports; const module = (installedModules[moduleId] = { exports: {} }); pushedModules[moduleId](module, module.exports, __webpack_require__); return module.exports; } __webpack_require__.r = (exports) => { if (typeof Symbol !== "undefined" && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); } Object.defineProperty(exports, "__esModule", { value: true }); }; __webpack_require__.d = (exports, definition) => { for (const key in definition) { if ( Object.prototype.hasOwnProperty.call(definition, key) && !Object.prototype.hasOwnProperty.call(exports, key) ) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); } } }; const mod7027 = __webpack_require__("7027"); cachedSigner = await mod7027.default; return cachedSigner; } /** * Scraper FastDL Instagram Downloader * @param {string} instagramUrl - URL postingan / Reels Instagram * @param {object} options - Opsi tambahan seperti cfToken / turnstile token */ async function scrapeFastDl(instagramUrl, options = {}) { if (!instagramUrl || typeof instagramUrl !== "string") { throw new Error("Instagram URL is required"); } // 1. Generate cryptographic signature via FastDL link engine const signer = await getFastDlSigner(); const signedPayload = await signer(instagramUrl.trim()); // 2. Siapkan headers request const headers = { "Content-Type": "application/json", Origin: "https://fastdl.app", Referer: "https://fastdl.app/en3Zu/video", }; if (options.cfToken) { headers["wh-cf-token"] = options.cfToken; } if (options.token) { headers["x-token"] = options.token; } // 3. Kirim request ke endpoint konversi const res = await fetchHttps( `${FASTDL_BASE_URL}/api/convert`, { method: "POST", headers, }, JSON.stringify(signedPayload) ); let json; try { json = JSON.parse(res.data); } catch { json = { raw: res.data }; } // Handle Turnstile Captcha challenge if (res.status === 422 || json.code === "CAPTCHA_REQUIRED") { return { status: false, code: "CAPTCHA_REQUIRED", message: "FastDL memerlukan verifikasi Cloudflare Turnstile.", challenge: json.challenge || { type: "turnstile", siteKey: "0x4AAAAAABhLwGG2XCb7fE2M", }, signedPayload, }; } if (res.status !== 200 || json.error) { return { status: false, code: res.status, message: json.message || json.error || "Gagal memproses media dari FastDL", data: json, }; } return { status: true, result: json, }; } if (typeof module !== "undefined" && module.exports) { module.exports = { scrapeFastDl, getFastDlSigner, }; } // CLI Execution if (require.main === module) { const targetUrl = process.argv[2] || "https://www.instagram.com/reel/DC5zT2ySPuM/"; console.log(`šŸ” Scraping FastDL for: ${targetUrl}`); scrapeFastDl(targetUrl) .then((res) => { console.log("\nšŸ“¦ Result:\n", JSON.stringify(res, null, 2)); }) .catch((err) => { console.error("āŒ Error:", err.message); }); }