If I open a binary or text file in Python with the open and read() commands to be written somewhere else, will it be executed? Could this expose the computer to malware if the file contains malicious code?
No, read and open file does not execute the executable file in python. If you want you can read the executable file in binary by adding "b"
open("readfile.txt", "rb")
For executing the py file you need to use "exec" function like
execfile('hello.py')
For executing external exe file there are several ways,where you need to import "os" or "subprocess".
example you can execute file by using the below function.
import os
os.startfile("C:\Documents and Settings\flow_model\flow.exe")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With