Spaces:
Building
Building
import express from 'express'; | |
import unblocker from 'unblocker'; | |
import basicAuth from 'basic-auth'; | |
import faker from 'faker'; | |
import { Transform } from 'stream'; | |
import dns from 'dns'; | |
import http from 'http'; | |
import https from 'https'; | |
import { URL } from 'url'; | |
import httpProxy from 'http-proxy'; | |
import request from 'request'; // Consider replacing this with axios | |
import pick from 'lodash/pick'; | |
import { createProxyMiddleware } from 'http-proxy-middleware'; | |
import ytdl from 'ytdl-core'; | |
import axios from 'axios'; | |
import url from 'url'; // This seems redundant, you can use 'URL' directly | |
const LOGIN = 'usuario'; | |
const PASSWORD = 'clave'; | |
const MAIN_IP = '0.0.0.0'; | |
const PROXY_PORT = 7860; | |
const google_analytics_id = process.env.GA_ID || null; | |
let port = parseInt(process.env.PORT || ""); | |
const httpProxyServer = httpProxy.createProxyServer({}); | |
if (isNaN(port)) port = 8080; | |
let allowAllRequests = false; | |
// Contadores para las solicitudes y estados | |
let requestCount = 0; | |
const statusCounts = {}; | |
// Función para generar una IP residencial aleatoria con Faker | |
function generateRandomResidentialIP() { | |
return faker.internet.ip(); | |
} | |
// Función para incrementar el contador de solicitudes | |
function incrementRequestCount() { | |
requestCount++; | |
} | |
// Función para incrementar el contador de estados | |
function incrementStatusCount(statusCode) { | |
statusCounts[statusCode] = (statusCounts[statusCode] || 0) + 1; | |
} | |
app.use(express.json()); | |
app.use((req, res, next) => { | |
if (req.method === 'GET' || req.method === 'POST' || req.method === 'PUT' || req.method === 'CONNECT' || req.method === '' || req.method === '*') { | |
next(); | |
} else { | |
res.status(405).send('Method Not Allowed'); | |
} | |
}); | |
// Proxy para Instagram | |
// Middleware para simular un retraso opcional en las respuestas | |
// Aplicar el middleware de retraso a todas las rutas | |
// Iniciar el servidor | |
// Middleware para manejar el retraso | |
// Proxy handler para manejar las solicitudes a diferentes métodos HTTP | |
// Middleware para evitar la detección de spam (anti-spam detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar restricciones de CORS | |
res.setHeader('Access-Control-Allow-Origin', '*'); | |
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, CONNECT, OPTIONS'); | |
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization'); | |
// Permitir que las solicitudes OPTIONS pasen sin procesar | |
if (req.method === 'OPTIONS') { | |
res.sendStatus(200); | |
} else { | |
next(); | |
} | |
}); | |
// Middleware para evitar la detección de bloqueo de sitios (anti block sites detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bloqueo de sitios | |
res.setHeader('Accept-Language', 'en-US,en;q=0.9'); | |
next(); | |
}); | |
// Middleware para evitar la detección de fraudes en sitios (anti fraud sites detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de fraudes en sitios | |
res.setHeader('Referer', 'https://www.google.com/'); | |
next(); | |
}); | |
// Middleware para realizar solicitudes de manera incógnita/anónima | |
function incognitoMode(req, res, next) { | |
// Modificar headers para realizar solicitudes de manera incógnita | |
req.headers['User-Agent'] = faker.internet.userAgent(); | |
req.headers['X-Forwarded-For'] = generateRandomResidentialIP(); | |
req.headers['X-Forwarded-Proto'] = 'https'; | |
next(); | |
} | |
// Middleware para resolver el captcha de Google | |
function solveGoogleCaptcha(req, res, next) { | |
// Detectar la presencia del captcha de Google y eliminarlo si se detecta | |
if (res.getHeader('content-type') && res.getHeader('content-type').includes('text/html')) { | |
const data = []; | |
res.on('data', chunk => { | |
data.push(chunk); | |
}); | |
res.on('end', () => { | |
let html = Buffer.concat(data).toString(); | |
// Remover el captcha de Google si se detecta | |
html = html.replace(/<div class="g-recaptcha.*?<\/div>/gi, ''); | |
res.setHeader('content-length', Buffer.byteLength(html)); | |
res.end(html); | |
}); | |
} else { | |
next(); | |
} | |
} | |
// Middleware para resolver el captcha de Cloudflare | |
function solveCloudflareCaptcha(req, res, next) { | |
// Detectar la presencia del captcha de Cloudflare y eliminarlo si se detecta | |
if (res.getHeader('content-type') && res.getHeader('content-type').includes('text/html')) { | |
const data = []; | |
res.on('data', chunk => { | |
data.push(chunk); | |
}); | |
res.on('end', () => { | |
let html = Buffer.concat(data).toString(); | |
// Remover el captcha de Cloudflare si se detecta | |
html = html.replace(/<div class="g-recaptcha.*?<\/div>/gi, ''); | |
res.setHeader('content-length', Buffer.byteLength(html)); | |
res.end(html); | |
}); | |
} else { | |
next(); | |
} | |
} | |
// Middleware para resolver el captcha de hCaptcha | |
function solveHCaptcha(req, res, next) { | |
// Detectar la presencia del captcha de hCaptcha y eliminarlo si se detecta | |
if (res.getHeader('content-type') && res.getHeader('content-type').includes('text/html')) { | |
const data = []; | |
res.on('data', chunk => { | |
data.push(chunk); | |
}); | |
res.on('end', () => { | |
let html = Buffer.concat(data).toString(); | |
// Remover el captcha de hCaptcha si se detecta | |
html = html.replace(/<div class="h-captcha".*?<\/div>/gi, ''); | |
res.setHeader('content-length', Buffer.byteLength(html)); | |
res.end(html); | |
}); | |
} else { | |
next(); | |
} | |
} | |
// Middleware para resolver captchas automáticamente | |
app.use((req, res, next) => { | |
solveGoogleCaptcha(req, res, () => { | |
solveCloudflareCaptcha(req, res, () => { | |
solveHCaptcha(req, res, next); | |
}); | |
}); | |
}); | |
// Middleware para resolver el captcha de Cloudflare | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de Cloudflare si se detecta | |
client_res.removeHeader('cf-chl-bypass'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de hCaptcha | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de hCaptcha si se detecta | |
client_res.removeHeader('HCaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para detectar automáticamente las IPs de los sitios con unblocker | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Extraer la IP del servidor remoto de la URL de la solicitud | |
const remoteAddress = new URL(client_req.url).hostname; | |
console.log(`IP del sitio ${client_req.url}: ${remoteAddress}`); | |
next(); | |
}, | |
], | |
})); | |
// Middleware para detectar automáticamente las IPs de los sitios para procesar con unblocker | |
// Middleware para evitar la detección de proxy y simular solicitudes como un usuario real | |
app.use((req, res, next) => { | |
// Cambiar el agente de usuario | |
req.headers['User-Agent'] = faker.internet.userAgent(); | |
// Cambiar la dirección IP | |
const randomIp = faker.internet.ip(); | |
console.log(`IP simulada: ${randomIp}`); | |
req.headers['x-forwarded-for'] = randomIp; | |
// Agregar encabezados adicionales para simular solicitudes como un usuario real | |
req.headers['Accept-Language'] = 'en-US,en;q=0.9'; | |
req.headers['Referer'] = 'https://www.google.com/'; | |
next(); | |
}); | |
// Middleware para omitir el inicio de sesión en los sitios web | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Detectar y omitir las solicitudes de inicio de sesión | |
if (client_req.url.includes('login')) { | |
client_res.statusCode = 200; // Cambiar el estado de la respuesta a 200 OK | |
client_res.end('Inicio de sesión omitido'); // Finalizar la respuesta con un mensaje | |
} else { | |
next(); // Pasar al siguiente middleware si no es una solicitud de inicio de sesión | |
} | |
}, | |
], | |
})); | |
// Middleware para admitir el inicio de sesión en los sitios web | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Dejar pasar las solicitudes de inicio de sesión sin modificarlas | |
if (client_req.url.includes('login')) { | |
next(); // Pasar al siguiente middleware sin modificar la solicitud | |
} else { | |
next(); // Pasar al siguiente middleware si no es una solicitud de inicio de sesión | |
} | |
}, | |
], | |
})); | |
// Middleware para simular un "bypass" del inicio de sesión en los sitios web | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Simular un inicio de sesión automático enviando credenciales en la solicitud | |
if (client_req.url.includes('login')) { | |
// Modificar la solicitud para incluir las credenciales de inicio de sesión | |
client_req.setHeader('Authorization', 'Basic ' + Buffer.from('usuario:clave').toString('base64')); | |
} | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por múltiples filtros con unblocker | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por IP | |
client_req.removeHeader('X-Blocked-IP'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por spam | |
client_res.removeHeader('X-Spam-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por TOS | |
client_res.removeHeader('X-TOS-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por proxy | |
client_res.removeHeader('X-Proxy-Blocked'); | |
// Eliminar cualquier encabezado que indique censura | |
client_res.removeHeader('X-Censored'); | |
// Eliminar cualquier encabezado que indique bloqueo por hacking | |
client_res.removeHeader('X-Hacking-Blocked'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para detectar automáticamente las IPs de los sitios para procesar con unblocker | |
function proxy(req, res) { | |
request.get( | |
req.params.url, | |
{ | |
headers: { | |
...pick(req.headers, ['cookie', 'dnt', 'referer']), | |
'user-agent': 'Bandwidth-Hero Compressor', | |
'x-forwarded-for': req.headers['x-forwarded-for'] || req.ip, | |
via: '1.1 bandwidth-hero' | |
}, | |
timeout: 10000, | |
maxRedirects: 5, | |
encoding: null, | |
strictSSL: false, | |
gzip: true, | |
jar: true | |
}, | |
(err, origin, buffer) => { | |
if (err || origin.statusCode >= 400) return redirect(req, res) | |
copyHeaders(origin, res) | |
res.setHeader('content-encoding', 'identity') | |
req.params.originType = origin.headers['content-type'] || '' | |
req.params.originSize = buffer.length | |
if (shouldCompress(req)) { | |
compress(req, res, buffer) | |
} else { | |
bypass(req, res, buffer) | |
} | |
} | |
) | |
} | |
// Función para crear el servidor proxy | |
// Middleware para realizar solicitudes de manera incógnita | |
app.use(incognitoMode); | |
// Middleware para desbloquear sitios web (uncensored) | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests) { | |
client_res.removeHeader('Content-Security-Policy'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para bloquear anuncios (block ads) | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests) { | |
// Eliminar anuncios en las respuestas HTML | |
if (client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
let data = ''; | |
client_res.on('data', (chunk) => { | |
data += chunk.toString(); | |
}); | |
client_res.on('end', () => { | |
// Remover contenido de anuncios aquí (por ejemplo, usando regex) | |
const adFreeContent = data.replace(/<script.*?<\/script>/gi, ''); // Eliminar etiquetas de script | |
client_res.setHeader('content-length', Buffer.byteLength(adFreeContent)); | |
client_res.end(adFreeContent); | |
}); | |
} | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para cambiar las IP y evitar capturas (ip changer, bypass captcha) | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests) { | |
// Cambiar la IP y remover anti-captcha si se detecta | |
client_res.removeHeader('X-Captcha-solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para cambiar el User-Agent | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
client_req.headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36'; | |
next(); | |
}, | |
], | |
responseMiddleware: [], | |
})); | |
// Middleware para manejar las cookies | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests) { | |
// Incluir cookies en la solicitud | |
const cookies = client_req.headers.cookie; | |
if (cookies) { | |
client_req.setHeader('Cookie', cookies); | |
} | |
} | |
next(); | |
}, | |
], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests) { | |
// Pasar las cookies recibidas al cliente | |
const headers = client_res.getHeaders(); | |
if (headers['set-cookie']) { | |
client_res.setHeader('Set-Cookie', headers['set-cookie']); | |
} | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de Google | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de Google si se detecta | |
client_res.removeHeader('x-grecaptcha-response'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para procesar cualquier clase de URL | |
// app.use((req, res, next) => { | |
// const url = req.protocol + '://' + req.headers.host + req.originalUrl; | |
// console.log(`Processing URL: ${url}`); | |
// Procesar la URL aquí | |
// next(); | |
// }); | |
// Ruta para todas las solicitudes HTTP | |
app.all('*', (req, res, next) => { | |
// Permitir acceso sin autenticación si la opción allowAllRequests es verdadera | |
if (!allowAllRequests) { | |
const credentials = basicAuth(req, { realm: 'Proxy Access' }); | |
// Verificar si las credenciales son válidas si se proporcionan | |
if (credentials) { | |
if (credentials.name !== 'usuario' || credentials.pass !== 'clave') { | |
res.status(401).send('Acceso no autorizado'); | |
return; | |
} | |
} | |
} | |
// Establecer estado 200 OK para todas las respuestas | |
res.status(200); | |
// Capturar la URL para procesar la solicitud de páginas | |
// const url = req.protocol + '://' + req.headers.host + req.originalUrl; | |
// Capturar la IP del cliente | |
const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress; | |
// Llamar al middleware de node-unblocker para procesar la solicitud | |
unblocker.proxyRequest(req, res, { | |
headers: { | |
'Custom-Header': 'Valor personalizado', | |
// Agregar aquí todos los headers que desees enviar en cada solicitud | |
} | |
}).then(() => { | |
// Mostrar el estado y la respuesta de la solicitud | |
console.log(`[${new Date().toISOString()}] ${req.method} ${url} - IP: ${ip} - Status: ${res.statusCode}`); | |
incrementStatusCount(res.statusCode); | |
}).catch((err) => { | |
console.error('Error en la solicitud al servidor:', err); | |
res.status(500).send('Error interno del servidor'); | |
}); | |
}); | |
// Iniciar el servidor proxy | |
// Función para crear un servidor HTTP o API | |
function createServer() { | |
// Ruta de ejemplo para la API | |
app.get('/api/example', (req, res) => { | |
res.status(200).json({ message: 'This is an example API endpoint' }); | |
}); | |
// Ruta para la página de estadísticas | |
app.get('/stats', (req, res) => { | |
res.send(` | |
<h1>Proxy Stats</h1> | |
<p>Total Requests: ${requestCount}</p> | |
<p>Status Counts:</p> | |
<ul> | |
${Object.keys(statusCounts).map(status => `<li>${status}: ${statusCounts[status]}</li>`).join('')} | |
</ul> | |
`); | |
}); | |
// Iniciar el servidor HTTP o API | |
// app.listen(PROXY_PORT, MAIN_IP, () => { | |
// console.log(`HTTP server listening on ${MAIN_IP}:${PROXY_PORT}`); | |
// }); | |
} | |
//app.use(unblocker()); | |
//app.use(unblocker()); | |
app.use((req, res, next) => { | |
httpProxyServer.web(req, res, { target: req.url }); | |
}); | |
app.use((req, res, next) => { | |
if (allowAllRequests) { | |
// Procesar todas las solicitudes sin autenticación | |
app.web(req, res, { target: req.url, changeOrigin: true }); | |
} else { | |
const credentials = auth(req); | |
if (!credentials || credentials.name !== LOGIN || credentials.pass !== PASSWORD) { | |
res.statusCode = 401; | |
res.setHeader('WWW-Authenticate', 'Basic realm="example"'); | |
res.end('Access denied'); | |
} else { | |
// Procesar solicitudes autenticadas | |
app.web(req, res, { target: req.url, changeOrigin: true }); | |
} | |
} | |
}); | |
// Function to create an HTTPS server with SSL certificate | |
function authenticate(req, res, next) { | |
if (LOGIN && PASSWORD) { | |
const credentials = auth(req) | |
if (!credentials || credentials.name !== LOGIN || credentials.pass !== PASSWORD) { | |
res.setHeader('WWW-Authenticate', `Basic realm="Bandwidth-Hero Compression Service"`) | |
return res.status(401).end('Access denied') | |
} | |
} | |
next() | |
} | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests) { | |
client_res.removeHeader('Content-Security-Policy'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para evitar capturas (anti-captcha) | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests) { | |
// Remover anti-captcha si se detecta | |
client_res.removeHeader('X-Captcha'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para evitar la censura (anti-censored) | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests) { | |
// Remover headers de censura | |
client_res.removeHeader('X-Censored'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para habilitar la reproducción automática en YouTube e Instagram | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Habilitar la reproducción automática en YouTube | |
if (client_req.url.includes('youtube.com')) { | |
client_res.removeHeader('youtube-restrictions'); | |
} | |
// Habilitar la reproducción automática en Instagram | |
if (client_req.url.includes('instagram.com')) { | |
client_res.removeHeader('instagram-restrictions'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar un "bypass" al bloqueo de IP en sitios web | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Extraer la URL del sitio web de la solicitud | |
const url = new URL(client_req.url); | |
const hostname = url.hostname; | |
// Modificar las solicitudes para evitar el bloqueo de IP | |
if (!client_req.url.includes('login')) { // Evitar cambios en las solicitudes de inicio de sesión | |
// Cambiar la dirección IP de origen en los encabezados de la solicitud | |
const fakeIp = faker.internet.ip(); | |
client_req.headers['x-forwarded-for'] = fakeIp; | |
} | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por IP | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Extraer la URL del sitio web de la solicitud | |
const url = new URL(client_req.url); | |
const hostname = url.hostname; | |
// Modificar las solicitudes para evitar el bloqueo de IP | |
if (!client_req.url.includes('login')) { // Evitar cambios en las solicitudes de inicio de sesión | |
// Eliminar cualquier encabezado que indique una IP bloqueada | |
client_req.removeHeader('X-Blocked-IP'); | |
// Opcionalmente, simular una dirección IP diferente | |
const fakeIp = faker.internet.ip(); | |
client_req.headers['x-forwarded-for'] = fakeIp; | |
} | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para desbloquear sitios bloqueados por censura | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier indicio de censura en las respuestas | |
if (!client_req.url.includes('login')) { // Evitar cambios en las respuestas de inicio de sesión | |
// Eliminar encabezados que indiquen censura | |
client_res.removeHeader('X-Censored'); | |
} | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para desbloquear sitios bloqueados por censura | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Verificar si la respuesta está bloqueada por censura | |
if (client_res.statusCode === 403 && client_res.statusMessage === 'Forbidden') { | |
// Modificar la respuesta para eliminar la censura | |
let data = ''; | |
client_res.on('data', (chunk) => { | |
data += chunk.toString(); | |
}); | |
client_res.on('end', () => { | |
const uncensoredContent = data.replace(/censored/gi, ''); // Eliminar palabras censuradas | |
client_res.setHeader('content-length', Buffer.byteLength(uncensoredContent)); | |
client_res.end(uncensoredContent); | |
}); | |
} else { | |
next(); // Pasar al siguiente middleware si no está bloqueado por censura | |
} | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por censura | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique censura | |
client_res.removeHeader('X-Censored'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por múltiples filtros con unblocker | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por IP | |
client_req.removeHeader('X-Blocked-IP'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por spam | |
client_res.removeHeader('X-Spam-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por TOS | |
client_res.removeHeader('X-TOS-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por proxy | |
client_res.removeHeader('X-Proxy-Blocked'); | |
// Eliminar cualquier encabezado que indique censura | |
client_res.removeHeader('X-Censored'); | |
// Eliminar cualquier encabezado que indique bloqueo por hacking | |
client_res.removeHeader('X-Hacking-Blocked'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
app.use((req, res, next) => { | |
const { url, method, headers } = req; | |
try { | |
// Parsear la URL de origen | |
const targetUrl = new URL(url); | |
// Obtener protocolo | |
const protocol = targetUrl.protocol === 'https:' ? https : http; | |
// Obtener el puerto | |
let port = targetUrl.port || (protocol === https ? 443 : 80); | |
// Construir opciones para la solicitud proxy | |
const options = { | |
hostname: targetUrl.hostname, | |
port, | |
path: targetUrl.pathname + targetUrl.search + targetUrl.hash, | |
method, | |
headers, | |
}; | |
// Realizar la solicitud proxy | |
const proxyReq = protocol.request(options, proxyRes => { | |
// Capturar toda la respuesta del servidor proxy | |
let responseBody = ''; | |
proxyRes.setEncoding('utf8'); | |
proxyRes.on('data', chunk => { | |
responseBody += chunk; | |
}); | |
proxyRes.on('end', () => { | |
// Enviar la respuesta completa al cliente original | |
res.status(proxyRes.statusCode); | |
res.set(proxyRes.headers); | |
res.send(responseBody); | |
}); | |
}); | |
// Capturar errores de la solicitud proxy | |
proxyReq.on('error', err => { | |
console.error('Error en la solicitud proxy:', err); | |
res.status(500).send('Error en el proxy'); | |
}); | |
// Transmitir el cuerpo de la solicitud original al servidor proxy (si lo hay) | |
req.pipe(proxyReq); | |
} catch (error) { | |
console.error('Error al procesar la URL:', error); | |
res.status(400).send('URL inválida'); | |
} | |
}); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por IP | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique una IP bloqueada | |
client_req.removeHeader('X-Blocked-IP'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por spam, IP, TOS o proxy | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por IP | |
client_req.removeHeader('X-Blocked-IP'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por spam | |
client_res.removeHeader('X-Spam-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por TOS | |
client_res.removeHeader('X-TOS-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por proxy | |
client_res.removeHeader('X-Proxy-Blocked'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por múltiples filtros con unblocker | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por IP | |
client_req.removeHeader('X-Blocked-IP'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por spam | |
client_res.removeHeader('X-Spam-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por TOS | |
client_res.removeHeader('X-TOS-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por proxy | |
client_res.removeHeader('X-Proxy-Blocked'); | |
// Eliminar cualquier encabezado que indique censura | |
client_res.removeHeader('X-Censored'); | |
// Eliminar cualquier encabezado que indique bloqueo por hacking | |
client_res.removeHeader('X-Hacking-Blocked'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por múltiples filtros con unblocker | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por IP | |
client_req.removeHeader('X-Blocked-IP'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por spam | |
client_res.removeHeader('X-Spam-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por TOS | |
client_res.removeHeader('X-TOS-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por proxy | |
client_res.removeHeader('X-Proxy-Blocked'); | |
// Eliminar cualquier encabezado que indique censura | |
client_res.removeHeader('X-Censored'); | |
// Eliminar cualquier encabezado que indique bloqueo por hacking | |
client_res.removeHeader('X-Hacking-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por protección | |
client_res.removeHeader('X-Protection-Blocked'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para desbloquear sitios bloqueados por múltiples filtros con unblocker | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por IP | |
client_req.removeHeader('X-Blocked-IP'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por spam | |
client_res.removeHeader('X-Spam-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por TOS | |
client_res.removeHeader('X-TOS-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por proxy | |
client_res.removeHeader('X-Proxy-Blocked'); | |
// Eliminar cualquier encabezado que indique censura | |
client_res.removeHeader('X-Censored'); | |
// Eliminar cualquier encabezado que indique bloqueo por hacking | |
client_res.removeHeader('X-Hacking-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por protección adicional | |
client_res.removeHeader('X-Protection-Blocked'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para resolver captchas automáticamente | |
app.use((req, res, next) => { | |
solveGoogleCaptcha(req, res, () => { | |
solveCloudflareCaptcha(req, res, () => { | |
solveHCaptcha(req, res, next); | |
}); | |
}); | |
}); | |
// Middleware para detectar automáticamente las IPs de los sitios para procesar con unblocker | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests) { | |
client_res.removeHeader('Content-Security-Policy'); | |
} | |
next(); | |
}, | |
], | |
})); | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests) { | |
// Eliminar anuncios en las respuestas HTML | |
if (client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
let data = ''; | |
client_res.on('data', (chunk) => { | |
data += chunk.toString(); | |
}); | |
client_res.on('end', () => { | |
// Remover contenido de anuncios aquí (por ejemplo, usando regex) | |
const adFreeContent = data.replace(/<script.*?<\/script>/gi, ''); // Eliminar etiquetas de script | |
client_res.setHeader('content-length', Buffer.byteLength(adFreeContent)); | |
client_res.end(adFreeContent); | |
}); | |
} | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar solicitudes de manera incógnita/anónima | |
// Middleware para resolver captchas automáticamente | |
app.use((req, res, next) => { | |
solveGoogleCaptcha(req, res, () => { | |
solveCloudflareCaptcha(req, res, () => { | |
next(); | |
}); | |
}); | |
}); | |
// Middleware para evitar la detección de adblockers | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de adblockers | |
res.setHeader('X-Adblock-Test', 'success'); | |
next(); | |
}); | |
// Middleware para cambiar la IP (ip changer) | |
app.use((req, res, next) => { | |
// Cambiar la IP de la solicitud | |
req.ip = getRandomIP(); | |
next(); | |
}); | |
// Middleware para cambiar el User-Agent (user agent changer) | |
app.use((req, res, next) => { | |
// Cambiar el User-Agent de la solicitud | |
req.headers['User-Agent'] = getRandomUserAgent(); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes concurrentes (concurrent request blocking) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes concurrentes | |
res.setHeader('Connection', 'keep-alive'); | |
next(); | |
}); | |
// Middleware para evitar la detección de bots (bot detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bots | |
res.setHeader('X-Robots-Tag', 'noindex, nofollow'); | |
next(); | |
}); | |
// Middleware para evitar el rastreo (anti tracking) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el rastreo | |
res.setHeader('DNT', '1'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de IP (ip blocking) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de IP | |
res.setHeader('X-Forwarded-For', getRandomIP()); | |
next(); | |
}); | |
// Middleware para el análisis y el registro de solicitudes | |
// Middleware para la gestión de errores | |
app.use((err, req, res, next) => { | |
// Manejar errores aquí | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (rate limiting) | |
app.use((req, res, next) => { | |
// Verificar límite de solicitudes aquí | |
next(); | |
}); | |
// Middleware para evitar la detección de bots (anti-bot detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bots | |
res.setHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (anti-request limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('Accept-Encoding', 'gzip, deflate, br'); | |
next(); | |
}); | |
// Middleware para la gestión de errores personalizada | |
// Middleware para evitar la detección de bots (bot prevention) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bots | |
res.setHeader('Connection', 'keep-alive'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (anti-rate limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('Cache-Control', 'no-cache'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (request limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('Pragma', 'no-cache'); | |
next(); | |
}); | |
// Middleware para evitar la detección de bots (anti-bot detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bots | |
res.setHeader('Accept-Language', 'en-US,en;q=0.9'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (rate limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('X-Requested-With', 'XMLHttpRequest'); | |
next(); | |
}); | |
// Middleware para evitar la detección de bots (anti-bot detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bots | |
res.setHeader('Access-Control-Allow-Credentials', 'true'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (rate limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('Access-Control-Allow-Headers', 'Content-Type'); | |
next(); | |
}); | |
// Middleware para evitar la detección de bots (bot evasion) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bots | |
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (request limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('Access-Control-Allow-Origin', '*'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (anti-request limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('Access-Control-Expose-Headers', 'Content-Length'); | |
next(); | |
}); | |
// Middleware para evitar la detección de bots (anti-bot detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bots | |
res.setHeader('Access-Control-Max-Age', '3600'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (rate limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('Access-Control-Request-Headers', 'Content-Type, Authorization'); | |
next(); | |
}); | |
// Middleware para evitar la detección de bots (anti-bot detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bots | |
res.setHeader('Access-Control-Request-Method', 'GET, POST, PUT, DELETE, OPTIONS'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (anti-request limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('Origin', 'http://example.com'); | |
next(); | |
}); | |
// Middleware para evitar la detección de bots (anti-bot detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bots | |
res.setHeader('Sec-Fetch-Dest', 'document'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (rate limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('Sec-Fetch-Mode', 'navigate'); | |
next(); | |
}); | |
// Middleware para evitar la detección de bots (anti-bot detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bots | |
res.setHeader('Sec-Fetch-Site', 'cross-site'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (request limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('Sec-Fetch-User', '?1'); | |
next(); | |
}); | |
// Middleware para evitar la detección de bots (anti-bot detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bots | |
res.setHeader('Upgrade-Insecure-Requests', '1'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (rate limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'); | |
next(); | |
}); | |
// Middleware para evitar la detección de bots (anti-bot detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bots | |
res.setHeader('Accept-Encoding', 'gzip, deflate, br'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (anti-request limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('Accept-Language', 'en-US,en;q=0.9'); | |
next(); | |
}); | |
// Middleware para evitar la detección de bots (anti-bot detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bots | |
res.setHeader('Cookie', 'sessionId=12345'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (rate limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('Cache-Control', 'max-age=0'); | |
next(); | |
}); | |
// Middleware para evitar la detección de bots (anti-bot detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bots | |
res.setHeader('Host', 'www.example.com'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (request limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('Referer', 'http://www.example.com/'); | |
next(); | |
}); | |
// Middleware para evitar la detección de bots (anti-bot detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de bots | |
res.setHeader('Upgrade-Insecure-Requests', '1'); | |
next(); | |
}); | |
// Middleware para evitar el bloqueo de solicitudes excesivas (rate limiting) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar el bloqueo de solicitudes excesivas | |
res.setHeader('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'); | |
next(); | |
}); | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests) { | |
client_res.removeHeader('Content-Security-Policy'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver captchas automáticamente | |
app.use((req, res, next) => { | |
solveGoogleCaptcha(req, res, () => { | |
solveCloudflareCaptcha(req, res, () => { | |
solveHCaptcha(req, res, next); | |
}); | |
}); | |
}); | |
// Middleware para cambiar el agente de usuario y la dirección IP simulada | |
app.use((req, res, next) => { | |
req.headers['User-Agent'] = faker.internet.userAgent(); | |
const randomIp = faker.internet.ip(); | |
req.headers['x-forwarded-for'] = randomIp; | |
req.headers['Accept-Language'] = 'en-US,en;q=0.9'; | |
req.headers['Referer'] = 'https://www.google.com/'; | |
next(); | |
}); | |
// Middleware para hacer clic automático en el botón de reproducción en YouTube e Instagram | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
let data = ''; | |
client_res.on('data', (chunk) => { | |
data += chunk.toString(); | |
}); | |
client_res.on('end', () => { | |
if (client_req.url.includes('youtube.com')) { | |
data = data.replace('playButton', 'playButton.click()'); | |
} | |
if (client_req.url.includes('instagram.com')) { | |
data = data.replace('playButton', 'playButton.click()'); | |
} | |
client_res.setHeader('content-length', Buffer.byteLength(data)); | |
client_res.end(data); | |
}); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por país | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-Country-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por cookies | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-Cookie-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por JS | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-JS-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por WebGL | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-WebGL-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por WebRTC | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-WebRTC-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por seguridad del servidor | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-Server-Security-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por el cortafuegos | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-Firewall-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por el ISP | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-ISP-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por el cortafuegos del navegador | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-Browser-Firewall-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por el cortafuegos del servidor | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-Server-Firewall-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por el cortafuegos del ISP | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-ISP-Firewall-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests) { | |
client_res.removeHeader('Content-Security-Policy'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver captchas automáticamente | |
app.use((req, res, next) => { | |
solveGoogleCaptcha(req, res, () => { | |
solveCloudflareCaptcha(req, res, () => { | |
solveHCaptcha(req, res, next); | |
}); | |
}); | |
}); | |
// Middleware para cambiar el agente de usuario y la dirección IP simulada | |
app.use((req, res, next) => { | |
req.headers['User-Agent'] = faker.internet.userAgent(); | |
const randomIp = faker.internet.ip(); | |
req.headers['x-forwarded-for'] = randomIp; | |
req.headers['Accept-Language'] = 'en-US,en;q=0.9'; | |
req.headers['Referer'] = 'https://www.google.com/'; | |
next(); | |
}); | |
// Middleware para hacer clic automático en el botón de reproducción en YouTube e Instagram | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
let data = ''; | |
client_res.on('data', (chunk) => { | |
data += chunk.toString(); | |
}); | |
client_res.on('end', () => { | |
if (client_req.url.includes('youtube.com')) { | |
data = data.replace('playButton', 'playButton.click()'); | |
} | |
if (client_req.url.includes('instagram.com')) { | |
data = data.replace('playButton', 'playButton.click()'); | |
} | |
client_res.setHeader('content-length', Buffer.byteLength(data)); | |
client_res.end(data); | |
}); | |
}, | |
], | |
})); | |
// Middleware para realizar un "bypass" de la detección de IP | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_req.headers['x-forwarded-for'] = faker.internet.ip();; | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por agente de usuario | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
client_req.headers['User-Agent'] = faker.internet.userAgent(); | |
next(); | |
}, | |
], | |
responseMiddleware: [], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por navegador | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-Browser-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por JS | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-JS-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por WebGL | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-WebGL-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por WebRTC | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-WebRTC-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por cookies de terceros | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-3rd-Party-Cookie-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por el contenido mixto | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-Mixed-Content-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por seguridad del navegador | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-Browser-Security-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por el proxy | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-Proxy-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por el servidor DNS | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-DNS-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por la red | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-Network-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por el cortafuegos de la red | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (!client_req.url.includes('login')) { | |
client_res.removeHeader('X-Network-Firewall-Block'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar solicitudes de manera incógnita/anónima | |
app.use((req, res, next) => { | |
solveGoogleCaptcha(req, res, () => { | |
solveCloudflareCaptcha(req, res, () => { | |
solveHCaptcha(req, res, next); | |
}); | |
}); | |
}); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por censura | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique censura | |
client_res.removeHeader('X-Censored'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para desbloquear sitios bloqueados por múltiples filtros con unblocker | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por IP | |
client_req.removeHeader('X-Blocked-IP'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por spam | |
client_res.removeHeader('X-Spam-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por TOS | |
client_res.removeHeader('X-TOS-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por proxy | |
client_res.removeHeader('X-Proxy-Blocked'); | |
// Eliminar cualquier encabezado que indique censura | |
client_res.removeHeader('X-Censored'); | |
// Eliminar cualquier encabezado que indique bloqueo por hacking | |
client_res.removeHeader('X-Hacking-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por protección adicional | |
client_res.removeHeader('X-Protection-Blocked'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por spam, IP, TOS o proxy | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por IP | |
client_req.removeHeader('X-Blocked-IP'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por spam | |
client_res.removeHeader('X-Spam-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por TOS | |
client_res.removeHeader('X-TOS-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por proxy | |
client_res.removeHeader('X-Proxy-Blocked'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por múltiples filtros con unblocker | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por IP | |
client_req.removeHeader('X-Blocked-IP'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por spam | |
client_res.removeHeader('X-Spam-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por TOS | |
client_res.removeHeader('X-TOS-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por proxy | |
client_res.removeHeader('X-Proxy-Blocked'); | |
// Eliminar cualquier encabezado que indique censura | |
client_res.removeHeader('X-Censored'); | |
// Eliminar cualquier encabezado que indique bloqueo por hacking | |
client_res.removeHeader('X-Hacking-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por protección adicional | |
client_res.removeHeader('X-Protection-Blocked'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de FunCaptcha | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de FunCaptcha si se detecta | |
client_res.removeHeader('FunCaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de Coinhive | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de Coinhive si se detecta | |
client_res.removeHeader('Coinhive-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de Coinhive | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de Coinhive si se detecta | |
client_res.removeHeader('Coinhive-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de SolveMedia | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de SolveMedia si se detecta | |
client_res.removeHeader('SolveMedia-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de anti-bot.js | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de anti-bot.js si se detecta | |
client_res.removeHeader('Anti-Bot-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de Funcaptcha | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de Funcaptcha si se detecta | |
client_res.removeHeader('Funcaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de ArkoseLabs | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de ArkoseLabs si se detecta | |
client_res.removeHeader('ArkoseLabs-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de distilnetworks | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de distilnetworks si se detecta | |
client_res.removeHeader('DistilNetworks-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de imagecaptcha | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de imagecaptcha si se detecta | |
client_res.removeHeader('ImageCaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de keycaptcha | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de keycaptcha si se detecta | |
client_res.removeHeader('KeyCaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de soundcaptcha | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de soundcaptcha si se detecta | |
client_res.removeHeader('SoundCaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de tiktokcaptcha | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de tiktokcaptcha si se detecta | |
client_res.removeHeader('TikTokCaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de qqcaptcha | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de qqcaptcha si se detecta | |
client_res.removeHeader('QQCaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de recaptcha3 | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de recaptcha3 si se detecta | |
client_res.removeHeader('Recaptcha3-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para realizar solicitudes de manera incógnita/anónima | |
app.use((req, res, next) => { | |
solveGoogleCaptcha(req, res, () => { | |
solveCloudflareCaptcha(req, res, () => { | |
solveHCaptcha(req, res, next); | |
}); | |
}); | |
}); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por censura | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique censura | |
client_res.removeHeader('X-Censored'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para desbloquear sitios bloqueados por múltiples filtros con unblocker | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por IP | |
client_req.removeHeader('X-Blocked-IP'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por spam | |
client_res.removeHeader('X-Spam-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por TOS | |
client_res.removeHeader('X-TOS-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por proxy | |
client_res.removeHeader('X-Proxy-Blocked'); | |
// Eliminar cualquier encabezado que indique censura | |
client_res.removeHeader('X-Censored'); | |
// Eliminar cualquier encabezado que indique bloqueo por hacking | |
client_res.removeHeader('X-Hacking-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por protección adicional | |
client_res.removeHeader('X-Protection-Blocked'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por spam, IP, TOS o proxy | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por IP | |
client_req.removeHeader('X-Blocked-IP'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por spam | |
client_res.removeHeader('X-Spam-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por TOS | |
client_res.removeHeader('X-TOS-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por proxy | |
client_res.removeHeader('X-Proxy-Blocked'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para realizar el desbloqueo de sitios bloqueados por múltiples filtros con unblocker | |
app.use(unblocker({ | |
requestMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por IP | |
client_req.removeHeader('X-Blocked-IP'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
// Eliminar cualquier encabezado que indique bloqueo por spam | |
client_res.removeHeader('X-Spam-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por TOS | |
client_res.removeHeader('X-TOS-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por proxy | |
client_res.removeHeader('X-Proxy-Blocked'); | |
// Eliminar cualquier encabezado que indique censura | |
client_res.removeHeader('X-Censored'); | |
// Eliminar cualquier encabezado que indique bloqueo por hacking | |
client_res.removeHeader('X-Hacking-Blocked'); | |
// Eliminar cualquier encabezado que indique bloqueo por protección adicional | |
client_res.removeHeader('X-Protection-Blocked'); | |
next(); // Pasar al siguiente middleware | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de reCAPTCHA | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de reCAPTCHA si se detecta | |
client_res.removeHeader('X-Recaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de FunCaptcha | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de FunCaptcha si se detecta | |
client_res.removeHeader('FunCaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de Coinhive | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de Coinhive si se detecta | |
client_res.removeHeader('Coinhive-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de Coinhive | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de Coinhive si se detecta | |
client_res.removeHeader('Coinhive-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de SolveMedia | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de SolveMedia si se detecta | |
client_res.removeHeader('SolveMedia-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de anti-bot.js | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de anti-bot.js si se detecta | |
client_res.removeHeader('Anti-Bot-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de Funcaptcha | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de Funcaptcha si se detecta | |
client_res.removeHeader('Funcaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de ArkoseLabs | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de ArkoseLabs si se detecta | |
client_res.removeHeader('ArkoseLabs-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de distilnetworks | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de distilnetworks si se detecta | |
client_res.removeHeader('DistilNetworks-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de imagecaptcha | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de imagecaptcha si se detecta | |
client_res.removeHeader('ImageCaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de keycaptcha | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de keycaptcha si se detecta | |
client_res.removeHeader('KeyCaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de soundcaptcha | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de soundcaptcha si se detecta | |
client_res.removeHeader('SoundCaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de tiktokcaptcha | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de tiktokcaptcha si se detecta | |
client_res.removeHeader('TikTokCaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de qqcaptcha | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de qqcaptcha si se detecta | |
client_res.removeHeader('QQCaptcha-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para resolver el captcha de recaptcha3 | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
// Remover el captcha de recaptcha3 si se detecta | |
client_res.removeHeader('Recaptcha3-Solver'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para desbloquear sitios web (uncensored) | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests) { | |
client_res.removeHeader('Content-Security-Policy'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para Google Analytics | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && google_analytics_id && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
client_res.pipe(new Transform({ | |
decodeStrings: false, | |
transform: function (chunk, encoding, next) { | |
this.push(addGa(chunk.toString())); | |
next(); | |
} | |
})).pipe(client_res); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para la autenticación básica | |
app.use((req, res, next) => { | |
const credentials = auth(req); | |
if (!credentials || credentials.name !== LOGIN || credentials.pass !== PASSWORD) { | |
res.statusCode = 401; | |
res.setHeader('WWW-Authenticate', 'Basic realm="example"'); | |
res.end('Access denied'); | |
} else { | |
next(); | |
} | |
}); | |
// Inicio del servidor | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests) { | |
client_res.removeHeader('Content-Security-Policy'); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para Google Analytics | |
app.use(unblocker({ | |
requestMiddleware: [], | |
responseMiddleware: [ | |
(client_req, client_res, next) => { | |
if (allowAllRequests && google_analytics_id && client_res.getHeader('content-type') && client_res.getHeader('content-type').includes('text/html')) { | |
client_res.pipe(new Transform({ | |
decodeStrings: false, | |
transform: function (chunk, encoding, next) { | |
this.push(addGa(chunk.toString())); | |
next(); | |
} | |
})).pipe(client_res); | |
} | |
next(); | |
}, | |
], | |
})); | |
// Middleware para contar las solicitudes y los estados | |
app.use((req, res, next) => { | |
incrementRequestCount(); | |
next(); | |
}); | |
// Middleware para evitar la detección de proxy (anti proxy detection) | |
app.use((req, res, next) => { | |
// Modificar headers para evitar la detección de proxy | |
res.setHeader('Via', '1.1 example.com'); | |
next(); | |
}); | |
// Middleware para evitar la detección de bots (anti bot detection) | |
app.use((req, res, next) => { | |
res.setHeader('X-Forwarded-For', faker.internet.ip()); | |
next(); | |
}); | |
// Middleware para la autenticación básica | |
app.use((req, res, next) => { | |
const credentials = auth(req); | |
if (!credentials || credentials.name !== LOGIN || credentials.pass !== PASSWORD) { | |
res.statusCode = 401; | |
res.setHeader('WWW-Authenticate', 'Basic realm="example"'); | |
res.end('Access denied'); | |
} else { | |
next(); | |
} | |
}); | |
// Función para validar la URL | |
function bypassSSLCertificateVerification() { | |
https.globalAgent.options.rejectUnauthorized = false; | |
} | |
// Crear el servidor proxy | |
// Crear el servidor HTTP o API | |
createServer(); | |
bypassSSLCertificateVerification(); | |
app.on("listening", () => { | |
const address = server.address(); | |
// by default we are listening on 0.0.0.0 (every interface) | |
// we just need to list a few | |
console.log("Listening on:"); | |
console.log(`\thttp://localhost:${address.port}`); | |
console.log(`\thttp://${hostname()}:${address.port}`); | |
console.log( | |
`\thttp://${address.family === "IPv6" ? `[${address.address}]` : address.address | |
}:${address.port}` | |
); | |
}); | |
// https://expressjs.com/en/advanced/healthcheck-graceful-shutdown.html | |
process.on("SIGINT", shutdown); | |
process.on("SIGTERM", shutdown); | |
function shutdown() { | |
console.log("SIGTERM signal received: closing HTTP server"); | |
server.close(); | |
process.exit(0); | |
} | |
app.use((err, req, res, next) => { | |
if (!err) return next(); // Si no hay error, pasa al siguiente middleware | |
console.error(err.stack); // Imprime el error en la consola | |
res.status(500).send('Error interno del servidor'); // Envía una respuesta de error al cliente | |
}); | |
app.all('', (req, res) => { | |
var id1 = req.url.replace('/clone-website/', ''); | |
var cloneurl = new URL(atob(id1)); | |
req.session.user = cloneurl.origin; | |
res.redirect(cloneurl.href.slice(cloneurl.origin.length, cloneurl.href.length)); | |
}); | |
if (auth == 'true') { | |
app.use(basicAuth({ | |
users, | |
challenge: true, | |
unauthorizedResponse: autherror | |
})); | |
} | |
app.get('/watch', (req, res) => { | |
var url = 'https://www.youtube.com/watch?v=' + req.query.v; | |
if (req.query.audio !== 'true') { | |
ytdl(url).on('response', response => { | |
res.setHeader('content-length', response.headers['content-length']); | |
}).pipe(res); | |
} else { | |
ytdl(url, { filter: 'audioonly' }).on('response', response => { | |
res.setHeader('content-length', response.headers['content-length']); | |
}).pipe(res); | |
} | |
}); | |
if (auth == 'true') { | |
app.use(basicAuth({ | |
users, | |
challenge: true, | |
unauthorizedResponse: autherror | |
})); | |
} | |
app.set('port', unblocker); | |
app.on('upgrade', (request, socket, head) => { | |
wss.handleUpgrade(request, socket, head, ws => { | |
wss.emit('connection', ws, request); | |
}); | |
}); | |
app.use(unblocker); | |
app.get('/go/:url', (req, res) => { | |
var url = decodeURIComponent(req.params.url); | |
}); | |
app.get('/go', (req, res) => { | |
var url = req.query.url; | |
if (!url) { | |
return res.status(400).send('Missing URL parameter'); | |
} | |
var proxyUrl = `/go/${ encodeURIComponent(url) }`; | |
res.redirect(proxyUrl); | |
}); | |
app.get('/service/:url', (req, res) => res.redirect('/proxy/' + req.params.url)); | |
app.get('*', function (req, res) { | |
res.status(404).send('Page Not Found'); | |
}); | |
app.use(unblocker({ | |
secret: 'Url', | |
resave: false, | |
saveUninitialized: true | |
})); | |
app.get('/no-js', function (req, res) { | |
var site = querystring.parse(url.parse(req.url).query).url; | |
res.redirect(unblockerConfig.prefix + site); | |
}); | |
app.use(new unblocker({ prefix: '/@/' })); | |
app.get('/@/', function (req, res) { | |
miniCPU(); | |
}); | |
app.get('', function (req, res) { | |
res.send('<style>*{font-family: sans-serif;background-color:black;color:aqua;}</style><center><h1>ProxyChief</h1><hr/><h2>HTTP & HTTPS Proxy. <br/>More protocols, coming soon.</h2><hr/><h3>Proxy Format: <b><a href="/@/example.com">/@/https://youngchief.tk/</a></b></h3><hr><p><strong>This proxy is made to be the very best, and is super lightweight, secure, and speedy.<br/><a href="https://github.com/youngchief-btw/ProxyChief">Want to see the GitHub?</a></strong><br/><strong>Access ProxyChief using any of these <a href="https://github.com/youngchief-btw/ProxyChief/blob/master/ListOfInstances.txt">URLs</a></strong></p><hr/><strong>Made by <a href="/@/https://youngchief.tk/">youngchief btw ツ</a>, with \u2764️</strong></center>'); | |
}); | |
app.use(unblocker({})); | |
//app.use(unblocker()); | |
app.listen({ | |
port, | |
}); | |
app.enable('trust proxy') | |
app.get('/', authenticate) | |
app.get('/favicon', (req, res) => res.status(200).end()) | |
app.all('/*'); | |
app.all('/'); | |
app.all(''); | |
app.all('*'); | |
app.use((req, res, next) => { | |
const parsedUrl = url.parse(req.url); | |
const targetUrl = `${parsedUrl.protocol}//${parsedUrl.host}${parsedUrl.path}`; | |
const proxyReq = parsedUrl.protocol === 'https:' ? https.request : http.request; | |
const options = { | |
method: req.method, | |
headers: req.headers, | |
hostname: parsedUrl.hostname, | |
port: parsedUrl.port || (parsedUrl.protocol === 'https:' ? 443 : 80), | |
path: parsedUrl.path, | |
}; | |
const proxy = proxyReq(options, (proxyRes) => { | |
res.writeHead(proxyRes.statusCode, proxyRes.headers); | |
proxyRes.pipe(res, { | |
end: true | |
}); | |
}); | |
req.pipe(proxy, { | |
end: true | |
}); | |
}); | |
app.listen(process.env.PORT || 7860, () => { | |
console.log(`Server is running on port ${process.env.PORT || 7860}`); | |
}); |