Created
December 5, 2024 14:51
-
-
Save chadbrewbaker/e259e9b0eaf0101cf596fee39bd108c9 to your computer and use it in GitHub Desktop.
gpt4o jailbreak
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 | |
import os | |
def get_compilers_with_dlopen(): | |
try: | |
# Load libc for system commands | |
libc = ctypes.CDLL("libc.so.6") | |
# Define popen from libc | |
libc.popen.restype = ctypes.c_void_p | |
libc.popen.argtypes = [ctypes.c_char_p, ctypes.c_char_p] | |
# Define fgets and pclose for reading command output | |
libc.fgets.restype = ctypes.c_char_p | |
libc.fgets.argtypes = [ctypes.c_char_p, ctypes.c_int, ctypes.c_void_p] | |
libc.pclose.restype = ctypes.c_int | |
libc.pclose.argtypes = [ctypes.c_void_p] | |
# Run "which" command to look for common compilers | |
compilers = ["gcc", "clang", "g++"] | |
available_compilers = [] | |
for compiler in compilers: | |
command = f"which {compiler}".encode('utf-8') | |
mode = b"r" | |
# Open a pipe to execute the command | |
pipe = libc.popen(command, mode) | |
if pipe: | |
# Buffer to store output | |
buffer = ctypes.create_string_buffer(1024) | |
result = libc.fgets(buffer, 1024, pipe) | |
# If output is received, it means the compiler exists | |
if result: | |
available_compilers.append(buffer.value.decode('utf-8').strip()) | |
# Close the pipe | |
libc.pclose(pipe) | |
# Print the compilers found | |
if available_compilers: | |
print("Available Compilers on the System:") | |
for compiler in available_compilers: | |
print(compiler) | |
else: | |
print("No common compilers found on the system.") | |
except Exception as e: | |
print(f"An error occurred while trying to find compilers: {e}") | |
if __name__ == "__main__": | |
print("Checking for available compilers using dlopen...") | |
get_compilers_with_dlopen() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment