r/Python • u/tom333444 • Feb 10 '22
Discussion Wrote a simple python script for some random guy, he thought it was a virus
Is this reasonable? i sent it to him as an EXE to make it more convenient and without even downloading and testing it for virsuses he just accused me of sending him a virus?
I'm actually pretty confused as i took the time out of my day to figure out how to turn the script into an EXE just to make it more comfortable for him only to then get accused and blocked.
I even sent him the .py file and he thought os.system("pause") was going to take control of his computer or something i guess lol wtf.
at least i learned how to make python exes.
18
5
u/Kerbart Feb 10 '22
A lot of script kiddies write their ViRuS SoFtWaRe in Python (because it’s easy) and then package it as a .exe. Hence, security software gets triggered when it sees a py2exe file — it doesn’t know what the Python code inside it does but it surely knows it could be malicious (based on other, similar files).
As such, the .exe file you sent to your friend got false flagged by their AV software, and then he panicked and not knowing any better assumed you sent him a virus. You didn’t, but it surely looked that way for him.
3
u/Natural-Intelligence Feb 10 '22
If you want to make it "safe", do a web app. That way your program simply couldn't harm his PC unless your app sends a suspicious file and he himself runs that. He also does not need to install anything to use the app though more effort hosting such app.
Of course if you need the script to interact with his filesystem then there is not much other choices than run your code on his machine that in theory could do anything. I would be skeptical if you sent that to me as exe file but if he cannot understand code in the first place, it wouldn't matter.
2
u/efmccurdy Feb 10 '22
Is this reasonable?
Did your user run an antivirus that reported a trojan with your program?
That is a common occurrence:
https://github.com/pyinstaller/pyinstaller/issues?q=is%3Aissue+virus
https://github.com/py2exe/py2exe/issues?q=is%3Aissue+virus
If the user got a message saying your program was a virus, should they ignore the message?
3
u/OriginalTyphus Feb 10 '22
Unless you are willing to pay for certification, i would advice you avoid executables for deployment. Depending on the task there are multiple, better alternatives, such as Docker, Webapps and self-contained Python Environments.
1
u/DrummerClean Feb 10 '22
Would you mind sharing 1 or 2 ways ro do self-contained python environments? I never found any simple solution myself besides docker, but that's too cumbersome for a small CLI or such.
2
u/OriginalTyphus Feb 11 '22
I once deployed a Python tool with a BASH-Script that would create a VENV and and install all pip dependencies in it as well as a symlink from /usr/local/bin to it.
Not 100% sure Windows/Batch can do the same tho.
1
1
0
5
u/coll_ryan Feb 10 '22
Unless they happen to know python well enough to understand the source code (the os.system comment suggests not) then sending the source code is not going to be any safer than sending him the executable. If you wanted to do some harm, there are many ways to obfuscate source code so that even an experienced developer might struggle to work out what it is actually doing.