gdtv icon indicating copy to clipboard operation
gdtv copied to clipboard

最近网站更新了,尝试逆向一下,可是能力不足

Open jackrun123 opened this issue 1 year ago • 2 comments

wasm的方法由get_header_j改成了a方法,调用的参数debug看起来没什么变化

旧:export function get_header_j(a:int, b:int, c:int, d:long_ptr, e:int, f:ubyte_ptr, g:long_ptr, h:int, i:int, j:long_ptr, k:int):int 
新:export function a(a:int, b:int, c:int, d:int, e:int, f:ubyte_ptr, g:int, h:int_ptr, i:int, j:int, k:int):int 

js调用方法在vendor js里面,全局搜索w.a(

var E = L(A, w.__wbindgen_export_0, w.__wbindgen_export_1)
  , D = h
  , i = L(g, w.__wbindgen_export_0, w.__wbindgen_export_1)
  , o = h
  , Y = L(I, w.__wbindgen_export_0, w.__wbindgen_export_1)
  , N = h
  , J = L(B, w.__wbindgen_export_0, w.__wbindgen_export_1)
  , k = h
  , K = L(Q, w.__wbindgen_export_0, w.__wbindgen_export_1)
  , y = h;
return G(w.a(E, D, i, o, Y, N, J, k, K, y, function(A) {
    if (1 == H)
        throw new Error("out of js stack");
    return M[--H] = A,
    H
}(C)))

但我尝试按你的方法把一些代码复制下来,修改一部分,但是运行出错,wasm部分就不清楚怎么调试了。

RuntimeError: unreachable
    at wasm://wasm/001f3f6e:wasm-function[149]:0x35a30
    at wasm://wasm/001f3f6e:wasm-function[32]:0x105e1
    at get_header_j (D:\Download\gdtv-main\gdtv.js:164:20)

附上我修改的代码

// Assume add.wasm file exists that contains a single function adding 2 provided arguments
const https = require('https');
const fs = require("fs");
const wasmBuffer = fs.readFileSync("download.wasm");

let location = {
  host: "www.gdtv.cn",
  hostname: "www.gdtv.cn",
  href: "https://www.gdtv.cn/tvChannelDetail/43",
  origin: "https://www.gdtv.cn",
  toString: function () {
    return this.href
  }
};

var w = null;
var M = new Array(128).fill(void 0);
function i(A) {
    return M[A]
}
M.push(void 0, null, !0, !1);
var o = M.length;
function G(A) {
    var g = i(A);
    return function(A) {
        A < 132 || (M[A] = o,
        o = A)
    }(A),
    g
}
function Y(A) {
    o === M.length && M.push(M.length + 1);
    var g = o;
    return o = M[g],
    M[g] = A,
    g
}
var N = "undefined" != typeof TextDecoder ? new TextDecoder("utf-8",{
    ignoreBOM: !0,
    fatal: !0
}) : {
    decode: function() {
        throw Error("TextDecoder not available")
    }
};
"undefined" != typeof TextDecoder && N.decode();
var J = null;
function k() {
    return null !== J && 0 !== J.byteLength || (J = new Uint8Array(w.memory.buffer)),
    J
}
function K(A, g) {
    return A >>>= 0,
    N.decode(k().subarray(A, A + g))
}
var h = 0
    , y = "undefined" != typeof TextEncoder ? new TextEncoder("utf-8") : {
    encode: function() {
        throw Error("TextEncoder not available")
    }
}
    , F = "function" == typeof y.encodeInto ? function(A, g) {
    return y.encodeInto(A, g)
}
: function(A, g) {
    var I = y.encode(A);
    return g.set(I),
    {
        read: A.length,
        written: I.length
    }
}
;
function L(A, g, I) {
    if (void 0 === I) {
        var B = y.encode(A)
            , Q = g(B.length, 1) >>> 0;
        return k().subarray(Q, Q + B.length).set(B),
        h = B.length,
        Q
    }
    for (var C = A.length, E = g(C, 1) >>> 0, D = k(), w = 0; w < C; w++) {
        var M = A.charCodeAt(w);
        if (M > 127)
            break;
        D[E + w] = M
    }
    if (w !== C) {
        0 !== w && (A = A.slice(w)),
        E = I(E, C, C = w + 3 * A.length, 1) >>> 0;
        var i = k().subarray(E + w, E + C);
        E = I(E, C, w += F(A, i).written, 1) >>> 0
    }
    return h = w,
    E
}
function U(A) {
    return null == A
}
var c = null;
function s() {
    return null !== c && 0 !== c.byteLength || (c = new Int32Array(w.memory.buffer)),
    c
}
var H = 128;
function S() {
    for (var A = arguments.length, g = new Array(A), I = 0; I < A; I++)
        g[I] = arguments[I];
    var B = function() {
        try {
            return E(P, g)
        } catch (A) {
            return function() {
                return null
            }
        }
    }();
    return B.toString = function() {
        return ""
    }
    ,
    B
}
function R(A, g) {
    try {
        return A.apply(this, g)
    } catch (A) {
        w.__wbindgen_export_3(Y(A))
    }
}
function a(A, g) {
    return q.apply(this, arguments)
}


function isLikeNone(A) {
    return null == A
}
var cachedInt32Memory0 = null;
function getInt32Memory0() {
    return null !== cachedInt32Memory0 && 0 !== cachedInt32Memory0.byteLength || (cachedInt32Memory0 = new Int32Array(w.memory.buffer)),
    cachedInt32Memory0
}
var stack_pointer = 128;
function addBorrowedObject(A) {
    if (1 == stack_pointer)
        throw new Error("out of js stack");
    return M[--stack_pointer] = A,
    stack_pointer
}

function get_header_j(A, g, I, B, Q, C) {
    try {
        var E = L(A, w.__wbindgen_export_0, w.__wbindgen_export_1)
          , D = h
          , i = L(g, w.__wbindgen_export_0, w.__wbindgen_export_1)
          , o = h
          , Y = L(I, w.__wbindgen_export_0, w.__wbindgen_export_1)
          , N = h
          , J = L(B, w.__wbindgen_export_0, w.__wbindgen_export_1)
          , k = h
          , K = L(Q, w.__wbindgen_export_0, w.__wbindgen_export_1)
          , y = h;
        return G(w.a(E, D, i, o, Y, N, J, k, K, y, function(A) {
            if (1 == H)
                throw new Error("out of js stack");
            return M[--H] = A,
            H
        }(C)))
    } finally {
        M[H++] = void 0
    }
}

function __wbg_get_imports() {
    var g = {
        wbg: {}
    };
    return g.wbg.__wbindgen_object_drop_ref = function(A) {
        G(A)
    }
    ,
    g.wbg.__wbg_self_1ff1d729e9aae938 = function() {
        return R((function() {
            return Y(self.self)
        }
        ), arguments)
    }
    ,
    g.wbg.__wbg_window_5f4faef6c12b79ec = function() {
        return R((function() {
            return Y(window.window)
        }
        ), arguments)
    }
    ,
    g.wbg.__wbg_globalThis_1d39714405582d3c = function() {
        return R((function() {
            return Y(globalThis.globalThis)
        }
        ), arguments)
    }
    ,
    g.wbg.__wbg_global_651f05c6a0944d1c = function() {
        return R((function() {
            return Y(A.global)
        }
        ), arguments)
    }
    ,
    g.wbg.__wbindgen_is_undefined = function(A) {
        return void 0 === i(A)
    }
    ,
    g.wbg.__wbg_newnoargs_581967eacc0e2604 = function(A, g) {
        return Y(S(K(A, g)))
    }
    ,
    g.wbg.__wbg_call_cb65541d95d71282 = function() {
        return R((function(A, g) {
            return Y(i(A).call(i(g)))
        }
        ), arguments)
    }
    ,
    g.wbg.__wbindgen_object_clone_ref = function(A) {
        return Y(i(A))
    }
    ,
    g.wbg.__wbg_instanceof_Window_9029196b662bc42a = function(A) {
        return true
    }
    ,
    g.wbg.__wbg_document_f7ace2b956f30a4f = function(A) {
        var g = {location};
        return U(g) ? 0 : Y(g)
    }
    ,
    g.wbg.__wbg_location_56243dba507f472d = function(A) {
        return Y(location)
    }
    ,
    g.wbg.__wbg_host_15090f3de0544fea = function() {
        return R((function(A, g) {
            var I = L(i(g).host, w.__wbindgen_export_0, w.__wbindgen_export_1)
              , B = h;
            s()[A / 4 + 1] = B,
            s()[A / 4 + 0] = I
        }
        ), arguments)
    }
    ,
    g.wbg.__wbg_origin_50aa482fa6784a0a = function() {
        return R((function(A, g) {
            var I = L(i(g).origin, w.__wbindgen_export_0, w.__wbindgen_export_1)
              , B = h;
            s()[A / 4 + 1] = B,
            s()[A / 4 + 0] = I
        }
        ), arguments)
    }
    ,
    g.wbg.__wbg_href_d62a28e4fc1ab948 = function() {
        return R((function(A, g) {
            var I = L(i(g).href, w.__wbindgen_export_0, w.__wbindgen_export_1)
              , B = h;
            s()[A / 4 + 1] = B,
            s()[A / 4 + 0] = I
        }
        ), arguments)
    }
    ,
    g.wbg.__wbg_newwithargs_a0432b7780c1dfa1 = function(A, g, I, B) {
        return Y(S(K(A, g), K(I, B)))
    }
    ,
    g.wbg.__wbindgen_string_new = function(A, g) {
        return Y(K(A, g))
    }
    ,
    g.wbg.__wbg_call_01734de55d61e11d = function() {
        return R((function(A, g, I) {
            return Y(i(A).call(i(g), i(I)))
        }
        ), arguments)
    }
    ,
    g.wbg.__wbindgen_string_get = function(A, g) {
        var I = i(g)
          , B = "string" == typeof I ? I : void 0
          , Q = U(B) ? 0 : L(B, w.__wbindgen_export_0, w.__wbindgen_export_1)
          , C = h;
        s()[A / 4 + 1] = C,
        s()[A / 4 + 0] = Q
    }
    ,
    g.wbg.__wbg_eval_8c72ad5eafe427f2 = function() {
        return R((function(A, g) {
            return Y(x(K(A, g)))
        }
        ), arguments)
    }
    ,
    g.wbg.__wbindgen_typeof = function(A) {
        return Y(I(i(A)))
    }
    ,
    g.wbg.__wbindgen_boolean_get = function(A) {
        var g = i(A);
        return "boolean" == typeof g ? g ? 1 : 0 : 2
    }
    ,
    g.wbg.__wbg_new_56693dbed0c32988 = function() {
        return Y(new Map)
    }
    ,
    g.wbg.__wbg_set_bedc3d02d0f05eb0 = function(A, g, I) {
        return Y(i(A).set(i(g), i(I)))
    }
    ,
    g.wbg.__wbindgen_number_new = function(A) {
        return Y(A)
    }
    ,
    g.wbg.__wbg_new0_c0be7df4b6bd481f = function() {
        return Y(new Date)
    }
    ,
    g.wbg.__wbg_getTime_5e2054f832d82ec9 = function(A) {
        return i(A).getTime()
    }
    ,
    g.wbg.__wbg_new_cd59bfc8881f487b = function(A) {
        return Y(new Date(i(A)))
    }
    ,
    g.wbg.__wbg_getTimezoneOffset_8aee3445f323973e = function(A) {
        return i(A).getTimezoneOffset()
    }
    ,
    g.wbg.__wbindgen_throw = function(A, g) {
        throw new Error(K(A, g))
    }
    ,
    g
}

const importObject = __wbg_get_imports();
function __wbg_init_memory(A, g) {}
__wbg_init_memory(importObject);

function __wbg_finalize_init(A, g) {
  return w = A.exports,
  cachedInt32Memory0 = null,
  cachedUint8Memory0 = null,
  w
}

WebAssembly.instantiate(wasmBuffer, importObject).then((obj) => {
  __wbg_finalize_init(obj.instance, obj.module);
  const url = "https://gdtv-api.gdtv.cn/api/tv/v2/tvChannel?category=0";
  var header = get_header_j(
    "GET",
    url,
    "WEB_ad66cd50-2be4-11ef-1849-c577dc20c160",
    "WEB_PC",
    "",
    undefined
  );
  console.log(header);
  let headers = {}
  for (const [key, value] of header) {
    headers[key] = value
  }
  https.get(url, {headers: headers}, res => {
    let list = [];
    res.on('data', chunk => {
      list.push(chunk);
    });
    res.on('end', () => {
      console.log('Response ended: ');
      const data = JSON.parse(Buffer.concat(list).toString());
      console.log(data);
    });
  }).on('error', err => {
    console.log('Error: ', err.message);
  });
});

jackrun123 avatar Jun 16 '24 16:06 jackrun123

继续加油,慢慢 debug

claviering avatar Jun 22 '24 03:06 claviering

@claviering 不搞了,从触电xw APP那里更简单些,WASM不懂

jackrun123 avatar Jun 23 '24 08:06 jackrun123

https://www.bilibili.com/video/BV1eEyoYAEcM/?vd_source=cae69f5f7f437d5b10d6bfe1a9306e80 b站有人分析了,楼主要不要看一下,粗略拖动看了一下 我感觉他的方式更彻底一些,不要自己去手动获取header

tongxunlu avatar Nov 01 '24 02:11 tongxunlu

好,学习学习

claviering avatar Nov 04 '24 08:11 claviering

@claviering 我根据你的代码以及这个https://fatkun.github.io/post/2024/crack_gdtv/ 搞出来了,基于以前的php,需要补充wss取串,另外就是getparam和最后一步获取播放链接请求需要添加 options预检,

tongxunlu avatar Dec 14 '24 02:12 tongxunlu

我环境补不上,proxy之后也没啥发现

claviering avatar Dec 14 '24 07:12 claviering

我环境补不上,proxy之后也没啥 这是我的补的环境,可以试试,我开始还以为环境要补很多,那些教程也说不清楚


window = myProxy1(global, "window") function Window() { } Object.setPrototypeOf(window, Window.prototype) document = myProxy1({}, 'document');

document.documentElement = myProxy1({}, "documentElement")
document.toString = function () {
    return '[object HTMLHtmlElement]'
}
document.documentElement.toString = function () {
    return '[object HTMLHtmlElement]'
}


XMLHttpRequest = myProxy({}, 'XMLHttpRequest');
document.addEventListener = function (type, listener) {
    console.log(type)
}

function HTMLElement() {
}

Object.setPrototypeOf(document.documentElement, HTMLElement.prototype)



var _location = {
    host: "www.gdtv.cn",
    hostname: "www.gdtv.cn",
    port: "",
    href: "https://www.gdtv.cn/tvChannelDetail/43",
    origin: "https://www.gdtv.cn",
    protocol: "https:",
    hash: "",
    pathname: "/tvChannelDetail/43",
    port: "",
    assign: function () {
    },
    replace: function () {
    },
    reload: function () {
    },
    search: "",
    ancestorOrigins: {}
};
location = myProxy1(_location, "location")
location.toString = function () `{`
    return "https://www.gdtv.cn/tvChannelDetail/43"
}


function Location() {
}

Object.setPrototypeOf(location, Location.prototype)
document.location = location


window.Location = Location

window.Window = Window
window.HTMLElement = HTMLElement
window.location = location
window.document = document

tongxunlu avatar Dec 14 '24 12:12 tongxunlu

我环境补不上,proxy之后也没啥 这是我的补的环境,可以试试,我开始还以为环境要补很多,那些教程也说不清楚

猫抓老鼠的游戏,如果广泛公开了,可能还会增加其他检测,补环境太麻烦了。

jackrun123 avatar Jan 02 '25 13:01 jackrun123

还好上车了,已经摸透,目前来说只要不改核心的,随便都能修复

tongxunlu avatar Jan 07 '25 07:01 tongxunlu

还好上车了,已经摸透,目前来说只要不改核心的,随便都能修复

贴一下代码?

Yigehaoren8848 avatar Apr 06 '25 16:04 Yigehaoren8848