mirror of
https://github.com/Pennyw0rth/NetExec.git
synced 2026-11-09 17:42:36 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45573e662e |
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import datetime
|
||||
import logging
|
||||
from os import makedirs
|
||||
|
||||
from nxc.paths import NXC_PATH
|
||||
|
||||
|
||||
def create_log_dir(module_name):
|
||||
makedirs(f"{NXC_PATH}/logs/{module_name}", exist_ok=True)
|
||||
|
||||
|
||||
def create_loot_dir(module_name):
|
||||
makedirs(f"{NXC_PATH}/loot/{module_name}", exist_ok=True)
|
||||
|
||||
|
||||
def generate_module_log_file(module_name):
|
||||
create_log_dir(module_name)
|
||||
return f"{NXC_PATH}/logs/{module_name}/{datetime.datetime.now().strftime('%Y-%m-%d')}.log"
|
||||
|
||||
|
||||
def create_module_logger(module_name):
|
||||
log_file = generate_module_log_file(module_name)
|
||||
module_logger = logging.getLogger(module_name)
|
||||
module_logger.propagate = False
|
||||
module_logger.setLevel(logging.INFO)
|
||||
module_file_handler = logging.FileHandler(log_file)
|
||||
module_file_handler.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(message)s"))
|
||||
module_logger.addHandler(module_file_handler)
|
||||
return module_logger
|
||||
|
||||
|
||||
def add_loot_data(module_name, filename, data):
|
||||
create_loot_dir(module_name)
|
||||
loot_file = get_loot_data_filepath(module_name, filename)
|
||||
with open(loot_file, "a") as file:
|
||||
file.write(data)
|
||||
|
||||
|
||||
def get_loot_data_filepath(module_name, filename):
|
||||
return f"{NXC_PATH}/loot/{module_name}/{filename}"
|
||||
|
||||
|
||||
def get_loot_data_folder(module_name):
|
||||
return f"{NXC_PATH}/loot/{module_name}"
|
||||
@@ -1,4 +1,5 @@
|
||||
from nxc.helpers.misc import CATEGORY
|
||||
from nxc.helpers.modules import add_loot_data
|
||||
|
||||
|
||||
class NXCModule:
|
||||
@@ -8,7 +9,7 @@ class NXCModule:
|
||||
Module by @yomama
|
||||
"""
|
||||
|
||||
name = "example module"
|
||||
name = "example_module" # Make sure this is unique and one word (no spaces)
|
||||
description = "I do something"
|
||||
supported_protocols = [] # Example: ['smb', 'mssql']
|
||||
category = CATEGORY.ENUMERATION # Must be one of "Enumeration", "Privilege Escalation" or "Credential Dumping". Use what fits best.
|
||||
@@ -45,8 +46,11 @@ class NXCModule:
|
||||
except Exception as e:
|
||||
context.log.exception(f"Exception occurred: {e}") # This will display an exception traceback screen after an exception was raised and should only be used for critical errors
|
||||
|
||||
# Use this function to add loot data you want to save to $NXC_PATH/loot/$MODULE_NAME/$FILENAME
|
||||
add_loot_data(self.name, "custom_loot_file.txt", "Data can be anything you want, passwords, hashes, or anything")
|
||||
|
||||
def on_admin_login(self, context, connection):
|
||||
"""Concurrent.
|
||||
Required if on_login is not present
|
||||
This gets called on each authenticated connection with Administrative privileges
|
||||
This gets called on each authenticated connection with Administrative privileges
|
||||
"""
|
||||
Reference in new issue
Block a user