mirror of
https://github.com/dobin/SuperMega
synced 2026-06-02 17:27:10 +00:00
feature: config file
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import yaml
|
||||
import os
|
||||
import logging
|
||||
|
||||
CONFIG_FILE = os.path.join(os.path.dirname(__file__), "config.yaml")
|
||||
|
||||
class Config(object):
|
||||
def __init__(self):
|
||||
self.data = {}
|
||||
|
||||
def getConfigPath(self):
|
||||
return CONFIG_FILE
|
||||
|
||||
def getConfig(self):
|
||||
return self.data
|
||||
|
||||
def load(self):
|
||||
with open(CONFIG_FILE) as jsonfile:
|
||||
try:
|
||||
self.data = yaml.safe_load(jsonfile)
|
||||
except yaml.YAMLError as e:
|
||||
print('Decoding {} as failed with: {}'.format(CONFIG_FILE, e))
|
||||
quit()
|
||||
|
||||
if 'server' in os.environ:
|
||||
server = os.environ["server"]
|
||||
self.data["server"] = { "server": server }
|
||||
print("Using ENV: server={}, overwriting all others from config.yaml".format(
|
||||
server))
|
||||
|
||||
def get(self, value):
|
||||
return self.data.get(value, "")
|
||||
|
||||
config = Config()
|
||||
@@ -0,0 +1,7 @@
|
||||
path_cl: 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\Hostx64\x64\cl.exe'
|
||||
path_ml64: 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\Hostx64\x64\ml64.exe'
|
||||
|
||||
path_masmshc: 'C:\Users\hacker\Source\Repos\masm_shc\out\build\x64-Debug\masm_shc\masm_shc.exe'
|
||||
path_runshc: 'C:\Users\hacker\Source\Repos\masm_shc\out\build\x64-Debug\runshc\runshc.exe'
|
||||
#- path_shexec = r'C:\Research\hasherezade\exec_fiber\sh-exec-fiber.exe'
|
||||
|
||||
@@ -5,15 +5,11 @@ import shutil
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
from config import config
|
||||
|
||||
|
||||
SHC_VERIFY_SLEEP = 0.1
|
||||
|
||||
path_cl = r'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\Hostx64\x64\cl.exe'
|
||||
path_ml64 = r'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\Hostx64\x64\ml64.exe'
|
||||
|
||||
path_masmshc = r'C:\Users\hacker\Source\Repos\masm_shc\out\build\x64-Debug\masm_shc\masm_shc.exe'
|
||||
path_runshc = r'C:\Users\hacker\Source\Repos\masm_shc\out\build\x64-Debug\runshc\runshc.exe'
|
||||
#path_shexec = r'C:\Research\hasherezade\exec_fiber\sh-exec-fiber.exe'
|
||||
|
||||
verify_filename = r'C:\Temp\a'
|
||||
build_dir = "build"
|
||||
@@ -54,7 +50,7 @@ def run_process_checkret(args):
|
||||
def try_start_shellcode(shc_file):
|
||||
print("--[ Blindly execute shellcode: {} ]".format(shc_file))
|
||||
subprocess.run([
|
||||
path_runshc,
|
||||
config.get["path_runshc"],
|
||||
shc_file,
|
||||
]) # , check=True
|
||||
|
||||
|
||||
+4
-2
@@ -1,13 +1,15 @@
|
||||
from helper import *
|
||||
import pefile
|
||||
|
||||
from helper import *
|
||||
from config import config
|
||||
|
||||
|
||||
def make_shc_from_asm(asm_file, exe_file, shc_file):
|
||||
print("--[ Assemble to exe: {} -> {} -> {} ]".format(asm_file, exe_file, shc_file))
|
||||
|
||||
print("---[ Assemble ASM to EXE: {} -> {} ]".format(asm_file, exe_file))
|
||||
run_process_checkret([
|
||||
path_ml64,
|
||||
config.get("path_ml64"),
|
||||
asm_file,
|
||||
"/link",
|
||||
"/OUT:{}".format(exe_file),
|
||||
|
||||
+3
-2
@@ -1,4 +1,5 @@
|
||||
from helper import *
|
||||
from config import config
|
||||
|
||||
|
||||
def make_c_to_asm(c_file, asm_file, payload_len):
|
||||
@@ -13,7 +14,7 @@ def make_c_to_asm(c_file, asm_file, payload_len):
|
||||
# Phase 1: Compile
|
||||
print("---[ Compile: {} ]".format(c_file))
|
||||
run_process_checkret([
|
||||
path_cl,
|
||||
config.get("path_cl"),
|
||||
"/c",
|
||||
"/FA",
|
||||
"/GS-",
|
||||
@@ -29,7 +30,7 @@ def make_c_to_asm(c_file, asm_file, payload_len):
|
||||
asm_clean_file = asm_file + ".clean"
|
||||
print("---[ Cleanup: {} ]".format(asm_file))
|
||||
run_process_checkret([
|
||||
path_masmshc,
|
||||
config.get("path_masmshc"),
|
||||
asm_file,
|
||||
asm_clean_file,
|
||||
])
|
||||
|
||||
+7
-7
@@ -3,6 +3,7 @@ from enum import Enum
|
||||
from helper import *
|
||||
import argparse
|
||||
|
||||
from config import config
|
||||
from phases.ctoasm import *
|
||||
from phases.asmtoshc import *
|
||||
from phases.shctoexe import *
|
||||
@@ -50,8 +51,8 @@ options_default = {
|
||||
"cleanup_files_on_exit": True,
|
||||
|
||||
# For debugging: Can disable some steps
|
||||
"generate_asm_from_c": True,
|
||||
"generate_shc_from_asm": True,
|
||||
"generate_asm_from_c": True, # phase 2
|
||||
"generate_shc_from_asm": True, # phase 3
|
||||
|
||||
# Not working atm
|
||||
"obfuscate_shc_loader": False,
|
||||
@@ -86,8 +87,8 @@ options_verify = {
|
||||
"inject_exe_out": "out/procexp64-a.exe",
|
||||
|
||||
# For debugging: Can disable some steps
|
||||
"generate_asm_from_c": True,
|
||||
"generate_shc_from_asm": True,
|
||||
"generate_asm_from_c": True, # phase 2
|
||||
"generate_shc_from_asm": True, # phase 3
|
||||
|
||||
# cleanup
|
||||
"cleanup_files_on_start": True,
|
||||
@@ -98,8 +99,6 @@ options_verify = {
|
||||
"test_obfuscated_shc": False,
|
||||
}
|
||||
|
||||
|
||||
|
||||
options = None
|
||||
|
||||
main_c_file = os.path.join(build_dir, "main.c")
|
||||
@@ -123,6 +122,7 @@ debug_data = {
|
||||
|
||||
def main():
|
||||
print("Super Mega")
|
||||
config.load()
|
||||
|
||||
parser = argparse.ArgumentParser(description='SuperMega shellcode loader')
|
||||
parser.add_argument('--shellcode', type=str, help='The path to the file of your payload shellcode')
|
||||
@@ -255,7 +255,7 @@ def verify_shellcode(shc_name):
|
||||
pathlib.Path(verify_filename).unlink(missing_ok=True)
|
||||
|
||||
subprocess.run([
|
||||
path_runshc,
|
||||
config.get("path_runshc"),
|
||||
"{}".format(shc_name),
|
||||
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) # , check=True
|
||||
time.sleep(SHC_VERIFY_SLEEP)
|
||||
|
||||
Reference in New Issue
Block a user