xhs x-mns,x-s-com,x_b3_traceid,x_xray_traceid逆向

xhs x-mns,x-s-com,x_b3_traceid,x_xray_traceid逆向

此分享只用于学习用途,不作商业用途,若有冒犯,请联系处理

x-mns

生成位置:
在这里插入图片描述
使用OB混淆js代码,同样使用补环境的方式

补环境要点

  • 注意不要格式化
  • 会使用Error抛出错误,捕获后使用RegExp匹配,来验证

代码

CryptoJS = require('crypto-js');

function watch(obj, name) {
   
   
    return new Proxy(obj, {
   
   
        get(target, p, receiver) {
   
   
            let val = Reflect.get(...arguments);
            // || p.toString().indexOf("Symbol(Symbol.") != -1
            if (p === "Math" || p === "isNaN" || p === "encodeURI" || p === "Uint8Array" || p=='Date') {
   
   
                return val
            }
            if (p === 'globalThis') {
   
   
                console.log('get | ', name ,'.globalThis');
            } else {
   
   
                // if (p=='stack'){
   
   
                //     debugger
                // }
                console.log(`get | `, name , '.' , p, `   ==>`, val);
            }
            // debugger
            return val
            
        },
        set(target, p, value, receiver) {
   
   
            let val = Reflect.get(...arguments);
            console.log(`set | `, name,'.',p, '    ',val,'==>',value);
            // debugger
            return Reflect.set(...arguments)
        }
    })
}


function Document() {
   
    }
Document.prototype.createElement = function () {
   
   
    console.log('====>createElement', arguments);
    return watch({
   
   }, 'document.createElement')
}
Document.prototype.getElementById = function () {
   
   
    console.log('====>getElementById:', arguments);
    return watch({
   
   }, 'document.getElementBy');

}
Document.prototype.getElementsByTagName = function () {
   
   
    console.log('====>getElementsByTagName:', arguments);
    if (arguments[0] == 'head') {
   
   
        return [watch({
   
   }, 'head')]
    }
    return watch({
   
   }, 'document.getElementsByTagName')
}
Document.prototype.getElementsByClassName = function () {
   
   
    console.log('====>getElementsByClassName:', arguments);
    return watch({
   
   }, 'document.getElementsByClassName')
}
Document.prototype.documentElement = watch({
   
   
    getAttribute: function () {
   
   
        console.log('====>getAttribute:', arguments);
        if (arguments[0] == 'selenium' || arguments[0] == 'webdriver' || arguments[0] == 'driver') return null
        return watch({
   
   }, 'document.documentElement.getAttribute')
    }
}, 'document.documentElement')

Document.prototype.querySelectorAll = watch(function querySelectorAll() {
   
    }, 'document.querySelectorAll')
Document.prototype.cookie = ''; //....


document = new Document();
document.toString = () => '[object HTMLDocument]'

let Navigator =function Navigator() {
   
    }
Navigator.prototype = {
   
   
    appCodeName: "Mozilla",
    appName: "Netscape",
    appVersion: "5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36",
    platform: "Win32",
    product: "Gecko",
    productSub: "20030107",
    'userAgent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36",
    language: "zh-CN",
    languages: ["zh-CN", "zh"],
}
let navigator = new Navigator();
navigator.toString = () => '[object Navigator]'

function Location() {
   
    }
Location.prototype = {
   
   
    "ancestorOrigins": {
   
   },
    "href": "https://www.xiaohongshu.com/explore",
    "origin": "https://www.xiaohongshu.com",
    "protocol": "https:",
    "host": "www.xiaohongshu.com",
    "hostname": "www.xiaohongshu.com",
    "port": "",
    "pathname": "/explore",
    "search": "",
    "hash": ""
};
let location = new Location();
location.toString = () => 'https://www.xiaohongshu.com/explore'

function Storage() {
   
   
    this.getItem = function () {
   
   
        console.log('====>getItem:', arguments);
        return this[arguments[0]]
    }
    this.setItem = function () {
   
   
        console.log('====>setItem:', arguments);
        this[arguments[0]] = arguments[1]
    }
}
Storage.prototype = {
   
   
    //....
}
let localStorage = new Storage();

function Screen() {
   
    }
Screen.prototype = {
   
   }
let screen = new Screen();
screen.toString = () => '[object Screen]';

function History() {
   
    }
History.prototype = {
   
   };
let history = new History();
history.toString = () => '[object History]';

