Files
moonsource-xiaoxiang/moonsource-xiaoxiang.koplugin/moonsource_xiaoxiang/fock.lua
T
GarfieldandCopilot 0907702861 ✨ 初始提交:月读第三方书源插件集合
每个书源一个独立插件目录,含微信读书公众号订阅、书架导入等完整功能。

Co-authored-by: Copilot <[email protected]>
2026-11-16 12:08:03 +08:00

60 lines
2.4 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
--[[--
潇湘 VIP 章节正文解密(Fock):阅文 wasm 的潇湘构建参数 + 子进程编排,宿主在 `moonsource_xiaoxiang.yuewen_fock`。
网页端用它解密 `chapterContents[].chapterContent`。
@module moonsource_xiaoxiang.fock
--]]--
local Shared = require("moonsource_xiaoxiang.yuewen_fock")
local Fock = {}
local HOST = {
["location.hostname"] = "www.xxsypro.com",
["location.protocol"] = "https:",
}
---@type YuewenFockBuild
local BUILD = {
wasm = "moonsource_xiaoxiang.fock_wasm",
callback = 22353,
stack = 5274656,
exports = { ctors = "g", main = "l", set_uid = "h", set_key = "i", decrypt = "j",
stack_save = "m", stack_restore = "n", alloc = "o", malloc = "p" },
-- 其余是反调试 / 定时器探测:返回 -1(那几个会返回 indexOf 结果)或 0
probe = function(code) return code % 709 == 151 and -1 or 0 end,
imports = function(env)
return {
f = function() return 0 end,
c = function(a, b) return env.malloc_str(HOST[env.cstr(a) .. "." .. env.cstr(b)] or "undefined") end,
e = function() return env.malloc_str("undefined") end,
}
end,
}
---@param content string base64 密文
---@param chapter_id string|number
---@param keypool string base64 密钥池(fkp 里 onkeyfocus 的第一个参数)
---@param version string
---@param uid string 用户 ywGuid
---@return string|nil text
---@return string|nil err
function Fock.decrypt(content, chapter_id, keypool, version, uid)
return Shared.decrypt(BUILD, content, chapter_id, keypool, version, uid)
end
--- 在子进程里解密并还原乱序字体,回调拿正文纯文本或错误。
---@param info table chapterContents 的一项(chapterContent、fontResponse)
---@param fixed_font string|nil fontResponse.fixedFontTtf 下载下来的字节;没有字体加密的章为 nil
---@return BookJob
function Fock.chapterAsync(info, fixed_font, chapter_id, keypool, version, uid, cb)
return Shared.jobAsync("xiaoxiang_fock", function(temp_paths)
local plain, err = Fock.decrypt(info.chapterContent, chapter_id, keypool, version, uid)
if not plain then return { err = err } end
local font = type(info.fontResponse) == "table" and info.fontResponse or {}
return { text = require("moonsource_xiaoxiang.yuewen_fonts").restore(plain, font, fixed_font, { temp_paths = temp_paths }) }
end, cb)
end
return Fock