mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-24 23:06:51 +00:00
支持朋友圈图片解密;视频解密;实况渲染
This commit is contained in:
@@ -64,7 +64,9 @@ export class WcdbCore {
|
||||
private wcdbVerifyUser: any = null
|
||||
private wcdbStartMonitorPipe: any = null
|
||||
private wcdbStopMonitorPipe: any = null
|
||||
|
||||
private monitorPipeClient: any = null
|
||||
private wcdbDecryptSnsImage: any = null
|
||||
|
||||
private avatarUrlCache: Map<string, { url?: string; updatedAt: number }> = new Map()
|
||||
private readonly avatarCacheTtlMs = 10 * 60 * 1000
|
||||
@@ -137,11 +139,48 @@ export class WcdbCore {
|
||||
this.writeLog('Monitor started via named pipe IPC')
|
||||
return true
|
||||
} catch (e) {
|
||||
console.error('startMonitor failed:', e)
|
||||
console.error('打开数据库异常:', e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密朋友圈图片
|
||||
*/
|
||||
async decryptSnsImage(encryptedData: Buffer, key: string): Promise<Buffer> {
|
||||
if (!this.initialized) {
|
||||
const initOk = await this.initialize()
|
||||
if (!initOk) return encryptedData
|
||||
}
|
||||
|
||||
if (!this.wcdbDecryptSnsImage) return encryptedData
|
||||
|
||||
try {
|
||||
if (!this.wcdbDecryptSnsImage) {
|
||||
console.error('[WCDB] wcdbDecryptSnsImage func is null')
|
||||
return encryptedData
|
||||
}
|
||||
|
||||
const outPtr = [null as any]
|
||||
// Koffi pass Buffer as char* pointer
|
||||
const result = this.wcdbDecryptSnsImage(encryptedData, encryptedData.length, key, outPtr)
|
||||
|
||||
if (result === 0 && outPtr[0]) {
|
||||
const hex = this.decodeJsonPtr(outPtr[0])
|
||||
if (hex) {
|
||||
return Buffer.from(hex, 'hex')
|
||||
}
|
||||
} else {
|
||||
console.error(`[WCDB] Decrypt SNS image failed with code: ${result}`)
|
||||
// 主动获取 DLL 内部日志以诊断问题
|
||||
await this.printLogs(true)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('解密图片失败:', e)
|
||||
}
|
||||
return encryptedData
|
||||
}
|
||||
|
||||
stopMonitor(): void {
|
||||
if (this.monitorPipeClient) {
|
||||
this.monitorPipeClient.destroy()
|
||||
@@ -563,6 +602,13 @@ export class WcdbCore {
|
||||
this.wcdbVerifyUser = null
|
||||
}
|
||||
|
||||
// wcdb_status wcdb_decrypt_sns_image(const char* encrypted_data, int32_t data_len, const char* key, char** out_hex)
|
||||
try {
|
||||
this.wcdbDecryptSnsImage = this.lib.func('int32 wcdb_decrypt_sns_image(const char* data, int32 len, const char* key, _Out_ void** outHex)')
|
||||
} catch {
|
||||
this.wcdbDecryptSnsImage = null
|
||||
}
|
||||
|
||||
// 初始化
|
||||
const initResult = this.wcdbInit()
|
||||
if (initResult !== 0) {
|
||||
|
||||
Reference in New Issue
Block a user