mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
refactor: make project not singleton
This commit is contained in:
@@ -7,6 +7,7 @@ CONFIG_FILE = os.path.join(os.path.dirname(__file__), "config.yaml")
|
|||||||
class Config(object):
|
class Config(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.data = {}
|
self.data = {}
|
||||||
|
self.ShowCommandOutput: bool = False
|
||||||
|
|
||||||
def getConfigPath(self):
|
def getConfigPath(self):
|
||||||
return CONFIG_FILE
|
return CONFIG_FILE
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ class FilePath(str):
|
|||||||
# with shellcodes/createfile.bin
|
# with shellcodes/createfile.bin
|
||||||
VerifyFilename: FilePath = r'C:\Temp\a'
|
VerifyFilename: FilePath = r'C:\Temp\a'
|
||||||
|
|
||||||
ShowCommandOutput: bool = False
|
|
||||||
|
|
||||||
# Correlated with real template files
|
# Correlated with real template files
|
||||||
# in plugins/
|
# in plugins/
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import glob
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from config import config
|
from config import config
|
||||||
from project import project
|
|
||||||
from defs import *
|
from defs import *
|
||||||
|
|
||||||
logger = logging.getLogger("Helper")
|
logger = logging.getLogger("Helper")
|
||||||
@@ -54,7 +53,7 @@ def run_process_checkret(args, check=True):
|
|||||||
if ret.stderr != None:
|
if ret.stderr != None:
|
||||||
logger.info(ret.stderr.decode('utf-8'))
|
logger.info(ret.stderr.decode('utf-8'))
|
||||||
raise Exception("Command failed: " + " ".join(args))
|
raise Exception("Command failed: " + " ".join(args))
|
||||||
if ShowCommandOutput:
|
if config.ShowCommandOutput:
|
||||||
logger.info("> " + " ".join(args))
|
logger.info("> " + " ".join(args))
|
||||||
if ret.stdout != None:
|
if ret.stdout != None:
|
||||||
logger.info(ret.stdout.decode('utf-8'))
|
logger.info(ret.stdout.decode('utf-8'))
|
||||||
|
|||||||
@@ -48,5 +48,3 @@ class Project():
|
|||||||
self.exe_info = ExeInfo()
|
self.exe_info = ExeInfo()
|
||||||
self.exe_info.parse_from_exe(self.inject_exe_in)
|
self.exe_info.parse_from_exe(self.inject_exe_in)
|
||||||
|
|
||||||
|
|
||||||
project = Project()
|
|
||||||
|
|||||||
+5
-4
@@ -15,7 +15,7 @@ import phases.compiler
|
|||||||
import phases.assembler
|
import phases.assembler
|
||||||
import phases.injector
|
import phases.injector
|
||||||
from observer import observer
|
from observer import observer
|
||||||
from project import project
|
from project import Project
|
||||||
|
|
||||||
|
|
||||||
log_messages = []
|
log_messages = []
|
||||||
@@ -24,6 +24,7 @@ log_messages = []
|
|||||||
def main():
|
def main():
|
||||||
logger.info("Super Mega")
|
logger.info("Super Mega")
|
||||||
config.load()
|
config.load()
|
||||||
|
project = Project()
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='SuperMega shellcode loader')
|
parser = argparse.ArgumentParser(description='SuperMega shellcode loader')
|
||||||
parser.add_argument('--shellcode', type=str, help='The path to the file of your payload shellcode')
|
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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.show:
|
if args.show:
|
||||||
ShowCommandOutput = True
|
config.ShowCommandOutput = True
|
||||||
|
|
||||||
if args.verify:
|
if args.verify:
|
||||||
project.payload_path = "shellcodes/createfile.bin"
|
project.payload_path = "shellcodes/createfile.bin"
|
||||||
@@ -106,10 +107,10 @@ def main():
|
|||||||
project.inject_exe_in = args.inject
|
project.inject_exe_in = args.inject
|
||||||
project.inject_exe_out = args.inject.replace(".exe", ".infected.exe")
|
project.inject_exe_out = args.inject.replace(".exe", ".infected.exe")
|
||||||
|
|
||||||
start()
|
start(project)
|
||||||
|
|
||||||
|
|
||||||
def start():
|
def start(project: Project):
|
||||||
# Delete: all old files
|
# Delete: all old files
|
||||||
if project.cleanup_files_on_start:
|
if project.cleanup_files_on_start:
|
||||||
clean_files()
|
clean_files()
|
||||||
|
|||||||
Reference in New Issue
Block a user