refactor: make project not singleton

This commit is contained in:
Dobin
2024-02-19 19:36:49 +00:00
parent f915b253a7
commit e3d2deb4a0
5 changed files with 7 additions and 10 deletions
+1
View File
@@ -7,6 +7,7 @@ CONFIG_FILE = os.path.join(os.path.dirname(__file__), "config.yaml")
class Config(object):
def __init__(self):
self.data = {}
self.ShowCommandOutput: bool = False
def getConfigPath(self):
return CONFIG_FILE
-2
View File
@@ -7,8 +7,6 @@ class FilePath(str):
# with shellcodes/createfile.bin
VerifyFilename: FilePath = r'C:\Temp\a'
ShowCommandOutput: bool = False
# Correlated with real template files
# in plugins/
+1 -2
View File
@@ -5,7 +5,6 @@ import glob
import logging
from config import config
from project import project
from defs import *
logger = logging.getLogger("Helper")
@@ -54,7 +53,7 @@ def run_process_checkret(args, check=True):
if ret.stderr != None:
logger.info(ret.stderr.decode('utf-8'))
raise Exception("Command failed: " + " ".join(args))
if ShowCommandOutput:
if config.ShowCommandOutput:
logger.info("> " + " ".join(args))
if ret.stdout != None:
logger.info(ret.stdout.decode('utf-8'))
-2
View File
@@ -48,5 +48,3 @@ class Project():
self.exe_info = ExeInfo()
self.exe_info.parse_from_exe(self.inject_exe_in)
project = Project()
+5 -4
View File
@@ -15,7 +15,7 @@ import phases.compiler
import phases.assembler
import phases.injector
from observer import observer
from project import project
from project import Project
log_messages = []
@@ -24,6 +24,7 @@ log_messages = []
def main():
logger.info("Super Mega")
config.load()
project = Project()
parser = argparse.ArgumentParser(description='SuperMega shellcode loader')
parser.add_argument('--shellcode', type=str, help='The path to the file of your payload shellcode')
@@ -40,7 +41,7 @@ def main():
args = parser.parse_args()
if args.show:
ShowCommandOutput = True
config.ShowCommandOutput = True
if args.verify:
project.payload_path = "shellcodes/createfile.bin"
@@ -106,10 +107,10 @@ def main():
project.inject_exe_in = args.inject
project.inject_exe_out = args.inject.replace(".exe", ".infected.exe")
start()
start(project)
def start():
def start(project: Project):
# Delete: all old files
if project.cleanup_files_on_start:
clean_files()