mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
feature: command line arguments
This commit is contained in:
@@ -183,7 +183,7 @@ def try_start_shellcode(shc_file):
|
|||||||
subprocess.run([
|
subprocess.run([
|
||||||
path_runshc,
|
path_runshc,
|
||||||
shc_file,
|
shc_file,
|
||||||
], check=True)
|
]) # , check=True
|
||||||
|
|
||||||
|
|
||||||
def obfuscate_shc_loader(file_shc_in, file_shc_out):
|
def obfuscate_shc_loader(file_shc_in, file_shc_out):
|
||||||
@@ -228,11 +228,11 @@ def verify_shellcode(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)
|
||||||
if os.path.isfile(verify_filename):
|
if os.path.isfile(verify_filename):
|
||||||
print("---> Verify OK. Shellcode payload verified (file was created)")
|
print("---> Verify OK. Shellcode works (file was created)")
|
||||||
os.remove(verify_filename)
|
os.remove(verify_filename)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print("---> Verify FAIL. Payload did not create file.")
|
print("---> Verify FAIL. Shellcode doesnt work (file was not created)")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@@ -262,12 +262,12 @@ def verify_injected_exe(exefile):
|
|||||||
], 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)
|
||||||
if os.path.isfile(verify_filename):
|
if os.path.isfile(verify_filename):
|
||||||
print("---> Verify OK. Infected exe verified (file was created)")
|
print("---> Verify OK. Infected exe works (file was created)")
|
||||||
# better to remove it immediately
|
# better to remove it immediately
|
||||||
os.remove(verify_filename)
|
os.remove(verify_filename)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print("---> Verify FAIL. Infected exe did not create file.")
|
print("---> Verify FAIL. Infected exe does not work (no file created)")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+34
-14
@@ -1,6 +1,7 @@
|
|||||||
import shutil
|
import shutil
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from helper import *
|
from helper import *
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
class AllocStyle(Enum):
|
class AllocStyle(Enum):
|
||||||
@@ -32,6 +33,7 @@ options_default = {
|
|||||||
|
|
||||||
"try_start_loader_shellcode": False, # without payload (Debugging)
|
"try_start_loader_shellcode": False, # without payload (Debugging)
|
||||||
"try_start_final_shellcode": True, # with payload (should work)
|
"try_start_final_shellcode": True, # with payload (should work)
|
||||||
|
"try_start_final_infected_exe": True, # with payload (should work)
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
"cleanup_files_on_start": True,
|
"cleanup_files_on_start": True,
|
||||||
@@ -84,16 +86,13 @@ options_verify = {
|
|||||||
"test_obfuscated_shc": False,
|
"test_obfuscated_shc": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
options = None
|
||||||
options = options_verify
|
|
||||||
|
|
||||||
|
|
||||||
main_c_file = os.path.join(build_dir, "main.c")
|
main_c_file = os.path.join(build_dir, "main.c")
|
||||||
main_asm_file = os.path.join(build_dir, "main.asm")
|
main_asm_file = os.path.join(build_dir, "main.asm")
|
||||||
main_exe_file = os.path.join(build_dir, "main.exe")
|
main_exe_file = os.path.join(build_dir, "main.exe")
|
||||||
main_shc_file = os.path.join(build_dir, "main.bin")
|
main_shc_file = os.path.join(build_dir, "main.bin")
|
||||||
|
|
||||||
|
|
||||||
debug_data = {
|
debug_data = {
|
||||||
"loader_shellcode": b"",
|
"loader_shellcode": b"",
|
||||||
"payload_shellcode": b"",
|
"payload_shellcode": b"",
|
||||||
@@ -111,6 +110,30 @@ debug_data = {
|
|||||||
def main():
|
def main():
|
||||||
print("Super Mega")
|
print("Super Mega")
|
||||||
|
|
||||||
|
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('--inject', type=str, help='The path to the file where we will inject ourselves in')
|
||||||
|
parser.add_argument('--verify', action='store_true', help='Debug: Perform verification')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.verify:
|
||||||
|
options = options_verify
|
||||||
|
else:
|
||||||
|
options = options_default
|
||||||
|
if args.shellcode:
|
||||||
|
if not os.path.isfile(args.shellcode):
|
||||||
|
print("Could not find: {}".format(args.shellcode))
|
||||||
|
return
|
||||||
|
options["payload"] = args.shellcode
|
||||||
|
if args.inject:
|
||||||
|
if not os.path.isfile(args.inject):
|
||||||
|
print("Could not find: {}".format(args.inject))
|
||||||
|
return
|
||||||
|
options["inject_exe"] = True
|
||||||
|
options["inject_exe_in"] = args.inject
|
||||||
|
options["inject_exe_out"] = args.inject.replace(".exe", ".infected.exe")
|
||||||
|
|
||||||
|
|
||||||
if options["cleanup_files_on_start"]:
|
if options["cleanup_files_on_start"]:
|
||||||
clean_files()
|
clean_files()
|
||||||
|
|
||||||
@@ -179,19 +202,16 @@ def main():
|
|||||||
if verify_injected_exe(options["inject_exe_out"]):
|
if verify_injected_exe(options["inject_exe_out"]):
|
||||||
debug_data["infected_exe"] = file_readall_binary(options["inject_exe_out"])
|
debug_data["infected_exe"] = file_readall_binary(options["inject_exe_out"])
|
||||||
|
|
||||||
|
if options["try_start_final_infected_exe"]:
|
||||||
|
print("--[ Start infected exe ]")
|
||||||
|
subprocess.run([
|
||||||
|
options["inject_exe_out"],
|
||||||
|
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
if options["cleanup_files_on_exit"]:
|
if options["cleanup_files_on_exit"]:
|
||||||
clean_files()
|
clean_files()
|
||||||
|
|
||||||
print("{} {} {} - {} {} {} - {} {}".format(
|
|
||||||
len(debug_data["loader_shellcode"]),
|
|
||||||
len(debug_data["payload_shellcode"]),
|
|
||||||
len(debug_data["final_shellcode"]),
|
|
||||||
len(debug_data["asm_initial"]),
|
|
||||||
len(debug_data["asm_cleanup"]),
|
|
||||||
len(debug_data["asm_fixup"]),
|
|
||||||
len(debug_data["original_exe"]),
|
|
||||||
len(debug_data["infected_exe"]),
|
|
||||||
))
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user