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
imageAesKey: string
wxidConfigs: Record<string, { decryptKey?: string; imageXorKey?: number; imageAesKey?: string; updatedAt?: number }>
exportPath?: string;
// 缓存相关
cachePath: string
lastOpenedDb: string

View File

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

View File

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