let Error = function Error() {
   
    
    console.log('====>Error:', arguments);
    return watch({
   
   
        stack:`Error
    at eval (eval at _0x2dad65 (https://fe-static.xhscdn.com/as/v1/3e44/public/11b080d07a42355a374e830a4a0dc392.js:1:45658), <anonymous>:1:1)
    at _0x2dad65 (https://fe-static.xhscdn.com/as/v1/3e44/public/11b080d07a42355a374e830a4a0dc392.js:1:45658)
    at Object.AlmBt (https://fe-static.xhscdn.com/as/v1/3e44/public/11b080d07a42355a374e830a4a0dc392.js:1:19104)
    at _0x5a7ef0 (https://fe-static.xhscdn.com/as/v1/3e44/public/11b080d07a42355a374e830a4a0dc392.js:1:59925)
    at _0x25d05c (https://fe-static.xhscdn.com/as/v1/3e44/public/11b080d07a42355a374e830a4a0dc392.js:1:51441)
    at _0x2dad65 (https://fe-static.xhscdn.com/as/v1/3e44/public/11b080d07a42355a374e830a4a0dc392.js:1:47823)
    at _0x2dad65 (https://fe-static.xhscdn.com/as/v1/3e44/public/11b080d07a42355a374e830a4a0dc392.js:1:54510)
    at Object.AlmBt (https://fe-static.xhscdn.com/as/v1/3e44/public/11b080d07a42355a374e830a4a0dc392.js:1:19104)
    at _0x5a7ef0 (https://fe-static.xhscdn.com/as/v1/3e44/public/11b080d07a42355a374e830a4a0dc392.js:1:59925)
    at _0x2dad65 (https://fe-static.xhscdn.com/as/v1/3e44/public/11b080d07a42355a374e830a4a0dc392.js:1:47430)
    at Object.AlmBt (https://fe-static.xhscdn.com/as/v1/3e44/public/11b080d07a42355a374e830a4a0dc392.js:1:19104)
    at _0x5a7ef0 (https://fe-static.xhscdn.com/as/v1/3e44/public/11b080d07a42355a374e830a4a0dc392.js:1:59925)
    at Object._0x25d05c [as getMnsToken] (https://fe-static.xhscdn.com/as/v1/3e44/public/11b080d07a42355a374e830a4a0dc392.js:1:51441)
    at xhsSign (https://fe-static.xhscdn.com/formula-static/xhs-pc-web/public/resource/js/vendor-dynamic.3e7bc84b.js:1:191965)
    at Object.<anonymous> (https://fe-static.xhscdn.com/formula-static/xhs-pc-web/public/resource/js/vendor-dynamic.3e7bc84b.js:1:190943)
    at step (https://fe-static.xhscdn.com/formula-static/xhs-pc-web/public/resource/js/vendor-dynamic.3e7bc84b.js:1:190607)
    at Object.next (https://fe-static.xhscdn.com/formula-static/xhs-pc-web/public/resource/js/vendor-dynamic.3e7bc84b.js:1:189888)
    at https://fe-static.xhscdn.com/formula-static/xhs-pc-web/public/resource/js/vendor-dynamic.3e7bc84b.js:1:189577
    at new Promise (<anonymous>)
    at signAdaptor_awaiter (https://fe-static.xhscdn.com/formula-static/xhs-pc-web/public/resource/js/vendor-dynamic.3e7bc84b.js:1:189328)
    at Object.signAdaptor (https://fe-static.xhscdn.com/formula-static/xhs-pc-web/public/resource/js/vendor-dynamic.3e7bc84b.js:1:190753)
    at https://fe-static.xhscdn.com/formula-static/xhs-pc-web/public/resource/js/vendor-dynamic.3e7bc84b.js:1:139943`
    },'Error')
    
}
// Error.prototype = { 
//     stackTraceLimit:10
// };
Error.stackTraceLimit=10


// 保存原始的 Error 构造函数
const originalError = Error;

// 定义一个新的 Error 构造函数来进行 Hook
// function HookedError(message) {
   
   
//     // 调用原始的 Error 构造函数
//     const error = new originalError(message);

//     // 在这里你可以添加自定义的逻辑,例如记录错误信息到控制台或者发送到服务器
//     console.log('Hooked Error:', error.message);
//     debugger;

//     // 返回错误实例
//     return error;
// }

// // 替换全局的 Error 构造函数
// window.Error = HookedError;


function Window() {
   
    }
Window.prototype = {
   
   
    "TEMPORARY": 0,
    "PERSISTENT": 1,
    navigator:navigator,
    location: location,
    history: history,
    localStorage: localStorage,
    screen: screen,
    document: document,
    String: String,
    Number: Number,
    Boolean: Boolean,
    Date: Date,
    Array: Array,
    Object: Object,
    Math: Math,
    JSON: JSON,
    console: console,
    Function: Function,
    Error: watch(Error,'Error'),
    eval: eval,
    parseInt: parseInt,
    parseFloat: parseFloat,
    isNaN: isNaN,
    isFinite: isFinite,
    decodeURI: decodeURI,
    decodeURIComponent: decodeURIComponent,
    encodeURI: encodeURI,
    encodeURIComponent: encodeURIComponent,
    RegExp: watch(RegExp,'RegExp'),
    toString: function () {
   
    return '[object Window]' }
}
window=new Window();


window.name = ''
window.alert = function () {
   
    }
window.setInterval = function () {
   
    }
window.setTimeout = function () {
   
    }
// window.toString=()=>'[object Window]';
window.toString = function () {
   
    return '[object Window]' }
