微信Mars-xlog日志加密踩坑指南

本文介绍如何在Python2环境下安装并配置pyelliptic库来实现Xlog加密功能,包括生成公私钥、修改Android初始化代码及解密日志文件等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

基础 - Xlog 加密使用指引 - 《Mars 开发文档》 - 书栈网 · BookStack

一、准备环境--Python2

准备Python2的环境,下面的一切操作都要在该环境下进行。

安装pyelliptic1.5.10

​​​​​https://github.com/mfranciszkiewicz/pyelliptic/archive/1.5.10.tar.gz#egg=pyelliptic

文档中写的是1.5.7,在踩坑过程中发现在新版本的macos下已不可用,已经有人提交了Issues,并给出了解决方案Exception: Couldn't load OpenSSL lib , 升级到MACOS 11.5.1后出现 · Issue #969 · Tencent/mars (github.com)

将pyelliptic1.5.10进行解压后,修改pyelliptic-1.5.10/pyelliptic.py文件中的内容

def find_crypto_lib():
    if sys.platform != 'win32':
       # 注释掉下面路径,写绝对路径
       # return ctypes.util.find_library('crypto')
       return '/usr/lib/libcrypto.dylib'

在Python2的环境下进行安装,到pyelliptic-1.5.10目录 执行

python setup.py install

二、生成公私钥

到Mars目录下mars-master/mars/log/crypt/gen_key.py

执行gen_key.py文件 

python gen_key.py
save private key:#私钥
xxxxxxxxxxxx

appender_open's parameter:#公钥
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

将私钥和公钥配置到decode_mars_crypt_log_file.py中

PRIV_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
PUB_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

三、修改android中Xlog的初始化代码

   val SDCARD: String = Environment.getExternalStorageDirectory().absolutePath
   val logPath: String = SDCARD + "/marssample/log"

   // this is necessary, or may crash for SIGBUS
   val cachePath: String = Ktx.app.filesDir.absolutePath + "/xlog"

   val xlog = Xlog()
   Log.setLogImp(xlog)
   Log.setConsoleLogOpen(true)
   Xlog.open(true,Xlog.LEVEL_DEBUG, Xlog.AppednerModeAsync, cachePath, logPath, "your_tag", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

四、解密日志文件

使用decode_mars_crypt_log_file.py进行解密

python /Users/hanxueqiang/yuanmanyuan/mars-master/mars/log/crypt/decode_mars_crypt_log_file.py /Users/hanxueqiang/Downloads/dbx_local_20211118.xlog

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值