Skip to content

making it possible to run main.py from wsl#34

Open
julienbarbaud wants to merge 2 commits intoylytdeng:mainfrom
julienbarbaud:feature/wsl-compatibility
Open

making it possible to run main.py from wsl#34
julienbarbaud wants to merge 2 commits intoylytdeng:mainfrom
julienbarbaud:feature/wsl-compatibility

Conversation

@julienbarbaud
Copy link
Copy Markdown

Windows Subsystem for Linux (WSL), is a growingly popular linux virtual machine that comes built-in with windows computers.
Currently, the script main.py can not be run from WSL because:

  • WSL can not access the memory of windows processes. Since wechat is open on windows, we can not scrape the keys
  • file formats are different

This commit makes some simple and minimal changes to port the existing windows scripts to wsl. The key idea is to call the windows version of python as a subprocess to run find_all_keys_windows.py, and to handle file formats appropriately. While not the most efficient strategy, it is the simplest and this process is not the bottleneck for compute time anyway.

The updated tool can now be used in a fully integrated wsl workflow, by launching main.py directly

@julienbarbaud
Copy link
Copy Markdown
Author

Note: The fix assumes that the user is writing his paths to config.json in windows file format

Copy link
Copy Markdown
Owner

@ylytdeng ylytdeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢提交!WSL 兼容的思路很好,通过调用 Windows 端 python.exe 来提取密钥是合理的方案。

审查后发现几个需要修改的问题:

P1 - 需要修复

  1. 路径注入风险find_all_keys_wsl.pycallWindowsScriptCommand 用 f-string 把 WINDOWS_DIR 拼接到 Python 代码字符串里:

    sys.path.append(r'{WINDOWS_DIR}')

    如果路径包含单引号或特殊字符会导致代码注入。建议改用 json.dumps() 转义路径,或通过环境变量/命令行参数传递。

  2. get_pids() 解析不稳定 — 用 ast.literal_eval 解析 stdout 最后一行,但如果 Windows 端 Python 输出了 warning、encoding 错误等额外信息,解析可能失败。建议加一个明确的标记(如 ##RESULT: 前缀)来定位输出。

  3. main() 无错误处理subprocess.run(["python.exe", windows_full_path]) 没有检查 returncode,执行失败时会静默通过。

  4. 路径转换不完整config.py 中只转换了 db_dir,但 keys_filedecrypted_dirdecoded_image_dir 在 WSL 下如果是 Windows 路径也需要转换。建议统一处理。

P2 - 建议改进

  1. 文件末尾缺少换行符find_all_keys_wsl.pywsl_utils.py 末尾缺少 newline。

  2. 命名风格不一致isRunningOnWslconvertWindowsPath2Wsl 是 camelCase,项目其他代码用 snake_case(如 load_configget_pids)。建议改为 is_running_on_wslconvert_windows_path_to_wsl

  3. 前置条件未说明 — WSL 模式需要 Windows 端也安装 Python 和 pycryptodome,建议在 README 中补充说明。

修复以上问题后可以合并,再次感谢贡献!

@julienbarbaud julienbarbaud requested a review from ylytdeng March 22, 2026 07:50
@julienbarbaud
Copy link
Copy Markdown
Author

The requested changes have been made

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants