TEWA-86X Super Administrator

TEWA-86X 系列光猫使用普通账户登录获取超级管理员权限,通过拦截并改写登录状态接口实现。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         TEWA-86X Super Administrator
// @namespace    http://tampermonkey.net/
// @version      2024-05-04
// @description  TEWA-86X 系列光猫使用普通账户登录获取超级管理员权限,通过拦截并改写登录状态接口实现。
// @author       小忍Lily
// @match        http://192.168.1.1/*
// @grant        none
// @run-at       document-start
// @require      https://unpkg.com/[email protected]/dist/ajaxhook.min.js
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    function ajax_hook() {
        ah.proxy({
            onRequest: (config, handler) => {
                handler.next(config);
            },
            onError: (err, handler) => {
                handler.next(err);
            },
            onResponse: (response, handler) => {
                let config = response.config;
                if (config.url.indexOf("/getLogStatus") !== -1) {
                    let res = JSON.parse(response.response);
                    res["skipAuth"] = true;
                    res["isAdmin"] = true;
                    response.response = JSON.stringify(res);
                    handler.resolve(response);
                } else {
                    handler.next(response);
                }
            },
        });
    }

    console.log('开始注入ajax_hook');
    ajax_hook();
    Object.assign(XMLHttpRequest, { UNSENT: 0, OPENED: 1, HEADERS_RECEIVED: 2, LOADING: 3, DONE: 4 });
})();