Advertisement
Guest User

crypterpython

a guest
Sep 30th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. #! /usr/bin/env python
  2. #! coding : utf-8
  3. """ usage :
  4. sudo ./nxcrypt.py --file=file_to_encrypt
  5. sudo ./nxcrypt.py --file=file_to_encrypt --output=output_file
  6. sudo ./nxcrypt.py --help
  7. """
  8.  
  9. # modules
  10. import sys
  11. import py_compile
  12. import optparse
  13. import os
  14. import commands
  15. import time
  16.  
  17. _output_ = "backdoor.py" # edit this line is you want edit default output .
  18. _byte_ = (_output_) + "c"
  19.  
  20. # if platform is linux and NXcrypt isn't launched as root
  21. if (sys.platform.startswith("linux")) :
  22. if (commands.getoutput("whoami")) != "root" :
  23. print ("run it as root")
  24. sys.exit() #exit
  25. else:
  26. pass
  27. else:
  28. pass
  29.  
  30.  
  31. #menu
  32. menu = """
  33. d8b db db db .o88b. d8888b. db db d8888b. d888888b
  34. 888o 88 `8b d8' d8P Y8 88 `8D `8b d8' 88 `8D `~~88~~'
  35. 88V8o 88 `8bd8' 8P 88oobY' `8bd8' 88oodD' 88
  36. 88 V8o88 .dPYb. 8b 88`8b 88 88~~~ 88
  37. 88 V888 .8P Y8. Y8b d8 88 `88. 88 88 88
  38. VP V8P YP YP `Y88P' 88 YD YP 88 YP
  39. (python backdoor encryption tool)
  40. """
  41. menu_linux = "\033[32m" + (menu) + "\033[37m"
  42.  
  43. name = """
  44. -NXcrypt is a tool for bypass AV
  45. -It encrypt python backdoors and payloads in bytecode
  46. -author: Hadi tux (had3s)
  47. -only for penetration testing
  48.  
  49. """
  50. name_linux = "\033[31m" + (name) + "\033[37m"
  51.  
  52. #options
  53. parser = optparse.OptionParser()
  54. parser.add_option("--file", "-f", help="python file to encrypt ", action="store", dest="file")
  55. parser.add_option("--output", "-o", help="output of crypted python file ", dest="out", action="store")
  56. option , arg = parser.parse_args()
  57. if not option.file :
  58. parser.error("file to encrypt hasn't given type --help for help ")
  59. sys.exit()
  60. elif option.file :
  61. payload = (option.file)
  62.  
  63. if not option.out :
  64. if (sys.platform.startswith("linux")) :
  65. print (menu_linux)
  66. print ("")
  67. print (name_linux)
  68. else:
  69. print (menu)
  70. print ("")
  71. print (name)
  72.  
  73. try:
  74. py_compile.compile(payload, cfile=_byte_, dfile=None, doraise=False, ) #compilation
  75. except (py_compile.PyCompileError,IOError,TypeError) :
  76. sys.exit("encryption error : file {} don't exist or it's already crypted ".format(option.file)) #error
  77. print ("[*] file : {}".format(option.file))
  78. print ("[*] default output : {}".format(_output_))
  79. if (sys.platform.startswith("linux")) :
  80. os.system(" mv {} {} ".format(_byte_,_output_))
  81.  
  82. elif (sys.platform.startswith("windows")) :
  83. os.system(" rename {} {} ".format(_byte_,_output_))
  84.  
  85. elif (sys.platform.startswith("darwin")):
  86. os.system(" mv {} {} ".format(_byte_,_output_))
  87. print ("[+] encryption finished 100% ")
  88. print time.strftime('[*] time : %H:%M ',time.localtime())
  89. print time.strftime('[*] date :%d/%m/%y ',time.localtime())
  90. print ("[+] file : {} ".format(_output_))
  91. elif option.out :
  92. output = option.out
  93. bytecode = (option.out) + "c"
  94. if (sys.platform.startswith("linux")) :
  95. print (menu_linux)
  96. print ("")
  97. print (name_linux)
  98. else:
  99. print (menu)
  100. print ("")
  101. print (name)
  102. print ("[*] file : {}".format(option.file))
  103. print ("[*] output : {}".format(output))
  104. try :
  105. py_compile.compile(payload, cfile=bytecode, dfile=None, doraise=False, ) #compilation
  106. except (py_compile.PyCompileError,IOError,TypeError) :
  107. sys.exit("encryption error : file don't exist or it's already crypted ")
  108. if (sys.platform.startswith("linux")):
  109. os.system("mv {} {} ".format(bytecode,output))
  110. elif (sys.platform.startswith("windows")):
  111. os.system("rename {} {} ".format(bytecode,output))
  112. elif (sys.platform.startswith("darwin")):
  113. os.system("mv {} {} ".format(bytecode,output))
  114. print ("[+] encryption finished 100% ")
  115. print time.strftime('[*] time : %H:%M ',time.localtime())
  116. print time.strftime('[*] date :%d/%m/%y ',time.localtime())
  117. print ("[*] file : {} ".format(output))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement