1

I have a script that I wrote in Python that someone will execute over and over again. It simply takes screenshots of their monitor and does some analysis.

I do not want the person to see the code itself. I just want them to be able to run it and get the output.

Is there some infrastructure to do this? Does git permit this for example?

ifrj
  • 91
  • 7
  • Do you want to user to download a python file, klick it and get the output? – ShadowCrafter_01 Jun 14 '23 at 09:53
  • No, because if they download the python file, it means they would have access to the code? (I think! - but this may not be the case?) I would just like for them to be able to run the code (via a very simple entry point) and get the output. – ifrj Jun 14 '23 at 09:55
  • it's pretty much impossible to [fully hide python code from a motivated end-user](https://stackoverflow.com/questions/261638/how-do-i-protect-python-code-from-being-read-by-users). If all you want is some sort of desktop or taskbar icon to double-click without the `.py` file being directly visible, you'll need to package your script, and create an installer to create a launcher to run your script (exactly how this is done depends on the OS). However, it'll still be very easy to find your script and read it, if someone so chooses. – Hoodlum Jun 14 '23 at 10:11

2 Answers2

1

You can use pyinstaller for turning python script into executable.

Sali
  • 11
  • 1
  • executable means they can only run it and not see the code? Sorry if this is a trivial question. – ifrj Jun 14 '23 at 10:09
  • It depends, they can run it and won't see the code, except if they use a package to reverse it and extract py file from it. Pyinstaller extractor allows you to get the code from an exe made with Pyinstaller for instance. – Sparkling Marcel Jun 14 '23 at 10:20
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 14 '23 at 11:53
  • Is it possible to encode the executable for example so that reversing it is not possible? – ifrj Jun 14 '23 at 11:56
0

you can package your script and run it via a cronjob. packaging

It might also be easier to use something like poetry for packaging. poetry

  • Do either of these hide the code from the user? - it would be very useful to package it all first and foremost of course. – ifrj Jun 14 '23 at 09:56
  • well that depends on the user. You can always somehow reverse packages or executables. If you really want to hide everything and make reverse engineering as hard as possible you should have a look at obfuscation techniques. But for the average user I would say it's easiest providing a package or an executable. But whats the point of hiding everything? – bugBounty Jun 15 '23 at 10:15