Hello! I have the following script:
import os
import stat
curDir = os.getcwd()
autorun_signature = [ "[Autorun]",
"Open=regsvr.exe",
"Shellexecute=regsvr.exe",
"Shell\Open\command=regsvr.exe",
"Shell=Open" ]
content = []
def read_signature(file_path):
try:
with open(file_path) as data:
for i in range(0,5):
content.append(data.readline())
except IOError as err:
print("File Error: "+ str(err))
read_signature(os.getcwd()+'/'+'autorun.inf')
if(content==autorun_signature):
print("Equal content")
else:
print("Not equal")
It prints not equal, then I tried this method:
import os
import stat
curDir = os.getcwd()
autorun_signature = "[Autorun]\nOpen=regsvr.exe\nShellexecute=regsvr.exe\nShell\Open\command=regsvr.exe\nShell=Open"
content = ""
def read_signature(file_path):
try:
with open(file_path) as data:
content = data.read()
except IOError as err:
print("File Error: "+ str(err))
read_signature(os.getcwd()+'/'+'autorun.inf')
if(content==autorun_signature):
print("Equal content")
else:
print("Not equal")
It also print not equal! I want to store the content of autorun.inf file in script and every time i find such file I want to check its content if it is or not, I could not do, can anyone help me? the content of autorun.inf:
[Autorun]
Open=regsvr.exe
Shellexecute=regsvr.exe
Shell\Open\command=regsvr.exe
Shell=Open
contentafter reading it, what does it display?