Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. from re import match
  2. class Detector:
  3. signa = dict()
  4. filename ="";
  5. def __init__(self):
  6. self.signa["hide"] = 0
  7. self.signa["echrenameotofile"] = 0
  8. self.signa["copy"] = 0
  9. self.signa["call"] = 0
  10. self.signa["windir"] = 0
  11. self.signa["rename"] = 0
  12. self.filename = input("Enter filename for detection: ")
  13. self.check()
  14. def check(self):
  15. with open(self.filename) as f:
  16. text = f.readlines()
  17. str_num = 1
  18. print("---------------------DETECTS------------------------------")
  19. for i in text:
  20. if match(r".*attrib .*[%]*[\w_][\w\b_]*[%]* \+h", i) != None:
  21. print("Hide some files line in " + str(str_num))
  22. self.signa["hide"] = 1
  23. if match(".*echo.*>>[%]*[\w_][\w\b_]*[%]*", i) != None:
  24. print("Write some strange data to file in line " + str(str_num))
  25. self.signa["echrenameotofile"] = 1
  26. if match(".*<%0>>[%]*[\w_][\w\b_]*[%]*", i) != None or match(
  27. ".*copy [%]*[\w_][\w\b_\+\.]* [%]*[\w_][\w\b_\+]*.*", i) != None:
  28. print("Make copy some file in line " + str(str_num))
  29. self.signa["copy"] = 1
  30. if match(".*ren [%]*[\w_][\w\b_]*[%]* \*\.bat", i) != None:
  31. print("Change extension in line " + str(str_num))
  32. self.signa["rename"] = 1
  33. if match("call [%]*[\w_][\w\b_\+\.]*[%]* [%]*[\w_][\w\b_\+\.]*[%]*", i) != None:
  34. print("Execute other bat-file in line " + str(str_num))
  35. self.signa["call"] = 1
  36. if match(r".*mkdir %windir%\\.*", i) != None:
  37. print("Make direcriory in System Windows directory in line " + str(str_num))
  38. self.signa["windir"] = 1
  39. str_num += 1
  40. print("-----------------------------------------------------------")
  41. self.results(list(self.signa.values()).count(1))
  42. def results(self,raiting):
  43. if (raiting==0):
  44. print("All right. It is not virus")
  45. elif (raiting==1):
  46. print("Detection one type of strange. It may be virus. check it.")
  47. elif (raiting==2):
  48. print("Detection two type of strange. It may be virus. check it.")
  49. elif (raiting==3):
  50. print("Detection three stranges. It may be virus. check it.")
  51. elif (raiting==4):
  52. print("WARNING Detection FOUR type of strange. It may be virus. check it.")
  53. elif (raiting==5):
  54. print("DANGER Detection FIVE type of strange. It is virus.")
  55. elif (raiting==6):
  56. print("DANGER ! ! ! IT IS VIRUS ! ! !")
  57. Detector()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement