ahmedkhlief / Ninja

Open source C2 server created for stealth red team operations
776 stars 169 forks source link

Running DA command crashes Ninja #26

Open mike-nolan-councilman opened 2 years ago

mike-nolan-councilman commented 2 years ago

Running DA command results in the following error every time.

Victim machine is a Windows 10 using the obfuscated powershell payload.

Ninja is running on Kali 2022.1

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ │ │ /home/kali/Ninja/Ninja.py:161 in │ │ │ │ 158 │ │ """Display banner""" │ │ 159 │ │ Ninja.Banner() │ │ 160 │ │ """Run Ninja""" │ │ ❱ 161 │ │ ninja.main() │ │ 162 │ except Exception: │ │ 163 │ │ console.print_exception() │ │ 164 │ │ /home/kali/Ninja/Ninja.py:139 in main │ │ │ │ 136 │ │ │ console.print("[!] Webshell list file doesn't exist.\n", style="red") │ │ 137 │ │ │ │ 138 │ │ """Start Ninja Command line""" │ │ ❱ 139 │ │ self.NinjaCMD() │ │ 140 │ │ │ 141 │ @staticmethod │ │ 142 │ def Banner(): │ │ │ │ /home/kali/Ninja/Ninja.py:74 in NinjaCMD │ │ │ │ 71 │ │ │ │ │ │ 72 │ │ │ │ if bcommand: │ │ 73 │ │ │ │ │ if bcommand[0] in cmd.COMMANDS: │ │ ❱ 74 │ │ │ │ │ │ result = getattr(globals()['cmd'](), bcommand[0])(bcommand) │ │ 75 │ │ │ │ │ elif bcommand[ │ │ 76 │ │ │ │ │ │ 0] not in cmd.COMMANDS and config.POINTER != 'main' and config.P │ │ 77 │ │ │ │ │ │ config.COMMAND[config.POINTER].append(encrypt(AESKey, command.st │ │ │ │ /home/kali/Ninja/core/cmd.py:331 in DA │ │ │ │ 328 │ │ if config.Implant_Type != 'agent': │ │ 329 │ │ │ print("This command can only be used in agent mode") │ │ 330 │ │ │ return │ │ ❱ 331 │ │ config.COMMAND[config.get_pointer()].append(encrypt(config.AESKey, "load PowerVi │ │ 332 │ │ config.COMMAND[config.get_pointer()].append(encrypt(config.AESKey, "load DA.ps1" │ │ 333 │ │ │ 334 │ def kerb(self, args=None): │ │ │ │ /home/kali/Ninja/core/Encryption.py:63 in encrypt │ │ │ │ 60 │ if mod != 0: │ │ 61 │ │ newlen = len(data) + (16 - mod) │ │ 62 │ │ data = data.ljust(newlen, ' ') │ │ ❱ 63 │ aes = get_encryption(key, os.urandom(16)) │ │ 64 │ data = aes.IV + aes.encrypt(data.encode("utf-8")) │ │ 65 │ if not gzip: │ │ 66 │ │ data = base64.b64encode(data) │ │ │ │ /home/kali/Ninja/core/Encryption.py:11 in get_encryption │ │ │ │ 8 │ from Crypto.Cipher import AES │ │ 9 │ iv = os.urandom(AES.block_size) │ │ 10 │ bkey = base64.b64decode(key) │ │ ❱ 11 │ aes = AES.new(bkey, AES.MODE_CBC, iv) │ │ 12 │ return aes │ │ 13 │ │ 14 │ │ │ │ /usr/local/lib/python3.10/dist-packages/Crypto/Cipher/AES.py:95 in new │ │ │ │ 92 │ │ │ 93 │ :Return: an AESCipher object │ │ 94 │ """ │ │ ❱ 95 │ return AESCipher(key, *args, kwargs) │ │ 96 │ │ 97 #: Electronic Code Book (ECB). See blockalgo.MODE_ECB. │ │ 98 MODE_ECB = 1 │ │ │ │ /usr/local/lib/python3.10/dist-packages/Crypto/Cipher/AES.py:59 in init │ │ │ │ 56 │ │ """Initialize an AES cipher object │ │ 57 │ │ │ │ 58 │ │ See also new() at the module level.""" │ │ ❱ 59 │ │ blockalgo.BlockAlgo.init(self, _AES, key, *args, *kwargs) │ │ 60 │ │ 61 def new(key, args, kwargs): │ │ 62 │ """Create a new AES cipher │ │ │ │ /usr/local/lib/python3.10/dist-packages/Crypto/Cipher/blockalgo.py:141 in init │ │ │ │ 138 │ │ self.block_size = factory.block_size │ │ 139 │ │ │ │ 140 │ │ if self.mode != MODE_OPENPGP: │ │ ❱ 141 │ │ │ self._cipher = factory.new(key, *args, **kwargs) │ │ 142 │ │ │ self.IV = self._cipher.IV │ │ 143 │ │ else: │ │ 144 │ │ │ # OPENPGP mode. For details, see 13.9 in RCC4880. │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

zAbuQasem commented 2 years ago

Hello @mike-nolan-councilman Please provide a screenshot of the error and your python version.