let External = function External() {
   
    }
window.external = watch(new External(), 'window.external')
window.constructor = Window;
// window.Window = Window;
window.Image = function Image() {
   
   
    return watch({
   
   }, 'Image')
}
function Element() {
   
    }
Element.prototype.append = function () {
   
    }
window.Element = watch(Element, 'Element')
window.addEventListener = function () {
   
    }
window.outerWidth = 1707;
window.innerWidth = 1707;
window.outerHeight = 27;
window.innerHeight = 791;
function RTCPeerConnection() {
   
    }
window.webkitRTCPeerConnection = watch(new RTCPeerConnection(), 'webkitRTCPeerConnection')
window.origin = 'https://www.xiaohongshu.com'
window.top = watch({
   
   
    0: window
}, 'top')



document = watch(document, "document");
navigator = watch(navigator, "navigator");
location = watch(location, "location");
localStorage = watch(localStorage, "localStorage");
screen = watch(screen, "screen");
history = watch(history, "history");


window = watch(window, "window");



let __process = process;
delete global
delete process
delete Buffer
delete __dirname
delete __filename

x-s-com

生成位置:
在这里插入图片描述
加密参数如下:
在这里插入图片描述

  • 缺什么补什么就行
  • 注意localStorage的b1参数,应该是浏览器指纹,每次都会变化(有大佬会的可以交流一下)

x_b3_traceid

生成位置:
在这里插入图片描述

就是一个随机数组合

function generateTraceId() {
   
   
    for (var e = "", r = 0; r < 16; r++)
        e += "abcdef0123456789".charAt(Math.floor(16 * Math.random()));
    return e
}
let x_b3_traceid = generateTraceId();

x_xray_traceid

生成位置:
在这里插入图片描述
虽然这是一个webpack,需要扣加载器和模块
但是,经过分析, 加密逻辑很简单(使用时间戳来进行移位,自增,随机数),可以直接扣代码:

  • 加密函数是50142模块里的一个函数
    在这里插入图片描述
  • 其中s是2044模块中的一个Long类,和其他模块没有耦合,可以直接扣
  • a 是一个函数的实例化,和其他模块没有耦合,可以直接扣

代码

helar={
   
   }

function B(A) {
   
   
    "use strict";
    Object.defineProperty(A, "__esModule", {
   
   
        value: !0
    }),
    A.default = void 0;
    var B = null;
    try {
   
   
        B = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0, 97, 115, 109, 1, 0, 
小红书作为一款广受欢迎的生活方式分享平台,其客户端在运行过程中会涉及到各种参数,而这些参数往往是动态生成的。在软件开发和网络安全领域,逆向工程技术常常被用来分析和理解软件的工作机制,包括参数生成和传递的方式。小红书x-s参数逆向分析,就是指对小红书应用中某种特定参数(假设为x-s)进行逆向工程的研究,目的是为了理解和还原小红书的补环境源码,从而进一步分析小红书应用程序的工作机制和安全特性。 逆向工程涉及的核心过程包括但不限于分析小红书应用的网络通信过程,抓取应用与服务器之间的通信数据包,并对数据包内容进行解析。这通常需要深入研究小红书应用的协议,比如其使用的HTTP/HTTPS协议以及对应的加密和签名机制。通过逆向分析,开发者可能会发现一些重要的线索,例如x-s参数在安全性和身份验证方面所起的作用。这有助于理解小红书是如何通过客户端发送的x-s参数来与服务器进行安全通信的。 在此基础上,研究者可能需要对小红书应用的客户端代码进行反编译,并借助静态代码分析工具或者动态调试手段,探索x-s参数在程序中的生成和使用过程。整个分析过程需要有扎实的编程基础,熟悉加密算法,了解网络协议,以及具备逆向工程的相关经验。 逆向工程通常也涉及到法律和道德的问题。由于小红书是一个商业产品,其代码和通信机制都属于公司的知识产权,未经允许进行逆向分析可能会违反相关的法律法规,因此这类研究活动在没有合适授权的情况下进行是不被鼓励的,也可能面临法律风险。 小红书x-s参数的逆向分析对于理解应用的安全机制、数据加密和身份验证流程至关重要,对于提升安全研究人员的安全防护能力、学习先进的加密技术和协议设计原理也具有重要的意义。同时,这项工作对于那些希望开发与小红书兼容的第三方插件或服务的开发者来说,能够提供深入的技术支持和数据交互的参考。 此外,逆向分析工作不仅限于x-s参数,还可能涵盖对整个小红书应用的逆向研究,包括但不限于用户认证流程、内容分发机制、广告加载逻辑等多个方面。每一个参数或功能的逆向分析结果,都可能成为提升用户体验、优化应用性能或防范潜在安全威胁的重要依据。 对于安全研究人员来说,掌握逆向工程技能并将其应用于实际案例中,可以极大地提高其对软件漏洞发现和修复的能力,同时也是对自身技术深度和广度
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值