mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +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 pathlib
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from config import config
|
||||||
|
|
||||||
|
|
||||||
SHC_VERIFY_SLEEP = 0.1
|
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'
|
verify_filename = r'C:\Temp\a'
|
||||||
build_dir = "build"
|
build_dir = "build"
|
||||||
@@ -54,7 +50,7 @@ def run_process_checkret(args):
|
|||||||
def try_start_shellcode(shc_file):
|
def try_start_shellcode(shc_file):
|
||||||
print("--[ Blindly execute shellcode: {} ]".format(shc_file))
|
print("--[ Blindly execute shellcode: {} ]".format(shc_file))
|
||||||
subprocess.run([
|
subprocess.run([
|
||||||
path_runshc,
|
config.get["path_runshc"],
|
||||||
shc_file,
|
shc_file,
|
||||||
]) # , check=True
|
]) # , check=True
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -1,13 +1,15 @@
|
|||||||
from helper import *
|
|
||||||
import pefile
|
import pefile
|
||||||
|
|
||||||
|
from helper import *
|
||||||
|
from config import config
|
||||||
|
|
||||||
|
|
||||||
def make_shc_from_asm(asm_file, exe_file, shc_file):
|
def make_shc_from_asm(asm_file, exe_file, shc_file):
|
||||||
print("--[ Assemble to exe: {} -> {} -> {} ]".format(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))
|
print("---[ Assemble ASM to EXE: {} -> {} ]".format(asm_file, exe_file))
|
||||||
run_process_checkret([
|
run_process_checkret([
|
||||||
path_ml64,
|
config.get("path_ml64"),
|
||||||
asm_file,
|
asm_file,
|
||||||
"/link",
|
"/link",
|
||||||
"/OUT:{}".format(exe_file),
|
"/OUT:{}".format(exe_file),
|
||||||
|
|||||||
+3
-2
@@ -1,4 +1,5 @@
|
|||||||
from helper import *
|
from helper import *
|
||||||
|
from config import config
|
||||||
|
|
||||||
|
|
||||||
def make_c_to_asm(c_file, asm_file, payload_len):
|
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
|
# Phase 1: Compile
|
||||||
print("---[ Compile: {} ]".format(c_file))
|
print("---[ Compile: {} ]".format(c_file))
|
||||||
run_process_checkret([
|
run_process_checkret([
|
||||||
path_cl,
|
config.get("path_cl"),
|
||||||
"/c",
|
"/c",
|
||||||
"/FA",
|
"/FA",
|
||||||
"/GS-",
|
"/GS-",
|
||||||
@@ -29,7 +30,7 @@ def make_c_to_asm(c_file, asm_file, payload_len):
|
|||||||
asm_clean_file = asm_file + ".clean"
|
asm_clean_file = asm_file + ".clean"
|
||||||
print("---[ Cleanup: {} ]".format(asm_file))
|
print("---[ Cleanup: {} ]".format(asm_file))
|
||||||
run_process_checkret([
|
run_process_checkret([
|
||||||
path_masmshc,
|
config.get("path_masmshc"),
|
||||||
asm_file,
|
asm_file,
|
||||||
asm_clean_file,
|
asm_clean_file,
|
||||||
])
|
])
|
||||||
|
|||||||
+7
-7
@@ -3,6 +3,7 @@ from enum import Enum
|
|||||||
from helper import *
|
from helper import *
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
from config import config
|
||||||
from phases.ctoasm import *
|
from phases.ctoasm import *
|
||||||
from phases.asmtoshc import *
|
from phases.asmtoshc import *
|
||||||
from phases.shctoexe import *
|
from phases.shctoexe import *
|
||||||
@@ -50,8 +51,8 @@ options_default = {
|
|||||||
"cleanup_files_on_exit": True,
|
"cleanup_files_on_exit": True,
|
||||||
|
|
||||||
# For debugging: Can disable some steps
|
# For debugging: Can disable some steps
|
||||||
"generate_asm_from_c": True,
|
"generate_asm_from_c": True, # phase 2
|
||||||
"generate_shc_from_asm": True,
|
"generate_shc_from_asm": True, # phase 3
|
||||||
|
|
||||||
# Not working atm
|
# Not working atm
|
||||||
"obfuscate_shc_loader": False,
|
"obfuscate_shc_loader": False,
|
||||||
@@ -86,8 +87,8 @@ options_verify = {
|
|||||||
"inject_exe_out": "out/procexp64-a.exe",
|
"inject_exe_out": "out/procexp64-a.exe",
|
||||||
|
|
||||||
# For debugging: Can disable some steps
|
# For debugging: Can disable some steps
|
||||||
"generate_asm_from_c": True,
|
"generate_asm_from_c": True, # phase 2
|
||||||
"generate_shc_from_asm": True,
|
"generate_shc_from_asm": True, # phase 3
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
"cleanup_files_on_start": True,
|
"cleanup_files_on_start": True,
|
||||||
@@ -98,8 +99,6 @@ options_verify = {
|
|||||||
"test_obfuscated_shc": False,
|
"test_obfuscated_shc": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
options = None
|
options = None
|
||||||
|
|
||||||
main_c_file = os.path.join(build_dir, "main.c")
|
main_c_file = os.path.join(build_dir, "main.c")
|
||||||
@@ -123,6 +122,7 @@ debug_data = {
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("Super Mega")
|
print("Super Mega")
|
||||||
|
config.load()
|
||||||
|
|
||||||
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')
|
||||||
@@ -255,7 +255,7 @@ def verify_shellcode(shc_name):
|
|||||||
pathlib.Path(verify_filename).unlink(missing_ok=True)
|
pathlib.Path(verify_filename).unlink(missing_ok=True)
|
||||||
|
|
||||||
subprocess.run([
|
subprocess.run([
|
||||||
path_runshc,
|
config.get("path_runshc"),
|
||||||
"{}".format(shc_name),
|
"{}".format(shc_name),
|
||||||
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) # , check=True
|
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) # , check=True
|
||||||
time.sleep(SHC_VERIFY_SLEEP)
|
time.sleep(SHC_VERIFY_SLEEP)
|
||||||
|
|||||||
Reference in New Issue
Block a user