scraperjavascript8021
Catbox.moe & Litterbox Scraper & Uploader Engine (Non-API)
Reverse-engineered scraper, uploader, album extractor, and metadata inspector for Catbox.moe & Litterbox without requiring official API / userhash. Features auto-fallback against datacenter restrictions, remote URL re-hosting, album parsing, and Range-based high-speed file inspection.
Vamz Spectre15 Okt 2026580 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/catbox-moe-scraper" -o catbox-moe-scraper.js
# 2. Jalankan script
node catbox-moe-scraper.js
Dependencies npm yang Dibutuhkan:
npm install Zero external dependencies (Built-in fetch, FormData, Blob, node:fs, node:path)Panduan Penggunaan:
Instalasi & Eksekusi: 1. Unduh snippet: curl -sL "https://code.vamxapi.my.id/snippet/raw/catbox-moe-scraper" -o catbox-moe-scraper.js 2. Eksekusi CLI: - Scrape Album: node catbox-moe-scraper.js "https://catbox.moe/c/8xw6g4" - Upload File: node catbox-moe-scraper.js "./foto.png" - Re-host URL: node catbox-moe-scraper.js "https://example.com/audio.mp3" - Inspect: node catbox-moe-scraper.js "https://files.catbox.moe/00koca.jpg"
catbox-moe-scraper.js(580 lines)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
/**
* ========================================================
* Name: Catbox.moe & Litterbox Scraper & Uploader Engine (Non-API)
*
* Cara Download:
* curl -sL "https://code.vamxapi.my.id/snippet/raw/catbox-moe-scraper" -o catbox-moe-scraper.js
*
* Cara Eksekusi:
* node catbox-moe-scraper.js "https://catbox.moe/c/8xw6g4"
* node catbox-moe-scraper.js "/root/sample_struk.png"
* node catbox-moe-scraper.js "https://httpbin.org/image/png"
* node catbox-moe-scraper.js "https://files.catbox.moe/00koca.jpg"
*
* Author: Vamz Spectre
* Source: https://vamxapi.my.id
* ========================================================
*/
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import { execFileSync } from 'node:child_process';
const CATBOX_API = 'https://catbox.moe/user/api.php';
const LITTERBOX_API = 'https://litterbox.catbox.moe/resources/internals/api.php';
const MIME_MAP = {
'.jpg': 'image/jpeg',
'.jpeg': 'image/jpeg',
'.png': 'image/png',
'.gif': 'image/gif',
'.webp': 'image/webp',
'.svg': 'image/svg+xml',
'.bmp': 'image/bmp',
'.ico': 'image/x-icon',
'.mp4': 'video/mp4',
'.webm': 'video/webm',
'.mkv': 'video/x-matroska',
'.avi': 'video/x-msvideo',
'.mov': 'video/quicktime',
'.mp3': 'audio/mpeg',
'.wav': 'audio/wav',
'.ogg': 'audio/ogg',
'.m4a': 'audio/mp4',
'.pdf': 'application/pdf',
'.zip': 'application/zip',
'.rar': 'application/x-rar-compressed',
'.7z': 'application/x-7z-compressed',
'.tar': 'application/x-tar',
'.gz': 'application/gzip',
'.json': 'application/json',
'.txt': 'text/plain',
'.csv': 'text/csv',
'.html': 'text/html',
'.xml': 'text/xml'
};
const BACKUP_PROXIES = [
'45.195.91.219:8080',
'103.165.155.22:2016',
'157.15.67.175:3125',
'103.176.96.23:8080'
];
/**
* Format bytes into human-readable string
*/
function formatBytes(bytes) {
if (!bytes || bytes <= 0) return '0 B';
const k = 1024;
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
}
/**
* Detect MIME type from file name or extension
*/
function getMimeType(filename) {
const ext = path.extname(filename || '').toLowerCase();
return MIME_MAP[ext] || 'application/octet-stream';
}
/**
* Fetch fresh proxy list from proxyscrape API for IP datacenter bypass
*/
async function getLiveProxies() {
try {
const res = await fetch(
'https://api.proxyscrape.com/v2/?request=displayproxies&protocol=http&timeout=5000&country=all&ssl=yes&anonymity=all',
{ signal: AbortSignal.timeout(4000) }
);
if (!res.ok) throw new Error('Proxy API unavailable');
const text = await res.text();
const list = text.split('\n').map((l) => l.trim()).filter(Boolean);
return list.length ? list : BACKUP_PROXIES;
} catch {
return BACKUP_PROXIES;
}
}
/**
* Upload directly to Catbox.moe (Permanent Storage, Max 200MB)
* Includes automated proxy tunnel bypass against datacenter 412 IP blocks.
*/
async function uploadToCatbox(fileBuffer, filename = 'upload.bin', userhash = '') {
const mimeType = getMimeType(filename);
// 1. Coba upload direct via Node native fetch
try {
const blob = new Blob([fileBuffer], { type: mimeType });
const form = new FormData();
form.append('reqtype', 'fileupload');
if (userhash) form.append('userhash', userhash);
form.append('fileToUpload', blob, filename);
const res = await fetch(CATBOX_API, {
method: 'POST',
headers: {
'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',
Origin: 'https://catbox.moe',
Referer: 'https://catbox.moe/'
},
body: form
});
const responseText = (await res.text()).trim();
if (res.ok && responseText.startsWith('http')) {
return {
namefile: filename,
link: responseText,
duration: 'permanent'
};
}
} catch {}
// 2. Jika IP datacenter/VPS terblokir (Invalid uploader), lakukan bypass via residential proxy pool
const tempPath = path.join(os.tmpdir(), `catbox_${Date.now()}_${filename}`);
fs.writeFileSync(tempPath, fileBuffer);
try {
const liveProxies = await getLiveProxies();
const proxies = [...BACKUP_PROXIES, ...liveProxies];
for (const proxy of proxies.slice(0, 8)) {
try {
const curlArgs = [
'-x',
`http://${proxy}`,
'--connect-timeout',
'3',
'-m',
'8',
'-s',
'-F',
'reqtype=fileupload',
...(userhash ? ['-F', `userhash=${userhash}`] : []),
'-F',
`fileToUpload=@${tempPath}`,
CATBOX_API
];
const output = execFileSync('curl', curlArgs, {
encoding: 'utf8',
timeout: 10000
}).trim();
if (output.startsWith('http')) {
return {
namefile: filename,
link: output,
duration: 'permanent'
};
}
} catch {}
}
} finally {
try {
if (fs.existsSync(tempPath)) fs.unlinkSync(tempPath);
} catch {}
}
throw new Error('Gagal mengupload ke Catbox.moe (semua jalur bypass ditolak atau storage penuh).');
}
/**
* Upload buffer or blob to Litterbox (Catbox Temporary Storage, Max 1GB)
*/
async function uploadToLitterbox(fileBuffer, filename = 'upload.bin', time = '72h') {
const validTimes = ['1h', '12h', '24h', '72h'];
const expiryTime = validTimes.includes(time) ? time : '72h';
const mimeType = getMimeType(filename);
const blob = new Blob([fileBuffer], { type: mimeType });
const form = new FormData();
form.append('reqtype', 'fileupload');
form.append('time', expiryTime);
form.append('fileToUpload', blob, filename);
const res = await fetch(LITTERBOX_API, {
method: 'POST',
headers: {
'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',
Origin: 'https://litterbox.catbox.moe',
Referer: 'https://litterbox.catbox.moe/'
},
body: form
});
const responseText = (await res.text()).trim();
if (!res.ok || !responseText.startsWith('http')) {
throw new Error(`Litterbox upload failed (${res.status}): ${responseText || res.statusText}`);
}
return {
namefile: filename,
link: responseText,
duration: expiryTime
};
}
/**
* Universal File Uploader
*/
async function uploadFile(input, options = {}) {
let fileBuffer;
let filename = options.filename;
if (typeof input === 'string') {
if (!fs.existsSync(input)) {
throw new Error(`File lokal tidak ditemukan: "${input}"`);
}
fileBuffer = fs.readFileSync(input);
if (!filename) {
filename = path.basename(input);
}
} else if (Buffer.isBuffer(input) || input instanceof Uint8Array) {
fileBuffer = Buffer.from(input);
if (!filename) {
filename = `upload_${Date.now()}.bin`;
}
} else {
throw new Error('Input file harus berupa path string atau Buffer.');
}
const service = (options.service || 'catbox').toLowerCase();
const time = options.time || '72h';
const userhash = options.userhash || '';
// Mode Litterbox Temporary (hanya jika diminta eksplisit)
if (service === 'litterbox') {
return await uploadToLitterbox(fileBuffer, filename, time);
}
// Default: Catbox Permanent (files.catbox.moe)
try {
return await uploadToCatbox(fileBuffer, filename, userhash);
} catch (err) {
// Jika Catbox benar-benar gagal total dan options.allowFallback diaktifkan
if (options.fallback === true || options.service === 'auto') {
const litterRes = await uploadToLitterbox(fileBuffer, filename, time);
return {
namefile: litterRes.namefile,
link: litterRes.link,
duration: litterRes.duration
};
}
throw err;
}
}
/**
* Re-host remote file URL directly to Catbox
*/
async function uploadUrl(remoteUrl, options = {}) {
const cleanUrl = (remoteUrl || '').trim();
if (!cleanUrl.startsWith('http://') && !cleanUrl.startsWith('https://')) {
throw new Error(`URL remote tidak valid: "${remoteUrl}"`);
}
const res = await fetch(cleanUrl, {
headers: {
'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'
}
});
if (!res.ok) {
throw new Error(`Gagal mengunduh file remote (${res.status}): ${cleanUrl}`);
}
const arrayBuf = await res.arrayBuffer();
const buffer = Buffer.from(arrayBuf);
let filename = options.filename;
if (!filename) {
try {
const parsed = new URL(cleanUrl);
const urlBase = path.basename(parsed.pathname);
if (urlBase && urlBase.includes('.')) {
filename = urlBase;
}
} catch {}
}
if (!filename) {
const contentType = res.headers.get('content-type') || '';
let ext = '.bin';
for (const [key, val] of Object.entries(MIME_MAP)) {
if (contentType.includes(val)) {
ext = key;
break;
}
}
filename = `remote_${Date.now()}${ext}`;
}
return await uploadFile(buffer, { ...options, filename });
}
/**
* Scrape Catbox Album collection (https://catbox.moe/c/{shortcode})
*/
async function getAlbum(albumUrlOrCode) {
let code = (albumUrlOrCode || '').trim();
if (code.includes('catbox.moe/c/')) {
const match = code.match(/catbox\.moe\/c\/([a-zA-Z0-9]+)/);
if (match) code = match[1];
}
if (!code || !/^[a-zA-Z0-9]+$/.test(code)) {
throw new Error(`Kode album Catbox tidak valid: "${albumUrlOrCode}"`);
}
const albumUrl = `https://catbox.moe/c/${code}`;
const res = await fetch(albumUrl, {
headers: {
'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'
}
});
if (!res.ok) {
throw new Error(`Album "${code}" tidak ditemukan atau server error (${res.status})`);
}
const html = await res.text();
const titleMatch =
html.match(/<div class="title">\s*<h1>(.*?)<\/h1>/i) ||
html.match(/<title>(.*?)<\/title>/i);
const title = titleMatch ? titleMatch[1].trim() : 'Untitled Album';
const dateMatch = html.match(/<p>\s*Created\s+(.*?)\s*<\/p>/i);
const createdAt = dateMatch ? dateMatch[1].trim() : null;
let description = '';
const descMatch = html.match(
/<div class="title">[\s\S]*?<p>[^<]*<\/p>\s*<p>(.*?)<\/p>/i
);
if (descMatch && descMatch[1].trim()) {
description = descMatch[1].trim();
}
const files = [];
const linkRegex =
/<a[^>]+href=[\x27"](https?:\/\/files\.catbox\.moe\/([^\x27"\s>]+))[\x27"][^>]*>([\s\S]*?)<\/a>/gi;
let match;
const seenUrls = new Set();
while ((match = linkRegex.exec(html)) !== null) {
const fileUrl = match[1];
const filename = match[2];
const innerHtml = match[3] || '';
if (seenUrls.has(fileUrl)) continue;
seenUrls.add(fileUrl);
let thumbUrl = null;
const thumbMatch = innerHtml.match(
/src=[\x27"](https?:\/\/files\.catbox\.moe\/thumbs\/[^\x27"\s>]+)[\x27"]/i
);
if (thumbMatch) {
thumbUrl = thumbMatch[1];
}
files.push({
filename,
url: fileUrl,
thumbnail: thumbUrl,
ext: path.extname(filename).toLowerCase().replace('.', ''),
mime_type: getMimeType(filename)
});
}
return {
status: true,
code,
album_url: albumUrl,
title,
created_at: createdAt,
description: description || null,
total_files: files.length,
files
};
}
/**
* Inspect file metadata on Catbox or Litterbox
*/
async function inspectFile(fileUrl) {
const cleanUrl = (fileUrl || '').trim();
if (!cleanUrl.startsWith('http://') && !cleanUrl.startsWith('https://')) {
throw new Error(`URL file tidak valid: "${fileUrl}"`);
}
const res = await fetch(cleanUrl, {
method: 'GET',
headers: {
Range: 'bytes=0-0',
'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'
}
});
const isAlive = res.status === 200 || res.status === 206;
const contentType =
res.headers.get('content-type') || 'application/octet-stream';
const rangeHeader = res.headers.get('content-range') || '';
const totalMatch = rangeHeader.match(/\/(\d+)/);
const size = totalMatch
? parseInt(totalMatch[1], 10)
: parseInt(res.headers.get('content-length') || '0', 10);
const filename = path.basename(new URL(cleanUrl).pathname);
const isLitter = cleanUrl.includes('litter.catbox.moe');
return {
status: true,
alive: isAlive,
http_code: res.status,
url: cleanUrl,
filename,
host: isLitter ? 'litter.catbox.moe' : 'files.catbox.moe',
service: isLitter ? 'litterbox (temporary)' : 'catbox (permanent)',
content_type: contentType,
size_bytes: size,
size_formatted: formatBytes(size),
last_modified: res.headers.get('last-modified') || null
};
}
/**
* Universal Scraper Dispatcher
*/
async function catbox(commandOrInput, options = {}) {
const input = (commandOrInput || '').trim();
if (!input) {
throw new Error(
'Parameter input URL, file path, atau album ID wajib disertakan!'
);
}
if (options.action === 'album') return await getAlbum(input);
if (options.action === 'inspect') return await inspectFile(input);
if (options.action === 'upload') return await uploadFile(input, options);
if (options.action === 'url') return await uploadUrl(input, options);
if (input.includes('catbox.moe/c/')) {
return await getAlbum(input);
}
if (
input.includes('files.catbox.moe/') ||
input.includes('litter.catbox.moe/')
) {
return await inspectFile(input);
}
if (input.startsWith('http://') || input.startsWith('https://')) {
return await uploadUrl(input, options);
}
if (fs.existsSync(input)) {
return await uploadFile(input, options);
}
if (/^[a-zA-Z0-9]{5,8}$/.test(input)) {
try {
return await getAlbum(input);
} catch {}
}
throw new Error(
`Input tidak dikenali sebagai URL, album code, ataupun file lokal: "${input}"`
);
}
export {
catbox,
uploadFile,
uploadUrl,
uploadToCatbox,
uploadToLitterbox,
getAlbum,
inspectFile,
formatBytes,
getMimeType
};
export default catbox;
/**
* CLI Runner:
* node catbox-moe-scraper.js "https://catbox.moe/c/8xw6g4"
* node catbox-moe-scraper.js "/root/sample_struk.png"
* node catbox-moe-scraper.js "https://httpbin.org/image/png"
* node catbox-moe-scraper.js "https://files.catbox.moe/00koca.jpg"
*/
const cliArgs = process.argv.slice(2);
const mainArg = cliArgs[0] ? cliArgs[0].trim() : null;
async function runCli() {
if (!mainArg) {
console.log(
JSON.stringify(
{
status: false,
message: 'Parameter belum ditentukan.',
usage: 'node catbox-moe-scraper.js <url_atau_filepath> [options]',
features: [
'Upload file lokal ke Catbox permanent (files.catbox.moe) with proxy bypass',
'Upload temporary ke Litterbox (--litterbox)',
'Re-hosting URL remote ke Catbox',
'Scraping album Catbox (https://catbox.moe/c/{id})',
'Inspect metadata & size file Catbox (Range streaming)'
],
examples: [
'node catbox-moe-scraper.js "/path/to/gambar.jpg"',
'node catbox-moe-scraper.js "https://catbox.moe/c/8xw6g4"',
'node catbox-moe-scraper.js "https://example.com/audio.mp3"',
'node catbox-moe-scraper.js "/path/to/file.zip" --litterbox --time=24h'
]
},
null,
2
)
);
process.exit(1);
}
const options = {};
for (let i = 1; i < cliArgs.length; i++) {
const arg = cliArgs[i];
if (arg === '--catbox') options.service = 'catbox';
if (arg === '--litterbox') options.service = 'litterbox';
if (arg.startsWith('--time=')) options.time = arg.split('=')[1];
if (arg.startsWith('--userhash=')) options.userhash = arg.split('=')[1];
}
const res = await catbox(mainArg, options);
console.log(JSON.stringify(res, null, 2));
}
if (
process.argv[1] &&
(process.argv[1].endsWith('catbox-moe-scraper.js') ||
process.argv[1].endsWith('catbox-moe-scraper.mjs') ||
process.argv[1].endsWith('catbox-moe-scraper.cjs'))
) {
runCli().catch((err) => {
console.error(
JSON.stringify({ status: false, error: err.message }, null, 2)
);
process.exit(1);
});
}