mirror of
https://github.com/XboxDev/endgame-exploit.git
synced 2025-12-19 17:27:35 -05:00
feat: Linux compatibility (looking for NASM in PATH) (#1)
* feat: Linux compatibility (looking for NASM in PATH) * just a tiny bit of cleanup/normalizing to my goofy code formatting
This commit is contained in:
18
main.py
18
main.py
@@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import ctypes
|
import ctypes
|
||||||
|
import shutil
|
||||||
import struct
|
import struct
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
@@ -31,7 +32,6 @@ def p16(value):
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
BASE_PATH = os.path.join(os.path.dirname(__file__))
|
BASE_PATH = os.path.join(os.path.dirname(__file__))
|
||||||
NASM_PATH = os.path.join(BASE_PATH, "nasm.exe")
|
|
||||||
ENDGAME_PATH = os.path.join(BASE_PATH, "ENDGAME")
|
ENDGAME_PATH = os.path.join(BASE_PATH, "ENDGAME")
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -78,15 +78,25 @@ def compile_shellcode(shellcode_filepath, debug=False):
|
|||||||
"""
|
"""
|
||||||
assert shellcode_filepath.endswith(".asm")
|
assert shellcode_filepath.endswith(".asm")
|
||||||
|
|
||||||
# Run nasm.exe and capture the output and errors
|
# for Windows-based systems just use the local nasm.exe included in the repo
|
||||||
command = [NASM_PATH, shellcode_filepath]
|
if os.name == "nt":
|
||||||
|
nasm_executable = os.path.join(BASE_PATH, "nasm.exe")
|
||||||
|
|
||||||
|
# for POSIX systems (linux, macOS) look for nasm in the system path
|
||||||
|
elif os.name == "posix":
|
||||||
|
if not shutil.which("nasm"):
|
||||||
|
raise FileNotFoundError("NASM cannot be found in PATH")
|
||||||
|
nasm_executable = "nasm"
|
||||||
|
|
||||||
|
command = [nasm_executable, shellcode_filepath]
|
||||||
if debug:
|
if debug:
|
||||||
command.insert(1, "-dDEBUG")
|
command.insert(1, "-dDEBUG")
|
||||||
|
|
||||||
|
# run nasm and capture the output and errors
|
||||||
print("[*] Assembling shellcode... ", end="")
|
print("[*] Assembling shellcode... ", end="")
|
||||||
result = subprocess.run(command, capture_output=True)
|
result = subprocess.run(command, capture_output=True)
|
||||||
|
|
||||||
# Check the return code of the command
|
# check the return code to determine if compilation succeeded
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
output = result.stdout.decode()
|
output = result.stdout.decode()
|
||||||
if output.strip():
|
if output.strip():
|
||||||
|
|||||||
Reference in New Issue
Block a user