/** * DeepAI AI Photo & Image Editor Scraper & Free Unlimited Bypass Engine * Target: https://deepai.org/machine-learning-model/image-editor * Author: Vamz Spectre (VamxAPI) * * Capabilities: * - 100% Free Unlimited Bypass: Menggunakan reverse-engineering signature DeepAI + Dynamic Proxy & Tor Stream Isolation. * - Berhasil melewati proteksi anti-bot token (_axwrt), signature hashing (tryitApiKey), dan bypass tuntas kuota IP ("anonymous try it exceeded" & "signed in try-it quota exceeded"). * - Native Zero-Dependency: Tidak memerlukan modul npm tambahan ataupun browser Chrome, berjalan instan via native TLS/HTTP. * - Universal Proxy Support: Mendukung SOCKS5, HTTP CONNECT proxy, local Tor (127.0.0.1:9050), serta direct fallback jika proxy tidak aktif. * - Auto-Retry & IP Rotation: Otomatis meminta circuit/IP baru bila exit node terkena rate limit atau filter edge. * - Mendukung Mode Direct Pro jika memiliki custom DEEPAI_API_KEY. * - Mendukung Remote Image URLs, Path File Gambar Lokal, dan Base64 Data URI. * - Output JSON murni dengan direct image URL. * * Download & Run (1:1 Konsisten): * curl -sL "https://code.vamxapi.my.id/snippet/raw/deepai-image-editor" -o deepai-image-editor.js * * Usage: * node deepai-image-editor.js "" "" [--proxy ""] * * Examples: * # Default (Auto-detect Tor / direct): * node deepai-image-editor.js "https://images.deepai.org/machine-learning-models/ba25fbba57eb410e9e2038b78eac5d9a/f078fe461c9c4046be4d810e9e4bb798.webp" "make it sunset with bright warm lighting" * * # Custom HTTP/SOCKS5 Proxy (jika Tor lokal / 127 tidak dipakai atau diblokir): * node deepai-image-editor.js "image.jpg" "enhance photo quality" --proxy "http://user:pass@1.2.3.4:8080" */ const fs = require("fs"); const net = require("net"); const tls = require("tls"); const https = require("https"); const crypto = require("crypto"); const API_BASE_URL = "https://api.deepai.org"; const MODEL_ID = "image-editor"; const DEFAULT_UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"; const SALT = "hackers_become_a_little_stinkier_every_time_they_hack"; function myHashFunction(str) { return crypto.createHash("md5").update(str, "utf8").digest("hex").split("").reverse().join(""); } function generateTryitApiKey(userAgent = DEFAULT_UA) { const randomStr = String(Math.round(Math.random() * 100000000000)); const hash1 = myHashFunction(userAgent + randomStr + SALT); const hash2 = myHashFunction(userAgent + hash1); const hash3 = myHashFunction(userAgent + hash2); return `tryit-${randomStr}-${hash3}`; } async function resolveImageInput(input) { if (typeof input === "string") { const trimmed = input.trim(); if (trimmed.startsWith("http://") || trimmed.startsWith("https://")) { return { type: "url", value: trimmed }; } if (fs.existsSync(trimmed)) { const buffer = fs.readFileSync(trimmed); const extMatch = trimmed.match(/\.([a-zA-Z0-9]+)$/); const ext = extMatch ? extMatch[1].toLowerCase() : "jpg"; const mime = ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : "image/jpeg"; return { type: "buffer", buffer, mime, filename: `image.${ext}` }; } if (trimmed.startsWith("data:image/")) { const match = trimmed.match(/^data:(image\/[a-zA-Z0-9_\-]+);base64,(.+)$/); if (match) { return { type: "buffer", buffer: Buffer.from(match[2], "base64"), mime: match[1], filename: "image.jpg" }; } } } if (Buffer.isBuffer(input)) { return { type: "buffer", buffer: input, mime: "image/jpeg", filename: "image.jpg" }; } throw new Error(`Input gambar tidak valid atau file tidak ditemukan: ${input}`); } /** * Cek apakah host:port terbuka */ function isPortOpen(host, port, timeout = 600) { return new Promise((resolve) => { const s = net.connect(port, host, () => { s.destroy(); resolve(true); }); s.setTimeout(timeout, () => { s.destroy(); resolve(false); }); s.on("error", () => { s.destroy(); resolve(false); }); }); } /** * Native SOCKS5 TLS Socket Handler dengan Tor Stream Isolation & Custom Proxy */ function createSocks5TlsSocket(proxyHost, proxyPort, targetHost, targetPort, authInfo = null, useTorIsolation = false) { return new Promise((resolve, reject) => { const socket = net.connect(proxyPort, proxyHost, () => { if (useTorIsolation || authInfo) { socket.write(Buffer.from([0x05, 0x01, 0x02])); } else { socket.write(Buffer.from([0x05, 0x01, 0x00])); } }); socket.once("data", (data) => { if (data[0] !== 0x05) { socket.destroy(); return reject(new Error("Handshake SOCKS5 gagal.")); } if (data[1] === 0x02) { let user, pass; if (useTorIsolation) { user = "tor_" + Date.now() + "_" + Math.random().toString(36).slice(2, 6); pass = "pass_" + Math.random().toString(36).slice(2, 6); } else if (authInfo) { user = authInfo.user || ""; pass = authInfo.pass || ""; } const userBuf = Buffer.from(user || "anonymous", "utf8"); const passBuf = Buffer.from(pass || "nopass", "utf8"); const authReq = Buffer.concat([ Buffer.from([0x01, userBuf.length]), userBuf, Buffer.from([passBuf.length]), passBuf ]); socket.write(authReq); socket.once("data", (authReply) => { if (authReply[1] !== 0x00) { socket.destroy(); return reject(new Error("Autentikasi SOCKS5 gagal: " + authReply[1])); } sendConnectCommand(); }); } else if (data[1] === 0x00) { sendConnectCommand(); } else { socket.destroy(); return reject(new Error("Metode auth SOCKS5 tidak didukung: " + data[1])); } }); function sendConnectCommand() { const hostBuf = Buffer.from(targetHost, "utf8"); const portBuf = Buffer.alloc(2); portBuf.writeUInt16BE(targetPort, 0); const connReq = Buffer.concat([ Buffer.from([0x05, 0x01, 0x00, 0x03, hostBuf.length]), hostBuf, portBuf ]); socket.write(connReq); socket.once("data", (connReply) => { if (connReply[1] !== 0x00) { socket.destroy(); return reject(new Error("Koneksi SOCKS5 tujuan gagal: " + connReply[1])); } const tlsSocket = tls.connect({ socket, servername: targetHost, rejectUnauthorized: true }, () => resolve(tlsSocket)); tlsSocket.on("error", (err) => { socket.destroy(); reject(err); }); }); } socket.on("error", reject); }); } /** * Native HTTP CONNECT TLS Socket Handler */ function createHttpConnectTlsSocket(proxyHost, proxyPort, targetHost, targetPort, auth = null) { return new Promise((resolve, reject) => { const socket = net.connect(proxyPort, proxyHost, () => { let connectReq = `CONNECT ${targetHost}:${targetPort} HTTP/1.1\r\nHost: ${targetHost}:${targetPort}\r\n`; if (auth) { connectReq += `Proxy-Authorization: Basic ${Buffer.from(auth).toString("base64")}\r\n`; } connectReq += "\r\n"; socket.write(connectReq); }); socket.once("data", (data) => { const resStr = data.toString("utf8"); if (resStr.includes("200 Connection established") || resStr.includes(" 200 ")) { const tlsSocket = tls.connect({ socket, servername: targetHost, rejectUnauthorized: true }, () => resolve(tlsSocket)); tlsSocket.on("error", (err) => { socket.destroy(); reject(err); }); } else { socket.destroy(); reject(new Error("HTTP Proxy CONNECT failed: " + resStr.split("\r\n")[0])); } }); socket.on("error", reject); }); } function parseProxyUrl(proxyUrlStr) { if (!proxyUrlStr) return null; try { const parsed = new URL(proxyUrlStr.includes("://") ? proxyUrlStr : `http://${proxyUrlStr}`); const protocol = parsed.protocol.replace(":", "").toLowerCase(); const isSocks = protocol.startsWith("socks"); const host = parsed.hostname; const port = parseInt(parsed.port, 10) || (isSocks ? 1080 : 8080); const auth = parsed.username ? `${parsed.username}:${parsed.password}` : null; const authInfo = parsed.username ? { user: parsed.username, pass: parsed.password } : null; return { protocol, isSocks, host, port, auth, authInfo }; } catch (_) { return null; } } function buildMultipartFormData(fields, files = []) { const boundary = "----WebKitFormBoundary" + Math.random().toString(36).slice(2) + Date.now().toString(36); const parts = []; for (const [key, val] of Object.entries(fields)) { if (val !== undefined && val !== null) { parts.push( Buffer.from( `--${boundary}\r\nContent-Disposition: form-data; name="${key}"\r\n\r\n${val}\r\n` ) ); } } for (const file of files) { const filename = file.filename || "image.jpg"; const mime = file.mime || "image/jpeg"; const header = Buffer.from( `--${boundary}\r\nContent-Disposition: form-data; name="${file.name}"; filename="${filename}"\r\nContent-Type: ${mime}\r\n\r\n` ); parts.push(header); parts.push(file.buffer); parts.push(Buffer.from("\r\n")); } parts.push(Buffer.from(`--${boundary}--\r\n`)); const body = Buffer.concat(parts); return { boundary, body, contentType: `multipart/form-data; boundary=${boundary}`, contentLength: body.length }; } /** * Eksekusi HTTP Request ke DeepAI */ async function sendDeepAIRequest(fields, files, options = {}) { const apiKey = options.apiKey || generateTryitApiKey(options.userAgent || DEFAULT_UA); const uuid = crypto.randomUUID(); const ua = options.userAgent || DEFAULT_UA; const { body, contentType, contentLength } = buildMultipartFormData(fields, files); const headers = { "api-key": apiKey, "user-agent": ua, "origin": "https://deepai.org", "referer": "https://deepai.org/", "cookie": `_axwrt=${uuid}; _axwrt_ts=${uuid}.${Date.now()}`, "Content-Type": contentType, "Content-Length": contentLength }; const customProxy = options.proxy || process.env.DEEPAI_PROXY; let createConnection; if (customProxy) { const p = parseProxyUrl(customProxy); if (p) { createConnection = async () => { if (p.isSocks) { return await createSocks5TlsSocket(p.host, p.port, "api.deepai.org", 443, p.authInfo, false); } else { return await createHttpConnectTlsSocket(p.host, p.port, "api.deepai.org", 443, p.auth); } }; } } else if (options.useTor !== false) { const torActive = await isPortOpen("127.0.0.1", 9050); if (torActive) { createConnection = async () => { return await createSocks5TlsSocket("127.0.0.1", 9050, "api.deepai.org", 443, null, true); }; } } return new Promise(async (resolve, reject) => { try { let connSocket; if (createConnection) { connSocket = await createConnection(); } const req = https.request({ hostname: "api.deepai.org", port: 443, path: "/api/image-editor", method: "POST", createConnection: connSocket ? () => connSocket : undefined, headers, timeout: 45000 }, (res) => { let rawData = ""; res.on("data", chunk => rawData += chunk); res.on("end", () => { try { const parsed = JSON.parse(rawData); resolve({ statusCode: res.statusCode, data: parsed }); } catch (_) { resolve({ statusCode: res.statusCode, raw: rawData }); } }); }); req.on("error", reject); req.on("timeout", () => { req.destroy(); reject(new Error("Request timeout ke DeepAI API.")); }); req.write(body); req.end(); } catch (err) { reject(err); } }); } /** * Main Controller * @param {string|Buffer} imageInput * @param {string} promptText * @param {object} [options] * @returns {Promise} */ async function editImageWithDeepAI(imageInput, promptText, options = {}) { const prompt = String(promptText || "").trim(); if (!prompt) { throw new Error("Instruksi edit (prompt) wajib diisi."); } const resolved = await resolveImageInput(imageInput); const fields = { text: prompt }; const files = []; if (resolved.type === "url") { fields.image = resolved.value; } else if (resolved.type === "buffer") { files.push({ name: "image", buffer: resolved.buffer, filename: resolved.filename, mime: resolved.mime }); } const proApiKey = options.apiKey || process.env.DEEPAI_API_KEY; // 1. Mode Direct Pro jika API Key resmi tersedia if (proApiKey) { const res = await sendDeepAIRequest(fields, files, { apiKey: proApiKey, useTor: false }); if (res.statusCode === 200 && res.data && (res.data.output_url || res.data.id)) { return { status: true, creator: "Vamz Spectre", model: MODEL_ID, mode: "direct_pro", data: { id: res.data.id || null, output_url: res.data.output_url, prompt } }; } const errMsg = res.data?.status || res.data?.err || `Status ${res.statusCode}`; throw new Error(`DeepAI Pro Error: ${errMsg}`); } // 2. Free Bypass Mode dengan Circuit / Proxy Rotation const maxRetries = options.proxy ? 2 : 6; let lastError = null; for (let attempt = 1; attempt <= maxRetries; attempt++) { try { const res = await sendDeepAIRequest(fields, files, options); if (res.statusCode === 200 && res.data && (res.data.output_url || res.data.id)) { return { status: true, creator: "Vamz Spectre", model: MODEL_ID, mode: options.proxy ? "custom_proxy_bypass" : "free_tor_bypass", data: { id: res.data.id || null, output_url: res.data.output_url, prompt } }; } const statusMsg = String(res.data?.status || res.data?.err || res.raw || ""); if ( statusMsg.includes("quota exceeded") || statusMsg.includes("exceeded") || statusMsg.includes("Please try this model on deepai.org") || res.statusCode === 401 ) { lastError = new Error(`DeepAI Limit/Edge Filter (${statusMsg}), memutar circuit IP baru...`); await new Promise(r => setTimeout(r, 1000)); continue; } throw new Error(`DeepAI Error (${res.statusCode}): ${statusMsg || JSON.stringify(res.data)}`); } catch (err) { lastError = err; await new Promise(r => setTimeout(r, 1000)); } } throw new Error( `Gagal memproses setelah ${maxRetries} percobaan (${lastError?.message || "Unknown error"}). ` + `Tips: Jika 127.0.0.1 (Tor) sedang banyak diblokir Cloudflare edge, gunakan custom proxy: node deepai-image-editor.js "img" "prompt" --proxy "http://host:port"` ); } // CLI Runner (1:1 Output Konsisten JSON) if (require.main === module) { const args = process.argv.slice(2); let inputImg = null; let inputPrompt = null; let customProxy = null; for (let i = 0; i < args.length; i++) { if (args[i] === "--proxy" && args[i + 1]) { customProxy = args[i + 1]; i++; } else if (!inputImg) { inputImg = args[i]; } else if (!inputPrompt) { inputPrompt = args[i]; } } if (!inputImg || !inputPrompt) { console.log(JSON.stringify({ status: false, creator: "Vamz Spectre", message: "Penggunaan: node deepai-image-editor.js [--proxy ]", example: 'node deepai-image-editor.js "https://images.deepai.org/machine-learning-models/ba25fbba57eb410e9e2038b78eac5d9a/f078fe461c9c4046be4d810e9e4bb798.webp" "make it sunset with bright warm lighting"' }, null, 2)); process.exit(1); } editImageWithDeepAI(inputImg, inputPrompt, { proxy: customProxy }) .then(result => { console.log(JSON.stringify(result, null, 2)); }) .catch(err => { console.error(JSON.stringify({ status: false, creator: "Vamz Spectre", error: err.message || String(err) }, null, 2)); process.exit(1); }); } module.exports = { editImageWithDeepAI, generateTryitApiKey, sendDeepAIRequest, createSocks5TlsSocket, createHttpConnectTlsSocket };