fix:修复一些bug

This commit is contained in:
H3CoF6
2026-03-17 04:05:50 +08:00
parent 56a8859eaf
commit 1680acb22c
3 changed files with 28 additions and 13 deletions

View File

@@ -16,7 +16,7 @@ interface ConfigSchema {
imageXorKey: number imageXorKey: number
imageAesKey: string imageAesKey: string
wxidConfigs: Record<string, { decryptKey?: string; imageXorKey?: number; imageAesKey?: string; updatedAt?: number }> wxidConfigs: Record<string, { decryptKey?: string; imageXorKey?: number; imageAesKey?: string; updatedAt?: number }>
exportPath?: string;
// 缓存相关 // 缓存相关
cachePath: string cachePath: string
lastOpenedDb: string lastOpenedDb: string

View File

@@ -74,7 +74,6 @@ export class KeyServiceLinux {
public async getDbKey(pid: number): Promise<DbKeyResult> { public async getDbKey(pid: number): Promise<DbKeyResult> {
try { try {
const helperPath = this.getHelperPath() const helperPath = this.getHelperPath()
const { stdout: scanOut } = await execFileAsync(helperPath, ['db_scan', pid.toString()]) const { stdout: scanOut } = await execFileAsync(helperPath, ['db_scan', pid.toString()])
const scanRes = JSON.parse(scanOut.trim()) const scanRes = JSON.parse(scanOut.trim())
@@ -109,8 +108,13 @@ export class KeyServiceLinux {
} }
} }
public async autoGetImageKey(_accountPath: string, wxid?: string): Promise<ImageKeyResult> { public async autoGetImageKey(
accountPath?: string,
onProgress?: (msg: string) => void,
wxid?: string
): Promise<ImageKeyResult> {
try { try {
if (onProgress) onProgress('正在初始化...');
const helperPath = this.getHelperPath() const helperPath = this.getHelperPath()
const { stdout } = await execFileAsync(helperPath, ['image_local']) const { stdout } = await execFileAsync(helperPath, ['image_local'])
const res = JSON.parse(stdout.trim()) const res = JSON.parse(stdout.trim())
@@ -121,6 +125,7 @@ export class KeyServiceLinux {
if (!account && accounts.length > 0) account = accounts[0] if (!account && accounts.length > 0) account = accounts[0]
if (account && account.keys && account.keys.length > 0) { if (account && account.keys && account.keys.length > 0) {
if (onProgress) onProgress('已找到匹配的图片密钥');
const keyObj = account.keys[0] const keyObj = account.keys[0]
return { success: true, xorKey: keyObj.xorKey, aesKey: keyObj.aesKey } return { success: true, xorKey: keyObj.xorKey, aesKey: keyObj.aesKey }
} }
@@ -130,23 +135,30 @@ export class KeyServiceLinux {
} }
} }
public async autoGetImageKeyByMemoryScan(accountPath: string): Promise<ImageKeyResult> { public async autoGetImageKeyByMemoryScan(
accountPath: string,
onProgress?: (msg: string) => void
): Promise<ImageKeyResult> {
try { try {
if (onProgress) onProgress('正在获取微信进程...');
const { stdout } = await execAsync('pidof wechat wechat-bin xwechat').catch(() => ({ stdout: '' })) const { stdout } = await execAsync('pidof wechat wechat-bin xwechat').catch(() => ({ stdout: '' }))
const pids = stdout.trim().split(/\s+/).filter(p => p) const pids = stdout.trim().split(/\s+/).filter(p => p)
if (pids.length === 0) return { success: false, error: '微信未运行,无法扫描内存' } if (pids.length === 0) return { success: false, error: '微信未运行,无法扫描内存' }
const pid = parseInt(pids[0], 10) const pid = parseInt(pids[0], 10)
if (onProgress) onProgress('正在提取图片特征码...');
const ciphertextHex = this.findAnyDatCiphertext(accountPath) const ciphertextHex = this.findAnyDatCiphertext(accountPath)
if (!ciphertextHex) { if (!ciphertextHex) {
return { success: false, error: '未在 FileStorage/Image 找到 .dat 图片,请在微信中随便点开一张大图后重试' } return { success: false, error: '未在 FileStorage/Image 找到缓存图片,请在微信中随便点开一张大图后重试' }
} }
if (onProgress) onProgress('正在提权扫描进程内存...');
const helperPath = this.getHelperPath() const helperPath = this.getHelperPath()
const { stdout: memOut } = await execFileAsync(helperPath, ['image_mem', pid.toString(), ciphertextHex]) const { stdout: memOut } = await execFileAsync(helperPath, ['image_mem', pid.toString(), ciphertextHex])
const res = JSON.parse(memOut.trim()) const res = JSON.parse(memOut.trim())
if (res.success) { if (res.success) {
if (onProgress) onProgress('内存扫描成功');
return { success: true, aesKey: res.key } return { success: true, aesKey: res.key }
} }
return { success: false, error: res.result } return { success: false, error: res.result }
@@ -154,7 +166,6 @@ export class KeyServiceLinux {
return { success: false, error: err.message } return { success: false, error: err.message }
} }
} }
private findAnyDatCiphertext(accountPath: string): string | null { private findAnyDatCiphertext(accountPath: string): string | null {
try { try {
const imgDir = join(accountPath, 'FileStorage', 'Image') const imgDir = join(accountPath, 'FileStorage', 'Image')

View File

@@ -647,7 +647,7 @@ function WelcomePage({ standalone = false }: WelcomePageProps) {
<input <input
type="text" type="text"
className="field-input" className="field-input"
placeholder="例如C:\\Users\\xxx\\Documents\\xwechat_files" placeholder={dbPathPlaceholder}
value={dbPath} value={dbPath}
onChange={(e) => setDbPath(e.target.value)} onChange={(e) => setDbPath(e.target.value)}
/> />
@@ -900,9 +900,13 @@ function WelcomePage({ standalone = false }: WelcomePageProps) {
<ConfirmDialog <ConfirmDialog
open={showDbKeyConfirm} open={showDbKeyConfirm}
title="开始获取数据库密钥" title="开始获取数据库密钥"
message={`当开始获取后 WeFlow 将会执行准备操作 message={`当开始获取后 WeFlow 将会执行准备操作
当 WeFlow 内的提示条变为绿色显示允许登录或看到来自WeFlow的登录通知时登录你的微信或退出当前登录并重新登录。`} 【⚠️ Linux 用户特别注意】
如果您在微信里勾选了“自动登录”,请务必先打开微信设置 取消勾选自动登录,然后再点击下方确认!
(因为授权弹窗输入密码需要时间,若自动登录太快,会导致获取密钥失败并卡死微信)
当 WeFlow 内的提示条变为绿色显示“允许登录”或看到来自 WeFlow 的登录通知时,请在手机上确认登录微信。`}
onConfirm={handleDbKeyConfirm} onConfirm={handleDbKeyConfirm}
onCancel={() => setShowDbKeyConfirm(false)} onCancel={() => setShowDbKeyConfirm(false)}
/> />