Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Reducing Imports

Hello everyone,
Recently I've written a bit of code and I have around 6 big module imports in it, which makes it's size around 10MB when compiled into an EXE with PyInstaller.

My goal is to reduce the size without using a packer (Because it will most likely make my EXE detectable), and I think I can achieve that by importing only necessary parts of the spoken modules, but I don't know how to do that..
Is there a program or something that can tell me which parts of the imports I'm really using so I can import only them? Or maybe another way to reduce the EXE's size?

I really need someone to help me with it, thanks in advance ✌
Firstly, what is your reason for "compiling" the Python program to an executable? There's never really any good reason to do this, the executable is naturally going to be bulky since it needs to contain Python (for running the script), all the standard modules and the ones you imported. Also, the Python script is never compiled it's more just packed into the executable and is extracted at run time by the loader, so if it's to hide your code then it's a bad idea since it can just be extracted manually. If your reason is for portability, then as we touched upon, this isn't a good idea because of the natural executable size, you could probably reduce this size but I doubt you'd get less than 3MB. The fact is Python wasn't made to be compiled, so there's going to be some issues, just a heads ups.

Take a look here, this may help you:
https://stackoverflow.com/questions/4769...taller-exe
(Aug 13, 2018 01:20 AM)ApexLead Wrote:  Hello everyone,
Recently I've written a bit of code and I have around 6 big module imports in it, which makes it's size around 10MB when compiled into an EXE with PyInstaller.

My goal is to reduce the size without using a packer (Because it will most likely make my EXE detectable), and I think I can achieve that by importing only necessary parts of the spoken modules, but I don't know how to do that..
Is there a program or something that can tell me which parts of the imports I'm really using so I can import only them? Or maybe another way to reduce the EXE's size?

I really need someone to help me with it, thanks in advance ✌

🤝 Sounds like you wanna make a RAT, WORM or VIRUS and i believe its a Mammal your trying to make in that cause i recommend tha you learn C++ or C which are a much better at addressing the current issue you are facing. Ps. my info is just for educational purposes 🤝
Knowledge is Power - Be Powerful!!!!!


LIFE IS A CHALLENGE SO ACCEPT IT!
(Aug 13, 2018 03:40 AM)hunter24957 Wrote:  Firstly, what is your reason for "compiling" the Python program to an executable? There's never really any good reason to do this, the executable is naturally going to be bulky since it needs to contain Python (for running the script), all the standard modules and the ones you imported. Also, the Python script is never compiled it's more just packed into the executable and is extracted at run time by the loader, so if it's to hide your code then it's a bad idea since it can just be extracted manually. If your reason is for portability, then as we touched upon, this isn't a good idea because of the natural executable size, you could probably reduce this size but I doubt you'd get less than 3MB. The fact is Python wasn't made to be compiled, so there's going to be some issues, just a heads ups.

Take a look here, this may help you:
https://stackoverflow.com/questions/4769...taller-exe

I'm learning C as well, but for now I'm trying to make my own tools with python, so w.e reduced the size works for me, and 3MB is way better than 10.
From what I see in the url you posted they didnt really explain how to find out what parts of the modules I need to import, can you help with that?

(Aug 13, 2018 04:56 AM)koolkid Wrote:  🤝 Sounds like you wanna make a RAT, WORM or VIRUS and i believe its a Mammal your trying to make in that cause i recommend tha you learn C++ or C which are a much better at addressing the current issue you are facing. Ps. my info is just for educational purposes 🤝

You're right, I started practicing in RATTING for educational purposes not long ago so decided to give my basic knowledge in python a cause, so for now writing a RAT with C or C++ isn't an option because it will take too much time and I want to write something meanwhile...
Do you know how to make my spoken EXE smaller?
(Aug 13, 2018 06:30 AM)ApexLead Wrote:  I'm learning C as well, but for now I'm trying to make my own tools with python, so w.e reduced the size works for me, and 3MB is way better than 10.
From what I see in the url you posted they didnt really explain how to find out what parts of the modules I need to import, can you help with that?


You're right, I started practicing in RATTING for educational purposes not long ago so decided to give my basic knowledge in python a cause, so for now writing a RAT with C or C++ isn't an option because it will take too much time and I want to write something meanwhile...
Do you know how to make my spoken EXE smaller?

nope never had a need to make it smaller, i have created projects with several files over 100MB didnt really care as long as my code / program worked. you can google to see if you find something thou
Knowledge is Power - Be Powerful!!!!!


LIFE IS A CHALLENGE SO ACCEPT IT!


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by Tr0jandogSep 10, 2019 11:47 AM 4 268 Sep 10, 2019 11:47 AM
Last Post: Tr0jandog
[C] by maryousJun 18, 2018 09:32 AM 13 415 Jun 18, 2018 09:32 AM
Last Post: 0xDEAD10CC
[.NET] by BarretNov 11, 2017 09:53 AM 3 374 Nov 11, 2017 09:53 AM
Last Post: StaPol