搞了个油猴脚本
- // ==UserScript==
- // @name FakeHTTP Payload 增强版 (多模板/CDN优化)
- // @namespace http://tampermonkey.net/
- // @version 3.0
- // @description 内置主流大厂CDN/测速模板,自动生成高仿真的 payload.bin,优化UI和稳定性
- // @author Gemini (优化版)
- // @match *://*/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // ========== 1. 扩展模板库:新增腾讯、百度、京东、字节、华为、阿里云OSS等主流CDN/大厂模板 ==========
- const templates = {
- // 测速模板
- 'speedtest': { host: 'www.speedtest.cn', path: '/test/download', desc: '测速网站' },
- // 阿里系
- 'alicdn': { host: 'update.alicdn.com', path: '/download/client.exe', desc: '阿里CDN' },
- 'alioss': { host: 'oss-cn-hangzhou.aliyuncs.com', path: '/aliyun-oss-sdk.zip', desc: '阿里云OSS' },
- // 腾讯系
- 'tencentcdn': { host: 'dl.qq.com', path: '/qqmail/cgi-bin/download', desc: '腾讯CDN' },
- 'txcloud': { host: 'mirrors.cloud.tencent.com', path: '/centos/7/isos/x86_64/', desc: '腾讯云镜像' },
- // 百度系
- 'baiducdn': { host: 'd.pcs.baidu.com', path: '/rest/2.0/pcs/file', desc: '百度网盘CDN' },
- // 字节系
- 'bytedance': { host: 'sf3-cn.byteimg.com', path: '/obj/eden-cn/ptlz_zlp/web/dist/app.js', desc: '字节跳动CDN' },
- // 微软/苹果/华为
- 'microsoft': { host: 'update.microsoft.com', path: '/v11/3/windowsupdate', desc: '微软更新' },
- 'apple': { host: 'iosapps.itunes.apple.com', path: '/apple-auth/auth', desc: '苹果应用商店' },
- 'huawei': { host: 'update.huawei.com', path: '/hmscore/update', desc: '华为更新' },
- // 电商系
- 'jd': { host: 'd.jd.com', path: '/drip/getDripData.json', desc: '京东CDN' },
- 'taobao': { host: 'g.alicdn.com', path: '/tb-homepage/tb-home-mini/2.3.5/index.min.js', desc: '淘宝CDN' }
- };
- // ========== 2. 创建优化后的UI:分类展示、加载状态、提示文案 ==========
- const container = document.createElement('div');
- container.style = `
- position:fixed;
- bottom:20px;
- right:20px;
- z-index:9999;
- background:#fff;
- padding:15px;
- border-radius:12px;
- box-shadow:0 6px 20px rgba(0,0,0,0.15);
- display:flex;
- flex-direction:column;
- gap:10px;
- border:1px solid #eee;
- min-width:200px;
- `;
- // 标题区域(增加版本和提示)
- const titleWrap = document.createElement('div');
- titleWrap.style = "display:flex;justify-content:space-between;align-items:center;margin-bottom:5px;";
- const title = document.createElement('div');
- title.innerText = 'FakeHTTP 提取器 v3.0';
- title.style = "font-weight:600;font-size:14px;color:#222;";
- const tips = document.createElement('div');
- tips.innerText = '高仿真请求头';
- tips.style = "font-size:10px;color:#999;";
- titleWrap.appendChild(title);
- titleWrap.appendChild(tips);
- container.appendChild(titleWrap);
- // 分类标题(区分测速/大厂/电商)
- const addCategoryTitle = (text) => {
- const t = document.createElement('div');
- t.innerText = text;
- t.style = "font-size:11px;color:#666;margin:5px 0 2px 0;padding-left:2px;";
- container.appendChild(t);
- };
- // ========== 3. 按分类生成按钮 ==========
- // 测速类
- addCategoryTitle('测速模板');
- createTemplateButton('speedtest');
- // 大厂CDN类
- addCategoryTitle('大厂CDN');
- ['alicdn', 'alioss', 'tencentcdn', 'txcloud', 'baiducdn', 'bytedance'].forEach(createTemplateButton);
- // 系统更新类
- addCategoryTitle('系统更新');
- ['microsoft', 'apple', 'huawei'].forEach(createTemplateButton);
- // 电商类
- addCategoryTitle('电商CDN');
- ['jd', 'taobao'].forEach(createTemplateButton);
- // ========== 4. 按钮创建函数(优化样式和交互) ==========
- function createTemplateButton(key) {
- const template = templates[key];
- const btn = document.createElement('button');
- btn.innerHTML = `${template.desc || key}`; // 显示描述而非英文key
- btn.style = `
- padding:8px 10px;
- background:#409eff;
- color:white;
- border:none;
- border-radius:6px;
- cursor:pointer;
- font-size:12px;
- transition:all 0.2s;
- text-align:left;
- `;
- btn.dataset.key = key;
- // 鼠标悬浮/离开效果
- btn.onmouseover = () => btn.style = `
- padding:8px 10px;
- background:#66b1ff;
- color:white;
- border:none;
- border-radius:6px;
- cursor:pointer;
- font-size:12px;
- transition:all 0.2s;
- text-align:left;
- transform:translateY(-1px);
- `;
- btn.onmouseout = () => btn.style = `
- padding:8px 10px;
- background:#409eff;
- color:white;
- border:none;
- border-radius:6px;
- cursor:pointer;
- font-size:12px;
- transition:all 0.2s;
- text-align:left;
- `;
- // 点击事件(增加加载状态、防重复点击)
- btn.onclick = async () => {
- // 禁用按钮+显示加载状态
- btn.disabled = true;
- btn.innerHTML = `生成中...`;
- btn.style.background = '#909399';
- try {
- await generatePayload(template.host, template.path, key);
- // 生成成功提示
- btn.innerHTML = `✅ ${template.desc}`;
- setTimeout(() => {
- btn.innerHTML = template.desc;
- btn.disabled = false;
- btn.style.background = '#409eff';
- }, 1500);
- } catch (e) {
- // 生成失败提示
- btn.innerHTML = `❌ 生成失败`;
- console.error('生成Payload失败:', e);
- setTimeout(() => {
- btn.innerHTML = template.desc;
- btn.disabled = false;
- btn.style.background = '#409eff';
- }, 2000);
- }
- };
- container.appendChild(btn);
- }
- // ========== 5. 核心生成函数(优化请求头/文件名/体积控制) ==========
- function generatePayload(host, path, key) {
- return new Promise((resolve) => {
- const ua = navigator.userAgent;
- // 优化填充逻辑:精准控制体积在 500-600 字节(更贴近真实请求)
- const paddingLen = 450 - (host.length + path.length + ua.length);
- const paddingStr = Array(Math.max(10, paddingLen)).fill(0).map(() =>
- Math.random().toString(36).charAt(2) || 'x'
- ).join('');
- const padding = `X-Padding: ${paddingStr}`;
- // 优化请求头:增加现代浏览器的 Sec-Fetch 系列头,更仿真
- const headerLines = [
- `GET ${path} HTTP/1.1`,
- `Host: ${host}`,
- `User-Agent: ${ua}`,
- `Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8`,
- `Accept-Encoding: gzip, deflate, br, zstd`,
- `Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7`,
- `Cache-Control: no-cache`,
- `Pragma: no-cache`,
- `Connection: keep-alive`,
- `Sec-Fetch-Dest: empty`,
- `Sec-Fetch-Mode: cors`,
- `Sec-Fetch-Site: cross-site`,
- `Sec-Fetch-User: ?1`,
- `Upgrade-Insecure-Requests: 1`,
- padding,
- ``, // HTTP头和体的分隔空行
- ``
- ];
- // 拼接HTTP头(必须用\r\n分隔,符合HTTP标准)
- const rawContent = headerLines.join('\r\n');
- const encoder = new TextEncoder();
- const data = encoder.encode(rawContent);
- // 生成二进制Blob
- const blob = new Blob([data], { type: 'application/octet-stream' });
- const url = URL.createObjectURL(blob);
- // 优化文件名:避免split越界,更规范
- const domainParts = host.split('.');
- const safeDomain = domainParts.length >= 2 ? domainParts[domainParts.length - 2] : key;
- const fileName = `payload_${safeDomain}_${Date.now()}.bin`; // 增加时间戳避免重名
- // 触发下载
- const a = document.createElement('a');
- a.href = url;
- a.download = fileName;
- a.style.display = 'none';
- document.body.appendChild(a);
- a.click();
- // 清理资源
- setTimeout(() => {
- document.body.removeChild(a);
- URL.revokeObjectURL(url);
- resolve();
- }, 100);
- });
- }
- // 挂载到页面
- document.body.appendChild(container);
- })();
复制代码 |