File size: 9,667 Bytes
a1ba13e 289c1a7 a1ba13e 289c1a7 a1ba13e 289c1a7 a1ba13e 289c1a7 a1ba13e 289c1a7 a1ba13e 289c1a7 a1ba13e 289c1a7 a1ba13e 289c1a7 a1ba13e 289c1a7 a1ba13e 289c1a7 a1ba13e 289c1a7 a1ba13e 289c1a7 a1ba13e 289c1a7 a1ba13e 289c1a7 a1ba13e 289c1a7 a1ba13e 289c1a7 | 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 | import express from "express";
import axios from "axios";
import cors from "cors";
const app = express();
// Enable CORS for all routes
app.use(cors());
// Parse JSON bodies
app.use(express.json());
// Health check
app.get("/", (req, res) => res.send("π₯ Advanced Proxy Server Live"));
// Main proxy endpoint with aggressive spoofing
app.get("/proxy", async (req, res) => {
const { url, matchId, home, away, referer } = req.query;
if (!url) return res.status(400).send("β Missing ?url param");
const targetUrl = decodeURIComponent(url);
// Dynamic referer generation
const customReferer = referer ||
(matchId && home && away
? `https://www.808ball6.com/football/${matchId}-${home}-vs-${away}.html`
: "https://www.808ball6.com/");
// Extract domain from target URL for origin spoofing
const urlObj = new URL(targetUrl);
const targetOrigin = `${urlObj.protocol}//${urlObj.hostname}`;
try {
const response = await axios.get(targetUrl, {
headers: {
// Browser identification
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
// Accept headers
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"Accept-Language": "en-US,en;q=0.9,es;q=0.8,fr;q=0.7",
"Accept-Encoding": "gzip, deflate, br, zstd",
// Referer and Origin
"Referer": customReferer,
"Origin": targetOrigin,
// Connection
"Connection": "keep-alive",
// Security/Fetch metadata
"Sec-Fetch-Dest": "iframe",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "cross-site",
"Sec-Fetch-User": "?1",
// Chrome-specific headers
"Sec-Ch-Ua": '"Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": '"Windows"',
"Sec-Ch-Ua-Arch": '"x86"',
"Sec-Ch-Ua-Bitness": '"64"',
"Sec-Ch-Ua-Full-Version-List": '"Google Chrome";v="131.0.6778.86", "Chromium";v="131.0.6778.86", "Not_A Brand";v="24.0.0.0"',
// Additional realistic headers
"Upgrade-Insecure-Requests": "1",
"DNT": "1",
"Cache-Control": "max-age=0",
"Priority": "u=0, i",
// Cookie forwarding (if provided)
...(req.headers.cookie && { "Cookie": req.headers.cookie }),
// Cloudflare bypass headers
"CF-Connecting-IP": "8.8.8.8",
"X-Forwarded-For": "8.8.8.8",
"X-Real-IP": "8.8.8.8",
"X-Forwarded-Host": urlObj.hostname,
"X-Forwarded-Proto": "https",
// Additional anti-detection
"Device-Memory": "8",
"Viewport-Width": "1920",
"DPR": "1"
},
responseType: "arraybuffer",
maxRedirects: 10,
validateStatus: () => true,
timeout: 30000,
decompress: true,
// Proxy configuration (if needed)
// proxy: false, // Disable if you don't have a proxy
// HTTP/2 support
httpAgent: false,
httpsAgent: false
});
// Set response headers
const contentType = response.headers["content-type"] || "text/html; charset=utf-8";
// Remove anti-iframe headers
const headersToRemove = [
"x-frame-options",
"content-security-policy",
"content-security-policy-report-only",
"x-content-security-policy",
"x-webkit-csp",
"strict-transport-security"
];
// Copy safe headers
Object.keys(response.headers).forEach(key => {
if (!headersToRemove.includes(key.toLowerCase())) {
res.setHeader(key, response.headers[key]);
}
});
res.setHeader("Content-Type", contentType);
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "*");
res.setHeader("Access-Control-Allow-Headers", "*");
res.setHeader("X-Frame-Options", "ALLOWALL");
res.setHeader("X-Content-Type-Options", "nosniff");
// Handle HTML responses with frame-busting prevention
if (contentType.includes("text/html")) {
let html = response.data.toString("utf-8");
// Aggressive frame-busting prevention
const antiFrameBust = `
<script>
(function() {
// Freeze top and parent
try {
Object.defineProperty(window, 'top', {
get: function() { return window.self; },
set: function() {},
configurable: false
});
Object.defineProperty(window, 'parent', {
get: function() { return window.self; },
set: function() {},
configurable: false
});
Object.defineProperty(window, 'frameElement', {
get: function() { return null; },
set: function() {},
configurable: false
});
// Override location checks
var originalLocation = window.location;
Object.defineProperty(window, 'location', {
get: function() { return originalLocation; },
set: function(val) {
if (window.self === window.top) {
originalLocation = val;
}
}
});
// Disable common frame-busting patterns
window.onbeforeunload = null;
// Intercept and block certain navigation attempts
var _confirm = window.confirm;
window.confirm = function() { return true; };
var _alert = window.alert;
window.alert = function() {};
} catch(e) {
console.log('Frame protection applied');
}
})();
</script>
`;
// Inject at multiple points for maximum coverage
html = html.replace(/<!DOCTYPE/i, antiFrameBust + '<!DOCTYPE');
html = html.replace(/<head>/i, `<head>${antiFrameBust}`);
html = html.replace(/<head\s/i, `<head>${antiFrameBust} `);
// If no head tag, inject at start
if (!/<head/i.test(html)) {
html = antiFrameBust + html;
}
// Rewrite absolute URLs to go through proxy
html = html.replace(
/(src|href)=["'](https?:\/\/[^"']+)["']/gi,
(match, attr, url) => {
if (url.includes(urlObj.hostname)) {
return `${attr}="/proxy?url=${encodeURIComponent(url)}"`;
}
return match;
}
);
return res.send(html);
}
// For non-HTML content, send as-is
res.send(response.data);
} catch (err) {
console.error("β Proxy error:", err.message);
console.error(" URL:", targetUrl);
console.error(" Status:", err.response?.status);
res.status(err.response?.status || 500).send({
error: "Proxy failed",
message: err.message,
url: targetUrl,
status: err.response?.status
});
}
});
// Catch-all proxy for any resource
app.use("/fetch/*", async (req, res) => {
const targetUrl = req.params[0];
if (!targetUrl) return res.status(400).send("β No URL provided");
try {
const response = await axios.get(targetUrl, {
headers: {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
"Accept": "*/*",
"Accept-Language": "en-US,en;q=0.9",
"Accept-Encoding": "gzip, deflate, br",
"Referer": "https://www.808ball6.com/",
"Origin": "https://www.808ball6.com",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "cross-site"
},
responseType: "arraybuffer",
timeout: 30000,
validateStatus: () => true
});
res.setHeader("Content-Type", response.headers["content-type"] || "application/octet-stream");
res.setHeader("Access-Control-Allow-Origin", "*");
res.send(response.data);
} catch (err) {
console.error("β Fetch error:", err.message);
res.status(500).send({ error: "Fetch failed", message: err.message });
}
});
// POST proxy for form submissions or API calls
app.post("/proxy", async (req, res) => {
const { url } = req.query;
const body = req.body;
if (!url) return res.status(400).send("β Missing ?url param");
const targetUrl = decodeURIComponent(url);
try {
const response = await axios.post(targetUrl, body, {
headers: {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
"Content-Type": "application/json",
"Accept": "*/*",
"Referer": "https://www.808ball6.com/",
"Origin": "https://www.808ball6.com"
},
validateStatus: () => true
});
res.status(response.status).json(response.data);
} catch (err) {
res.status(500).send({ error: "POST proxy failed", message: err.message });
}
});
const PORT = process.env.PORT || 7860;
app.listen(PORT, () => {
console.log(`\nπ Proxy Server Running`);
console.log(`π‘ Port: ${PORT}`);
console.log(`π Endpoints:`);
console.log(` β’ GET / (health check)`);
console.log(` β’ GET /proxy?url=<target>`);
console.log(` β’ GET /fetch/<target>`);
console.log(` β’ POST /proxy?url=<target>`);
}); |