├── .gitignore ├── .idea ├── .gitignore ├── inspectionProfiles │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── paula.iml └── vcs.xml ├── Benchmarks ├── forktest.py └── forktest2.py ├── Constants.py ├── FuzzingScripts ├── Fuzzer.py ├── FuzzerLauncher.py ├── bench1.py ├── fuzzme │ ├── .directory │ ├── AutomatonGenerator.py │ ├── a.out │ ├── busy0 │ │ ├── results0-10 │ │ ├── results1-10 │ │ ├── results2-10 │ │ └── results3-10 │ ├── busy4 │ │ ├── results0-10 │ │ ├── results1-10 │ │ ├── results2-10 │ │ └── results3-10 │ ├── busy5 │ │ ├── results0-10 │ │ └── results1-10 │ ├── busyb │ │ ├── results0-10 │ │ └── results1-10 │ ├── fuzzme │ ├── fuzzme.asm │ ├── fuzzme.c │ ├── fuzzme_busy0 │ ├── fuzzme_busy0_read │ ├── fuzzme_busy10_read │ ├── fuzzme_busy2 │ ├── fuzzme_busy20_read │ ├── fuzzme_busy2_read │ ├── fuzzme_busy40_read │ ├── fuzzme_busy4_read │ ├── fuzzme_busy5_read │ ├── fuzzme_busy60_read │ ├── fuzzme_busy6_read │ ├── fuzzme_busy70_read │ ├── fuzzme_busy80_read │ ├── fuzzme_busy8_read │ ├── fuzzme_busya_read │ ├── fuzzme_busyb_read │ ├── fuzzme_busyc_read │ ├── fuzzme_busye_read │ ├── fuzzme_busyf_read │ ├── fuzzme_fgetc.c │ ├── fuzzme_novolatile │ ├── fuzzme_volatile │ ├── novolatile.asm │ ├── results_0 │ │ ├── ForkFuzzer-seed11-DOSYS0 │ │ ├── ForkFuzzer-seed11-DOSYS1 │ │ └── FuzzerForkserver-seed11-DOSYS0 │ ├── results_10 │ │ ├── ForkFuzzer-seed11-DOSYS0 │ │ └── FuzzerForkserver-seed11-DOSYS0 │ ├── results_2 │ │ ├── ForkFuzzer-seed11-DOSYS0 │ │ ├── ForkFuzzer-seed11-DOSYS1 │ │ └── FuzzerForkserver-seed11-DOSYS0 │ ├── results_20 │ │ ├── ForkFuzzer-seed11-DOSYS0 │ │ └── FuzzerForkserver-seed11-DOSYS0 │ ├── results_4 │ │ ├── ForkFuzzer-seed11-DOSYS0 │ │ ├── ForkFuzzer-seed11-DOSYS1 │ │ └── FuzzerForkserver-seed11-DOSYS0 │ ├── results_40 │ │ ├── ForkFuzzer-seed11-DOSYS0 │ │ └── FuzzerForkserver-seed11-DOSYS0 │ ├── results_6 │ │ ├── ForkFuzzer-seed11-DOSYS0 │ │ ├── ForkFuzzer-seed11-DOSYS1 │ │ └── results '__main__.ForkFuzzer'>-seed11-DOSYS0--9132 │ ├── results_8 │ │ ├── ForkFuzzer-seed11-DOSYS0 │ │ ├── ForkFuzzer-seed11-DOSYS1 │ │ └── FuzzerForkserver-seed11-DOSYS0 │ ├── results_a │ │ ├── ForkFuzzer-seed11-DOSYS0 │ │ └── ForkFuzzer-seed11-DOSYS1 │ ├── results_c │ │ ├── ForkFuzzer-seed11-DOSYS0--7055 │ │ └── ForkFuzzer-seed11-DOSYS1 │ ├── results_e │ │ ├── ForkFuzzer-seed11-DOSYS0 │ │ ├── ForkFuzzer-seed11-DOSYS1 │ │ └── results '__main__.FuzzerForkserver'>-seed11-DOSYS0--5486 │ ├── testpipe │ │ ├── PaulaPipe.py │ │ ├── test.py │ │ └── waiter.py │ └── volatile.asm └── runbenchmark.sh ├── HyxTalker.py ├── InputHandler.py ├── License.txt ├── ProcessManager.py ├── ProcessWrapper.py ├── README.md ├── demo ├── ba_kolloq_init ├── berzandemo.c ├── exittest.c ├── forktest.c └── simple_heap_exploit.c ├── docs ├── Screenshot1.png ├── _config.yml ├── praesi.pdf ├── test └── thesis.pdf ├── forkever.py ├── init_demo ├── init_file_example ├── installCptrace ├── README.rst ├── build │ ├── bdist.linux-x86_64 │ │ └── egg │ │ │ └── ptrace │ │ │ ├── __init__.py │ │ │ ├── binding │ │ │ ├── __init__.py │ │ │ ├── cpu.py │ │ │ ├── freebsd_struct.py │ │ │ ├── func.py │ │ │ ├── linux_struct.py │ │ │ └── openbsd_struct.py │ │ │ ├── cpu_info.py │ │ │ ├── ctypes_libc.py │ │ │ ├── ctypes_tools.py │ │ │ ├── debugger │ │ │ ├── __init__.py │ │ │ ├── application.py │ │ │ ├── backtrace.py │ │ │ ├── breakpoint.py │ │ │ ├── child.py │ │ │ ├── debugger.py │ │ │ ├── memory_mapping.py │ │ │ ├── parse_expr.py │ │ │ ├── process.py │ │ │ ├── process_error.py │ │ │ ├── process_event.py │ │ │ ├── ptrace_signal.py │ │ │ ├── signal_reason.py │ │ │ └── syscall_state.py │ │ │ ├── disasm.py │ │ │ ├── error.py │ │ │ ├── func_arg.py │ │ │ ├── func_call.py │ │ │ ├── linux_proc.py │ │ │ ├── logging_tools.py │ │ │ ├── mockup.py │ │ │ ├── os_tools.py │ │ │ ├── process_tools.py │ │ │ ├── profiler.py │ │ │ ├── pydistorm.py │ │ │ ├── signames.py │ │ │ ├── syscall │ │ │ ├── __init__.py │ │ │ ├── freebsd_constants.py │ │ │ ├── freebsd_syscall.py │ │ │ ├── linux_constants.py │ │ │ ├── linux_struct.py │ │ │ ├── linux_syscall32.py │ │ │ ├── linux_syscall64.py │ │ │ ├── names.py │ │ │ ├── posix_arg.py │ │ │ ├── posix_constants.py │ │ │ ├── prototypes.py │ │ │ ├── ptrace_syscall.py │ │ │ ├── socketcall.py │ │ │ ├── socketcall_constants.py │ │ │ ├── socketcall_struct.py │ │ │ └── syscall_argument.py │ │ │ ├── terminal.py │ │ │ ├── tools.py │ │ │ └── version.py │ ├── lib.linux-x86_64-3.7 │ │ └── cptrace.cpython-37m-x86_64-linux-gnu.so │ ├── lib │ │ └── ptrace │ │ │ ├── __init__.py │ │ │ ├── binding │ │ │ ├── __init__.py │ │ │ ├── cpu.py │ │ │ ├── freebsd_struct.py │ │ │ ├── func.py │ │ │ ├── linux_struct.py │ │ │ └── openbsd_struct.py │ │ │ ├── cpu_info.py │ │ │ ├── ctypes_libc.py │ │ │ ├── ctypes_tools.py │ │ │ ├── debugger │ │ │ ├── __init__.py │ │ │ ├── application.py │ │ │ ├── backtrace.py │ │ │ ├── breakpoint.py │ │ │ ├── child.py │ │ │ ├── debugger.py │ │ │ ├── memory_mapping.py │ │ │ ├── parse_expr.py │ │ │ ├── process.py │ │ │ ├── process_error.py │ │ │ ├── process_event.py │ │ │ ├── ptrace_signal.py │ │ │ ├── signal_reason.py │ │ │ └── syscall_state.py │ │ │ ├── disasm.py │ │ │ ├── error.py │ │ │ ├── func_arg.py │ │ │ ├── func_call.py │ │ │ ├── linux_proc.py │ │ │ ├── logging_tools.py │ │ │ ├── mockup.py │ │ │ ├── os_tools.py │ │ │ ├── process_tools.py │ │ │ ├── profiler.py │ │ │ ├── pydistorm.py │ │ │ ├── signames.py │ │ │ ├── syscall │ │ │ ├── __init__.py │ │ │ ├── freebsd_constants.py │ │ │ ├── freebsd_syscall.py │ │ │ ├── linux_constants.py │ │ │ ├── linux_struct.py │ │ │ ├── linux_syscall32.py │ │ │ ├── linux_syscall64.py │ │ │ ├── names.py │ │ │ ├── posix_arg.py │ │ │ ├── posix_constants.py │ │ │ ├── prototypes.py │ │ │ ├── ptrace_syscall.py │ │ │ ├── socketcall.py │ │ │ ├── socketcall_constants.py │ │ │ ├── socketcall_struct.py │ │ │ └── syscall_argument.py │ │ │ ├── terminal.py │ │ │ ├── tools.py │ │ │ └── version.py │ ├── scripts-3.7 │ │ └── strace.py │ └── temp.linux-x86_64-3.7 │ │ └── cptrace │ │ └── cptrace.o ├── cptrace │ ├── Makefile │ ├── cptrace.c │ └── version.py ├── doc │ └── cptrace.rst ├── ptrace │ ├── __init__.py │ ├── binding │ │ ├── __init__.py │ │ ├── cpu.py │ │ ├── freebsd_struct.py │ │ ├── func.py │ │ ├── linux_struct.py │ │ └── openbsd_struct.py │ ├── cpu_info.py │ ├── ctypes_libc.py │ ├── ctypes_tools.py │ ├── debugger │ │ ├── __init__.py │ │ ├── application.py │ │ ├── backtrace.py │ │ ├── breakpoint.py │ │ ├── child.py │ │ ├── debugger.py │ │ ├── memory_mapping.py │ │ ├── parse_expr.py │ │ ├── process.py │ │ ├── process_error.py │ │ ├── process_event.py │ │ ├── ptrace_signal.py │ │ ├── signal_reason.py │ │ └── syscall_state.py │ ├── disasm.py │ ├── error.py │ ├── func_arg.py │ ├── func_call.py │ ├── linux_proc.py │ ├── logging_tools.py │ ├── mockup.py │ ├── os_tools.py │ ├── process_tools.py │ ├── profiler.py │ ├── pydistorm.py │ ├── signames.py │ ├── syscall │ │ ├── __init__.py │ │ ├── freebsd_constants.py │ │ ├── freebsd_syscall.py │ │ ├── linux_constants.py │ │ ├── linux_struct.py │ │ ├── linux_syscall32.py │ │ ├── linux_syscall64.py │ │ ├── names.py │ │ ├── posix_arg.py │ │ ├── posix_constants.py │ │ ├── prototypes.py │ │ ├── ptrace_syscall.py │ │ ├── socketcall.py │ │ ├── socketcall_constants.py │ │ ├── socketcall_struct.py │ │ └── syscall_argument.py │ ├── terminal.py │ ├── tools.py │ └── version.py ├── python_ptrace.egg-info │ ├── PKG-INFO │ ├── SOURCES.txt │ ├── dependency_links.txt │ ├── requires.txt │ └── top_level.txt ├── setup.py ├── setup_cptrace.py └── strace.py ├── launcher ├── babymalloc ├── babymalloc.c ├── dummy.asm ├── dummylauncher ├── launcher.c └── makefile ├── logging2.py ├── ptrace ├── __init__.py ├── binding │ ├── __init__.py │ ├── cpu.py │ ├── freebsd_struct.py │ ├── func.py │ ├── linux_struct.py │ └── openbsd_struct.py ├── cpu_info.py ├── ctypes_libc.py ├── ctypes_tools.py ├── debugger │ ├── __init__.py │ ├── application.py │ ├── backtrace.py │ ├── breakpoint.py │ ├── child.py │ ├── debugger.py │ ├── memory_mapping.py │ ├── parse_expr.py │ ├── process.py │ ├── process_error.py │ ├── process_event.py │ ├── ptrace_signal.py │ ├── signal_reason.py │ └── syscall_state.py ├── disasm.py ├── error.py ├── func_arg.py ├── func_call.py ├── linux_proc.py ├── logging_tools.py ├── mockup.py ├── os_tools.py ├── process_tools.py ├── profiler.py ├── pydistorm.py ├── signames.py ├── syscall │ ├── __init__.py │ ├── freebsd_constants.py │ ├── freebsd_syscall.py │ ├── linux_constants.py │ ├── linux_struct.py │ ├── linux_syscall32.py │ ├── linux_syscall64.py │ ├── names.py │ ├── posix_arg.py │ ├── posix_constants.py │ ├── prototypes.py │ ├── ptrace_syscall.py │ ├── socketcall.py │ ├── socketcall_constants.py │ ├── socketcall_struct.py │ └── syscall_argument.py ├── terminal.py ├── tools.py └── version.py └── utilsFolder ├── HeapClass.py ├── Helper.py ├── InputReader.py ├── MapsReader.py ├── Parsing.py ├── PaulaPipe.py ├── PaulaPoll.py ├── PollableQueue.py ├── ProgramInfo.py ├── tree.py └── utils.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Project exclude paths 2 | /venv/ 3 | /logfile 4 | /venvcopy/ 5 | /docs/demo.webm 6 | /docs/demo.mp4 7 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /workspace.xml -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 10 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/paula.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Benchmarks/forktest.py: -------------------------------------------------------------------------------- 1 | from os import fork 2 | from errno import errorcode 3 | from time import sleep 4 | from random import uniform 5 | 6 | 7 | i=0 8 | while 1: 9 | i+=1 10 | try: 11 | ret= fork() 12 | if not ret: 13 | sleep(uniform(0, 10)) 14 | exit(1) 15 | except BaseException as e: 16 | print(i) 17 | print(ret) 18 | print(e) 19 | break 20 | exit(1) 21 | 22 | exit(2) 23 | -------------------------------------------------------------------------------- /Benchmarks/forktest2.py: -------------------------------------------------------------------------------- 1 | from os import fork, getpid 2 | from errno import errorcode 3 | from time import sleep 4 | from random import uniform 5 | 6 | 7 | i=0 8 | 9 | print( "pid = %d " % getpid()) 10 | 11 | with open("/proc/%d/limits" % getpid(), "r") as f: 12 | print(f.read()) 13 | 14 | 15 | try: 16 | while fork(): 17 | i+=1 18 | 19 | except BaseException as e: 20 | print(i) 21 | print(e) 22 | sleep(10) 23 | print("done") 24 | 25 | exit(1) 26 | -------------------------------------------------------------------------------- /Constants.py: -------------------------------------------------------------------------------- 1 | from signal import SIGCHLD 2 | from pwn import asm 3 | from os.path import realpath 4 | 5 | _self_dir,_,_ = realpath(__file__).rpartition("/") 6 | _self_dir += "/" 7 | hyx_path = _self_dir + "../hyx4forkever/hyx" 8 | path_launcher = _self_dir + "launcher/launcher" 9 | socketname = "/tmp/forkever_hyx_sock" 10 | 11 | # relevant for communication with hyx 12 | UPD_FROMBLOB = b"\x40" 13 | UPD_FROMBLOBNEXT = b"\x41" 14 | UPD_FROMPAULA = b"\x01" 15 | UPD_FROMPAULA_INSERT = b"\x02" 16 | MSG_FROMPAULA = b"\x03" 17 | CMD_REQUEST = b"\x50" 18 | CMD_REQUEST_SUCCESS = b"\x51" 19 | 20 | SIGNALS_IGNORE = {} # dict([("SIGCHLD", SIGCHLD)]) 21 | 22 | SYSCALL_INSTR = asm("syscall") 23 | 24 | # relevant for performance optimization (Fuzzer.py) 25 | DO_SYSCALL = True 26 | LOAD_PROGRAMINFO = True 27 | 28 | # ------- DONT MODIFY STUFF ABOVE ------ # 29 | 30 | USE_ASCII = True 31 | COLOR_NORMAL = "\033[m" 32 | COLOR_CURRENT_PROCESS = "\033[0;31m" # red 33 | COLOR_TERMINATED_PROCESS = "\033[0;34m" # blue 34 | 35 | # this will be used to launch hyx, set to "None" and the command will be printed out so you can launch it yourself 36 | runargs = ["x-terminal-emulator", "-e"] # , "-e"] 37 | 38 | # Breakpoints in PIEs will be relative to the base adress if they are below this value 39 | RELATIVE_ADRESS_THRESHOLD = 0xFFffFFff 40 | 41 | PRINT_BORING_SYSCALLS = False # all syscalls will be printed if true 42 | 43 | CONT_AFTER_WRITE = True # no need to explicitly continue after writing to stdin 44 | 45 | # if this is true, you need to be careful to not continue on a process that is waiting on another process. 46 | # It also isnt really tested 47 | FOLLOW_NEW_PROCS = False 48 | 49 | # when looking up a symbol, other symbols matching the lookup will be printed 50 | PRINT_OTHER_CANDIDATES = False 51 | 52 | # this is relevant if you want forkever to send and receive output of the debugged program via a sock 53 | # enable this feature when launching 54 | HOST = "" 55 | PORT = 9999 56 | -------------------------------------------------------------------------------- /FuzzingScripts/FuzzerLauncher.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import resource 3 | 4 | soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) 5 | soft_filelimit = soft * 256 * 4 6 | resource.setrlimit(resource.RLIMIT_NOFILE, (soft_filelimit, hard)) 7 | 8 | result = [] 9 | ind = 1 10 | seed = 0 11 | for num_gens in range(4,20,5): 12 | args = "python3 Fuzzer.py %d %d %d" % (ind, num_gens, seed) 13 | result.append(subprocess.check_output(args.split())) 14 | 15 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/.directory: -------------------------------------------------------------------------------- 1 | [Dolphin] 2 | Timestamp=2020,7,20,11,34,5 3 | Version=4 4 | ViewMode=1 5 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/a.out -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define ALP_START 'a' 6 | #define ALP_SIZE 6 7 | #define STATES_SIZE 10 8 | #define MAX_CHR (ALP_START + ALP_SIZE - 1) 9 | 10 | 11 | 12 | int trans[][7] = { 13 | { 0, 0, 0, 0, 0, 0, 0, }, 14 | { 2, 2, 2, 0, 0, 0, 0, }, 15 | { 1, 0, 0, 2, 3, 0, 0, }, 16 | { 4, 6, 0, 0, 0, 0, 0, }, 17 | { 0, 5, 0, 0, 0, 0, 0, }, 18 | { 0, 0, 0, 0, 6, 0, 0, }, 19 | { 0, 0, 7, 7, 0, 0, 0, }, 20 | { 1, 1, 0, 0, 0, 8, 0, }}; 21 | 22 | 23 | 24 | int trans_counter[STATES_SIZE * ALP_SIZE]; 25 | int count_edges(){ 26 | int result= 0; 27 | for (int i=0; i< sizeof(trans_counter); i++){ 28 | if (trans_counter[i]) 29 | result++; 30 | } 31 | return result; 32 | } 33 | 34 | #define BUSY_COUNT 0x100000 35 | void busy(){ 36 | for (int i=0; i< BUSY_COUNT; i++){}; 37 | } 38 | 39 | int is_in_alphabet(char input_char){ 40 | return (input_char >= ALP_START && input_char <= MAX_CHR); 41 | } 42 | 43 | int main(){ 44 | char input_char; 45 | int current_state=1; 46 | 47 | while(1){ 48 | busy(); 49 | if (1> read(STDIN_FILENO, &input_char, 1)) break; 50 | 51 | if (is_in_alphabet(input_char)){ 52 | int prev_state = current_state; 53 | current_state = trans[current_state][input_char - ALP_START]; 54 | 55 | if (current_state){ 56 | trans_counter[ prev_state * ALP_SIZE + (input_char-ALP_START)]++; 57 | } else { 58 | //printf("%c entering error", input); 59 | //break; 60 | } 61 | 62 | } else { 63 | //printf("%c invalid", input); 64 | break; 65 | } 66 | } 67 | 68 | printf(",%d.", count_edges()); 69 | exit(0); 70 | } 71 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busy0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busy0 -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busy0_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busy0_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busy10_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busy10_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busy2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busy2 -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busy20_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busy20_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busy2_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busy2_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busy40_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busy40_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busy4_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busy4_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busy5_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busy5_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busy60_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busy60_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busy6_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busy6_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busy70_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busy70_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busy80_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busy80_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busy8_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busy8_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busya_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busya_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busyb_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busyb_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busyc_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busyc_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busye_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busye_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_busyf_read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_busyf_read -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_fgetc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define ALP_START 'a' 5 | #define ALP_SIZE 6 6 | #define STATES_SIZE 10 7 | #define MAX_CHR (ALP_START + ALP_SIZE - 1) 8 | #define BUSY_COUNT 0x00000 9 | 10 | int trans[][7] = { 11 | { 0, 0, 0, 0, 0, 0, 0, }, 12 | { 2, 2, 2, 0, 0, 0, 0, }, 13 | { 1, 0, 0, 2, 3, 0, 0, }, 14 | { 4, 6, 0, 0, 0, 0, 0, }, 15 | { 0, 5, 0, 0, 0, 0, 0, }, 16 | { 0, 0, 0, 0, 6, 0, 0, }, 17 | { 0, 0, 7, 7, 0, 0, 0, }, 18 | { 1, 1, 0, 0, 0, 8, 0, }}; 19 | 20 | 21 | 22 | int trans_counter[STATES_SIZE * ALP_SIZE]; 23 | int count_edges(){ 24 | int result= 0; 25 | for (int i=0; i< sizeof(trans_counter); i++){ 26 | if (trans_counter[i]) 27 | result++; 28 | } 29 | return result; 30 | } 31 | 32 | void busy(){ 33 | for (volatile int i=0; i< BUSY_COUNT; i++){}; 34 | return; 35 | } 36 | 37 | 38 | int main(){ 39 | int input; 40 | int current_state=1; 41 | 42 | while(input= fgetc(stdin)){ 43 | busy(); 44 | 45 | 46 | char input_char = (char) input; 47 | 48 | if ( input_char >= ALP_START && input_char <= MAX_CHR){ 49 | int prev_state = current_state; 50 | current_state = trans[current_state][input - ALP_START]; 51 | 52 | if (current_state){ 53 | trans_counter[ prev_state * ALP_SIZE + (input-ALP_START)]++; 54 | } else { 55 | //printf("%c entering error", input); 56 | //break; 57 | } 58 | 59 | } else { 60 | //printf("%c invalid", input); 61 | break; 62 | } 63 | } 64 | 65 | printf(",%d.", count_edges()); 66 | exit(0); 67 | } 68 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_novolatile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_novolatile -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/fuzzme_volatile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/FuzzingScripts/fuzzme/fuzzme_volatile -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_0/ForkFuzzer-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.01535762599814916 ('a', -9, -9) 2 | 5 0.10072559699983685 ('aea', 3, 3.0) 3 | 10 0.2177094139988185 ('aeab', 4, 4.0) 4 | 15 0.35341953600072884 ('aebdaa', 5, 4.6) 5 | 20 0.49463251899942406 ('aebdaa', 5, 4.6) 6 | 25 0.6776598619981087 ('aebdaa', 5, 4.6) 7 | 30 0.8767357670003548 ('aebdac', 6, 6.0) 8 | 35 1.1450269749984727 ('aebcabae', 7, 6.6) 9 | 40 1.4790130229994247 ('aebcaba', 7, 7.0) 10 | 45 1.8754452590001165 ('aebcabac', 8, 8.0) 11 | 50 2.420521992000431 ('aebcabac', 8, 8.0) 12 | 55 3.035521488000086 ('aebcabac', 8, 8.0) 13 | 60 3.6489633159981167 ('aebcabac', 8, 8.0) 14 | 65 4.238352931999543 ('aebcabac', 8, 8.0) 15 | 70 4.955440174999239 ('aebcabac', 8, 8.0) 16 | 75 5.706159624998691 ('aebcabac', 8, 8.0) 17 | 80 6.5593700889985485 ('cebcabaad', 9, 9.0) 18 | 85 7.613383471998532 ('cebcabaad', 9, 9.0) 19 | 90 8.729936547999387 ('cebcabaad', 9, 9.0) 20 | 95 9.921346465998795 ('cebcabaad', 9, 9.0) 21 | 100 11.225509823998436 ('cebcabaad', 9, 9.0) 22 | 105 12.630524057000002 ('cebcabaad', 9, 9.0) 23 | 110 14.063374326000485 ('cebcabaad', 9, 9.0) 24 | 115 15.587238812000578 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_0/ForkFuzzer-seed11-DOSYS1: -------------------------------------------------------------------------------- 1 | 0 0.008428821001871256 ('a', -9, -9) 2 | 5 0.08910219500103267 ('aea', 3, 3.0) 3 | 10 0.20442945000104373 ('aeab', 4, 4.0) 4 | 15 0.3676593199998024 ('aebdaa', 5, 4.6) 5 | 20 0.5156530040003418 ('aebdaa', 5, 4.6) 6 | 25 0.6959551889995055 ('aebdaa', 5, 4.6) 7 | 30 0.9486304640013259 ('aebdac', 6, 6.0) 8 | 35 1.2596974709995266 ('aebcabae', 7, 6.6) 9 | 40 1.652205963000597 ('aebcaba', 7, 7.0) 10 | 45 2.150553770999977 ('aebcabac', 8, 8.0) 11 | 50 2.7845738239993807 ('aebcabac', 8, 8.0) 12 | 55 3.4573412710014964 ('aebcabac', 8, 8.0) 13 | 60 4.193404980000196 ('aebcabac', 8, 8.0) 14 | 65 4.931677936001506 ('aebcabac', 8, 8.0) 15 | 70 5.83057239000118 ('aebcabac', 8, 8.0) 16 | 75 6.84986183500223 ('aebcabac', 8, 8.0) 17 | 80 7.990194016001624 ('cebcabaad', 9, 9.0) 18 | 85 9.404604806000862 ('cebcabaad', 9, 9.0) 19 | 90 10.914911915999255 ('cebcabaad', 9, 9.0) 20 | 95 12.46515348700268 ('cebcabaad', 9, 9.0) 21 | 100 14.124198904999503 ('cebcabaad', 9, 9.0) 22 | 105 15.933355092001875 ('cebcabaad', 9, 9.0) 23 | 110 17.76753786200061 ('cebcabaad', 9, 9.0) 24 | 115 19.73895145899951 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_0/FuzzerForkserver-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.005366538000089349 ('a', -9, -9) 2 | 5 0.0602974590001395 ('aea', 3, 3.0) 3 | 10 0.13462572500066017 ('aeab', 4, 4.0) 4 | 15 0.22171333500227774 ('aebdaa', 5, 4.6) 5 | 20 0.3139753440009372 ('aebdaa', 5, 4.6) 6 | 25 0.40150045300106285 ('aebdaa', 5, 4.6) 7 | 30 0.4858701020020817 ('aebdac', 6, 6.0) 8 | 35 0.5721429629993509 ('aebcabae', 7, 6.6) 9 | 40 0.6521010790020227 ('aebcaba', 7, 7.0) 10 | 45 0.737808870999288 ('aebcabac', 8, 8.0) 11 | 50 0.8209927899988543 ('aebcabac', 8, 8.0) 12 | 55 0.9022944720018131 ('aebcabac', 8, 8.0) 13 | 60 0.986549825000111 ('aebcabac', 8, 8.0) 14 | 65 1.0760944440007734 ('aebcabac', 8, 8.0) 15 | 70 1.1560415849999117 ('aebcabac', 8, 8.0) 16 | 75 1.2388427360019705 ('aebcabac', 8, 8.0) 17 | 80 1.32390781399954 ('cebcabaad', 9, 9.0) 18 | 85 1.410442853000859 ('cebcabaad', 9, 9.0) 19 | 90 1.4964424979989417 ('cebcabaad', 9, 9.0) 20 | 95 1.5807247609991464 ('cebcabaad', 9, 9.0) 21 | 100 1.6594341800009715 ('cebcabaad', 9, 9.0) 22 | 105 1.7506261240014283 ('cebcabaad', 9, 9.0) 23 | 110 1.8335729329992319 ('cebcabaad', 9, 9.0) 24 | 115 1.916910130999895 ('cebcabaad', 9, 9.0) 25 | 120 2.0027444539991848 ('cebcabaad', 9, 9.0) 26 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_10/ForkFuzzer-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.022295987997495104 ('a', -9, -9) 2 | 5 0.1776814819968422 ('aea', 3, 3.0) 3 | 10 0.4266349179961253 ('aeab', 4, 4.0) 4 | 15 0.7408772349954234 ('aebdaa', 5, 4.6) 5 | 20 1.0774357400005101 ('aebdaa', 5, 4.6) 6 | 25 1.4841120060009416 ('aebdaa', 5, 4.6) 7 | 30 2.0131429609973566 ('aebdac', 6, 6.0) 8 | 35 2.749127465998754 ('aebcabae', 7, 6.6) 9 | 40 3.6568453119980404 ('aebcaba', 7, 7.0) 10 | 45 4.668662110998412 ('aebcabac', 8, 8.0) 11 | 50 5.869520790001843 ('aebcabac', 8, 8.0) 12 | 55 7.004148219995841 ('aebcabac', 8, 8.0) 13 | 60 8.16207277799549 ('aebcabac', 8, 8.0) 14 | 65 9.191395700996509 ('aebcabac', 8, 8.0) 15 | 70 10.419766166996851 ('aebcabac', 8, 8.0) 16 | 75 11.74841515099979 ('aebcabac', 8, 8.0) 17 | 80 13.119124240998644 ('cebcabaad', 9, 9.0) 18 | 85 14.81950720000168 ('cebcabaad', 9, 9.0) 19 | 90 16.559363759995904 ('cebcabaad', 9, 9.0) 20 | 95 18.324900510997395 ('cebcabaad', 9, 9.0) 21 | 100 20.16245225199964 ('cebcabaad', 9, 9.0) 22 | 105 22.084664171998156 ('cebcabaad', 9, 9.0) 23 | 110 24.021869244999834 ('cebcabaad', 9, 9.0) 24 | 115 26.086800730001414 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_10/FuzzerForkserver-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.027775675000157207 ('a', -9, -9) 2 | 5 0.5982367169999634 ('aea', 3, 3.0) 3 | 10 1.627903057000367 ('aeab', 4, 4.0) 4 | 15 2.9091011049968074 ('aebdaa', 5, 4.6) 5 | 20 4.290814078995027 ('aebdaa', 5, 4.6) 6 | 25 5.759033001995704 ('aebdaa', 5, 4.6) 7 | 30 7.388283733002027 ('aebdac', 6, 6.0) 8 | 35 9.249486155997147 ('aebcabae', 7, 6.6) 9 | 40 11.288995299997623 ('aebcaba', 7, 7.0) 10 | 45 13.5541048160012 ('aebcabac', 8, 8.0) 11 | 50 15.97214478800015 ('aebcabac', 8, 8.0) 12 | 55 18.390455959000974 ('aebcabac', 8, 8.0) 13 | 60 20.803765327000292 ('aebcabac', 8, 8.0) 14 | 65 23.127336353994906 ('aebcabac', 8, 8.0) 15 | 70 25.505210395996983 ('aebcabac', 8, 8.0) 16 | 75 27.948946714997874 ('aebcabac', 8, 8.0) 17 | 80 30.422098274000746 ('cebcabaad', 9, 9.0) 18 | 85 32.98787612599699 ('cebcabaad', 9, 9.0) 19 | 90 35.62216577599611 ('cebcabaad', 9, 9.0) 20 | 95 38.19040812100138 ('cebcabaad', 9, 9.0) 21 | 100 40.75145704299939 ('cebcabaad', 9, 9.0) 22 | 105 43.32534142900113 ('cebcabaad', 9, 9.0) 23 | 110 45.91019665099884 ('cebcabaad', 9, 9.0) 24 | 115 48.52548130899959 ('cebcabaad', 9, 9.0) 25 | 120 51.10603633400024 ('cebcabaad', 9, 9.0) 26 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_2/ForkFuzzer-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.011406038000131957 ('a', -9, -9) 2 | 5 0.09977677400092944 ('aea', 3, 3.0) 3 | 10 0.22631636900041485 ('aeab', 4, 4.0) 4 | 15 0.40210170399950584 ('aebdaa', 5, 4.6) 5 | 20 0.5723297779986751 ('aebdaa', 5, 4.6) 6 | 25 0.7761815310004749 ('aebdaa', 5, 4.6) 7 | 30 1.0448743769993598 ('aebdac', 6, 6.0) 8 | 35 1.3894312429983984 ('aebcabae', 7, 6.6) 9 | 40 1.8096392519983056 ('aebcaba', 7, 7.0) 10 | 45 2.295495344998926 ('aebcabac', 8, 8.0) 11 | 50 2.855578016999061 ('aebcabac', 8, 8.0) 12 | 55 3.47184110300077 ('aebcabac', 8, 8.0) 13 | 60 4.12077034899994 ('aebcabac', 8, 8.0) 14 | 65 4.731272682998679 ('aebcabac', 8, 8.0) 15 | 70 5.4565430660004495 ('aebcabac', 8, 8.0) 16 | 75 6.231728390001081 ('aebcabac', 8, 8.0) 17 | 80 7.062393503998464 ('cebcabaad', 9, 9.0) 18 | 85 8.063368472998263 ('cebcabaad', 9, 9.0) 19 | 90 9.119780089000415 ('cebcabaad', 9, 9.0) 20 | 95 10.254799263999303 ('cebcabaad', 9, 9.0) 21 | 100 11.45226574100161 ('cebcabaad', 9, 9.0) 22 | 105 12.75845869800105 ('cebcabaad', 9, 9.0) 23 | 110 14.111253283001133 ('cebcabaad', 9, 9.0) 24 | 115 15.569589300001098 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_2/ForkFuzzer-seed11-DOSYS1: -------------------------------------------------------------------------------- 1 | 0 0.012331546000496019 ('a', -9, -9) 2 | 5 0.09949477599730017 ('aea', 3, 3.0) 3 | 10 0.2469580449978821 ('aeab', 4, 4.0) 4 | 15 0.4268113429970981 ('aebdaa', 5, 4.6) 5 | 20 0.599393164000503 ('aebdaa', 5, 4.6) 6 | 25 0.8186685019973083 ('aebdaa', 5, 4.6) 7 | 30 1.0910478410005453 ('aebdac', 6, 6.0) 8 | 35 1.459821585998725 ('aebcabae', 7, 6.6) 9 | 40 1.94565925599818 ('aebcaba', 7, 7.0) 10 | 45 2.4945109779982886 ('aebcabac', 8, 8.0) 11 | 50 3.1864505109988386 ('aebcabac', 8, 8.0) 12 | 55 3.920815863999451 ('aebcabac', 8, 8.0) 13 | 60 4.7201492589992995 ('aebcabac', 8, 8.0) 14 | 65 5.4651501849984925 ('aebcabac', 8, 8.0) 15 | 70 6.3550472110000555 ('aebcabac', 8, 8.0) 16 | 75 7.333863444000599 ('aebcabac', 8, 8.0) 17 | 80 8.453055527999823 ('cebcabaad', 9, 9.0) 18 | 85 9.838356449999992 ('cebcabaad', 9, 9.0) 19 | 90 11.303193361000012 ('cebcabaad', 9, 9.0) 20 | 95 12.828565948999312 ('cebcabaad', 9, 9.0) 21 | 100 14.480622871000378 ('cebcabaad', 9, 9.0) 22 | 105 16.286875538997265 ('cebcabaad', 9, 9.0) 23 | 110 18.11636850499781 ('cebcabaad', 9, 9.0) 24 | 115 20.079468719999568 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_2/FuzzerForkserver-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.008272705003037117 ('a', -9, -9) 2 | 5 0.14408044800075004 ('aea', 3, 3.0) 3 | 10 0.36104594400239876 ('aeab', 4, 4.0) 4 | 15 0.6162227660024655 ('aebdaa', 5, 4.6) 5 | 20 0.8842694600025425 ('aebdaa', 5, 4.6) 6 | 25 1.1600224900030298 ('aebdaa', 5, 4.6) 7 | 30 1.4706887320025999 ('aebdac', 6, 6.0) 8 | 35 1.8055931520029844 ('aebcabae', 7, 6.6) 9 | 40 2.1648109150009986 ('aebcaba', 7, 7.0) 10 | 45 2.5523815670021577 ('aebcabac', 8, 8.0) 11 | 50 2.962154928001837 ('aebcabac', 8, 8.0) 12 | 55 3.369557405003434 ('aebcabac', 8, 8.0) 13 | 60 3.7749001140000473 ('aebcabac', 8, 8.0) 14 | 65 4.1784608400012075 ('aebcabac', 8, 8.0) 15 | 70 4.5772755990001315 ('aebcabac', 8, 8.0) 16 | 75 4.987017754003318 ('aebcabac', 8, 8.0) 17 | 80 5.398258866000106 ('cebcabaad', 9, 9.0) 18 | 85 5.824021711003297 ('cebcabaad', 9, 9.0) 19 | 90 6.25947255200299 ('cebcabaad', 9, 9.0) 20 | 95 6.682930438000767 ('cebcabaad', 9, 9.0) 21 | 100 7.108685684001102 ('cebcabaad', 9, 9.0) 22 | 105 7.529875905001973 ('cebcabaad', 9, 9.0) 23 | 110 7.960784482002055 ('cebcabaad', 9, 9.0) 24 | 115 8.389958782001486 ('cebcabaad', 9, 9.0) 25 | 120 8.816078634001315 ('cebcabaad', 9, 9.0) 26 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_20/ForkFuzzer-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.035170859999198 ('a', -9, -9) 2 | 5 0.2606382010017114 ('aea', 3, 3.0) 3 | 10 0.598935509002331 ('aeab', 4, 4.0) 4 | 15 1.0823660080022819 ('aebdaa', 5, 4.6) 5 | 20 1.5541282119993411 ('aebdaa', 5, 4.6) 6 | 25 2.1544954660021176 ('aebdaa', 5, 4.6) 7 | 30 2.978495619001478 ('aebdac', 6, 6.0) 8 | 35 4.106201967002562 ('aebcabae', 7, 6.6) 9 | 40 5.514522553999996 ('aebcaba', 7, 7.0) 10 | 45 7.091619322000042 ('aebcabac', 8, 8.0) 11 | 50 8.812783500001387 ('aebcabac', 8, 8.0) 12 | 55 10.481501921000017 ('aebcabac', 8, 8.0) 13 | 60 12.147768374001316 ('aebcabac', 8, 8.0) 14 | 65 13.588891674000479 ('aebcabac', 8, 8.0) 15 | 70 15.234769016002247 ('aebcabac', 8, 8.0) 16 | 75 16.951139510001667 ('aebcabac', 8, 8.0) 17 | 80 18.7586910070022 ('cebcabaad', 9, 9.0) 18 | 85 20.965234538001823 ('cebcabaad', 9, 9.0) 19 | 90 23.194547564002278 ('cebcabaad', 9, 9.0) 20 | 95 25.462544728001376 ('cebcabaad', 9, 9.0) 21 | 100 27.820817178999278 ('cebcabaad', 9, 9.0) 22 | 105 30.385120283001015 ('cebcabaad', 9, 9.0) 23 | 110 32.922132881001744 ('cebcabaad', 9, 9.0) 24 | 115 35.591407583000546 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_20/FuzzerForkserver-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.05027433199938969 ('a', -9, -9) 2 | 5 1.1082484600010503 ('aea', 3, 3.0) 3 | 10 3.0462499060013215 ('aeab', 4, 4.0) 4 | 15 5.491124252999725 ('aebdaa', 5, 4.6) 5 | 20 8.139177762001054 ('aebdaa', 5, 4.6) 6 | 25 10.935252536000917 ('aebdaa', 5, 4.6) 7 | 30 14.062422210001387 ('aebdac', 6, 6.0) 8 | 35 17.65160095000101 ('aebcabae', 7, 6.6) 9 | 40 21.555193036001583 ('aebcaba', 7, 7.0) 10 | 45 25.904306307998922 ('aebcabac', 8, 8.0) 11 | 50 30.56411767499958 ('aebcabac', 8, 8.0) 12 | 55 35.219995016999746 ('aebcabac', 8, 8.0) 13 | 60 39.86952279899924 ('aebcabac', 8, 8.0) 14 | 65 44.36885970000003 ('aebcabac', 8, 8.0) 15 | 70 48.958981018000486 ('aebcabac', 8, 8.0) 16 | 75 53.67516864500067 ('aebcabac', 8, 8.0) 17 | 80 58.437525850000384 ('cebcabaad', 9, 9.0) 18 | 85 63.392249331998755 ('cebcabaad', 9, 9.0) 19 | 90 68.49296970700016 ('cebcabaad', 9, 9.0) 20 | 95 73.41050510900095 ('cebcabaad', 9, 9.0) 21 | 100 78.37166854799943 ('cebcabaad', 9, 9.0) 22 | 105 83.32788437699855 ('cebcabaad', 9, 9.0) 23 | 110 88.30043318599928 ('cebcabaad', 9, 9.0) 24 | 115 93.3482781390012 ('cebcabaad', 9, 9.0) 25 | 120 98.35267741999996 ('cebcabaad', 9, 9.0) 26 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_4/ForkFuzzer-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.013262196000141557 ('a', -9, -9) 2 | 5 0.12706256399906124 ('aea', 3, 3.0) 3 | 10 0.2809098420002556 ('aeab', 4, 4.0) 4 | 15 0.4717478589991515 ('aebdaa', 5, 4.6) 5 | 20 0.6695154320004804 ('aebdaa', 5, 4.6) 6 | 25 0.9020174139986921 ('aebdaa', 5, 4.6) 7 | 30 1.2064837049983907 ('aebdac', 6, 6.0) 8 | 35 1.6186639699990337 ('aebcabae', 7, 6.6) 9 | 40 2.1207268299986026 ('aebcaba', 7, 7.0) 10 | 45 2.6920289549998415 ('aebcabac', 8, 8.0) 11 | 50 3.316313462997641 ('aebcabac', 8, 8.0) 12 | 55 3.988926502999675 ('aebcabac', 8, 8.0) 13 | 60 4.724894317998405 ('aebcabac', 8, 8.0) 14 | 65 5.404366643000685 ('aebcabac', 8, 8.0) 15 | 70 6.193686870999954 ('aebcabac', 8, 8.0) 16 | 75 7.047880629997962 ('aebcabac', 8, 8.0) 17 | 80 7.975267167999846 ('cebcabaad', 9, 9.0) 18 | 85 9.085071094999876 ('cebcabaad', 9, 9.0) 19 | 90 10.23318699399897 ('cebcabaad', 9, 9.0) 20 | 95 11.432087765999313 ('cebcabaad', 9, 9.0) 21 | 100 12.712871520998306 ('cebcabaad', 9, 9.0) 22 | 105 14.100668462000613 ('cebcabaad', 9, 9.0) 23 | 110 15.52258827499827 ('cebcabaad', 9, 9.0) 24 | 115 17.045639825999388 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_4/ForkFuzzer-seed11-DOSYS1: -------------------------------------------------------------------------------- 1 | 0 0.011890175999724306 ('a', -9, -9) 2 | 5 0.11539319700023043 ('aea', 3, 3.0) 3 | 10 0.27477667499988456 ('aeab', 4, 4.0) 4 | 15 0.471539288002532 ('aebdaa', 5, 4.6) 5 | 20 0.6739579390014114 ('aebdaa', 5, 4.6) 6 | 25 0.9296479170006933 ('aebdaa', 5, 4.6) 7 | 30 1.2509128210003837 ('aebdac', 6, 6.0) 8 | 35 1.6865984950018174 ('aebcabae', 7, 6.6) 9 | 40 2.24142247400232 ('aebcaba', 7, 7.0) 10 | 45 2.8703223420016 ('aebcabac', 8, 8.0) 11 | 50 3.6332628070013016 ('aebcabac', 8, 8.0) 12 | 55 4.45517584800109 ('aebcabac', 8, 8.0) 13 | 60 5.340780620001169 ('aebcabac', 8, 8.0) 14 | 65 6.160738984999625 ('aebcabac', 8, 8.0) 15 | 70 7.122898238001653 ('aebcabac', 8, 8.0) 16 | 75 8.17099847099962 ('aebcabac', 8, 8.0) 17 | 80 9.351769348002563 ('cebcabaad', 9, 9.0) 18 | 85 10.809474863002833 ('cebcabaad', 9, 9.0) 19 | 90 12.357163119002507 ('cebcabaad', 9, 9.0) 20 | 95 13.97441737400004 ('cebcabaad', 9, 9.0) 21 | 100 15.724144523999712 ('cebcabaad', 9, 9.0) 22 | 105 17.653595536001376 ('cebcabaad', 9, 9.0) 23 | 110 19.611589334999735 ('cebcabaad', 9, 9.0) 24 | 115 21.71241744800136 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_4/FuzzerForkserver-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.011132286002975889 ('a', -9, -9) 2 | 5 0.21456076700269477 ('aea', 3, 3.0) 3 | 10 0.5547889700028463 ('aeab', 4, 4.0) 4 | 15 0.9614269910016446 ('aebdaa', 5, 4.6) 5 | 20 1.3910744759996305 ('aebdaa', 5, 4.6) 6 | 25 1.8415792980013066 ('aebdaa', 5, 4.6) 7 | 30 2.334021610000491 ('aebdac', 6, 6.0) 8 | 35 2.8962980159994913 ('aebcabae', 7, 6.6) 9 | 40 3.4973680260009132 ('aebcaba', 7, 7.0) 10 | 45 4.155865914999595 ('aebcabac', 8, 8.0) 11 | 50 4.859348683999997 ('aebcabac', 8, 8.0) 12 | 55 5.556446835002134 ('aebcabac', 8, 8.0) 13 | 60 6.25494619500023 ('aebcabac', 8, 8.0) 14 | 65 6.9299044300023525 ('aebcabac', 8, 8.0) 15 | 70 7.618316356001742 ('aebcabac', 8, 8.0) 16 | 75 8.324085996002395 ('aebcabac', 8, 8.0) 17 | 80 9.038208858000871 ('cebcabaad', 9, 9.0) 18 | 85 9.775864553001156 ('cebcabaad', 9, 9.0) 19 | 90 10.53184785600024 ('cebcabaad', 9, 9.0) 20 | 95 11.268287482002052 ('cebcabaad', 9, 9.0) 21 | 100 12.00560587200016 ('cebcabaad', 9, 9.0) 22 | 105 12.746047306001856 ('cebcabaad', 9, 9.0) 23 | 110 13.48864132000017 ('cebcabaad', 9, 9.0) 24 | 115 14.236092991002806 ('cebcabaad', 9, 9.0) 25 | 120 14.978317458000674 ('cebcabaad', 9, 9.0) 26 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_40/ForkFuzzer-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.05940015999658499 ('a', -9, -9) 2 | 5 0.4056165179972595 ('aea', 3, 3.0) 3 | 10 0.9098455399980594 ('aeab', 4, 4.0) 4 | 15 1.6908327509991068 ('aebdaa', 5, 4.6) 5 | 20 2.462331851998897 ('aebdaa', 5, 4.6) 6 | 25 3.447101303998352 ('aebdaa', 5, 4.6) 7 | 30 4.816643640999246 ('aebdac', 6, 6.0) 8 | 35 6.735890136998933 ('aebcabae', 7, 6.6) 9 | 40 9.171527584996511 ('aebcaba', 7, 7.0) 10 | 45 11.879593018999003 ('aebcabac', 8, 8.0) 11 | 50 14.825891423999565 ('aebcabac', 8, 8.0) 12 | 55 17.65528093699686 ('aebcabac', 8, 8.0) 13 | 60 20.48081007699875 ('aebcabac', 8, 8.0) 14 | 65 22.855495875999623 ('aebcabac', 8, 8.0) 15 | 70 25.57203931999902 ('aebcabac', 8, 8.0) 16 | 75 28.370709849998093 ('aebcabac', 8, 8.0) 17 | 80 31.29635403899738 ('cebcabaad', 9, 9.0) 18 | 85 34.8627021909997 ('cebcabaad', 9, 9.0) 19 | 90 38.38783091799996 ('cebcabaad', 9, 9.0) 20 | 95 41.84637239699805 ('cebcabaad', 9, 9.0) 21 | 100 45.33780511099758 ('cebcabaad', 9, 9.0) 22 | 105 49.039726472998154 ('cebcabaad', 9, 9.0) 23 | 110 52.6912387759985 ('cebcabaad', 9, 9.0) 24 | 115 56.47229497999797 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_40/FuzzerForkserver-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.09675898199930089 ('a', -9, -9) 2 | 5 2.1022652279971226 ('aea', 3, 3.0) 3 | 10 5.830890935998468 ('aeab', 4, 4.0) 4 | 15 10.603440156999568 ('aebdaa', 5, 4.6) 5 | 20 15.746724042997812 ('aebdaa', 5, 4.6) 6 | 25 21.190271909999865 ('aebdaa', 5, 4.6) 7 | 30 27.27996541599714 ('aebdac', 6, 6.0) 8 | 35 34.31134070799817 ('aebcabae', 7, 6.6) 9 | 40 41.97734901699732 ('aebcaba', 7, 7.0) 10 | 45 50.496363149999524 ('aebcabac', 8, 8.0) 11 | 50 59.646348086000216 ('aebcabac', 8, 8.0) 12 | 55 68.81115984999997 ('aebcabac', 8, 8.0) 13 | 60 77.96470526899793 ('aebcabac', 8, 8.0) 14 | 65 86.77243156999975 ('aebcabac', 8, 8.0) 15 | 70 95.77535397499742 ('aebcabac', 8, 8.0) 16 | 75 105.02056633599932 ('aebcabac', 8, 8.0) 17 | 80 114.35693458699825 ('cebcabaad', 9, 9.0) 18 | 85 124.07548763500017 ('cebcabaad', 9, 9.0) 19 | 90 134.1273193019988 ('cebcabaad', 9, 9.0) 20 | 95 143.77589264699782 ('cebcabaad', 9, 9.0) 21 | 100 153.5006604099981 ('cebcabaad', 9, 9.0) 22 | 105 163.26783274699847 ('cebcabaad', 9, 9.0) 23 | 110 173.07837514799758 ('cebcabaad', 9, 9.0) 24 | 115 182.9954430939979 ('cebcabaad', 9, 9.0) 25 | 120 192.93437988499863 ('cebcabaad', 9, 9.0) 26 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_6/ForkFuzzer-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.015113266999833286 ('a', -9, -9) 2 | 5 0.12901329200030887 ('aea', 3, 3.0) 3 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_6/ForkFuzzer-seed11-DOSYS1: -------------------------------------------------------------------------------- 1 | 0 0.014982397999119712 ('a', -9, -9) 2 | 5 0.1321843749974505 ('aea', 3, 3.0) 3 | 10 0.2991394999990007 ('aeab', 4, 4.0) 4 | 15 0.5303707429993665 ('aebdaa', 5, 4.6) 5 | 20 0.7561957619982422 ('aebdaa', 5, 4.6) 6 | 25 1.0362823149989708 ('aebdaa', 5, 4.6) 7 | 30 1.3965323379998154 ('aebdac', 6, 6.0) 8 | 35 1.891036011998949 ('aebcabae', 7, 6.6) 9 | 40 2.525607929997932 ('aebcaba', 7, 7.0) 10 | 45 3.2389774289986235 ('aebcabac', 8, 8.0) 11 | 50 4.062855262000085 ('aebcabac', 8, 8.0) 12 | 55 4.949334773998999 ('aebcabac', 8, 8.0) 13 | 60 5.907322822000424 ('aebcabac', 8, 8.0) 14 | 65 6.792629183997633 ('aebcabac', 8, 8.0) 15 | 70 7.835541461998218 ('aebcabac', 8, 8.0) 16 | 75 8.95959670999946 ('aebcabac', 8, 8.0) 17 | 80 10.199854544000118 ('cebcabaad', 9, 9.0) 18 | 85 11.729050879999704 ('cebcabaad', 9, 9.0) 19 | 90 13.35085284500019 ('cebcabaad', 9, 9.0) 20 | 95 15.049806536997494 ('cebcabaad', 9, 9.0) 21 | 100 16.86489663499742 ('cebcabaad', 9, 9.0) 22 | 105 18.87017725199985 ('cebcabaad', 9, 9.0) 23 | 110 20.909651317997486 ('cebcabaad', 9, 9.0) 24 | 115 23.108076984000945 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_6/results '__main__.ForkFuzzer'>-seed11-DOSYS0--9132: -------------------------------------------------------------------------------- 1 | 0 0.01551365699924645 ('a', -9, -9) 2 | 5 0.14249143100096262 ('aea', 3, 3.0) 3 | 10 0.3104245499998797 ('aeab', 4, 4.0) 4 | 15 0.5242351480010257 ('aebdaa', 5, 4.6) 5 | 20 0.7545658279996132 ('aebdaa', 5, 4.6) 6 | 25 1.0203358769977058 ('aebdaa', 5, 4.6) 7 | 30 1.3666893720001099 ('aebdac', 6, 6.0) 8 | 35 1.84169752699745 ('aebcabae', 7, 6.6) 9 | 40 2.414550605997647 ('aebcaba', 7, 7.0) 10 | 45 3.0613305879996915 ('aebcabac', 8, 8.0) 11 | 50 3.7764247649975005 ('aebcabac', 8, 8.0) 12 | 55 4.49650476899842 ('aebcabac', 8, 8.0) 13 | 60 5.291426378000324 ('aebcabac', 8, 8.0) 14 | 65 6.042185061000055 ('aebcabac', 8, 8.0) 15 | 70 6.91503063699929 ('aebcabac', 8, 8.0) 16 | 75 7.838457288999052 ('aebcabac', 8, 8.0) 17 | 80 8.835026276999997 ('cebcabaad', 9, 9.0) 18 | 85 10.045818455000699 ('cebcabaad', 9, 9.0) 19 | 90 11.304955769999651 ('cebcabaad', 9, 9.0) 20 | 95 12.615288769000472 ('cebcabaad', 9, 9.0) 21 | 100 13.95046283299962 ('cebcabaad', 9, 9.0) 22 | 105 15.383924162997573 ('cebcabaad', 9, 9.0) 23 | 110 16.87794162299906 ('cebcabaad', 9, 9.0) 24 | 115 18.462076252999395 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_8/ForkFuzzer-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.01625920100195799 ('a', -9, -9) 2 | 5 0.1430230140031199 ('aea', 3, 3.0) 3 | 10 0.3198473440024827 ('aeab', 4, 4.0) 4 | 15 0.5651798460021382 ('aebdaa', 5, 4.6) 5 | 20 0.815425545002654 ('aebdaa', 5, 4.6) 6 | 25 1.1140090090011654 ('aebdaa', 5, 4.6) 7 | 30 1.4998000330015202 ('aebdac', 6, 6.0) 8 | 35 2.019243546001235 ('aebcabae', 7, 6.6) 9 | 40 2.647710992001521 ('aebcaba', 7, 7.0) 10 | 45 3.3690941380009463 ('aebcabac', 8, 8.0) 11 | 50 4.165751707001618 ('aebcabac', 8, 8.0) 12 | 55 4.961715618002927 ('aebcabac', 8, 8.0) 13 | 60 5.811562376002257 ('aebcabac', 8, 8.0) 14 | 65 6.598948912000196 ('aebcabac', 8, 8.0) 15 | 70 7.549146187000588 ('aebcabac', 8, 8.0) 16 | 75 8.557497257002979 ('aebcabac', 8, 8.0) 17 | 80 9.629273792001186 ('cebcabaad', 9, 9.0) 18 | 85 10.928823849000764 ('cebcabaad', 9, 9.0) 19 | 90 12.272957234003115 ('cebcabaad', 9, 9.0) 20 | 95 13.66476014500222 ('cebcabaad', 9, 9.0) 21 | 100 15.106688427000336 ('cebcabaad', 9, 9.0) 22 | 105 16.63320147200284 ('cebcabaad', 9, 9.0) 23 | 110 18.18557766000231 ('cebcabaad', 9, 9.0) 24 | 115 19.825647874000424 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_8/ForkFuzzer-seed11-DOSYS1: -------------------------------------------------------------------------------- 1 | 0 0.016872653999598697 ('a', -9, -9) 2 | 5 0.1426135939982487 ('aea', 3, 3.0) 3 | 10 0.3250223780014494 ('aeab', 4, 4.0) 4 | 15 0.5766783530016255 ('aebdaa', 5, 4.6) 5 | 20 0.8243685140005255 ('aebdaa', 5, 4.6) 6 | 25 1.1353933159989538 ('aebdaa', 5, 4.6) 7 | 30 1.551244072001282 ('aebdac', 6, 6.0) 8 | 35 2.103635702998872 ('aebcabae', 7, 6.6) 9 | 40 2.7902800970005046 ('aebcaba', 7, 7.0) 10 | 45 3.5960517970015644 ('aebcabac', 8, 8.0) 11 | 50 4.477656521001336 ('aebcabac', 8, 8.0) 12 | 55 5.438313869999547 ('aebcabac', 8, 8.0) 13 | 60 6.484683610000502 ('aebcabac', 8, 8.0) 14 | 65 7.437206278998929 ('aebcabac', 8, 8.0) 15 | 70 8.555159135001304 ('aebcabac', 8, 8.0) 16 | 75 9.764933259000827 ('aebcabac', 8, 8.0) 17 | 80 11.09460740799841 ('cebcabaad', 9, 9.0) 18 | 85 12.69744220999928 ('cebcabaad', 9, 9.0) 19 | 90 14.376622116000362 ('cebcabaad', 9, 9.0) 20 | 95 16.125042014999053 ('cebcabaad', 9, 9.0) 21 | 100 18.009820289000345 ('cebcabaad', 9, 9.0) 22 | 105 20.084762450998824 ('cebcabaad', 9, 9.0) 23 | 110 22.19378046899874 ('cebcabaad', 9, 9.0) 24 | 115 24.46156044899908 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_8/FuzzerForkserver-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.0168632559980324 ('a', -9, -9) 2 | 5 0.3410006159974728 ('aea', 3, 3.0) 3 | 10 0.9103018729983887 ('aeab', 4, 4.0) 4 | 15 1.6072614549993887 ('aebdaa', 5, 4.6) 5 | 20 2.3644057710007473 ('aebdaa', 5, 4.6) 6 | 25 3.151662373998988 ('aebdaa', 5, 4.6) 7 | 30 4.0280188159995305 ('aebdac', 6, 6.0) 8 | 35 5.023197636000987 ('aebcabae', 7, 6.6) 9 | 40 6.101778321000893 ('aebcaba', 7, 7.0) 10 | 45 7.297587860000931 ('aebcabac', 8, 8.0) 11 | 50 8.576663677999022 ('aebcabac', 8, 8.0) 12 | 55 9.851426180000999 ('aebcabac', 8, 8.0) 13 | 60 11.12307239099755 ('aebcabac', 8, 8.0) 14 | 65 12.35468780500014 ('aebcabac', 8, 8.0) 15 | 70 13.604464322997956 ('aebcabac', 8, 8.0) 16 | 75 14.89046563499869 ('aebcabac', 8, 8.0) 17 | 80 16.188235825000447 ('cebcabaad', 9, 9.0) 18 | 85 17.537253231999784 ('cebcabaad', 9, 9.0) 19 | 90 18.921773532998486 ('cebcabaad', 9, 9.0) 20 | 95 20.34725924200029 ('cebcabaad', 9, 9.0) 21 | 100 21.73801491699851 ('cebcabaad', 9, 9.0) 22 | 105 23.092379790999985 ('cebcabaad', 9, 9.0) 23 | 110 24.50454682599957 ('cebcabaad', 9, 9.0) 24 | 115 25.890566175999993 ('cebcabaad', 9, 9.0) 25 | 120 27.282652244997735 ('cebcabaad', 9, 9.0) 26 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_a/ForkFuzzer-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.018596959998831153 ('a', -9, -9) 2 | 5 0.16561482500037528 ('aea', 3, 3.0) 3 | 10 0.36562086299818475 ('aeab', 4, 4.0) 4 | 15 0.6290350109993597 ('aebdaa', 5, 4.6) 5 | 20 0.8913026379996154 ('aebdaa', 5, 4.6) 6 | 25 1.2122058029999607 ('aebdaa', 5, 4.6) 7 | 30 1.6272132140002213 ('aebdac', 6, 6.0) 8 | 35 2.2036600789979275 ('aebcabae', 7, 6.6) 9 | 40 2.9011979659990175 ('aebcaba', 7, 7.0) 10 | 45 3.7007337670002016 ('aebcabac', 8, 8.0) 11 | 50 4.580521023999609 ('aebcabac', 8, 8.0) 12 | 55 5.441273614000238 ('aebcabac', 8, 8.0) 13 | 60 6.356355388998054 ('aebcabac', 8, 8.0) 14 | 65 7.201414880997618 ('aebcabac', 8, 8.0) 15 | 70 8.197244189999765 ('aebcabac', 8, 8.0) 16 | 75 9.272973998999078 ('aebcabac', 8, 8.0) 17 | 80 10.435393505998945 ('cebcabaad', 9, 9.0) 18 | 85 11.832418738998967 ('cebcabaad', 9, 9.0) 19 | 90 13.271817339998961 ('cebcabaad', 9, 9.0) 20 | 95 14.754015344999061 ('cebcabaad', 9, 9.0) 21 | 100 16.290569344000687 ('cebcabaad', 9, 9.0) 22 | 105 17.916279545999714 ('cebcabaad', 9, 9.0) 23 | 110 19.548909065997577 ('cebcabaad', 9, 9.0) 24 | 115 21.29034602200045 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_a/ForkFuzzer-seed11-DOSYS1: -------------------------------------------------------------------------------- 1 | 0 0.01809778999813716 ('a', -9, -9) 2 | 5 0.15727855899967835 ('aea', 3, 3.0) 3 | 10 0.3526806719964952 ('aeab', 4, 4.0) 4 | 15 0.632319849999476 ('aebdaa', 5, 4.6) 5 | 20 0.9022341509989928 ('aebdaa', 5, 4.6) 6 | 25 1.2314769529984915 ('aebdaa', 5, 4.6) 7 | 30 1.6808421089990588 ('aebdac', 6, 6.0) 8 | 35 2.29790331699769 ('aebcabae', 7, 6.6) 9 | 40 3.0650891169971146 ('aebcaba', 7, 7.0) 10 | 45 3.9235320099978708 ('aebcabac', 8, 8.0) 11 | 50 4.887617938999028 ('aebcabac', 8, 8.0) 12 | 55 5.89257388599799 ('aebcabac', 8, 8.0) 13 | 60 7.014066397998249 ('aebcabac', 8, 8.0) 14 | 65 8.035042457999225 ('aebcabac', 8, 8.0) 15 | 70 9.2283568189996 ('aebcabac', 8, 8.0) 16 | 75 10.503957980999985 ('aebcabac', 8, 8.0) 17 | 80 11.91282988599778 ('cebcabaad', 9, 9.0) 18 | 85 13.609805899999628 ('cebcabaad', 9, 9.0) 19 | 90 15.364604679998592 ('cebcabaad', 9, 9.0) 20 | 95 17.187101699997584 ('cebcabaad', 9, 9.0) 21 | 100 19.13790589999917 ('cebcabaad', 9, 9.0) 22 | 105 21.254031522999867 ('cebcabaad', 9, 9.0) 23 | 110 23.439702185998613 ('cebcabaad', 9, 9.0) 24 | 115 25.775879241999064 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_c/ForkFuzzer-seed11-DOSYS0--7055: -------------------------------------------------------------------------------- 1 | 0 0.01940509599808138 ('a', -9, -9) 2 | 5 0.16815826299716718 ('aea', 3, 3.0) 3 | 10 0.3742946849997679 ('aeab', 4, 4.0) 4 | 15 0.6615471579971199 ('aebdaa', 5, 4.6) 5 | 20 0.9421388339978876 ('aebdaa', 5, 4.6) 6 | 25 1.283631444999628 ('aebdaa', 5, 4.6) 7 | 30 1.73168891000023 ('aebdac', 6, 6.0) 8 | 35 2.360997239997232 ('aebcabae', 7, 6.6) 9 | 40 3.1236513829971955 ('aebcaba', 7, 7.0) 10 | 45 3.970526663997589 ('aebcabac', 8, 8.0) 11 | 50 4.919220451996807 ('aebcabac', 8, 8.0) 12 | 55 5.850933044999692 ('aebcabac', 8, 8.0) 13 | 60 6.818143835997034 ('aebcabac', 8, 8.0) 14 | 65 7.700840012999834 ('aebcabac', 8, 8.0) 15 | 70 8.750298312999803 ('aebcabac', 8, 8.0) 16 | 75 9.87998217799759 ('aebcabac', 8, 8.0) 17 | 80 11.11594234400036 ('cebcabaad', 9, 9.0) 18 | 85 12.613061189997097 ('cebcabaad', 9, 9.0) 19 | 90 14.133225908997701 ('cebcabaad', 9, 9.0) 20 | 95 15.691702855998301 ('cebcabaad', 9, 9.0) 21 | 100 17.314114437998796 ('cebcabaad', 9, 9.0) 22 | 105 19.046719441997993 ('cebcabaad', 9, 9.0) 23 | 110 20.77566402299999 ('cebcabaad', 9, 9.0) 24 | 115 22.58943576299862 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_c/ForkFuzzer-seed11-DOSYS1: -------------------------------------------------------------------------------- 1 | 0 0.019403386999329086 ('a', -9, -9) 2 | 5 0.16068374899987248 ('aea', 3, 3.0) 3 | 10 0.3681554549984867 ('aeab', 4, 4.0) 4 | 15 0.6590966090006987 ('aebdaa', 5, 4.6) 5 | 20 0.9640860789986618 ('aebdaa', 5, 4.6) 6 | 25 1.3226562790005119 ('aebdaa', 5, 4.6) 7 | 30 1.8056481599996914 ('aebdac', 6, 6.0) 8 | 35 2.462162903000717 ('aebcabae', 7, 6.6) 9 | 40 3.274474719000864 ('aebcaba', 7, 7.0) 10 | 45 4.2122495629992045 ('aebcabac', 8, 8.0) 11 | 50 5.26111833899995 ('aebcabac', 8, 8.0) 12 | 55 6.32133871699989 ('aebcabac', 8, 8.0) 13 | 60 7.493227697999828 ('aebcabac', 8, 8.0) 14 | 65 8.578684134998184 ('aebcabac', 8, 8.0) 15 | 70 9.8394678629993 ('aebcabac', 8, 8.0) 16 | 75 11.193384056001378 ('aebcabac', 8, 8.0) 17 | 80 12.678333439998823 ('cebcabaad', 9, 9.0) 18 | 85 14.484180151001055 ('cebcabaad', 9, 9.0) 19 | 90 16.33008353400146 ('cebcabaad', 9, 9.0) 20 | 95 18.21409217100154 ('cebcabaad', 9, 9.0) 21 | 100 20.22987612900033 ('cebcabaad', 9, 9.0) 22 | 105 22.42470116899858 ('cebcabaad', 9, 9.0) 23 | 110 24.65214286199989 ('cebcabaad', 9, 9.0) 24 | 115 27.05512779700075 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_e/ForkFuzzer-seed11-DOSYS0: -------------------------------------------------------------------------------- 1 | 0 0.02156264400036889 ('a', -9, -9) 2 | 5 0.17398658800084377 ('aea', 3, 3.0) 3 | 10 0.39198962100272183 ('aeab', 4, 4.0) 4 | 15 0.6994911980000325 ('aebdaa', 5, 4.6) 5 | 20 0.9983620470011374 ('aebdaa', 5, 4.6) 6 | 25 1.360441199001798 ('aebdaa', 5, 4.6) 7 | 30 1.8549116180001874 ('aebdac', 6, 6.0) 8 | 35 2.5304004890022043 ('aebcabae', 7, 6.6) 9 | 40 3.353673287001584 ('aebcaba', 7, 7.0) 10 | 45 4.288769934999436 ('aebcabac', 8, 8.0) 11 | 50 5.315880016001756 ('aebcabac', 8, 8.0) 12 | 55 6.327656345001742 ('aebcabac', 8, 8.0) 13 | 60 7.36824872500074 ('aebcabac', 8, 8.0) 14 | 65 8.305660183999862 ('aebcabac', 8, 8.0) 15 | 70 9.404258721002407 ('aebcabac', 8, 8.0) 16 | 75 10.612960739999835 ('aebcabac', 8, 8.0) 17 | 80 11.909384279002552 ('cebcabaad', 9, 9.0) 18 | 85 13.50745273800203 ('cebcabaad', 9, 9.0) 19 | 90 15.136981669002125 ('cebcabaad', 9, 9.0) 20 | 95 16.793644458000927 ('cebcabaad', 9, 9.0) 21 | 100 18.50175557300099 ('cebcabaad', 9, 9.0) 22 | 105 20.323810163001326 ('cebcabaad', 9, 9.0) 23 | 110 22.164483412001573 ('cebcabaad', 9, 9.0) 24 | 115 24.07955022600072 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_e/ForkFuzzer-seed11-DOSYS1: -------------------------------------------------------------------------------- 1 | 0 0.021583843998087104 ('a', -9, -9) 2 | 5 0.17124564299956546 ('aea', 3, 3.0) 3 | 10 0.40093072399758967 ('aeab', 4, 4.0) 4 | 15 0.7178588909991959 ('aebdaa', 5, 4.6) 5 | 20 1.028074199999537 ('aebdaa', 5, 4.6) 6 | 25 1.4171064809997915 ('aebdaa', 5, 4.6) 7 | 30 1.9428250069977366 ('aebdac', 6, 6.0) 8 | 35 2.656304756001191 ('aebcabae', 7, 6.6) 9 | 40 3.532908019999013 ('aebcaba', 7, 7.0) 10 | 45 4.535439860999759 ('aebcabac', 8, 8.0) 11 | 50 5.65708581799845 ('aebcabac', 8, 8.0) 12 | 55 6.785069109999313 ('aebcabac', 8, 8.0) 13 | 60 8.0206740729991 ('aebcabac', 8, 8.0) 14 | 65 9.167330690997915 ('aebcabac', 8, 8.0) 15 | 70 10.518291991000297 ('aebcabac', 8, 8.0) 16 | 75 11.942765930998576 ('aebcabac', 8, 8.0) 17 | 80 13.501173859000119 ('cebcabaad', 9, 9.0) 18 | 85 15.4114945729998 ('cebcabaad', 9, 9.0) 19 | 90 17.360675836000155 ('cebcabaad', 9, 9.0) 20 | 95 19.336498179000046 ('cebcabaad', 9, 9.0) 21 | 100 21.408686053000565 ('cebcabaad', 9, 9.0) 22 | 105 23.6785342209987 ('cebcabaad', 9, 9.0) 23 | 110 25.98323806699773 ('cebcabaad', 9, 9.0) 24 | 115 28.46214331399824 ('cebcabaad', 9, 9.0) 25 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/results_e/results '__main__.FuzzerForkserver'>-seed11-DOSYS0--5486: -------------------------------------------------------------------------------- 1 | 0 0.027855788997840136 ('a', -9, -9) 2 | 5 0.5400921269974788 ('aea', 3, 3.0) 3 | 10 1.4548277369976859 ('aeab', 4, 4.0) 4 | 15 2.60293374399771 ('aebdaa', 5, 4.6) 5 | 20 3.841446091999387 ('aebdaa', 5, 4.6) 6 | 25 5.142709064999508 ('aebdaa', 5, 4.6) 7 | 30 6.591052309999213 ('aebdac', 6, 6.0) 8 | 35 8.240123545998358 ('aebcabae', 7, 6.6) 9 | 40 10.040582557998277 ('aebcaba', 7, 7.0) 10 | 45 12.022898799998075 ('aebcabac', 8, 8.0) 11 | 50 14.151427241999045 ('aebcabac', 8, 8.0) 12 | 55 16.286004350997246 ('aebcabac', 8, 8.0) 13 | 60 18.411938099998224 ('aebcabac', 8, 8.0) 14 | 65 20.454180341999745 ('aebcabac', 8, 8.0) 15 | 70 22.55355224699815 ('aebcabac', 8, 8.0) 16 | 75 24.701464658999612 ('aebcabac', 8, 8.0) 17 | 80 26.867841958999634 ('cebcabaad', 9, 9.0) 18 | 85 29.114135689997056 ('cebcabaad', 9, 9.0) 19 | 90 31.427693601999636 ('cebcabaad', 9, 9.0) 20 | 95 33.6697468429993 ('cebcabaad', 9, 9.0) 21 | 100 35.92751649999991 ('cebcabaad', 9, 9.0) 22 | 105 38.194249197997124 ('cebcabaad', 9, 9.0) 23 | 110 40.46642724099729 ('cebcabaad', 9, 9.0) 24 | 115 42.766490182999405 ('cebcabaad', 9, 9.0) 25 | 120 45.03293604499777 ('cebcabaad', 9, 9.0) 26 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/testpipe/PaulaPipe.py: -------------------------------------------------------------------------------- 1 | import pty 2 | import os 3 | import subprocess 4 | 5 | PIPE_BUFSIZE = 4096 6 | 7 | 8 | class Pipe: 9 | 10 | def __init__(self, flags=0, terminal=False): 11 | """Creates a Pipe you can easily write to and read from. Default is to open up a regular pipe.""" 12 | 13 | if flags or not terminal: 14 | self._readfd, self._writefd = os.pipe2(flags) 15 | else: # terminal 16 | self._readfd, self._writefd = pty.openpty() 17 | 18 | os.set_inheritable(self._readfd, True) 19 | os.set_inheritable(self._writefd, True) 20 | 21 | self.readobj = open(self._readfd, "rb", 0) 22 | self.writeobj = open(self._writefd, "wb", 0) 23 | 24 | def fileno(self, which): 25 | if which == "read": 26 | return self._readfd 27 | elif which == "write": 28 | return self._writefd 29 | else: 30 | raise KeyError 31 | 32 | def write(self, text): 33 | if isinstance(text, str): 34 | text = text.encode() 35 | 36 | result = self.writeobj.write(text) 37 | self.writeobj.flush() 38 | return result 39 | 40 | def read(self, n): 41 | self.writeobj.flush() 42 | return self.readobj.read(n) 43 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/testpipe/test.py: -------------------------------------------------------------------------------- 1 | from PaulaPipe import Pipe 2 | import subprocess 3 | 4 | args="python3 waiter.py" 5 | 6 | p=Pipe() 7 | 8 | subprocess.Popen(args.split(), stdout=p.writeobj) 9 | 10 | print(p.read(100)) 11 | -------------------------------------------------------------------------------- /FuzzingScripts/fuzzme/testpipe/waiter.py: -------------------------------------------------------------------------------- 1 | import time 2 | time.sleep(5) 3 | print("sup") 4 | -------------------------------------------------------------------------------- /FuzzingScripts/runbenchmark.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | x=1 3 | while [ $x -le 10 ] 4 | do 5 | python3 bench1.py 10001 44444 6 | sleep 2s 7 | x=$(( $x + 1 )) 8 | done 9 | -------------------------------------------------------------------------------- /demo/ba_kolloq_init: -------------------------------------------------------------------------------- 1 | b main 2 | c 3 | malloc 1 4 | call libc:setbuf 0x0007ffff7f93760 0 5 | hyx 6 | -------------------------------------------------------------------------------- /demo/berzandemo.c: -------------------------------------------------------------------------------- 1 | //#include 2 | #include 3 | 4 | int main() 5 | { 6 | puts("normal"); 7 | malloc(1); 8 | } 9 | -------------------------------------------------------------------------------- /demo/exittest.c: -------------------------------------------------------------------------------- 1 | int main(){ 2 | int a=1; 3 | foo(); 4 | exit(1); 5 | 6 | } 7 | int foo(){ 8 | puts("goodbye"); 9 | } 10 | -------------------------------------------------------------------------------- /demo/forktest.c: -------------------------------------------------------------------------------- 1 | int main(){ 2 | 3 | if (fork()){ 4 | puts("true"); 5 | } else { 6 | puts("false"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/Screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/docs/Screenshot1.png -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-midnight -------------------------------------------------------------------------------- /docs/praesi.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/docs/praesi.pdf -------------------------------------------------------------------------------- /docs/test: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/thesis.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/docs/thesis.pdf -------------------------------------------------------------------------------- /forkever.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | from argparse import ArgumentParser, REMAINDER 4 | 5 | import pwn 6 | 7 | from InputHandler import InputHandler 8 | from ProcessWrapper import LaunchArguments 9 | 10 | 11 | def main(): 12 | pwn.context.log_level = "ERROR" 13 | 14 | def _handle_final_outputs(poll_res): 15 | if not poll_res: 16 | return 17 | outs = map(lambda poll_elem: poll_elem[0], poll_res) 18 | 19 | if any("out" in out for out in outs): 20 | handler.handle_procout(None, None, None) 21 | if any("err" in out for out in outs): 22 | handler.handle_stderr(None) 23 | 24 | p = ArgumentParser() 25 | p.add_argument("-init", help="Pass a file for initial commands") 26 | # randomization disabled by default 27 | p.add_argument("-rand", action="store_true", 28 | help="to enable randomization") 29 | p.add_argument("-sock", action="store_true", # no socket by default 30 | help="if you want to communicate with the program via a socket. (Adjust in Constants.py)") 31 | p.add_argument("runargs", nargs=REMAINDER) 32 | 33 | parsed_args = p.parse_args() 34 | launch_args = LaunchArguments(parsed_args.runargs, parsed_args.rand) 35 | 36 | handler = InputHandler( 37 | launch_args, startupfile=parsed_args.init, inputsock=parsed_args.sock) 38 | 39 | try: 40 | handler.inputLoop() 41 | 42 | # for now, Ctrl + C exits. The issue is that the event might abort 43 | # a procedure right in the middle of it. 44 | except KeyboardInterrupt: 45 | handler.manager.quit() 46 | _handle_final_outputs(handler.inputPoll.poll(10)) 47 | exit(1) 48 | 49 | except BaseException as e: 50 | print("oh noes, a bug! please copy everything and send it to haxkor") 51 | print(handler.manager.family()) 52 | handler.manager.quit() # otherwise launched children stay alive 53 | raise e 54 | 55 | 56 | if __name__ == "__main__": 57 | main() 58 | -------------------------------------------------------------------------------- /init_demo: -------------------------------------------------------------------------------- 1 | c 2 | w 1 3 | w 0x500 4 | fork m500 5 | w 1 6 | w 0x10 7 | fork m10 8 | 9 | w 3 10 | w 0x555555559260 11 | 12 | w 8 13 | w 0x555555559260 14 | w 8 15 | 16 | fork beforeoverwritingfreehook 17 | 18 | tree 19 | 20 | w 0 21 | w 7 22 | p libc:free_hoo 23 | w 0x7ffff7fa88e8 24 | w 8 25 | p libc:system 26 | w b'\xc0\xf9\xe2\xf7\xff\x7f\x00\x00' 27 | 28 | fork beforefreebinsh 29 | 30 | w 3 31 | trace * 32 | w 0x7ffff7f6c519 33 | 34 | -------------------------------------------------------------------------------- /init_file_example: -------------------------------------------------------------------------------- 1 | trace write 2 | trace mmap 3 | c 4 | malloc 0x100 5 | fork beforefree 6 | call libc:free $rax+0x1a4 7 | hyx heap rwp 8 | c 9 | switch beforefree 10 | -------------------------------------------------------------------------------- /installCptrace/README.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | python-ptrace 3 | ============= 4 | 5 | .. image:: http://unmaintained.tech/badge.svg 6 | :target: http://unmaintained.tech/ 7 | :alt: No Maintenance Intended 8 | 9 | .. image:: https://img.shields.io/pypi/v/python-ptrace.svg 10 | :alt: Latest release on the Python Cheeseshop (PyPI) 11 | :target: https://pypi.python.org/pypi/python-ptrace 12 | 13 | .. image:: https://travis-ci.org/vstinner/python-ptrace.svg?branch=master 14 | :alt: Build status of python-ptrace on Travis CI 15 | :target: https://travis-ci.org/vstinner/python-ptrace 16 | 17 | **This project is no longer maintained and is looking for a new maintainer.** 18 | 19 | python-ptrace is a debugger using ptrace (Linux, BSD and Darwin system call to 20 | trace processes) written in Python. 21 | 22 | * `python-ptrace documentation 23 | `_ 24 | * `python-ptrace at GitHub 25 | `_ 26 | * `python-ptrace at the Python Cheeseshop (PyPI) 27 | `_ 28 | 29 | python-ptrace is an opensource project written in Python under GNU GPLv2 30 | license. 31 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.signames import SIGNAMES, signalName # noqa 2 | from ptrace.error import PtraceError # noqa 3 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/binding/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.binding.func import ( # noqa 2 | HAS_PTRACE_SINGLESTEP, HAS_PTRACE_EVENTS, 3 | HAS_PTRACE_IO, HAS_PTRACE_SIGINFO, HAS_PTRACE_GETREGS, 4 | REGISTER_NAMES, 5 | ptrace_attach, ptrace_traceme, 6 | ptrace_detach, ptrace_kill, 7 | ptrace_cont, ptrace_syscall, 8 | ptrace_setregs, 9 | ptrace_peektext, ptrace_poketext, 10 | ptrace_peekuser, 11 | ptrace_registers_t) 12 | if HAS_PTRACE_EVENTS: 13 | from ptrace.binding.func import (WPTRACEEVENT, # noqa 14 | PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK, PTRACE_EVENT_CLONE, 15 | PTRACE_EVENT_EXEC, 16 | ptrace_setoptions, ptrace_geteventmsg) 17 | if HAS_PTRACE_SINGLESTEP: 18 | from ptrace.binding.func import ptrace_singlestep # noqa 19 | if HAS_PTRACE_SIGINFO: 20 | from ptrace.binding.func import ptrace_getsiginfo # noqa 21 | if HAS_PTRACE_IO: 22 | from ptrace.binding.func import ptrace_io # noqa 23 | from ptrace.binding.freebsd_struct import ( # noqa 24 | ptrace_io_desc, 25 | PIOD_READ_D, PIOD_WRITE_D, 26 | PIOD_READ_I, PIOD_WRITE_I) 27 | if HAS_PTRACE_GETREGS: 28 | from ptrace.binding.func import ptrace_getregs # noqa 29 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/binding/cpu.py: -------------------------------------------------------------------------------- 1 | from ptrace.cpu_info import ( 2 | CPU_POWERPC, CPU_INTEL, CPU_X86_64, CPU_I386, CPU_ARM) 3 | 4 | CPU_INSTR_POINTER = None 5 | CPU_STACK_POINTER = None 6 | CPU_FRAME_POINTER = None 7 | CPU_SUB_REGISTERS = {} 8 | 9 | if CPU_POWERPC: 10 | CPU_INSTR_POINTER = "nip" 11 | # FIXME: Is it the right register? 12 | CPU_STACK_POINTER = 'gpr1' 13 | elif CPU_ARM: 14 | CPU_INSTR_POINTER = 'r15' 15 | CPU_STACK_POINTER = 'r14' 16 | CPU_FRAME_POINTER = 'r11' 17 | elif CPU_X86_64: 18 | CPU_INSTR_POINTER = "rip" 19 | CPU_STACK_POINTER = "rsp" 20 | CPU_FRAME_POINTER = "rbp" 21 | CPU_SUB_REGISTERS = { 22 | # main register name, shift, mask 23 | 'al': ('rax', 0, 0xff), 24 | 'bl': ('rbx', 0, 0xff), 25 | 'cl': ('rcx', 0, 0xff), 26 | 'dl': ('rdx', 0, 0xff), 27 | 'ah': ('rax', 8, 0xff), 28 | 'bh': ('rbx', 8, 0xff), 29 | 'ch': ('rcx', 8, 0xff), 30 | 'dh': ('rdx', 8, 0xff), 31 | 'ax': ('rax', 0, 0xffff), 32 | 'bx': ('rbx', 0, 0xffff), 33 | 'cx': ('rcx', 0, 0xffff), 34 | 'dx': ('rdx', 0, 0xffff), 35 | 'eax': ('rax', 32, None), 36 | 'ebx': ('rbx', 32, None), 37 | 'ecx': ('rcx', 32, None), 38 | 'edx': ('rdx', 32, None), 39 | } 40 | elif CPU_I386: 41 | CPU_INSTR_POINTER = "eip" 42 | CPU_STACK_POINTER = "esp" 43 | CPU_FRAME_POINTER = "ebp" 44 | CPU_SUB_REGISTERS = { 45 | 'al': ('eax', 0, 0xff), 46 | 'bl': ('ebx', 0, 0xff), 47 | 'cl': ('ecx', 0, 0xff), 48 | 'dl': ('edx', 0, 0xff), 49 | 'ah': ('eax', 8, 0xff), 50 | 'bh': ('ebx', 8, 0xff), 51 | 'ch': ('ecx', 8, 0xff), 52 | 'dh': ('edx', 8, 0xff), 53 | 'ax': ('eax', 0, 0xffff), 54 | 'bx': ('ebx', 0, 0xffff), 55 | 'cx': ('ecx', 0, 0xffff), 56 | 'dx': ('edx', 0, 0xffff), 57 | } 58 | 59 | if CPU_INTEL: 60 | CPU_SUB_REGISTERS.update({ 61 | 'cf': ('eflags', 0, 1), 62 | 'pf': ('eflags', 2, 1), 63 | 'af': ('eflags', 4, 1), 64 | 'zf': ('eflags', 6, 1), 65 | 'sf': ('eflags', 7, 1), 66 | 'tf': ('eflags', 8, 1), 67 | 'if': ('eflags', 9, 1), 68 | 'df': ('eflags', 10, 1), 69 | 'of': ('eflags', 11, 1), 70 | 'iopl': ('eflags', 12, 2), 71 | }) 72 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/binding/freebsd_struct.py: -------------------------------------------------------------------------------- 1 | from ctypes import (Structure, 2 | c_int, c_uint, c_ulong, c_void_p, 3 | c_uint16, c_uint32, c_size_t) 4 | from ptrace.cpu_info import CPU_X86_64 5 | 6 | PIOD_READ_D = 1 7 | PIOD_WRITE_D = 2 8 | PIOD_READ_I = 3 9 | PIOD_WRITE_I = 4 10 | 11 | # /usr/include/machine/reg.h 12 | if CPU_X86_64: 13 | register_t = c_ulong 14 | 15 | class reg(Structure): 16 | _fields_ = ( 17 | ("r15", register_t), 18 | ("r14", register_t), 19 | ("r13", register_t), 20 | ("r12", register_t), 21 | ("r11", register_t), 22 | ("r10", register_t), 23 | ("r9", register_t), 24 | ("r8", register_t), 25 | ("rdi", register_t), 26 | ("rsi", register_t), 27 | ("rbp", register_t), 28 | ("rbx", register_t), 29 | ("rdx", register_t), 30 | ("rcx", register_t), 31 | ("rax", register_t), 32 | ("trapno", c_uint32), 33 | ("fs", c_uint16), 34 | ("gs", c_uint16), 35 | ("err", c_uint32), 36 | ("es", c_uint16), 37 | ("ds", c_uint16), 38 | ("rip", register_t), 39 | ("cs", register_t), 40 | ("rflags", register_t), 41 | ("rsp", register_t), 42 | ("ss", register_t), 43 | ) 44 | else: 45 | class reg(Structure): 46 | _fields_ = ( 47 | ("fs", c_uint), 48 | ("es", c_uint), 49 | ("ds", c_uint), 50 | ("edi", c_uint), 51 | ("esi", c_uint), 52 | ("ebp", c_uint), 53 | ("isp", c_uint), 54 | ("ebx", c_uint), 55 | ("edx", c_uint), 56 | ("ecx", c_uint), 57 | ("eax", c_uint), 58 | ("trapno", c_uint), 59 | ("err", c_uint), 60 | ("eip", c_uint), 61 | ("cs", c_uint), 62 | ("eflags", c_uint), 63 | ("esp", c_uint), 64 | ("ss", c_uint), 65 | ("gs", c_uint), 66 | ) 67 | 68 | 69 | class ptrace_io_desc(Structure): 70 | _fields_ = ( 71 | ("piod_op", c_int), 72 | ("piod_offs", c_void_p), 73 | ("piod_addr", c_void_p), 74 | ("piod_len", c_size_t), 75 | ) 76 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/binding/openbsd_struct.py: -------------------------------------------------------------------------------- 1 | from ctypes import Structure, c_int, c_uint, c_ulong, c_void_p, c_char 2 | 3 | PIOD_READ_D = 1 4 | PIOD_WRITE_D = 2 5 | PIOD_READ_I = 3 6 | PIOD_WRITE_I = 4 7 | 8 | size_t = c_ulong 9 | pid_t = c_int 10 | 11 | # /usr/include/machine/reg.h 12 | 13 | 14 | class reg(Structure): 15 | _fields_ = ( 16 | ("eax", c_uint), 17 | ("ecx", c_uint), 18 | ("edx", c_uint), 19 | ("ebx", c_uint), 20 | ("esp", c_uint), 21 | ("ebp", c_uint), 22 | ("esi", c_uint), 23 | ("edi", c_uint), 24 | ("eip", c_uint), 25 | ("eflags", c_uint), 26 | ("cs", c_uint), 27 | ("ss", c_uint), 28 | ("ds", c_uint), 29 | ("es", c_uint), 30 | ("fs", c_uint), 31 | ("gs", c_uint), 32 | ) 33 | 34 | 35 | class fpreg(Structure): 36 | _fields_ = ( 37 | ("__data", c_char * 116), 38 | ) 39 | 40 | 41 | class ptrace_io_desc(Structure): 42 | _fields_ = ( 43 | ("piod_op", c_int), 44 | ("piod_offs", c_void_p), 45 | ("piod_addr", c_void_p), 46 | ("piod_len", size_t), 47 | ) 48 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/cpu_info.py: -------------------------------------------------------------------------------- 1 | """ 2 | Constants about the CPU: 3 | 4 | - CPU_BIGENDIAN (bool) 5 | - CPU_64BITS (bool) 6 | - CPU_WORD_SIZE (int) 7 | - CPU_MAX_UINT (int) 8 | - CPU_PPC32 (bool) 9 | - CPU_PPC64 (bool) 10 | - CPU_I386 (bool) 11 | - CPU_X86_64 (bool) 12 | - CPU_INTEL (bool) 13 | - CPU_POWERPC (bool) 14 | """ 15 | 16 | try: 17 | from os import uname 18 | HAS_UNAME = True 19 | except ImportError: 20 | HAS_UNAME = False 21 | from platform import architecture 22 | from sys import byteorder 23 | from ctypes import sizeof, c_void_p 24 | 25 | CPU_BIGENDIAN = (byteorder == 'big') 26 | CPU_64BITS = (sizeof(c_void_p) == 8) 27 | 28 | if CPU_64BITS: 29 | CPU_WORD_SIZE = 8 # bytes 30 | CPU_MAX_UINT = 0xffffffffffffffff 31 | else: 32 | CPU_WORD_SIZE = 4 # bytes 33 | CPU_MAX_UINT = 0xffffffff 34 | 35 | if HAS_UNAME: 36 | # guess machine type using uname() 37 | _machine = uname()[4] 38 | CPU_PPC32 = (_machine == 'ppc') 39 | CPU_PPC64 = (_machine == 'ppc64') 40 | CPU_I386 = (_machine in ("i386", "i686")) # compatible Intel 32 bits 41 | CPU_X86_64 = (_machine in ("x86_64", "amd64")) # compatible Intel 64 bits 42 | CPU_ARM = _machine.startswith('arm') 43 | del _machine 44 | else: 45 | # uname() fallback for Windows 46 | # I hope that your Windows doesn't run on PPC32/PPC64 47 | CPU_PPC32 = False 48 | CPU_PPC64 = False 49 | CPU_I386 = False 50 | CPU_X86_64 = False 51 | CPU_ARM = False 52 | bits, linkage = architecture() 53 | if bits == '32bit': 54 | CPU_I386 = True 55 | elif bits == '64bit': 56 | CPU_X86_64 = True 57 | else: 58 | raise ValueError("Unknown architecture bits: %r" % bits) 59 | 60 | CPU_INTEL = (CPU_I386 or CPU_X86_64) 61 | CPU_POWERPC = (CPU_PPC32 or CPU_PPC64) 62 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/ctypes_libc.py: -------------------------------------------------------------------------------- 1 | """ 2 | Load the system C library. Variables: 3 | - LIBC_FILENAME: the C library filename 4 | - libc: the loaded library 5 | """ 6 | 7 | from ctypes import CDLL 8 | from ctypes.util import find_library 9 | 10 | LIBC_FILENAME = find_library('c') 11 | libc = CDLL(LIBC_FILENAME, use_errno=True) 12 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/debugger/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.debugger.breakpoint import Breakpoint # noqa 2 | from ptrace.debugger.process_event import (ProcessEvent, ProcessExit, # noqa 3 | NewProcessEvent, ProcessExecution) 4 | from ptrace.debugger.ptrace_signal import ProcessSignal # noqa 5 | from ptrace.debugger.process_error import ProcessError # noqa 6 | from ptrace.debugger.child import ChildError # noqa 7 | from ptrace.debugger.process import PtraceProcess # noqa 8 | from ptrace.debugger.debugger import PtraceDebugger, DebuggerError # noqa 9 | from ptrace.debugger.application import Application # noqa 10 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/debugger/breakpoint.py: -------------------------------------------------------------------------------- 1 | from ptrace.ctypes_tools import formatAddress 2 | from ptrace import PtraceError 3 | from logging2 import info 4 | from weakref import ref 5 | from ptrace.cpu_info import CPU_POWERPC, CPU_WORD_SIZE 6 | from ptrace.ctypes_tools import word2bytes 7 | from six import b 8 | 9 | 10 | class Breakpoint(object): 11 | """ 12 | Software breakpoint. 13 | 14 | Use desinstall() method to remove the breakpoint from the process. 15 | """ 16 | 17 | def __init__(self, process, address, size=None): 18 | self._installed = False 19 | self.process = ref(process) 20 | self.address = address 21 | if CPU_POWERPC: 22 | size = CPU_WORD_SIZE 23 | elif size is None: 24 | size = 1 25 | self.size = size 26 | 27 | # Store instruction bytes 28 | info("Install %s" % self) 29 | self.old_bytes = process.readBytes(address, size) 30 | 31 | if CPU_POWERPC: 32 | # Replace instruction with "TRAP" 33 | new_bytes = word2bytes(0x0cc00000) 34 | else: 35 | # Replace instruction with "INT 3" 36 | new_bytes = b("\xCC") * size 37 | process.writeBytes(address, new_bytes) 38 | self._installed = True 39 | 40 | def desinstall(self, set_ip=False): 41 | """ 42 | Remove the breakpoint from the associated process. If set_ip is True, 43 | restore the instruction pointer to the address of the breakpoint. 44 | """ 45 | if not self._installed: 46 | return 47 | self._installed = False 48 | info("Desinstall %s" % self) 49 | process = self.process() 50 | if not process: 51 | return 52 | if process.running: 53 | process.writeBytes(self.address, self.old_bytes) 54 | if set_ip: 55 | process.setInstrPointer(self.address) 56 | process.removeBreakpoint(self) 57 | 58 | def __str__(self): 59 | return "" % ( 60 | formatAddress(self.address), 61 | formatAddress(self.address + self.size - 1)) 62 | 63 | def __del__(self): 64 | try: 65 | self.desinstall(False) 66 | except PtraceError: 67 | pass 68 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/debugger/process_error.py: -------------------------------------------------------------------------------- 1 | from ptrace.error import PtraceError 2 | 3 | 4 | class ProcessError(PtraceError): 5 | 6 | def __init__(self, process, message): 7 | PtraceError.__init__(self, message, pid=process.pid) 8 | self.process = process 9 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/debugger/process_event.py: -------------------------------------------------------------------------------- 1 | from ptrace.signames import signalName 2 | 3 | 4 | class ProcessEvent(Exception): 5 | """ 6 | A process event: program exit, program killed by a signal, program 7 | received a signal, etc. 8 | 9 | The attribute "process" contains the related process. 10 | """ 11 | 12 | def __init__(self, process, message): 13 | Exception.__init__(self, message) 14 | self.process = process 15 | 16 | 17 | class ProcessExit(ProcessEvent): 18 | """ 19 | Process exit event: 20 | - process kill by a signal (if signum attribute is not None) 21 | - process exited with a code (if exitcode attribute is not None) 22 | - process terminated abnormally (otherwise) 23 | """ 24 | 25 | def __init__(self, process, signum=None, exitcode=None): 26 | pid = process.pid 27 | if signum: 28 | message = "Process %s killed by signal %s" % ( 29 | pid, signalName(signum)) 30 | elif exitcode is not None: 31 | if not exitcode: 32 | message = "Process %s exited normally" % pid 33 | else: 34 | message = "Process %s exited with code %s" % (pid, exitcode) 35 | else: 36 | message = "Process %s terminated abnormally" % pid 37 | ProcessEvent.__init__(self, process, message) 38 | self.signum = signum 39 | self.exitcode = exitcode 40 | 41 | 42 | class ProcessExecution(ProcessEvent): 43 | """ 44 | Process execution: event send just after the process calls the exec() 45 | syscall if exec() tracing option is enabled. 46 | """ 47 | 48 | def __init__(self, process): 49 | ProcessEvent.__init__( 50 | self, process, "Process %s execution" % process.pid) 51 | 52 | 53 | class NewProcessEvent(ProcessEvent): 54 | """ 55 | New process: event send when a process calls the fork() syscall if fork() 56 | tracing option is enabled. The attribute process contains the new child 57 | process. 58 | """ 59 | 60 | def __init__(self, process): 61 | ProcessEvent.__init__(self, process, "New process %s" % process.pid) 62 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/debugger/syscall_state.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall import PtraceSyscall 2 | from signal import SIGTRAP 3 | 4 | 5 | class SyscallState(object): 6 | 7 | def __init__(self, process): 8 | self.process = process 9 | self.ignore_exec_trap = True 10 | self.ignore_callback = None 11 | self.clear() 12 | 13 | def event(self, options): 14 | if self.next_event == "exit": 15 | return self.exit() 16 | else: 17 | return self.enter(options) 18 | 19 | def enter(self, options): 20 | # syscall enter 21 | regs = self.process.getregs() 22 | self.syscall = PtraceSyscall(self.process, options, regs) 23 | self.name = self.syscall.name 24 | if (not self.ignore_callback) \ 25 | or (not self.ignore_callback(self.syscall)): 26 | self.syscall.enter(regs) 27 | else: 28 | self.syscall = None 29 | self.next_event = "exit" 30 | return self.syscall 31 | 32 | def exit(self): 33 | if self.syscall: 34 | self.syscall.exit() 35 | if self.ignore_exec_trap \ 36 | and self.name == "execve" \ 37 | and not self.process.debugger.trace_exec: 38 | # Ignore the SIGTRAP after exec() syscall exit 39 | self.process.syscall() 40 | self.process.waitSignals(SIGTRAP) 41 | syscall = self.syscall 42 | self.clear() 43 | return syscall 44 | 45 | def clear(self): 46 | self.syscall = None 47 | self.name = None 48 | self.next_event = "enter" 49 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/error.py: -------------------------------------------------------------------------------- 1 | from sys import exc_info 2 | from traceback import format_exception 3 | from logging2 import ERROR, getLogger 4 | from ptrace.logging_tools import getLogFunc, changeLogLevel 5 | 6 | PTRACE_ERRORS = Exception 7 | 8 | 9 | def writeBacktrace(logger, log_level=ERROR): 10 | """ 11 | Write a backtrace into the logger with the specified log level. 12 | """ 13 | log_func = getLogFunc(logger, log_level) 14 | try: 15 | info = exc_info() 16 | trace = format_exception(*info) 17 | if trace[0] != "None\n": 18 | trace = ''.join(trace).rstrip() 19 | for line in trace.split("\n"): 20 | log_func(line.rstrip()) 21 | return 22 | except Exception: 23 | pass 24 | log_func("Unable to get backtrace") 25 | 26 | 27 | def formatError(error): 28 | """ 29 | Format an error as a string. Write the error type as prefix. 30 | Eg. "[ValueError] invalid value". 31 | """ 32 | return "[%s] %s" % (error.__class__.__name__, error) 33 | 34 | 35 | def writeError(logger, error, title="ERROR", log_level=ERROR): 36 | """ 37 | Write an error into the logger: 38 | - logger: the logger (if None, use getLogger()) 39 | - error: the exception object 40 | - title: error message prefix (e.g. title="Initialization error") 41 | - log_level: log level of the error 42 | 43 | If the exception is a SystemExit or a KeyboardInterrupt, re-emit 44 | (raise) the exception and don't write it. 45 | """ 46 | if not logger: 47 | logger = getLogger() 48 | if error.__class__ in (SystemExit, KeyboardInterrupt): 49 | raise error 50 | log_func = getLogFunc(logger, log_level) 51 | log_func("%s: %s" % (title, formatError(error))) 52 | writeBacktrace(logger, log_level=changeLogLevel(log_level, -1)) 53 | 54 | 55 | class PtraceError(Exception): 56 | """ 57 | Ptrace error: have the optional attributes errno and pid. 58 | """ 59 | 60 | def __init__(self, message, errno=None, pid=None): 61 | Exception.__init__(self, message) 62 | self.errno = errno 63 | self.pid = pid 64 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/logging_tools.py: -------------------------------------------------------------------------------- 1 | from ptrace.tools import minmax 2 | from logging2 import ERROR, WARNING, INFO, DEBUG 3 | 4 | 5 | def getLogFunc(logger, level): 6 | """ 7 | Get the logger function for the specified logging level. 8 | """ 9 | if level == ERROR: 10 | return logger.error 11 | elif level == WARNING: 12 | return logger.warning 13 | elif level == INFO: 14 | return logger.info 15 | elif level == DEBUG: 16 | return logger.debug 17 | else: 18 | return logger.error 19 | 20 | 21 | def changeLogLevel(level, delta): 22 | """ 23 | Compute log level and make sure that the result is in DEBUG..ERROR. 24 | 25 | >>> changeLogLevel(ERROR, -1) == WARNING 26 | True 27 | >>> changeLogLevel(DEBUG, 1) == INFO 28 | True 29 | """ 30 | return minmax(DEBUG, level + delta * 10, ERROR) 31 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/mockup.py: -------------------------------------------------------------------------------- 1 | """ 2 | Mockup classes used in unit tests. 3 | """ 4 | 5 | 6 | class FakeProcess(object): 7 | 8 | def __init__(self): 9 | self.regs = {} 10 | 11 | def setreg(self, name, value): 12 | self.regs[name] = value 13 | 14 | def getreg(self, name): 15 | return self.regs[name] 16 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/os_tools.py: -------------------------------------------------------------------------------- 1 | """ 2 | Constants about the operating system: 3 | 4 | - RUNNING_PYPY (bool) 5 | - RUNNING_WINDOWS (bool) 6 | - RUNNING_LINUX (bool) 7 | - RUNNING_FREEBSD (bool) 8 | - RUNNING_OPENBSD (bool) 9 | - RUNNING_MACOSX (bool) 10 | - RUNNING_BSD (bool) 11 | - HAS_PROC (bool) 12 | - HAS_PTRACE (bool) 13 | """ 14 | 15 | from sys import platform, version, version_info 16 | 17 | RUNNING_PYTHON3 = version_info[0] == 3 18 | RUNNING_PYPY = ("pypy" in version.lower()) 19 | RUNNING_WINDOWS = (platform == 'win32') 20 | RUNNING_LINUX = platform.startswith('linux') 21 | RUNNING_FREEBSD = (platform.startswith('freebsd') 22 | or platform.startswith('gnukfreebsd')) 23 | RUNNING_OPENBSD = platform.startswith('openbsd') 24 | RUNNING_MACOSX = (platform == 'darwin') 25 | RUNNING_BSD = RUNNING_FREEBSD or RUNNING_MACOSX or RUNNING_OPENBSD 26 | 27 | HAS_PROC = RUNNING_LINUX 28 | HAS_PTRACE = (RUNNING_BSD or RUNNING_LINUX) 29 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/profiler.py: -------------------------------------------------------------------------------- 1 | from hotshot import Profile 2 | from hotshot.stats import load as loadStats 3 | from os import unlink 4 | from io import StringIO 5 | 6 | 7 | def runProfiler(logger, func, args=tuple(), kw={}, 8 | verbose=True, nb_func=25, 9 | sort_by=('time',)): 10 | """ 11 | Run a function in a profiler and then display the functions sorted by time. 12 | """ 13 | profile_filename = "/tmp/profiler" 14 | prof = Profile(profile_filename) 15 | try: 16 | logger.warning("Run profiler") 17 | result = prof.runcall(func, *args, **kw) 18 | prof.close() 19 | logger.error("Profiler: Process data...") 20 | stat = loadStats(profile_filename) 21 | stat.strip_dirs() 22 | stat.sort_stats(*sort_by) 23 | 24 | logger.error("Profiler: Result:") 25 | log = StringIO() 26 | stat.stream = log 27 | stat.print_stats(nb_func) 28 | log.seek(0) 29 | for line in log: 30 | logger.error(line.rstrip()) 31 | return result 32 | finally: 33 | unlink(profile_filename) 34 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/signames.py: -------------------------------------------------------------------------------- 1 | """ 2 | Name of process signals. 3 | 4 | SIGNAMES contains a dictionary mapping a signal number to it's name. But you 5 | should better use signalName() instead of SIGNAMES since it returns a string 6 | even if the signal is unknown. 7 | """ 8 | 9 | PREFERRED_NAMES = ("SIGABRT", "SIGHUP", "SIGCHLD", "SIGPOLL") 10 | 11 | 12 | def getSignalNames(): 13 | """ 14 | Create signal names dictionary (e.g. 9 => 'SIGKILL') using dir(signal). 15 | If multiple signal names have the same number, use the first matching name 16 | in PREFERRED_NAME to select preferred name (e.g. SIGIOT=SIGABRT=17). 17 | """ 18 | import signal 19 | allnames = {} 20 | for name in dir(signal): 21 | if not name.startswith("SIG"): 22 | continue 23 | signum = getattr(signal, name) 24 | try: 25 | allnames[signum].append(name) 26 | except KeyError: 27 | allnames[signum] = [name] 28 | signames = {} 29 | for signum, names in allnames.items(): 30 | if not signum: 31 | # Skip signal 0 32 | continue 33 | name = None 34 | for preferred in PREFERRED_NAMES: 35 | if preferred in names: 36 | name = preferred 37 | break 38 | if not name: 39 | name = names[0] 40 | signames[signum] = name 41 | return signames 42 | 43 | 44 | SIGNAMES = getSignalNames() 45 | 46 | 47 | def signalName(signum): 48 | """ 49 | Get the name of a signal 50 | 51 | >>> from signal import SIGINT 52 | >>> signalName(SIGINT) 53 | 'SIGINT' 54 | >>> signalName(404) 55 | 'signal<404>' 56 | """ 57 | try: 58 | return SIGNAMES[signum] 59 | except KeyError: 60 | return "signal<%s>" % signum 61 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/syscall/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.names import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES # noqa 2 | from ptrace.syscall.prototypes import SYSCALL_PROTOTYPES, FILENAME_ARGUMENTS, DIRFD_ARGUMENTS # noqa 3 | from ptrace.syscall.syscall_argument import SyscallArgument # noqa 4 | from ptrace.syscall.ptrace_syscall import PtraceSyscall, SYSCALL_REGISTER, RETURN_VALUE_REGISTER # noqa 5 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/syscall/freebsd_constants.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.posix_constants import SYSCALL_ARG_DICT 2 | 3 | RLIMIT_RESOURCE = { 4 | 0: "RLIMIT_CPU", 5 | 1: "RLIMIT_FSIZE", 6 | 2: "RLIMIT_DATA", 7 | 3: "RLIMIT_STACK", 8 | 4: "RLIMIT_CORE", 9 | 5: "RLIMIT_RSS", 10 | 6: "RLIMIT_MEMLOCK", 11 | 7: "RLIMIT_NPROC", 12 | 8: "RLIMIT_NOFILE", 13 | 9: "RLIMIT_SBSIZE", 14 | 10: "RLIMIT_VMEM", 15 | } 16 | 17 | SIGPROCMASK_HOW = {1: " SIG_BLOCK", 2: "SIG_UNBLOCK", 3: "SIG_SETMASK"} 18 | 19 | SYSCALL_ARG_DICT.update({ 20 | "getrlimit": {"resource": RLIMIT_RESOURCE}, 21 | "setrlimit": {"resource": RLIMIT_RESOURCE}, 22 | "sigprocmask": {"how": SIGPROCMASK_HOW}, 23 | "rt_sigprocmask": {"how": SIGPROCMASK_HOW}, 24 | }) 25 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/syscall/linux_constants.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.posix_constants import SYSCALL_ARG_DICT 2 | 3 | SIGSET_SIZE = 64 4 | FD_SETSIZE = 1024 5 | 6 | RLIMIT_RESOURCE = { 7 | 0: "RLIMIT_CPU", 8 | 1: "RLIMIT_FSIZE", 9 | 2: "RLIMIT_DATA", 10 | 3: "RLIMIT_STACK", 11 | 4: "RLIMIT_CORE", 12 | 5: "RLIMIT_RSS", 13 | 6: "RLIMIT_NPROC", 14 | 7: "RLIMIT_NOFILE", 15 | 8: "RLIMIT_MEMLOCK", 16 | 9: "RLIMIT_AS", 17 | 10: "RLIMIT_LOCKS", 18 | 11: "RLIMIT_SIGPENDING", 19 | 12: "RLIMIT_MSGQUEUE", 20 | 13: "RLIMIT_NICE", 21 | 14: "RLIMIT_RTPRIO", 22 | 15: "RLIMIT_NLIMITS", 23 | } 24 | 25 | SIGPROCMASK_HOW = {0: "SIG_BLOCK", 1: "SIG_UNBLOCK", 2: "SIG_SETMASK"} 26 | 27 | SYSCALL_ARG_DICT.update({ 28 | "getrlimit": {"resource": RLIMIT_RESOURCE}, 29 | "setrlimit": {"resource": RLIMIT_RESOURCE}, 30 | "sigprocmask": {"how": SIGPROCMASK_HOW}, 31 | "rt_sigprocmask": {"how": SIGPROCMASK_HOW}, 32 | }) 33 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/syscall/linux_struct.py: -------------------------------------------------------------------------------- 1 | from ctypes import (Structure, 2 | c_char, c_short, c_int, c_uint, c_long, c_ulong) 3 | 4 | time_t = c_long 5 | suseconds_t = c_long 6 | rlim_t = c_long 7 | 8 | 9 | class timeval(Structure): 10 | _fields_ = ( 11 | ("tv_sec", time_t), 12 | ("tv_usec", suseconds_t), 13 | ) 14 | 15 | 16 | class timespec(Structure): 17 | _fields_ = ( 18 | ("tv_sec", time_t), 19 | ("tv_nsec", c_long), 20 | ) 21 | 22 | 23 | class pollfd(Structure): 24 | _fields_ = ( 25 | ("fd", c_int), 26 | ("events", c_short), 27 | ("revents", c_short), 28 | ) 29 | 30 | 31 | class rlimit(Structure): 32 | _fields_ = ( 33 | ("rlim_cur", rlim_t), 34 | ("rlim_max", rlim_t), 35 | ) 36 | 37 | 38 | class new_utsname(Structure): 39 | _fields_ = ( 40 | ("sysname", c_char * 65), 41 | ("nodename", c_char * 65), 42 | ("release", c_char * 65), 43 | ("version", c_char * 65), 44 | ("machine", c_char * 65), 45 | ("domainname", c_char * 65), 46 | ) 47 | 48 | # Arch depend 49 | 50 | 51 | class user_desc(Structure): 52 | _fields_ = ( 53 | ("entry_number", c_uint), 54 | ("base_addr", c_ulong), 55 | ("limit", c_uint), 56 | ("_bits_", c_char), 57 | # unsigned int seg_32bit:1; 58 | # unsigned int contents:2; 59 | # unsigned int read_exec_only:1; 60 | # unsigned int limit_in_pages:1; 61 | # unsigned int seg_not_present:1; 62 | # unsigned int useable:1; 63 | ) 64 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/syscall/names.py: -------------------------------------------------------------------------------- 1 | from ptrace.cpu_info import CPU_64BITS 2 | from ptrace.os_tools import RUNNING_LINUX, RUNNING_FREEBSD 3 | if RUNNING_LINUX: 4 | if CPU_64BITS: 5 | from ptrace.syscall.linux_syscall64 import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES 6 | else: 7 | from ptrace.syscall.linux_syscall32 import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES 8 | elif RUNNING_FREEBSD: 9 | from ptrace.syscall.freebsd_syscall import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES 10 | else: 11 | SYSCALL_NAMES = {} 12 | SOCKET_SYSCALL_NAMES = set() 13 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/syscall/posix_constants.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.socketcall_constants import ( 2 | SOCKET_FAMILY, SOCKET_PROTOCOL, 3 | SETSOCKOPT_LEVEL, SETSOCKOPT_OPTNAME) 4 | 5 | SYSCALL_ARG_DICT = { 6 | "lseek": { 7 | "origin": {0: "SEEK_SET", 1: "SEEK_CUR", 2: "SEEK_END"}, 8 | }, 9 | "futex": { 10 | "op": { 11 | 0: "FUTEX_WAIT", 12 | 1: "FUTEX_WAKE", 13 | 2: "FUTEX_FD", 14 | 3: "FUTEX_REQUEUE", 15 | 4: "FUTEX_CMP_REQUEUE", 16 | 5: "FUTEX_WAKE_OP", 17 | 6: "FUTEX_LOCK_PI", 18 | 7: "FUTEX_UNLOCK_PI", 19 | 8: "FUTEX_TRYLOCK_PI", 20 | }, 21 | }, 22 | "fcntl": { 23 | "cmd": { 24 | 0: "F_DUPFD", 25 | 1: "F_GETFD", 26 | 2: "F_SETFD", 27 | 3: "F_GETFL", 28 | 4: "F_SETFL", 29 | 5: "F_GETOWN", 30 | 6: "F_SETOWN", 31 | 7: "F_GETLK", 32 | 8: "F_SETLK", 33 | 9: "F_SETLKW", 34 | }, 35 | }, 36 | "ipc": { 37 | "call": { 38 | 1: "SEMOP", 39 | 2: "SEMGET", 40 | 3: "SEMCTL", 41 | 4: "SEMTIMEDOP", 42 | 11: "MSGSND", 43 | 12: "MSGRCV", 44 | 13: "MSGGET", 45 | 14: "MSGCTL", 46 | 21: "SHMAT", 47 | 22: "SHMDT", 48 | 23: "SHMGET", 49 | 24: "SHMCTL", 50 | }, 51 | }, 52 | "socket": { 53 | "domain": SOCKET_FAMILY, 54 | "protocol": SOCKET_PROTOCOL, 55 | }, 56 | "getsockopt": { 57 | "level": SETSOCKOPT_LEVEL, 58 | "optname": SETSOCKOPT_OPTNAME, 59 | }, 60 | } 61 | 62 | SYSCALL_ARG_DICT["setsockopt"] = SYSCALL_ARG_DICT["getsockopt"] 63 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/syscall/socketcall_constants.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | SOCKETCALL = { 4 | 1: "socket", 5 | 2: "bind", 6 | 3: "connect", 7 | 4: "listen", 8 | 5: "accept", 9 | 6: "getsockname", 10 | 7: "getpeername", 11 | 8: "socketpair", 12 | 9: "send", 13 | 10: "recv", 14 | 11: "sendto", 15 | 12: "recvfrom", 16 | 13: "shutdown", 17 | 14: "setsockopt", 18 | 15: "getsockopt", 19 | 16: "sendmsg", 20 | 17: "recvmsg", 21 | } 22 | 23 | SOCKET_FAMILY = { 24 | 0: "AF_UNSPEC", 25 | 1: "AF_FILE", 26 | 2: "AF_INET", 27 | 3: "AF_AX25", 28 | 4: "AF_IPX", 29 | 5: "AF_APPLETALK", 30 | 6: "AF_NETROM", 31 | 7: "AF_BRIDGE", 32 | 8: "AF_ATMPVC", 33 | 9: "AF_X25", 34 | 10: "AF_INET6", 35 | 11: "AF_ROSE", 36 | 12: "AF_DECnet", 37 | 13: "AF_NETBEUI", 38 | 14: "AF_SECURITY", 39 | 15: "AF_KEY", 40 | 16: "AF_NETLINK", 41 | 17: "AF_PACKET", 42 | 18: "AF_ASH", 43 | 19: "AF_ECONET", 44 | 20: "AF_ATMSVC", 45 | 22: "AF_SNA", 46 | 23: "AF_IRDA", 47 | 24: "AF_PPPOX", 48 | 25: "AF_WANPIPE", 49 | 31: "AF_BLUETOOTH", 50 | } 51 | 52 | SOCKET_TYPE = { 53 | 1: "SOCK_STREAM", 54 | 2: "SOCK_DGRAM", 55 | 3: "SOCK_RAW", 56 | 4: "SOCK_RDM", 57 | 5: "SOCK_SEQPACKET", 58 | 10: "SOCK_PACKET", 59 | } 60 | 61 | 62 | def formatSocketType(argument): 63 | value = argument.value 64 | text = [] 65 | if hasattr(socket, 'SOCK_CLOEXEC'): 66 | cloexec = value & socket.SOCK_CLOEXEC 67 | value &= ~socket.SOCK_CLOEXEC 68 | else: 69 | cloexec = False 70 | text = SOCKET_TYPE.get(value, str(value)) 71 | if cloexec: 72 | text += '|SOCK_CLOEXEC' 73 | return text 74 | 75 | 76 | SOCKET_PROTOCOL = { 77 | 1: "IPPROTO_ICMP", 78 | 58: "IPPROTO_ICMPV6", 79 | } 80 | 81 | SETSOCKOPT_LEVEL = { 82 | 0: "SOL_IP", 83 | 1: "SOL_SOCKET", 84 | } 85 | 86 | SETSOCKOPT_OPTNAME = { 87 | # level 0 (SOL_IP) 88 | 1: "IP_TOS", 89 | # level 1 (SOL_SOCKET) 90 | 2: "SO_REUSEADDR", 91 | 9: "SO_KEEPALIVE", 92 | 20: "SO_RCVTIMEO", 93 | 21: "SO_SNDTIMEO", 94 | } 95 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/terminal.py: -------------------------------------------------------------------------------- 1 | """ 2 | Terminal functions. 3 | """ 4 | 5 | from termios import tcgetattr, tcsetattr, ECHO, TCSADRAIN, TIOCGWINSZ 6 | from sys import stdin, stdout 7 | from fcntl import ioctl 8 | from struct import unpack 9 | import os 10 | 11 | TERMIO_LFLAGS = 3 12 | 13 | 14 | def _terminalSize(): 15 | fd = stdout.fileno() 16 | size = ioctl(fd, TIOCGWINSZ, '1234') 17 | height, width = unpack('hh', size) 18 | return (width, height) 19 | 20 | 21 | def terminalWidth(): 22 | """ 23 | Get the terminal width in characters. 24 | """ 25 | return _terminalSize()[0] 26 | 27 | 28 | def enableEchoMode(): 29 | """ 30 | Enable echo mode in the terminal. Return True if the echo mode is set 31 | correctly, or False if the mode was already set. 32 | """ 33 | fd = stdin.fileno() 34 | if not os.isatty(fd): 35 | return False 36 | state = tcgetattr(fd) 37 | if state[TERMIO_LFLAGS] & ECHO: 38 | return False 39 | state[TERMIO_LFLAGS] = state[TERMIO_LFLAGS] | ECHO 40 | tcsetattr(fd, TCSADRAIN, state) 41 | return True 42 | -------------------------------------------------------------------------------- /installCptrace/build/bdist.linux-x86_64/egg/ptrace/version.py: -------------------------------------------------------------------------------- 1 | PACKAGE = "python-ptrace" 2 | VERSION = "0.9.5" 3 | WEBSITE = "http://python-ptrace.readthedocs.io/" 4 | LICENSE = "GNU GPL v2" 5 | -------------------------------------------------------------------------------- /installCptrace/build/lib.linux-x86_64-3.7/cptrace.cpython-37m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/installCptrace/build/lib.linux-x86_64-3.7/cptrace.cpython-37m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.signames import SIGNAMES, signalName # noqa 2 | from ptrace.error import PtraceError # noqa 3 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/binding/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.binding.func import ( # noqa 2 | HAS_PTRACE_SINGLESTEP, HAS_PTRACE_EVENTS, 3 | HAS_PTRACE_IO, HAS_PTRACE_SIGINFO, HAS_PTRACE_GETREGS, 4 | REGISTER_NAMES, 5 | ptrace_attach, ptrace_traceme, 6 | ptrace_detach, ptrace_kill, 7 | ptrace_cont, ptrace_syscall, 8 | ptrace_setregs, 9 | ptrace_peektext, ptrace_poketext, 10 | ptrace_peekuser, 11 | ptrace_registers_t) 12 | if HAS_PTRACE_EVENTS: 13 | from ptrace.binding.func import (WPTRACEEVENT, # noqa 14 | PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK, PTRACE_EVENT_CLONE, 15 | PTRACE_EVENT_EXEC, 16 | ptrace_setoptions, ptrace_geteventmsg) 17 | if HAS_PTRACE_SINGLESTEP: 18 | from ptrace.binding.func import ptrace_singlestep # noqa 19 | if HAS_PTRACE_SIGINFO: 20 | from ptrace.binding.func import ptrace_getsiginfo # noqa 21 | if HAS_PTRACE_IO: 22 | from ptrace.binding.func import ptrace_io # noqa 23 | from ptrace.binding.freebsd_struct import ( # noqa 24 | ptrace_io_desc, 25 | PIOD_READ_D, PIOD_WRITE_D, 26 | PIOD_READ_I, PIOD_WRITE_I) 27 | if HAS_PTRACE_GETREGS: 28 | from ptrace.binding.func import ptrace_getregs # noqa 29 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/binding/cpu.py: -------------------------------------------------------------------------------- 1 | from ptrace.cpu_info import ( 2 | CPU_POWERPC, CPU_INTEL, CPU_X86_64, CPU_I386, CPU_ARM) 3 | 4 | CPU_INSTR_POINTER = None 5 | CPU_STACK_POINTER = None 6 | CPU_FRAME_POINTER = None 7 | CPU_SUB_REGISTERS = {} 8 | 9 | if CPU_POWERPC: 10 | CPU_INSTR_POINTER = "nip" 11 | # FIXME: Is it the right register? 12 | CPU_STACK_POINTER = 'gpr1' 13 | elif CPU_ARM: 14 | CPU_INSTR_POINTER = 'r15' 15 | CPU_STACK_POINTER = 'r14' 16 | CPU_FRAME_POINTER = 'r11' 17 | elif CPU_X86_64: 18 | CPU_INSTR_POINTER = "rip" 19 | CPU_STACK_POINTER = "rsp" 20 | CPU_FRAME_POINTER = "rbp" 21 | CPU_SUB_REGISTERS = { 22 | # main register name, shift, mask 23 | 'al': ('rax', 0, 0xff), 24 | 'bl': ('rbx', 0, 0xff), 25 | 'cl': ('rcx', 0, 0xff), 26 | 'dl': ('rdx', 0, 0xff), 27 | 'ah': ('rax', 8, 0xff), 28 | 'bh': ('rbx', 8, 0xff), 29 | 'ch': ('rcx', 8, 0xff), 30 | 'dh': ('rdx', 8, 0xff), 31 | 'ax': ('rax', 0, 0xffff), 32 | 'bx': ('rbx', 0, 0xffff), 33 | 'cx': ('rcx', 0, 0xffff), 34 | 'dx': ('rdx', 0, 0xffff), 35 | 'eax': ('rax', 32, None), 36 | 'ebx': ('rbx', 32, None), 37 | 'ecx': ('rcx', 32, None), 38 | 'edx': ('rdx', 32, None), 39 | } 40 | elif CPU_I386: 41 | CPU_INSTR_POINTER = "eip" 42 | CPU_STACK_POINTER = "esp" 43 | CPU_FRAME_POINTER = "ebp" 44 | CPU_SUB_REGISTERS = { 45 | 'al': ('eax', 0, 0xff), 46 | 'bl': ('ebx', 0, 0xff), 47 | 'cl': ('ecx', 0, 0xff), 48 | 'dl': ('edx', 0, 0xff), 49 | 'ah': ('eax', 8, 0xff), 50 | 'bh': ('ebx', 8, 0xff), 51 | 'ch': ('ecx', 8, 0xff), 52 | 'dh': ('edx', 8, 0xff), 53 | 'ax': ('eax', 0, 0xffff), 54 | 'bx': ('ebx', 0, 0xffff), 55 | 'cx': ('ecx', 0, 0xffff), 56 | 'dx': ('edx', 0, 0xffff), 57 | } 58 | 59 | if CPU_INTEL: 60 | CPU_SUB_REGISTERS.update({ 61 | 'cf': ('eflags', 0, 1), 62 | 'pf': ('eflags', 2, 1), 63 | 'af': ('eflags', 4, 1), 64 | 'zf': ('eflags', 6, 1), 65 | 'sf': ('eflags', 7, 1), 66 | 'tf': ('eflags', 8, 1), 67 | 'if': ('eflags', 9, 1), 68 | 'df': ('eflags', 10, 1), 69 | 'of': ('eflags', 11, 1), 70 | 'iopl': ('eflags', 12, 2), 71 | }) 72 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/binding/freebsd_struct.py: -------------------------------------------------------------------------------- 1 | from ctypes import (Structure, 2 | c_int, c_uint, c_ulong, c_void_p, 3 | c_uint16, c_uint32, c_size_t) 4 | from ptrace.cpu_info import CPU_X86_64 5 | 6 | PIOD_READ_D = 1 7 | PIOD_WRITE_D = 2 8 | PIOD_READ_I = 3 9 | PIOD_WRITE_I = 4 10 | 11 | # /usr/include/machine/reg.h 12 | if CPU_X86_64: 13 | register_t = c_ulong 14 | 15 | class reg(Structure): 16 | _fields_ = ( 17 | ("r15", register_t), 18 | ("r14", register_t), 19 | ("r13", register_t), 20 | ("r12", register_t), 21 | ("r11", register_t), 22 | ("r10", register_t), 23 | ("r9", register_t), 24 | ("r8", register_t), 25 | ("rdi", register_t), 26 | ("rsi", register_t), 27 | ("rbp", register_t), 28 | ("rbx", register_t), 29 | ("rdx", register_t), 30 | ("rcx", register_t), 31 | ("rax", register_t), 32 | ("trapno", c_uint32), 33 | ("fs", c_uint16), 34 | ("gs", c_uint16), 35 | ("err", c_uint32), 36 | ("es", c_uint16), 37 | ("ds", c_uint16), 38 | ("rip", register_t), 39 | ("cs", register_t), 40 | ("rflags", register_t), 41 | ("rsp", register_t), 42 | ("ss", register_t), 43 | ) 44 | else: 45 | class reg(Structure): 46 | _fields_ = ( 47 | ("fs", c_uint), 48 | ("es", c_uint), 49 | ("ds", c_uint), 50 | ("edi", c_uint), 51 | ("esi", c_uint), 52 | ("ebp", c_uint), 53 | ("isp", c_uint), 54 | ("ebx", c_uint), 55 | ("edx", c_uint), 56 | ("ecx", c_uint), 57 | ("eax", c_uint), 58 | ("trapno", c_uint), 59 | ("err", c_uint), 60 | ("eip", c_uint), 61 | ("cs", c_uint), 62 | ("eflags", c_uint), 63 | ("esp", c_uint), 64 | ("ss", c_uint), 65 | ("gs", c_uint), 66 | ) 67 | 68 | 69 | class ptrace_io_desc(Structure): 70 | _fields_ = ( 71 | ("piod_op", c_int), 72 | ("piod_offs", c_void_p), 73 | ("piod_addr", c_void_p), 74 | ("piod_len", c_size_t), 75 | ) 76 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/binding/openbsd_struct.py: -------------------------------------------------------------------------------- 1 | from ctypes import Structure, c_int, c_uint, c_ulong, c_void_p, c_char 2 | 3 | PIOD_READ_D = 1 4 | PIOD_WRITE_D = 2 5 | PIOD_READ_I = 3 6 | PIOD_WRITE_I = 4 7 | 8 | size_t = c_ulong 9 | pid_t = c_int 10 | 11 | # /usr/include/machine/reg.h 12 | 13 | 14 | class reg(Structure): 15 | _fields_ = ( 16 | ("eax", c_uint), 17 | ("ecx", c_uint), 18 | ("edx", c_uint), 19 | ("ebx", c_uint), 20 | ("esp", c_uint), 21 | ("ebp", c_uint), 22 | ("esi", c_uint), 23 | ("edi", c_uint), 24 | ("eip", c_uint), 25 | ("eflags", c_uint), 26 | ("cs", c_uint), 27 | ("ss", c_uint), 28 | ("ds", c_uint), 29 | ("es", c_uint), 30 | ("fs", c_uint), 31 | ("gs", c_uint), 32 | ) 33 | 34 | 35 | class fpreg(Structure): 36 | _fields_ = ( 37 | ("__data", c_char * 116), 38 | ) 39 | 40 | 41 | class ptrace_io_desc(Structure): 42 | _fields_ = ( 43 | ("piod_op", c_int), 44 | ("piod_offs", c_void_p), 45 | ("piod_addr", c_void_p), 46 | ("piod_len", size_t), 47 | ) 48 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/cpu_info.py: -------------------------------------------------------------------------------- 1 | """ 2 | Constants about the CPU: 3 | 4 | - CPU_BIGENDIAN (bool) 5 | - CPU_64BITS (bool) 6 | - CPU_WORD_SIZE (int) 7 | - CPU_MAX_UINT (int) 8 | - CPU_PPC32 (bool) 9 | - CPU_PPC64 (bool) 10 | - CPU_I386 (bool) 11 | - CPU_X86_64 (bool) 12 | - CPU_INTEL (bool) 13 | - CPU_POWERPC (bool) 14 | """ 15 | 16 | try: 17 | from os import uname 18 | HAS_UNAME = True 19 | except ImportError: 20 | HAS_UNAME = False 21 | from platform import architecture 22 | from sys import byteorder 23 | from ctypes import sizeof, c_void_p 24 | 25 | CPU_BIGENDIAN = (byteorder == 'big') 26 | CPU_64BITS = (sizeof(c_void_p) == 8) 27 | 28 | if CPU_64BITS: 29 | CPU_WORD_SIZE = 8 # bytes 30 | CPU_MAX_UINT = 0xffffffffffffffff 31 | else: 32 | CPU_WORD_SIZE = 4 # bytes 33 | CPU_MAX_UINT = 0xffffffff 34 | 35 | if HAS_UNAME: 36 | # guess machine type using uname() 37 | _machine = uname()[4] 38 | CPU_PPC32 = (_machine == 'ppc') 39 | CPU_PPC64 = (_machine == 'ppc64') 40 | CPU_I386 = (_machine in ("i386", "i686")) # compatible Intel 32 bits 41 | CPU_X86_64 = (_machine in ("x86_64", "amd64")) # compatible Intel 64 bits 42 | CPU_ARM = _machine.startswith('arm') 43 | del _machine 44 | else: 45 | # uname() fallback for Windows 46 | # I hope that your Windows doesn't run on PPC32/PPC64 47 | CPU_PPC32 = False 48 | CPU_PPC64 = False 49 | CPU_I386 = False 50 | CPU_X86_64 = False 51 | CPU_ARM = False 52 | bits, linkage = architecture() 53 | if bits == '32bit': 54 | CPU_I386 = True 55 | elif bits == '64bit': 56 | CPU_X86_64 = True 57 | else: 58 | raise ValueError("Unknown architecture bits: %r" % bits) 59 | 60 | CPU_INTEL = (CPU_I386 or CPU_X86_64) 61 | CPU_POWERPC = (CPU_PPC32 or CPU_PPC64) 62 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/ctypes_libc.py: -------------------------------------------------------------------------------- 1 | """ 2 | Load the system C library. Variables: 3 | - LIBC_FILENAME: the C library filename 4 | - libc: the loaded library 5 | """ 6 | 7 | from ctypes import CDLL 8 | from ctypes.util import find_library 9 | 10 | LIBC_FILENAME = find_library('c') 11 | libc = CDLL(LIBC_FILENAME, use_errno=True) 12 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/debugger/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.debugger.breakpoint import Breakpoint # noqa 2 | from ptrace.debugger.process_event import (ProcessEvent, ProcessExit, # noqa 3 | NewProcessEvent, ProcessExecution) 4 | from ptrace.debugger.ptrace_signal import ProcessSignal # noqa 5 | from ptrace.debugger.process_error import ProcessError # noqa 6 | from ptrace.debugger.child import ChildError # noqa 7 | from ptrace.debugger.process import PtraceProcess # noqa 8 | from ptrace.debugger.debugger import PtraceDebugger, DebuggerError # noqa 9 | from ptrace.debugger.application import Application # noqa 10 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/debugger/breakpoint.py: -------------------------------------------------------------------------------- 1 | from ptrace.ctypes_tools import formatAddress 2 | from ptrace import PtraceError 3 | from logging2 import info 4 | from weakref import ref 5 | from ptrace.cpu_info import CPU_POWERPC, CPU_WORD_SIZE 6 | from ptrace.ctypes_tools import word2bytes 7 | from six import b 8 | 9 | 10 | class Breakpoint(object): 11 | """ 12 | Software breakpoint. 13 | 14 | Use desinstall() method to remove the breakpoint from the process. 15 | """ 16 | 17 | def __init__(self, process, address, size=None): 18 | self._installed = False 19 | self.process = ref(process) 20 | self.address = address 21 | if CPU_POWERPC: 22 | size = CPU_WORD_SIZE 23 | elif size is None: 24 | size = 1 25 | self.size = size 26 | 27 | # Store instruction bytes 28 | info("Install %s" % self) 29 | self.old_bytes = process.readBytes(address, size) 30 | 31 | if CPU_POWERPC: 32 | # Replace instruction with "TRAP" 33 | new_bytes = word2bytes(0x0cc00000) 34 | else: 35 | # Replace instruction with "INT 3" 36 | new_bytes = b("\xCC") * size 37 | process.writeBytes(address, new_bytes) 38 | self._installed = True 39 | 40 | def desinstall(self, set_ip=False): 41 | """ 42 | Remove the breakpoint from the associated process. If set_ip is True, 43 | restore the instruction pointer to the address of the breakpoint. 44 | """ 45 | if not self._installed: 46 | return 47 | self._installed = False 48 | info("Desinstall %s" % self) 49 | process = self.process() 50 | if not process: 51 | return 52 | if process.running: 53 | process.writeBytes(self.address, self.old_bytes) 54 | if set_ip: 55 | process.setInstrPointer(self.address) 56 | process.removeBreakpoint(self) 57 | 58 | def __str__(self): 59 | return "" % ( 60 | formatAddress(self.address), 61 | formatAddress(self.address + self.size - 1)) 62 | 63 | def __del__(self): 64 | try: 65 | self.desinstall(False) 66 | except PtraceError: 67 | pass 68 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/debugger/process_error.py: -------------------------------------------------------------------------------- 1 | from ptrace.error import PtraceError 2 | 3 | 4 | class ProcessError(PtraceError): 5 | 6 | def __init__(self, process, message): 7 | PtraceError.__init__(self, message, pid=process.pid) 8 | self.process = process 9 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/debugger/process_event.py: -------------------------------------------------------------------------------- 1 | from ptrace.signames import signalName 2 | 3 | 4 | class ProcessEvent(Exception): 5 | """ 6 | A process event: program exit, program killed by a signal, program 7 | received a signal, etc. 8 | 9 | The attribute "process" contains the related process. 10 | """ 11 | 12 | def __init__(self, process, message): 13 | Exception.__init__(self, message) 14 | self.process = process 15 | 16 | 17 | class ProcessExit(ProcessEvent): 18 | """ 19 | Process exit event: 20 | - process kill by a signal (if signum attribute is not None) 21 | - process exited with a code (if exitcode attribute is not None) 22 | - process terminated abnormally (otherwise) 23 | """ 24 | 25 | def __init__(self, process, signum=None, exitcode=None): 26 | pid = process.pid 27 | if signum: 28 | message = "Process %s killed by signal %s" % ( 29 | pid, signalName(signum)) 30 | elif exitcode is not None: 31 | if not exitcode: 32 | message = "Process %s exited normally" % pid 33 | else: 34 | message = "Process %s exited with code %s" % (pid, exitcode) 35 | else: 36 | message = "Process %s terminated abnormally" % pid 37 | ProcessEvent.__init__(self, process, message) 38 | self.signum = signum 39 | self.exitcode = exitcode 40 | 41 | 42 | class ProcessExecution(ProcessEvent): 43 | """ 44 | Process execution: event send just after the process calls the exec() 45 | syscall if exec() tracing option is enabled. 46 | """ 47 | 48 | def __init__(self, process): 49 | ProcessEvent.__init__( 50 | self, process, "Process %s execution" % process.pid) 51 | 52 | 53 | class NewProcessEvent(ProcessEvent): 54 | """ 55 | New process: event send when a process calls the fork() syscall if fork() 56 | tracing option is enabled. The attribute process contains the new child 57 | process. 58 | """ 59 | 60 | def __init__(self, process): 61 | ProcessEvent.__init__(self, process, "New process %s" % process.pid) 62 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/debugger/syscall_state.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall import PtraceSyscall 2 | from signal import SIGTRAP 3 | 4 | 5 | class SyscallState(object): 6 | 7 | def __init__(self, process): 8 | self.process = process 9 | self.ignore_exec_trap = True 10 | self.ignore_callback = None 11 | self.clear() 12 | 13 | def event(self, options): 14 | if self.next_event == "exit": 15 | return self.exit() 16 | else: 17 | return self.enter(options) 18 | 19 | def enter(self, options): 20 | # syscall enter 21 | regs = self.process.getregs() 22 | self.syscall = PtraceSyscall(self.process, options, regs) 23 | self.name = self.syscall.name 24 | if (not self.ignore_callback) \ 25 | or (not self.ignore_callback(self.syscall)): 26 | self.syscall.enter(regs) 27 | else: 28 | self.syscall = None 29 | self.next_event = "exit" 30 | return self.syscall 31 | 32 | def exit(self): 33 | if self.syscall: 34 | self.syscall.exit() 35 | if self.ignore_exec_trap \ 36 | and self.name == "execve" \ 37 | and not self.process.debugger.trace_exec: 38 | # Ignore the SIGTRAP after exec() syscall exit 39 | self.process.syscall() 40 | self.process.waitSignals(SIGTRAP) 41 | syscall = self.syscall 42 | self.clear() 43 | return syscall 44 | 45 | def clear(self): 46 | self.syscall = None 47 | self.name = None 48 | self.next_event = "enter" 49 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/error.py: -------------------------------------------------------------------------------- 1 | from sys import exc_info 2 | from traceback import format_exception 3 | from logging2 import ERROR, getLogger 4 | from ptrace.logging_tools import getLogFunc, changeLogLevel 5 | 6 | PTRACE_ERRORS = Exception 7 | 8 | 9 | def writeBacktrace(logger, log_level=ERROR): 10 | """ 11 | Write a backtrace into the logger with the specified log level. 12 | """ 13 | log_func = getLogFunc(logger, log_level) 14 | try: 15 | info = exc_info() 16 | trace = format_exception(*info) 17 | if trace[0] != "None\n": 18 | trace = ''.join(trace).rstrip() 19 | for line in trace.split("\n"): 20 | log_func(line.rstrip()) 21 | return 22 | except Exception: 23 | pass 24 | log_func("Unable to get backtrace") 25 | 26 | 27 | def formatError(error): 28 | """ 29 | Format an error as a string. Write the error type as prefix. 30 | Eg. "[ValueError] invalid value". 31 | """ 32 | return "[%s] %s" % (error.__class__.__name__, error) 33 | 34 | 35 | def writeError(logger, error, title="ERROR", log_level=ERROR): 36 | """ 37 | Write an error into the logger: 38 | - logger: the logger (if None, use getLogger()) 39 | - error: the exception object 40 | - title: error message prefix (e.g. title="Initialization error") 41 | - log_level: log level of the error 42 | 43 | If the exception is a SystemExit or a KeyboardInterrupt, re-emit 44 | (raise) the exception and don't write it. 45 | """ 46 | if not logger: 47 | logger = getLogger() 48 | if error.__class__ in (SystemExit, KeyboardInterrupt): 49 | raise error 50 | log_func = getLogFunc(logger, log_level) 51 | log_func("%s: %s" % (title, formatError(error))) 52 | writeBacktrace(logger, log_level=changeLogLevel(log_level, -1)) 53 | 54 | 55 | class PtraceError(Exception): 56 | """ 57 | Ptrace error: have the optional attributes errno and pid. 58 | """ 59 | 60 | def __init__(self, message, errno=None, pid=None): 61 | Exception.__init__(self, message) 62 | self.errno = errno 63 | self.pid = pid 64 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/logging_tools.py: -------------------------------------------------------------------------------- 1 | from ptrace.tools import minmax 2 | from logging2 import ERROR, WARNING, INFO, DEBUG 3 | 4 | 5 | def getLogFunc(logger, level): 6 | """ 7 | Get the logger function for the specified logging level. 8 | """ 9 | if level == ERROR: 10 | return logger.error 11 | elif level == WARNING: 12 | return logger.warning 13 | elif level == INFO: 14 | return logger.info 15 | elif level == DEBUG: 16 | return logger.debug 17 | else: 18 | return logger.error 19 | 20 | 21 | def changeLogLevel(level, delta): 22 | """ 23 | Compute log level and make sure that the result is in DEBUG..ERROR. 24 | 25 | >>> changeLogLevel(ERROR, -1) == WARNING 26 | True 27 | >>> changeLogLevel(DEBUG, 1) == INFO 28 | True 29 | """ 30 | return minmax(DEBUG, level + delta * 10, ERROR) 31 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/mockup.py: -------------------------------------------------------------------------------- 1 | """ 2 | Mockup classes used in unit tests. 3 | """ 4 | 5 | 6 | class FakeProcess(object): 7 | 8 | def __init__(self): 9 | self.regs = {} 10 | 11 | def setreg(self, name, value): 12 | self.regs[name] = value 13 | 14 | def getreg(self, name): 15 | return self.regs[name] 16 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/os_tools.py: -------------------------------------------------------------------------------- 1 | """ 2 | Constants about the operating system: 3 | 4 | - RUNNING_PYPY (bool) 5 | - RUNNING_WINDOWS (bool) 6 | - RUNNING_LINUX (bool) 7 | - RUNNING_FREEBSD (bool) 8 | - RUNNING_OPENBSD (bool) 9 | - RUNNING_MACOSX (bool) 10 | - RUNNING_BSD (bool) 11 | - HAS_PROC (bool) 12 | - HAS_PTRACE (bool) 13 | """ 14 | 15 | from sys import platform, version, version_info 16 | 17 | RUNNING_PYTHON3 = version_info[0] == 3 18 | RUNNING_PYPY = ("pypy" in version.lower()) 19 | RUNNING_WINDOWS = (platform == 'win32') 20 | RUNNING_LINUX = platform.startswith('linux') 21 | RUNNING_FREEBSD = (platform.startswith('freebsd') 22 | or platform.startswith('gnukfreebsd')) 23 | RUNNING_OPENBSD = platform.startswith('openbsd') 24 | RUNNING_MACOSX = (platform == 'darwin') 25 | RUNNING_BSD = RUNNING_FREEBSD or RUNNING_MACOSX or RUNNING_OPENBSD 26 | 27 | HAS_PROC = RUNNING_LINUX 28 | HAS_PTRACE = (RUNNING_BSD or RUNNING_LINUX) 29 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/profiler.py: -------------------------------------------------------------------------------- 1 | from hotshot import Profile 2 | from hotshot.stats import load as loadStats 3 | from os import unlink 4 | from io import StringIO 5 | 6 | 7 | def runProfiler(logger, func, args=tuple(), kw={}, 8 | verbose=True, nb_func=25, 9 | sort_by=('time',)): 10 | """ 11 | Run a function in a profiler and then display the functions sorted by time. 12 | """ 13 | profile_filename = "/tmp/profiler" 14 | prof = Profile(profile_filename) 15 | try: 16 | logger.warning("Run profiler") 17 | result = prof.runcall(func, *args, **kw) 18 | prof.close() 19 | logger.error("Profiler: Process data...") 20 | stat = loadStats(profile_filename) 21 | stat.strip_dirs() 22 | stat.sort_stats(*sort_by) 23 | 24 | logger.error("Profiler: Result:") 25 | log = StringIO() 26 | stat.stream = log 27 | stat.print_stats(nb_func) 28 | log.seek(0) 29 | for line in log: 30 | logger.error(line.rstrip()) 31 | return result 32 | finally: 33 | unlink(profile_filename) 34 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/signames.py: -------------------------------------------------------------------------------- 1 | """ 2 | Name of process signals. 3 | 4 | SIGNAMES contains a dictionary mapping a signal number to it's name. But you 5 | should better use signalName() instead of SIGNAMES since it returns a string 6 | even if the signal is unknown. 7 | """ 8 | 9 | PREFERRED_NAMES = ("SIGABRT", "SIGHUP", "SIGCHLD", "SIGPOLL") 10 | 11 | 12 | def getSignalNames(): 13 | """ 14 | Create signal names dictionary (e.g. 9 => 'SIGKILL') using dir(signal). 15 | If multiple signal names have the same number, use the first matching name 16 | in PREFERRED_NAME to select preferred name (e.g. SIGIOT=SIGABRT=17). 17 | """ 18 | import signal 19 | allnames = {} 20 | for name in dir(signal): 21 | if not name.startswith("SIG"): 22 | continue 23 | signum = getattr(signal, name) 24 | try: 25 | allnames[signum].append(name) 26 | except KeyError: 27 | allnames[signum] = [name] 28 | signames = {} 29 | for signum, names in allnames.items(): 30 | if not signum: 31 | # Skip signal 0 32 | continue 33 | name = None 34 | for preferred in PREFERRED_NAMES: 35 | if preferred in names: 36 | name = preferred 37 | break 38 | if not name: 39 | name = names[0] 40 | signames[signum] = name 41 | return signames 42 | 43 | 44 | SIGNAMES = getSignalNames() 45 | 46 | 47 | def signalName(signum): 48 | """ 49 | Get the name of a signal 50 | 51 | >>> from signal import SIGINT 52 | >>> signalName(SIGINT) 53 | 'SIGINT' 54 | >>> signalName(404) 55 | 'signal<404>' 56 | """ 57 | try: 58 | return SIGNAMES[signum] 59 | except KeyError: 60 | return "signal<%s>" % signum 61 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/syscall/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.names import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES # noqa 2 | from ptrace.syscall.prototypes import SYSCALL_PROTOTYPES, FILENAME_ARGUMENTS, DIRFD_ARGUMENTS # noqa 3 | from ptrace.syscall.syscall_argument import SyscallArgument # noqa 4 | from ptrace.syscall.ptrace_syscall import PtraceSyscall, SYSCALL_REGISTER, RETURN_VALUE_REGISTER # noqa 5 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/syscall/freebsd_constants.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.posix_constants import SYSCALL_ARG_DICT 2 | 3 | RLIMIT_RESOURCE = { 4 | 0: "RLIMIT_CPU", 5 | 1: "RLIMIT_FSIZE", 6 | 2: "RLIMIT_DATA", 7 | 3: "RLIMIT_STACK", 8 | 4: "RLIMIT_CORE", 9 | 5: "RLIMIT_RSS", 10 | 6: "RLIMIT_MEMLOCK", 11 | 7: "RLIMIT_NPROC", 12 | 8: "RLIMIT_NOFILE", 13 | 9: "RLIMIT_SBSIZE", 14 | 10: "RLIMIT_VMEM", 15 | } 16 | 17 | SIGPROCMASK_HOW = {1: " SIG_BLOCK", 2: "SIG_UNBLOCK", 3: "SIG_SETMASK"} 18 | 19 | SYSCALL_ARG_DICT.update({ 20 | "getrlimit": {"resource": RLIMIT_RESOURCE}, 21 | "setrlimit": {"resource": RLIMIT_RESOURCE}, 22 | "sigprocmask": {"how": SIGPROCMASK_HOW}, 23 | "rt_sigprocmask": {"how": SIGPROCMASK_HOW}, 24 | }) 25 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/syscall/linux_constants.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.posix_constants import SYSCALL_ARG_DICT 2 | 3 | SIGSET_SIZE = 64 4 | FD_SETSIZE = 1024 5 | 6 | RLIMIT_RESOURCE = { 7 | 0: "RLIMIT_CPU", 8 | 1: "RLIMIT_FSIZE", 9 | 2: "RLIMIT_DATA", 10 | 3: "RLIMIT_STACK", 11 | 4: "RLIMIT_CORE", 12 | 5: "RLIMIT_RSS", 13 | 6: "RLIMIT_NPROC", 14 | 7: "RLIMIT_NOFILE", 15 | 8: "RLIMIT_MEMLOCK", 16 | 9: "RLIMIT_AS", 17 | 10: "RLIMIT_LOCKS", 18 | 11: "RLIMIT_SIGPENDING", 19 | 12: "RLIMIT_MSGQUEUE", 20 | 13: "RLIMIT_NICE", 21 | 14: "RLIMIT_RTPRIO", 22 | 15: "RLIMIT_NLIMITS", 23 | } 24 | 25 | SIGPROCMASK_HOW = {0: "SIG_BLOCK", 1: "SIG_UNBLOCK", 2: "SIG_SETMASK"} 26 | 27 | SYSCALL_ARG_DICT.update({ 28 | "getrlimit": {"resource": RLIMIT_RESOURCE}, 29 | "setrlimit": {"resource": RLIMIT_RESOURCE}, 30 | "sigprocmask": {"how": SIGPROCMASK_HOW}, 31 | "rt_sigprocmask": {"how": SIGPROCMASK_HOW}, 32 | }) 33 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/syscall/linux_struct.py: -------------------------------------------------------------------------------- 1 | from ctypes import (Structure, 2 | c_char, c_short, c_int, c_uint, c_long, c_ulong) 3 | 4 | time_t = c_long 5 | suseconds_t = c_long 6 | rlim_t = c_long 7 | 8 | 9 | class timeval(Structure): 10 | _fields_ = ( 11 | ("tv_sec", time_t), 12 | ("tv_usec", suseconds_t), 13 | ) 14 | 15 | 16 | class timespec(Structure): 17 | _fields_ = ( 18 | ("tv_sec", time_t), 19 | ("tv_nsec", c_long), 20 | ) 21 | 22 | 23 | class pollfd(Structure): 24 | _fields_ = ( 25 | ("fd", c_int), 26 | ("events", c_short), 27 | ("revents", c_short), 28 | ) 29 | 30 | 31 | class rlimit(Structure): 32 | _fields_ = ( 33 | ("rlim_cur", rlim_t), 34 | ("rlim_max", rlim_t), 35 | ) 36 | 37 | 38 | class new_utsname(Structure): 39 | _fields_ = ( 40 | ("sysname", c_char * 65), 41 | ("nodename", c_char * 65), 42 | ("release", c_char * 65), 43 | ("version", c_char * 65), 44 | ("machine", c_char * 65), 45 | ("domainname", c_char * 65), 46 | ) 47 | 48 | # Arch depend 49 | 50 | 51 | class user_desc(Structure): 52 | _fields_ = ( 53 | ("entry_number", c_uint), 54 | ("base_addr", c_ulong), 55 | ("limit", c_uint), 56 | ("_bits_", c_char), 57 | # unsigned int seg_32bit:1; 58 | # unsigned int contents:2; 59 | # unsigned int read_exec_only:1; 60 | # unsigned int limit_in_pages:1; 61 | # unsigned int seg_not_present:1; 62 | # unsigned int useable:1; 63 | ) 64 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/syscall/names.py: -------------------------------------------------------------------------------- 1 | from ptrace.cpu_info import CPU_64BITS 2 | from ptrace.os_tools import RUNNING_LINUX, RUNNING_FREEBSD 3 | if RUNNING_LINUX: 4 | if CPU_64BITS: 5 | from ptrace.syscall.linux_syscall64 import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES 6 | else: 7 | from ptrace.syscall.linux_syscall32 import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES 8 | elif RUNNING_FREEBSD: 9 | from ptrace.syscall.freebsd_syscall import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES 10 | else: 11 | SYSCALL_NAMES = {} 12 | SOCKET_SYSCALL_NAMES = set() 13 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/syscall/posix_constants.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.socketcall_constants import ( 2 | SOCKET_FAMILY, SOCKET_PROTOCOL, 3 | SETSOCKOPT_LEVEL, SETSOCKOPT_OPTNAME) 4 | 5 | SYSCALL_ARG_DICT = { 6 | "lseek": { 7 | "origin": {0: "SEEK_SET", 1: "SEEK_CUR", 2: "SEEK_END"}, 8 | }, 9 | "futex": { 10 | "op": { 11 | 0: "FUTEX_WAIT", 12 | 1: "FUTEX_WAKE", 13 | 2: "FUTEX_FD", 14 | 3: "FUTEX_REQUEUE", 15 | 4: "FUTEX_CMP_REQUEUE", 16 | 5: "FUTEX_WAKE_OP", 17 | 6: "FUTEX_LOCK_PI", 18 | 7: "FUTEX_UNLOCK_PI", 19 | 8: "FUTEX_TRYLOCK_PI", 20 | }, 21 | }, 22 | "fcntl": { 23 | "cmd": { 24 | 0: "F_DUPFD", 25 | 1: "F_GETFD", 26 | 2: "F_SETFD", 27 | 3: "F_GETFL", 28 | 4: "F_SETFL", 29 | 5: "F_GETOWN", 30 | 6: "F_SETOWN", 31 | 7: "F_GETLK", 32 | 8: "F_SETLK", 33 | 9: "F_SETLKW", 34 | }, 35 | }, 36 | "ipc": { 37 | "call": { 38 | 1: "SEMOP", 39 | 2: "SEMGET", 40 | 3: "SEMCTL", 41 | 4: "SEMTIMEDOP", 42 | 11: "MSGSND", 43 | 12: "MSGRCV", 44 | 13: "MSGGET", 45 | 14: "MSGCTL", 46 | 21: "SHMAT", 47 | 22: "SHMDT", 48 | 23: "SHMGET", 49 | 24: "SHMCTL", 50 | }, 51 | }, 52 | "socket": { 53 | "domain": SOCKET_FAMILY, 54 | "protocol": SOCKET_PROTOCOL, 55 | }, 56 | "getsockopt": { 57 | "level": SETSOCKOPT_LEVEL, 58 | "optname": SETSOCKOPT_OPTNAME, 59 | }, 60 | } 61 | 62 | SYSCALL_ARG_DICT["setsockopt"] = SYSCALL_ARG_DICT["getsockopt"] 63 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/syscall/socketcall_constants.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | SOCKETCALL = { 4 | 1: "socket", 5 | 2: "bind", 6 | 3: "connect", 7 | 4: "listen", 8 | 5: "accept", 9 | 6: "getsockname", 10 | 7: "getpeername", 11 | 8: "socketpair", 12 | 9: "send", 13 | 10: "recv", 14 | 11: "sendto", 15 | 12: "recvfrom", 16 | 13: "shutdown", 17 | 14: "setsockopt", 18 | 15: "getsockopt", 19 | 16: "sendmsg", 20 | 17: "recvmsg", 21 | } 22 | 23 | SOCKET_FAMILY = { 24 | 0: "AF_UNSPEC", 25 | 1: "AF_FILE", 26 | 2: "AF_INET", 27 | 3: "AF_AX25", 28 | 4: "AF_IPX", 29 | 5: "AF_APPLETALK", 30 | 6: "AF_NETROM", 31 | 7: "AF_BRIDGE", 32 | 8: "AF_ATMPVC", 33 | 9: "AF_X25", 34 | 10: "AF_INET6", 35 | 11: "AF_ROSE", 36 | 12: "AF_DECnet", 37 | 13: "AF_NETBEUI", 38 | 14: "AF_SECURITY", 39 | 15: "AF_KEY", 40 | 16: "AF_NETLINK", 41 | 17: "AF_PACKET", 42 | 18: "AF_ASH", 43 | 19: "AF_ECONET", 44 | 20: "AF_ATMSVC", 45 | 22: "AF_SNA", 46 | 23: "AF_IRDA", 47 | 24: "AF_PPPOX", 48 | 25: "AF_WANPIPE", 49 | 31: "AF_BLUETOOTH", 50 | } 51 | 52 | SOCKET_TYPE = { 53 | 1: "SOCK_STREAM", 54 | 2: "SOCK_DGRAM", 55 | 3: "SOCK_RAW", 56 | 4: "SOCK_RDM", 57 | 5: "SOCK_SEQPACKET", 58 | 10: "SOCK_PACKET", 59 | } 60 | 61 | 62 | def formatSocketType(argument): 63 | value = argument.value 64 | text = [] 65 | if hasattr(socket, 'SOCK_CLOEXEC'): 66 | cloexec = value & socket.SOCK_CLOEXEC 67 | value &= ~socket.SOCK_CLOEXEC 68 | else: 69 | cloexec = False 70 | text = SOCKET_TYPE.get(value, str(value)) 71 | if cloexec: 72 | text += '|SOCK_CLOEXEC' 73 | return text 74 | 75 | 76 | SOCKET_PROTOCOL = { 77 | 1: "IPPROTO_ICMP", 78 | 58: "IPPROTO_ICMPV6", 79 | } 80 | 81 | SETSOCKOPT_LEVEL = { 82 | 0: "SOL_IP", 83 | 1: "SOL_SOCKET", 84 | } 85 | 86 | SETSOCKOPT_OPTNAME = { 87 | # level 0 (SOL_IP) 88 | 1: "IP_TOS", 89 | # level 1 (SOL_SOCKET) 90 | 2: "SO_REUSEADDR", 91 | 9: "SO_KEEPALIVE", 92 | 20: "SO_RCVTIMEO", 93 | 21: "SO_SNDTIMEO", 94 | } 95 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/terminal.py: -------------------------------------------------------------------------------- 1 | """ 2 | Terminal functions. 3 | """ 4 | 5 | from termios import tcgetattr, tcsetattr, ECHO, TCSADRAIN, TIOCGWINSZ 6 | from sys import stdin, stdout 7 | from fcntl import ioctl 8 | from struct import unpack 9 | import os 10 | 11 | TERMIO_LFLAGS = 3 12 | 13 | 14 | def _terminalSize(): 15 | fd = stdout.fileno() 16 | size = ioctl(fd, TIOCGWINSZ, '1234') 17 | height, width = unpack('hh', size) 18 | return (width, height) 19 | 20 | 21 | def terminalWidth(): 22 | """ 23 | Get the terminal width in characters. 24 | """ 25 | return _terminalSize()[0] 26 | 27 | 28 | def enableEchoMode(): 29 | """ 30 | Enable echo mode in the terminal. Return True if the echo mode is set 31 | correctly, or False if the mode was already set. 32 | """ 33 | fd = stdin.fileno() 34 | if not os.isatty(fd): 35 | return False 36 | state = tcgetattr(fd) 37 | if state[TERMIO_LFLAGS] & ECHO: 38 | return False 39 | state[TERMIO_LFLAGS] = state[TERMIO_LFLAGS] | ECHO 40 | tcsetattr(fd, TCSADRAIN, state) 41 | return True 42 | -------------------------------------------------------------------------------- /installCptrace/build/lib/ptrace/version.py: -------------------------------------------------------------------------------- 1 | PACKAGE = "python-ptrace" 2 | VERSION = "0.9.5" 3 | WEBSITE = "http://python-ptrace.readthedocs.io/" 4 | LICENSE = "GNU GPL v2" 5 | -------------------------------------------------------------------------------- /installCptrace/build/temp.linux-x86_64-3.7/cptrace/cptrace.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/installCptrace/build/temp.linux-x86_64-3.7/cptrace/cptrace.o -------------------------------------------------------------------------------- /installCptrace/cptrace/Makefile: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | CFLAGS=-fPIC -shared -Wall -Wextra -Wextra $(shell python-config --cflags) 3 | LIBS=$(shell python-config --libs) 4 | LIBRARY=cptrace.so 5 | 6 | $(LIBRARY): cptrace.c 7 | $(CC) -o $@ $< $(CFLAGS) $(LIBS) 8 | 9 | clean: 10 | rm -f $(LIBRARY) 11 | -------------------------------------------------------------------------------- /installCptrace/cptrace/version.py: -------------------------------------------------------------------------------- 1 | PACKAGE = "cptrace" 2 | VERSION = "0.6.1" 3 | WEBSITE = "http://python-ptrace.readthedocs.io/" 4 | LICENSE = "GNU GPL v2" 5 | -------------------------------------------------------------------------------- /installCptrace/doc/cptrace.rst: -------------------------------------------------------------------------------- 1 | +++++++++++++++++++++ 2 | cptrace Python module 3 | +++++++++++++++++++++ 4 | 5 | Python binding for ptrace written in C. 6 | 7 | Example 8 | ======= 9 | 10 | Dummy example: :: 11 | 12 | >>> import cptrace 13 | >>> cptrace.ptrace(1, 1) 14 | Traceback (most recent call last): 15 | File "", line 1, in 16 | ValueError: ptrace(request=1, pid=1, 0x(nil), 0x(nil)) error #1: Operation not permitted 17 | 18 | 19 | -------------------------------------------------------------------------------- /installCptrace/ptrace/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.signames import SIGNAMES, signalName # noqa 2 | from ptrace.error import PtraceError # noqa 3 | -------------------------------------------------------------------------------- /installCptrace/ptrace/binding/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.binding.func import ( # noqa 2 | HAS_PTRACE_SINGLESTEP, HAS_PTRACE_EVENTS, 3 | HAS_PTRACE_IO, HAS_PTRACE_SIGINFO, HAS_PTRACE_GETREGS, 4 | REGISTER_NAMES, 5 | ptrace_attach, ptrace_traceme, 6 | ptrace_detach, ptrace_kill, 7 | ptrace_cont, ptrace_syscall, 8 | ptrace_setregs, 9 | ptrace_peektext, ptrace_poketext, 10 | ptrace_peekuser, 11 | ptrace_registers_t) 12 | if HAS_PTRACE_EVENTS: 13 | from ptrace.binding.func import (WPTRACEEVENT, # noqa 14 | PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK, PTRACE_EVENT_CLONE, 15 | PTRACE_EVENT_EXEC, 16 | ptrace_setoptions, ptrace_geteventmsg) 17 | if HAS_PTRACE_SINGLESTEP: 18 | from ptrace.binding.func import ptrace_singlestep # noqa 19 | if HAS_PTRACE_SIGINFO: 20 | from ptrace.binding.func import ptrace_getsiginfo # noqa 21 | if HAS_PTRACE_IO: 22 | from ptrace.binding.func import ptrace_io # noqa 23 | from ptrace.binding.freebsd_struct import ( # noqa 24 | ptrace_io_desc, 25 | PIOD_READ_D, PIOD_WRITE_D, 26 | PIOD_READ_I, PIOD_WRITE_I) 27 | if HAS_PTRACE_GETREGS: 28 | from ptrace.binding.func import ptrace_getregs # noqa 29 | -------------------------------------------------------------------------------- /installCptrace/ptrace/binding/cpu.py: -------------------------------------------------------------------------------- 1 | from ptrace.cpu_info import ( 2 | CPU_POWERPC, CPU_INTEL, CPU_X86_64, CPU_I386, CPU_ARM) 3 | 4 | CPU_INSTR_POINTER = None 5 | CPU_STACK_POINTER = None 6 | CPU_FRAME_POINTER = None 7 | CPU_SUB_REGISTERS = {} 8 | 9 | if CPU_POWERPC: 10 | CPU_INSTR_POINTER = "nip" 11 | # FIXME: Is it the right register? 12 | CPU_STACK_POINTER = 'gpr1' 13 | elif CPU_ARM: 14 | CPU_INSTR_POINTER = 'r15' 15 | CPU_STACK_POINTER = 'r14' 16 | CPU_FRAME_POINTER = 'r11' 17 | elif CPU_X86_64: 18 | CPU_INSTR_POINTER = "rip" 19 | CPU_STACK_POINTER = "rsp" 20 | CPU_FRAME_POINTER = "rbp" 21 | CPU_SUB_REGISTERS = { 22 | # main register name, shift, mask 23 | 'al': ('rax', 0, 0xff), 24 | 'bl': ('rbx', 0, 0xff), 25 | 'cl': ('rcx', 0, 0xff), 26 | 'dl': ('rdx', 0, 0xff), 27 | 'ah': ('rax', 8, 0xff), 28 | 'bh': ('rbx', 8, 0xff), 29 | 'ch': ('rcx', 8, 0xff), 30 | 'dh': ('rdx', 8, 0xff), 31 | 'ax': ('rax', 0, 0xffff), 32 | 'bx': ('rbx', 0, 0xffff), 33 | 'cx': ('rcx', 0, 0xffff), 34 | 'dx': ('rdx', 0, 0xffff), 35 | 'eax': ('rax', 32, None), 36 | 'ebx': ('rbx', 32, None), 37 | 'ecx': ('rcx', 32, None), 38 | 'edx': ('rdx', 32, None), 39 | } 40 | elif CPU_I386: 41 | CPU_INSTR_POINTER = "eip" 42 | CPU_STACK_POINTER = "esp" 43 | CPU_FRAME_POINTER = "ebp" 44 | CPU_SUB_REGISTERS = { 45 | 'al': ('eax', 0, 0xff), 46 | 'bl': ('ebx', 0, 0xff), 47 | 'cl': ('ecx', 0, 0xff), 48 | 'dl': ('edx', 0, 0xff), 49 | 'ah': ('eax', 8, 0xff), 50 | 'bh': ('ebx', 8, 0xff), 51 | 'ch': ('ecx', 8, 0xff), 52 | 'dh': ('edx', 8, 0xff), 53 | 'ax': ('eax', 0, 0xffff), 54 | 'bx': ('ebx', 0, 0xffff), 55 | 'cx': ('ecx', 0, 0xffff), 56 | 'dx': ('edx', 0, 0xffff), 57 | } 58 | 59 | if CPU_INTEL: 60 | CPU_SUB_REGISTERS.update({ 61 | 'cf': ('eflags', 0, 1), 62 | 'pf': ('eflags', 2, 1), 63 | 'af': ('eflags', 4, 1), 64 | 'zf': ('eflags', 6, 1), 65 | 'sf': ('eflags', 7, 1), 66 | 'tf': ('eflags', 8, 1), 67 | 'if': ('eflags', 9, 1), 68 | 'df': ('eflags', 10, 1), 69 | 'of': ('eflags', 11, 1), 70 | 'iopl': ('eflags', 12, 2), 71 | }) 72 | -------------------------------------------------------------------------------- /installCptrace/ptrace/binding/freebsd_struct.py: -------------------------------------------------------------------------------- 1 | from ctypes import (Structure, 2 | c_int, c_uint, c_ulong, c_void_p, 3 | c_uint16, c_uint32, c_size_t) 4 | from ptrace.cpu_info import CPU_X86_64 5 | 6 | PIOD_READ_D = 1 7 | PIOD_WRITE_D = 2 8 | PIOD_READ_I = 3 9 | PIOD_WRITE_I = 4 10 | 11 | # /usr/include/machine/reg.h 12 | if CPU_X86_64: 13 | register_t = c_ulong 14 | 15 | class reg(Structure): 16 | _fields_ = ( 17 | ("r15", register_t), 18 | ("r14", register_t), 19 | ("r13", register_t), 20 | ("r12", register_t), 21 | ("r11", register_t), 22 | ("r10", register_t), 23 | ("r9", register_t), 24 | ("r8", register_t), 25 | ("rdi", register_t), 26 | ("rsi", register_t), 27 | ("rbp", register_t), 28 | ("rbx", register_t), 29 | ("rdx", register_t), 30 | ("rcx", register_t), 31 | ("rax", register_t), 32 | ("trapno", c_uint32), 33 | ("fs", c_uint16), 34 | ("gs", c_uint16), 35 | ("err", c_uint32), 36 | ("es", c_uint16), 37 | ("ds", c_uint16), 38 | ("rip", register_t), 39 | ("cs", register_t), 40 | ("rflags", register_t), 41 | ("rsp", register_t), 42 | ("ss", register_t), 43 | ) 44 | else: 45 | class reg(Structure): 46 | _fields_ = ( 47 | ("fs", c_uint), 48 | ("es", c_uint), 49 | ("ds", c_uint), 50 | ("edi", c_uint), 51 | ("esi", c_uint), 52 | ("ebp", c_uint), 53 | ("isp", c_uint), 54 | ("ebx", c_uint), 55 | ("edx", c_uint), 56 | ("ecx", c_uint), 57 | ("eax", c_uint), 58 | ("trapno", c_uint), 59 | ("err", c_uint), 60 | ("eip", c_uint), 61 | ("cs", c_uint), 62 | ("eflags", c_uint), 63 | ("esp", c_uint), 64 | ("ss", c_uint), 65 | ("gs", c_uint), 66 | ) 67 | 68 | 69 | class ptrace_io_desc(Structure): 70 | _fields_ = ( 71 | ("piod_op", c_int), 72 | ("piod_offs", c_void_p), 73 | ("piod_addr", c_void_p), 74 | ("piod_len", c_size_t), 75 | ) 76 | -------------------------------------------------------------------------------- /installCptrace/ptrace/binding/openbsd_struct.py: -------------------------------------------------------------------------------- 1 | from ctypes import Structure, c_int, c_uint, c_ulong, c_void_p, c_char 2 | 3 | PIOD_READ_D = 1 4 | PIOD_WRITE_D = 2 5 | PIOD_READ_I = 3 6 | PIOD_WRITE_I = 4 7 | 8 | size_t = c_ulong 9 | pid_t = c_int 10 | 11 | # /usr/include/machine/reg.h 12 | 13 | 14 | class reg(Structure): 15 | _fields_ = ( 16 | ("eax", c_uint), 17 | ("ecx", c_uint), 18 | ("edx", c_uint), 19 | ("ebx", c_uint), 20 | ("esp", c_uint), 21 | ("ebp", c_uint), 22 | ("esi", c_uint), 23 | ("edi", c_uint), 24 | ("eip", c_uint), 25 | ("eflags", c_uint), 26 | ("cs", c_uint), 27 | ("ss", c_uint), 28 | ("ds", c_uint), 29 | ("es", c_uint), 30 | ("fs", c_uint), 31 | ("gs", c_uint), 32 | ) 33 | 34 | 35 | class fpreg(Structure): 36 | _fields_ = ( 37 | ("__data", c_char * 116), 38 | ) 39 | 40 | 41 | class ptrace_io_desc(Structure): 42 | _fields_ = ( 43 | ("piod_op", c_int), 44 | ("piod_offs", c_void_p), 45 | ("piod_addr", c_void_p), 46 | ("piod_len", size_t), 47 | ) 48 | -------------------------------------------------------------------------------- /installCptrace/ptrace/cpu_info.py: -------------------------------------------------------------------------------- 1 | """ 2 | Constants about the CPU: 3 | 4 | - CPU_BIGENDIAN (bool) 5 | - CPU_64BITS (bool) 6 | - CPU_WORD_SIZE (int) 7 | - CPU_MAX_UINT (int) 8 | - CPU_PPC32 (bool) 9 | - CPU_PPC64 (bool) 10 | - CPU_I386 (bool) 11 | - CPU_X86_64 (bool) 12 | - CPU_INTEL (bool) 13 | - CPU_POWERPC (bool) 14 | """ 15 | 16 | try: 17 | from os import uname 18 | HAS_UNAME = True 19 | except ImportError: 20 | HAS_UNAME = False 21 | from platform import architecture 22 | from sys import byteorder 23 | from ctypes import sizeof, c_void_p 24 | 25 | CPU_BIGENDIAN = (byteorder == 'big') 26 | CPU_64BITS = (sizeof(c_void_p) == 8) 27 | 28 | if CPU_64BITS: 29 | CPU_WORD_SIZE = 8 # bytes 30 | CPU_MAX_UINT = 0xffffffffffffffff 31 | else: 32 | CPU_WORD_SIZE = 4 # bytes 33 | CPU_MAX_UINT = 0xffffffff 34 | 35 | if HAS_UNAME: 36 | # guess machine type using uname() 37 | _machine = uname()[4] 38 | CPU_PPC32 = (_machine == 'ppc') 39 | CPU_PPC64 = (_machine == 'ppc64') 40 | CPU_I386 = (_machine in ("i386", "i686")) # compatible Intel 32 bits 41 | CPU_X86_64 = (_machine in ("x86_64", "amd64")) # compatible Intel 64 bits 42 | CPU_ARM = _machine.startswith('arm') 43 | del _machine 44 | else: 45 | # uname() fallback for Windows 46 | # I hope that your Windows doesn't run on PPC32/PPC64 47 | CPU_PPC32 = False 48 | CPU_PPC64 = False 49 | CPU_I386 = False 50 | CPU_X86_64 = False 51 | CPU_ARM = False 52 | bits, linkage = architecture() 53 | if bits == '32bit': 54 | CPU_I386 = True 55 | elif bits == '64bit': 56 | CPU_X86_64 = True 57 | else: 58 | raise ValueError("Unknown architecture bits: %r" % bits) 59 | 60 | CPU_INTEL = (CPU_I386 or CPU_X86_64) 61 | CPU_POWERPC = (CPU_PPC32 or CPU_PPC64) 62 | -------------------------------------------------------------------------------- /installCptrace/ptrace/ctypes_libc.py: -------------------------------------------------------------------------------- 1 | """ 2 | Load the system C library. Variables: 3 | - LIBC_FILENAME: the C library filename 4 | - libc: the loaded library 5 | """ 6 | 7 | from ctypes import CDLL 8 | from ctypes.util import find_library 9 | 10 | LIBC_FILENAME = find_library('c') 11 | libc = CDLL(LIBC_FILENAME, use_errno=True) 12 | -------------------------------------------------------------------------------- /installCptrace/ptrace/debugger/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.debugger.breakpoint import Breakpoint # noqa 2 | from ptrace.debugger.process_event import (ProcessEvent, ProcessExit, # noqa 3 | NewProcessEvent, ProcessExecution) 4 | from ptrace.debugger.ptrace_signal import ProcessSignal # noqa 5 | from ptrace.debugger.process_error import ProcessError # noqa 6 | from ptrace.debugger.child import ChildError # noqa 7 | from ptrace.debugger.process import PtraceProcess # noqa 8 | from ptrace.debugger.debugger import PtraceDebugger, DebuggerError # noqa 9 | from ptrace.debugger.application import Application # noqa 10 | -------------------------------------------------------------------------------- /installCptrace/ptrace/debugger/breakpoint.py: -------------------------------------------------------------------------------- 1 | from ptrace.ctypes_tools import formatAddress 2 | from ptrace import PtraceError 3 | from logging2 import info 4 | from weakref import ref 5 | from ptrace.cpu_info import CPU_POWERPC, CPU_WORD_SIZE 6 | from ptrace.ctypes_tools import word2bytes 7 | from six import b 8 | 9 | 10 | class Breakpoint(object): 11 | """ 12 | Software breakpoint. 13 | 14 | Use desinstall() method to remove the breakpoint from the process. 15 | """ 16 | 17 | def __init__(self, process, address, size=None): 18 | self._installed = False 19 | self.process = ref(process) 20 | self.address = address 21 | if CPU_POWERPC: 22 | size = CPU_WORD_SIZE 23 | elif size is None: 24 | size = 1 25 | self.size = size 26 | 27 | # Store instruction bytes 28 | info("Install %s" % self) 29 | self.old_bytes = process.readBytes(address, size) 30 | 31 | if CPU_POWERPC: 32 | # Replace instruction with "TRAP" 33 | new_bytes = word2bytes(0x0cc00000) 34 | else: 35 | # Replace instruction with "INT 3" 36 | new_bytes = b("\xCC") * size 37 | process.writeBytes(address, new_bytes) 38 | self._installed = True 39 | 40 | def desinstall(self, set_ip=False): 41 | """ 42 | Remove the breakpoint from the associated process. If set_ip is True, 43 | restore the instruction pointer to the address of the breakpoint. 44 | """ 45 | if not self._installed: 46 | return 47 | self._installed = False 48 | info("Desinstall %s" % self) 49 | process = self.process() 50 | if not process: 51 | return 52 | if process.running: 53 | process.writeBytes(self.address, self.old_bytes) 54 | if set_ip: 55 | process.setInstrPointer(self.address) 56 | process.removeBreakpoint(self) 57 | 58 | def __str__(self): 59 | return "" % ( 60 | formatAddress(self.address), 61 | formatAddress(self.address + self.size - 1)) 62 | 63 | def __del__(self): 64 | try: 65 | self.desinstall(False) 66 | except PtraceError: 67 | pass 68 | -------------------------------------------------------------------------------- /installCptrace/ptrace/debugger/parse_expr.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | # Match a register name: $eax, $gp0, $orig_eax 4 | REGISTER_REGEX = re.compile(r"([a-z]+[a-z0-9_]+)") 5 | 6 | # Hexadecimal number (e.g. 0xa) 7 | HEXADECIMAL_REGEX = re.compile(r"0x[0-9a-f]+") 8 | 9 | # Make sure that the expression does not contain invalid characters 10 | # Examples: 11 | # (1-2)<<5 12 | # 340&91 13 | EXPR_REGEX = re.compile(r"^[()<>+*/&0-9-]+$") 14 | 15 | 16 | def replaceHexadecimal(regs): 17 | """ 18 | Convert an hexadecimal number to decimal number (as string). 19 | Callback used by parseExpression(). 20 | """ 21 | text = regs.group(0) 22 | if text.startswith("0x"): 23 | text = text[2:] 24 | elif not re.search("[a-f]", text): 25 | return text 26 | value = int(text, 16) 27 | return str(value) 28 | 29 | 30 | def parseExpression(process, text): 31 | """ 32 | Parse an expression. Syntax: 33 | - "10": decimal number 34 | - "0x10": hexadecimal number 35 | - "eax": register value 36 | - "a+b", "a-b", "a*b", "a/b", "a**b", "a<>b": operators 37 | 38 | >>> from ptrace.mockup import FakeProcess 39 | >>> process = FakeProcess() 40 | >>> parseExpression(process, "1+1") 41 | 2 42 | >>> process.setreg("eax", 3) 43 | >>> parseExpression(process, "eax*0x10") 44 | 48 45 | """ 46 | # Remove spaces and convert to lower case 47 | text = text.strip() 48 | orig_text = text 49 | if " " in text: 50 | raise ValueError("Space are forbidden: %r" % text) 51 | text = text.lower() 52 | 53 | def readRegister(regs): 54 | name = regs.group(1) 55 | value = process.getreg(name) 56 | return str(value) 57 | 58 | # Replace hexadecimal by decimal 59 | text = HEXADECIMAL_REGEX.sub(replaceHexadecimal, text) 60 | 61 | # Replace registers by their value 62 | text = REGISTER_REGEX.sub(readRegister, text) 63 | 64 | # Reject invalid characters 65 | if not EXPR_REGEX.match(text): 66 | raise ValueError("Invalid expression: %r" % orig_text) 67 | 68 | # Use integer division (a//b) instead of float division (a/b) 69 | text = text.replace("/", "//") 70 | 71 | # Finally, evaluate the expression 72 | try: 73 | value = eval(text) 74 | except SyntaxError: 75 | raise ValueError("Invalid expression: %r" % orig_text) 76 | return value 77 | -------------------------------------------------------------------------------- /installCptrace/ptrace/debugger/process_error.py: -------------------------------------------------------------------------------- 1 | from ptrace.error import PtraceError 2 | 3 | 4 | class ProcessError(PtraceError): 5 | 6 | def __init__(self, process, message): 7 | PtraceError.__init__(self, message, pid=process.pid) 8 | self.process = process 9 | -------------------------------------------------------------------------------- /installCptrace/ptrace/debugger/process_event.py: -------------------------------------------------------------------------------- 1 | from ptrace.signames import signalName 2 | 3 | 4 | class ProcessEvent(Exception): 5 | """ 6 | A process event: program exit, program killed by a signal, program 7 | received a signal, etc. 8 | 9 | The attribute "process" contains the related process. 10 | """ 11 | 12 | def __init__(self, process, message): 13 | Exception.__init__(self, message) 14 | self.process = process 15 | 16 | 17 | class ProcessExit(ProcessEvent): 18 | """ 19 | Process exit event: 20 | - process kill by a signal (if signum attribute is not None) 21 | - process exited with a code (if exitcode attribute is not None) 22 | - process terminated abnormally (otherwise) 23 | """ 24 | 25 | def __init__(self, process, signum=None, exitcode=None): 26 | pid = process.pid 27 | if signum: 28 | message = "Process %s killed by signal %s" % ( 29 | pid, signalName(signum)) 30 | elif exitcode is not None: 31 | if not exitcode: 32 | message = "Process %s exited normally" % pid 33 | else: 34 | message = "Process %s exited with code %s" % (pid, exitcode) 35 | else: 36 | message = "Process %s terminated abnormally" % pid 37 | ProcessEvent.__init__(self, process, message) 38 | self.signum = signum 39 | self.exitcode = exitcode 40 | 41 | 42 | class ProcessExecution(ProcessEvent): 43 | """ 44 | Process execution: event send just after the process calls the exec() 45 | syscall if exec() tracing option is enabled. 46 | """ 47 | 48 | def __init__(self, process): 49 | ProcessEvent.__init__( 50 | self, process, "Process %s execution" % process.pid) 51 | 52 | 53 | class NewProcessEvent(ProcessEvent): 54 | """ 55 | New process: event send when a process calls the fork() syscall if fork() 56 | tracing option is enabled. The attribute process contains the new child 57 | process. 58 | """ 59 | 60 | def __init__(self, process): 61 | ProcessEvent.__init__(self, process, "New process %s" % process.pid) 62 | -------------------------------------------------------------------------------- /installCptrace/ptrace/debugger/syscall_state.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall import PtraceSyscall 2 | from signal import SIGTRAP 3 | 4 | 5 | class SyscallState(object): 6 | 7 | def __init__(self, process): 8 | self.process = process 9 | self.ignore_exec_trap = True 10 | self.ignore_callback = None 11 | self.clear() 12 | 13 | def event(self, options): 14 | if self.next_event == "exit": 15 | return self.exit() 16 | else: 17 | return self.enter(options) 18 | 19 | def enter(self, options): 20 | # syscall enter 21 | regs = self.process.getregs() 22 | self.syscall = PtraceSyscall(self.process, options, regs) 23 | self.name = self.syscall.name 24 | if (not self.ignore_callback) \ 25 | or (not self.ignore_callback(self.syscall)): 26 | self.syscall.enter(regs) 27 | else: 28 | self.syscall = None 29 | self.next_event = "exit" 30 | return self.syscall 31 | 32 | def exit(self): 33 | if self.syscall: 34 | self.syscall.exit() 35 | if self.ignore_exec_trap \ 36 | and self.name == "execve" \ 37 | and not self.process.debugger.trace_exec: 38 | # Ignore the SIGTRAP after exec() syscall exit 39 | self.process.syscall() 40 | self.process.waitSignals(SIGTRAP) 41 | syscall = self.syscall 42 | self.clear() 43 | return syscall 44 | 45 | def clear(self): 46 | self.syscall = None 47 | self.name = None 48 | self.next_event = "enter" 49 | -------------------------------------------------------------------------------- /installCptrace/ptrace/error.py: -------------------------------------------------------------------------------- 1 | from sys import exc_info 2 | from traceback import format_exception 3 | from logging2 import ERROR, getLogger 4 | from ptrace.logging_tools import getLogFunc, changeLogLevel 5 | 6 | PTRACE_ERRORS = Exception 7 | 8 | 9 | def writeBacktrace(logger, log_level=ERROR): 10 | """ 11 | Write a backtrace into the logger with the specified log level. 12 | """ 13 | log_func = getLogFunc(logger, log_level) 14 | try: 15 | info = exc_info() 16 | trace = format_exception(*info) 17 | if trace[0] != "None\n": 18 | trace = ''.join(trace).rstrip() 19 | for line in trace.split("\n"): 20 | log_func(line.rstrip()) 21 | return 22 | except Exception: 23 | pass 24 | log_func("Unable to get backtrace") 25 | 26 | 27 | def formatError(error): 28 | """ 29 | Format an error as a string. Write the error type as prefix. 30 | Eg. "[ValueError] invalid value". 31 | """ 32 | return "[%s] %s" % (error.__class__.__name__, error) 33 | 34 | 35 | def writeError(logger, error, title="ERROR", log_level=ERROR): 36 | """ 37 | Write an error into the logger: 38 | - logger: the logger (if None, use getLogger()) 39 | - error: the exception object 40 | - title: error message prefix (e.g. title="Initialization error") 41 | - log_level: log level of the error 42 | 43 | If the exception is a SystemExit or a KeyboardInterrupt, re-emit 44 | (raise) the exception and don't write it. 45 | """ 46 | if not logger: 47 | logger = getLogger() 48 | if error.__class__ in (SystemExit, KeyboardInterrupt): 49 | raise error 50 | log_func = getLogFunc(logger, log_level) 51 | log_func("%s: %s" % (title, formatError(error))) 52 | writeBacktrace(logger, log_level=changeLogLevel(log_level, -1)) 53 | 54 | 55 | class PtraceError(Exception): 56 | """ 57 | Ptrace error: have the optional attributes errno and pid. 58 | """ 59 | 60 | def __init__(self, message, errno=None, pid=None): 61 | Exception.__init__(self, message) 62 | self.errno = errno 63 | self.pid = pid 64 | -------------------------------------------------------------------------------- /installCptrace/ptrace/logging_tools.py: -------------------------------------------------------------------------------- 1 | from ptrace.tools import minmax 2 | from logging2 import ERROR, WARNING, INFO, DEBUG 3 | 4 | 5 | def getLogFunc(logger, level): 6 | """ 7 | Get the logger function for the specified logging level. 8 | """ 9 | if level == ERROR: 10 | return logger.error 11 | elif level == WARNING: 12 | return logger.warning 13 | elif level == INFO: 14 | return logger.info 15 | elif level == DEBUG: 16 | return logger.debug 17 | else: 18 | return logger.error 19 | 20 | 21 | def changeLogLevel(level, delta): 22 | """ 23 | Compute log level and make sure that the result is in DEBUG..ERROR. 24 | 25 | >>> changeLogLevel(ERROR, -1) == WARNING 26 | True 27 | >>> changeLogLevel(DEBUG, 1) == INFO 28 | True 29 | """ 30 | return minmax(DEBUG, level + delta * 10, ERROR) 31 | -------------------------------------------------------------------------------- /installCptrace/ptrace/mockup.py: -------------------------------------------------------------------------------- 1 | """ 2 | Mockup classes used in unit tests. 3 | """ 4 | 5 | 6 | class FakeProcess(object): 7 | 8 | def __init__(self): 9 | self.regs = {} 10 | 11 | def setreg(self, name, value): 12 | self.regs[name] = value 13 | 14 | def getreg(self, name): 15 | return self.regs[name] 16 | -------------------------------------------------------------------------------- /installCptrace/ptrace/os_tools.py: -------------------------------------------------------------------------------- 1 | """ 2 | Constants about the operating system: 3 | 4 | - RUNNING_PYPY (bool) 5 | - RUNNING_WINDOWS (bool) 6 | - RUNNING_LINUX (bool) 7 | - RUNNING_FREEBSD (bool) 8 | - RUNNING_OPENBSD (bool) 9 | - RUNNING_MACOSX (bool) 10 | - RUNNING_BSD (bool) 11 | - HAS_PROC (bool) 12 | - HAS_PTRACE (bool) 13 | """ 14 | 15 | from sys import platform, version, version_info 16 | 17 | RUNNING_PYTHON3 = version_info[0] == 3 18 | RUNNING_PYPY = ("pypy" in version.lower()) 19 | RUNNING_WINDOWS = (platform == 'win32') 20 | RUNNING_LINUX = platform.startswith('linux') 21 | RUNNING_FREEBSD = (platform.startswith('freebsd') 22 | or platform.startswith('gnukfreebsd')) 23 | RUNNING_OPENBSD = platform.startswith('openbsd') 24 | RUNNING_MACOSX = (platform == 'darwin') 25 | RUNNING_BSD = RUNNING_FREEBSD or RUNNING_MACOSX or RUNNING_OPENBSD 26 | 27 | HAS_PROC = RUNNING_LINUX 28 | HAS_PTRACE = (RUNNING_BSD or RUNNING_LINUX) 29 | -------------------------------------------------------------------------------- /installCptrace/ptrace/profiler.py: -------------------------------------------------------------------------------- 1 | from hotshot import Profile 2 | from hotshot.stats import load as loadStats 3 | from os import unlink 4 | from io import StringIO 5 | 6 | 7 | def runProfiler(logger, func, args=tuple(), kw={}, 8 | verbose=True, nb_func=25, 9 | sort_by=('time',)): 10 | """ 11 | Run a function in a profiler and then display the functions sorted by time. 12 | """ 13 | profile_filename = "/tmp/profiler" 14 | prof = Profile(profile_filename) 15 | try: 16 | logger.warning("Run profiler") 17 | result = prof.runcall(func, *args, **kw) 18 | prof.close() 19 | logger.error("Profiler: Process data...") 20 | stat = loadStats(profile_filename) 21 | stat.strip_dirs() 22 | stat.sort_stats(*sort_by) 23 | 24 | logger.error("Profiler: Result:") 25 | log = StringIO() 26 | stat.stream = log 27 | stat.print_stats(nb_func) 28 | log.seek(0) 29 | for line in log: 30 | logger.error(line.rstrip()) 31 | return result 32 | finally: 33 | unlink(profile_filename) 34 | -------------------------------------------------------------------------------- /installCptrace/ptrace/signames.py: -------------------------------------------------------------------------------- 1 | """ 2 | Name of process signals. 3 | 4 | SIGNAMES contains a dictionary mapping a signal number to it's name. But you 5 | should better use signalName() instead of SIGNAMES since it returns a string 6 | even if the signal is unknown. 7 | """ 8 | 9 | PREFERRED_NAMES = ("SIGABRT", "SIGHUP", "SIGCHLD", "SIGPOLL") 10 | 11 | 12 | def getSignalNames(): 13 | """ 14 | Create signal names dictionary (e.g. 9 => 'SIGKILL') using dir(signal). 15 | If multiple signal names have the same number, use the first matching name 16 | in PREFERRED_NAME to select preferred name (e.g. SIGIOT=SIGABRT=17). 17 | """ 18 | import signal 19 | allnames = {} 20 | for name in dir(signal): 21 | if not name.startswith("SIG"): 22 | continue 23 | signum = getattr(signal, name) 24 | try: 25 | allnames[signum].append(name) 26 | except KeyError: 27 | allnames[signum] = [name] 28 | signames = {} 29 | for signum, names in allnames.items(): 30 | if not signum: 31 | # Skip signal 0 32 | continue 33 | name = None 34 | for preferred in PREFERRED_NAMES: 35 | if preferred in names: 36 | name = preferred 37 | break 38 | if not name: 39 | name = names[0] 40 | signames[signum] = name 41 | return signames 42 | 43 | 44 | SIGNAMES = getSignalNames() 45 | 46 | 47 | def signalName(signum): 48 | """ 49 | Get the name of a signal 50 | 51 | >>> from signal import SIGINT 52 | >>> signalName(SIGINT) 53 | 'SIGINT' 54 | >>> signalName(404) 55 | 'signal<404>' 56 | """ 57 | try: 58 | return SIGNAMES[signum] 59 | except KeyError: 60 | return "signal<%s>" % signum 61 | -------------------------------------------------------------------------------- /installCptrace/ptrace/syscall/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.names import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES # noqa 2 | from ptrace.syscall.prototypes import SYSCALL_PROTOTYPES, FILENAME_ARGUMENTS, DIRFD_ARGUMENTS # noqa 3 | from ptrace.syscall.syscall_argument import SyscallArgument # noqa 4 | from ptrace.syscall.ptrace_syscall import PtraceSyscall, SYSCALL_REGISTER, RETURN_VALUE_REGISTER # noqa 5 | -------------------------------------------------------------------------------- /installCptrace/ptrace/syscall/freebsd_constants.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.posix_constants import SYSCALL_ARG_DICT 2 | 3 | RLIMIT_RESOURCE = { 4 | 0: "RLIMIT_CPU", 5 | 1: "RLIMIT_FSIZE", 6 | 2: "RLIMIT_DATA", 7 | 3: "RLIMIT_STACK", 8 | 4: "RLIMIT_CORE", 9 | 5: "RLIMIT_RSS", 10 | 6: "RLIMIT_MEMLOCK", 11 | 7: "RLIMIT_NPROC", 12 | 8: "RLIMIT_NOFILE", 13 | 9: "RLIMIT_SBSIZE", 14 | 10: "RLIMIT_VMEM", 15 | } 16 | 17 | SIGPROCMASK_HOW = {1: " SIG_BLOCK", 2: "SIG_UNBLOCK", 3: "SIG_SETMASK"} 18 | 19 | SYSCALL_ARG_DICT.update({ 20 | "getrlimit": {"resource": RLIMIT_RESOURCE}, 21 | "setrlimit": {"resource": RLIMIT_RESOURCE}, 22 | "sigprocmask": {"how": SIGPROCMASK_HOW}, 23 | "rt_sigprocmask": {"how": SIGPROCMASK_HOW}, 24 | }) 25 | -------------------------------------------------------------------------------- /installCptrace/ptrace/syscall/linux_constants.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.posix_constants import SYSCALL_ARG_DICT 2 | 3 | SIGSET_SIZE = 64 4 | FD_SETSIZE = 1024 5 | 6 | RLIMIT_RESOURCE = { 7 | 0: "RLIMIT_CPU", 8 | 1: "RLIMIT_FSIZE", 9 | 2: "RLIMIT_DATA", 10 | 3: "RLIMIT_STACK", 11 | 4: "RLIMIT_CORE", 12 | 5: "RLIMIT_RSS", 13 | 6: "RLIMIT_NPROC", 14 | 7: "RLIMIT_NOFILE", 15 | 8: "RLIMIT_MEMLOCK", 16 | 9: "RLIMIT_AS", 17 | 10: "RLIMIT_LOCKS", 18 | 11: "RLIMIT_SIGPENDING", 19 | 12: "RLIMIT_MSGQUEUE", 20 | 13: "RLIMIT_NICE", 21 | 14: "RLIMIT_RTPRIO", 22 | 15: "RLIMIT_NLIMITS", 23 | } 24 | 25 | SIGPROCMASK_HOW = {0: "SIG_BLOCK", 1: "SIG_UNBLOCK", 2: "SIG_SETMASK"} 26 | 27 | SYSCALL_ARG_DICT.update({ 28 | "getrlimit": {"resource": RLIMIT_RESOURCE}, 29 | "setrlimit": {"resource": RLIMIT_RESOURCE}, 30 | "sigprocmask": {"how": SIGPROCMASK_HOW}, 31 | "rt_sigprocmask": {"how": SIGPROCMASK_HOW}, 32 | }) 33 | -------------------------------------------------------------------------------- /installCptrace/ptrace/syscall/linux_struct.py: -------------------------------------------------------------------------------- 1 | from ctypes import (Structure, 2 | c_char, c_short, c_int, c_uint, c_long, c_ulong) 3 | 4 | time_t = c_long 5 | suseconds_t = c_long 6 | rlim_t = c_long 7 | 8 | 9 | class timeval(Structure): 10 | _fields_ = ( 11 | ("tv_sec", time_t), 12 | ("tv_usec", suseconds_t), 13 | ) 14 | 15 | 16 | class timespec(Structure): 17 | _fields_ = ( 18 | ("tv_sec", time_t), 19 | ("tv_nsec", c_long), 20 | ) 21 | 22 | 23 | class pollfd(Structure): 24 | _fields_ = ( 25 | ("fd", c_int), 26 | ("events", c_short), 27 | ("revents", c_short), 28 | ) 29 | 30 | 31 | class rlimit(Structure): 32 | _fields_ = ( 33 | ("rlim_cur", rlim_t), 34 | ("rlim_max", rlim_t), 35 | ) 36 | 37 | 38 | class new_utsname(Structure): 39 | _fields_ = ( 40 | ("sysname", c_char * 65), 41 | ("nodename", c_char * 65), 42 | ("release", c_char * 65), 43 | ("version", c_char * 65), 44 | ("machine", c_char * 65), 45 | ("domainname", c_char * 65), 46 | ) 47 | 48 | # Arch depend 49 | 50 | 51 | class user_desc(Structure): 52 | _fields_ = ( 53 | ("entry_number", c_uint), 54 | ("base_addr", c_ulong), 55 | ("limit", c_uint), 56 | ("_bits_", c_char), 57 | # unsigned int seg_32bit:1; 58 | # unsigned int contents:2; 59 | # unsigned int read_exec_only:1; 60 | # unsigned int limit_in_pages:1; 61 | # unsigned int seg_not_present:1; 62 | # unsigned int useable:1; 63 | ) 64 | -------------------------------------------------------------------------------- /installCptrace/ptrace/syscall/names.py: -------------------------------------------------------------------------------- 1 | from ptrace.cpu_info import CPU_64BITS 2 | from ptrace.os_tools import RUNNING_LINUX, RUNNING_FREEBSD 3 | if RUNNING_LINUX: 4 | if CPU_64BITS: 5 | from ptrace.syscall.linux_syscall64 import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES 6 | else: 7 | from ptrace.syscall.linux_syscall32 import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES 8 | elif RUNNING_FREEBSD: 9 | from ptrace.syscall.freebsd_syscall import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES 10 | else: 11 | SYSCALL_NAMES = {} 12 | SOCKET_SYSCALL_NAMES = set() 13 | -------------------------------------------------------------------------------- /installCptrace/ptrace/syscall/posix_constants.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.socketcall_constants import ( 2 | SOCKET_FAMILY, SOCKET_PROTOCOL, 3 | SETSOCKOPT_LEVEL, SETSOCKOPT_OPTNAME) 4 | 5 | SYSCALL_ARG_DICT = { 6 | "lseek": { 7 | "origin": {0: "SEEK_SET", 1: "SEEK_CUR", 2: "SEEK_END"}, 8 | }, 9 | "futex": { 10 | "op": { 11 | 0: "FUTEX_WAIT", 12 | 1: "FUTEX_WAKE", 13 | 2: "FUTEX_FD", 14 | 3: "FUTEX_REQUEUE", 15 | 4: "FUTEX_CMP_REQUEUE", 16 | 5: "FUTEX_WAKE_OP", 17 | 6: "FUTEX_LOCK_PI", 18 | 7: "FUTEX_UNLOCK_PI", 19 | 8: "FUTEX_TRYLOCK_PI", 20 | }, 21 | }, 22 | "fcntl": { 23 | "cmd": { 24 | 0: "F_DUPFD", 25 | 1: "F_GETFD", 26 | 2: "F_SETFD", 27 | 3: "F_GETFL", 28 | 4: "F_SETFL", 29 | 5: "F_GETOWN", 30 | 6: "F_SETOWN", 31 | 7: "F_GETLK", 32 | 8: "F_SETLK", 33 | 9: "F_SETLKW", 34 | }, 35 | }, 36 | "ipc": { 37 | "call": { 38 | 1: "SEMOP", 39 | 2: "SEMGET", 40 | 3: "SEMCTL", 41 | 4: "SEMTIMEDOP", 42 | 11: "MSGSND", 43 | 12: "MSGRCV", 44 | 13: "MSGGET", 45 | 14: "MSGCTL", 46 | 21: "SHMAT", 47 | 22: "SHMDT", 48 | 23: "SHMGET", 49 | 24: "SHMCTL", 50 | }, 51 | }, 52 | "socket": { 53 | "domain": SOCKET_FAMILY, 54 | "protocol": SOCKET_PROTOCOL, 55 | }, 56 | "getsockopt": { 57 | "level": SETSOCKOPT_LEVEL, 58 | "optname": SETSOCKOPT_OPTNAME, 59 | }, 60 | } 61 | 62 | SYSCALL_ARG_DICT["setsockopt"] = SYSCALL_ARG_DICT["getsockopt"] 63 | -------------------------------------------------------------------------------- /installCptrace/ptrace/syscall/socketcall_constants.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | SOCKETCALL = { 4 | 1: "socket", 5 | 2: "bind", 6 | 3: "connect", 7 | 4: "listen", 8 | 5: "accept", 9 | 6: "getsockname", 10 | 7: "getpeername", 11 | 8: "socketpair", 12 | 9: "send", 13 | 10: "recv", 14 | 11: "sendto", 15 | 12: "recvfrom", 16 | 13: "shutdown", 17 | 14: "setsockopt", 18 | 15: "getsockopt", 19 | 16: "sendmsg", 20 | 17: "recvmsg", 21 | } 22 | 23 | SOCKET_FAMILY = { 24 | 0: "AF_UNSPEC", 25 | 1: "AF_FILE", 26 | 2: "AF_INET", 27 | 3: "AF_AX25", 28 | 4: "AF_IPX", 29 | 5: "AF_APPLETALK", 30 | 6: "AF_NETROM", 31 | 7: "AF_BRIDGE", 32 | 8: "AF_ATMPVC", 33 | 9: "AF_X25", 34 | 10: "AF_INET6", 35 | 11: "AF_ROSE", 36 | 12: "AF_DECnet", 37 | 13: "AF_NETBEUI", 38 | 14: "AF_SECURITY", 39 | 15: "AF_KEY", 40 | 16: "AF_NETLINK", 41 | 17: "AF_PACKET", 42 | 18: "AF_ASH", 43 | 19: "AF_ECONET", 44 | 20: "AF_ATMSVC", 45 | 22: "AF_SNA", 46 | 23: "AF_IRDA", 47 | 24: "AF_PPPOX", 48 | 25: "AF_WANPIPE", 49 | 31: "AF_BLUETOOTH", 50 | } 51 | 52 | SOCKET_TYPE = { 53 | 1: "SOCK_STREAM", 54 | 2: "SOCK_DGRAM", 55 | 3: "SOCK_RAW", 56 | 4: "SOCK_RDM", 57 | 5: "SOCK_SEQPACKET", 58 | 10: "SOCK_PACKET", 59 | } 60 | 61 | 62 | def formatSocketType(argument): 63 | value = argument.value 64 | text = [] 65 | if hasattr(socket, 'SOCK_CLOEXEC'): 66 | cloexec = value & socket.SOCK_CLOEXEC 67 | value &= ~socket.SOCK_CLOEXEC 68 | else: 69 | cloexec = False 70 | text = SOCKET_TYPE.get(value, str(value)) 71 | if cloexec: 72 | text += '|SOCK_CLOEXEC' 73 | return text 74 | 75 | 76 | SOCKET_PROTOCOL = { 77 | 1: "IPPROTO_ICMP", 78 | 58: "IPPROTO_ICMPV6", 79 | } 80 | 81 | SETSOCKOPT_LEVEL = { 82 | 0: "SOL_IP", 83 | 1: "SOL_SOCKET", 84 | } 85 | 86 | SETSOCKOPT_OPTNAME = { 87 | # level 0 (SOL_IP) 88 | 1: "IP_TOS", 89 | # level 1 (SOL_SOCKET) 90 | 2: "SO_REUSEADDR", 91 | 9: "SO_KEEPALIVE", 92 | 20: "SO_RCVTIMEO", 93 | 21: "SO_SNDTIMEO", 94 | } 95 | -------------------------------------------------------------------------------- /installCptrace/ptrace/terminal.py: -------------------------------------------------------------------------------- 1 | """ 2 | Terminal functions. 3 | """ 4 | 5 | from termios import tcgetattr, tcsetattr, ECHO, TCSADRAIN, TIOCGWINSZ 6 | from sys import stdin, stdout 7 | from fcntl import ioctl 8 | from struct import unpack 9 | import os 10 | 11 | TERMIO_LFLAGS = 3 12 | 13 | 14 | def _terminalSize(): 15 | fd = stdout.fileno() 16 | size = ioctl(fd, TIOCGWINSZ, '1234') 17 | height, width = unpack('hh', size) 18 | return (width, height) 19 | 20 | 21 | def terminalWidth(): 22 | """ 23 | Get the terminal width in characters. 24 | """ 25 | return _terminalSize()[0] 26 | 27 | 28 | def enableEchoMode(): 29 | """ 30 | Enable echo mode in the terminal. Return True if the echo mode is set 31 | correctly, or False if the mode was already set. 32 | """ 33 | fd = stdin.fileno() 34 | if not os.isatty(fd): 35 | return False 36 | state = tcgetattr(fd) 37 | if state[TERMIO_LFLAGS] & ECHO: 38 | return False 39 | state[TERMIO_LFLAGS] = state[TERMIO_LFLAGS] | ECHO 40 | tcsetattr(fd, TCSADRAIN, state) 41 | return True 42 | -------------------------------------------------------------------------------- /installCptrace/ptrace/version.py: -------------------------------------------------------------------------------- 1 | PACKAGE = "python-ptrace" 2 | VERSION = "0.9.5" 3 | WEBSITE = "http://python-ptrace.readthedocs.io/" 4 | LICENSE = "GNU GPL v2" 5 | -------------------------------------------------------------------------------- /installCptrace/python_ptrace.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.1 2 | Name: python-ptrace 3 | Version: 0.9.5 4 | Summary: python binding of ptrace 5 | Home-page: http://python-ptrace.readthedocs.io/ 6 | Author: Victor Stinner 7 | Author-email: UNKNOWN 8 | License: GNU GPL v2 9 | Download-URL: http://python-ptrace.readthedocs.io/ 10 | Description: ============= 11 | python-ptrace 12 | ============= 13 | 14 | .. image:: http://unmaintained.tech/badge.svg 15 | :target: http://unmaintained.tech/ 16 | :alt: No Maintenance Intended 17 | 18 | .. image:: https://img.shields.io/pypi/v/python-ptrace.svg 19 | :alt: Latest release on the Python Cheeseshop (PyPI) 20 | :target: https://pypi.python.org/pypi/python-ptrace 21 | 22 | .. image:: https://travis-ci.org/vstinner/python-ptrace.svg?branch=master 23 | :alt: Build status of python-ptrace on Travis CI 24 | :target: https://travis-ci.org/vstinner/python-ptrace 25 | 26 | **This project is no longer maintained and is looking for a new maintainer.** 27 | 28 | python-ptrace is a debugger using ptrace (Linux, BSD and Darwin system call to 29 | trace processes) written in Python. 30 | 31 | * `python-ptrace documentation 32 | `_ 33 | * `python-ptrace at GitHub 34 | `_ 35 | * `python-ptrace at the Python Cheeseshop (PyPI) 36 | `_ 37 | 38 | python-ptrace is an opensource project written in Python under GNU GPLv2 39 | license. 40 | 41 | Platform: UNKNOWN 42 | Classifier: Intended Audience :: Developers 43 | Classifier: Development Status :: 7 - Inactive 44 | Classifier: Environment :: Console 45 | Classifier: License :: OSI Approved :: GNU General Public License (GPL) 46 | Classifier: Operating System :: OS Independent 47 | Classifier: Natural Language :: English 48 | Classifier: Programming Language :: Python 49 | Classifier: Programming Language :: Python :: 3 50 | -------------------------------------------------------------------------------- /installCptrace/python_ptrace.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | README.rst 2 | setup.py 3 | strace.py 4 | ptrace/__init__.py 5 | ptrace/cpu_info.py 6 | ptrace/ctypes_libc.py 7 | ptrace/ctypes_tools.py 8 | ptrace/disasm.py 9 | ptrace/error.py 10 | ptrace/func_arg.py 11 | ptrace/func_call.py 12 | ptrace/linux_proc.py 13 | ptrace/logging_tools.py 14 | ptrace/mockup.py 15 | ptrace/os_tools.py 16 | ptrace/process_tools.py 17 | ptrace/profiler.py 18 | ptrace/pydistorm.py 19 | ptrace/signames.py 20 | ptrace/terminal.py 21 | ptrace/tools.py 22 | ptrace/version.py 23 | ptrace/binding/__init__.py 24 | ptrace/binding/cpu.py 25 | ptrace/binding/freebsd_struct.py 26 | ptrace/binding/func.py 27 | ptrace/binding/linux_struct.py 28 | ptrace/binding/openbsd_struct.py 29 | ptrace/debugger/__init__.py 30 | ptrace/debugger/application.py 31 | ptrace/debugger/backtrace.py 32 | ptrace/debugger/breakpoint.py 33 | ptrace/debugger/child.py 34 | ptrace/debugger/debugger.py 35 | ptrace/debugger/memory_mapping.py 36 | ptrace/debugger/parse_expr.py 37 | ptrace/debugger/process.py 38 | ptrace/debugger/process_error.py 39 | ptrace/debugger/process_event.py 40 | ptrace/debugger/ptrace_signal.py 41 | ptrace/debugger/signal_reason.py 42 | ptrace/debugger/syscall_state.py 43 | ptrace/syscall/__init__.py 44 | ptrace/syscall/freebsd_constants.py 45 | ptrace/syscall/freebsd_syscall.py 46 | ptrace/syscall/linux_constants.py 47 | ptrace/syscall/linux_struct.py 48 | ptrace/syscall/linux_syscall32.py 49 | ptrace/syscall/linux_syscall64.py 50 | ptrace/syscall/names.py 51 | ptrace/syscall/posix_arg.py 52 | ptrace/syscall/posix_constants.py 53 | ptrace/syscall/prototypes.py 54 | ptrace/syscall/ptrace_syscall.py 55 | ptrace/syscall/socketcall.py 56 | ptrace/syscall/socketcall_constants.py 57 | ptrace/syscall/socketcall_struct.py 58 | ptrace/syscall/syscall_argument.py 59 | python_ptrace.egg-info/PKG-INFO 60 | python_ptrace.egg-info/SOURCES.txt 61 | python_ptrace.egg-info/dependency_links.txt 62 | python_ptrace.egg-info/requires.txt 63 | python_ptrace.egg-info/top_level.txt -------------------------------------------------------------------------------- /installCptrace/python_ptrace.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /installCptrace/python_ptrace.egg-info/requires.txt: -------------------------------------------------------------------------------- 1 | six 2 | -------------------------------------------------------------------------------- /installCptrace/python_ptrace.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | ptrace 2 | -------------------------------------------------------------------------------- /installCptrace/setup_cptrace.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | SOURCES = ['cptrace/cptrace.c'] 4 | 5 | CLASSIFIERS = [ 6 | 'Intended Audience :: Developers', 7 | 'Development Status :: 4 - Beta', 8 | 'Environment :: Console', 9 | 'License :: OSI Approved :: GNU General Public License (GPL)', 10 | 'Operating System :: OS Independent', 11 | 'Natural Language :: English', 12 | 'Programming Language :: C', 13 | 'Programming Language :: Python', 14 | ] 15 | 16 | LONG_DESCRIPTION = open('doc/cptrace.rst').read() 17 | 18 | 19 | def main(): 20 | from imp import load_source 21 | from os import path 22 | from sys import argv 23 | 24 | if "--setuptools" in argv: 25 | argv.remove("--setuptools") 26 | from setuptools import setup, Extension 27 | else: 28 | from distutils.core import setup, Extension 29 | 30 | cptrace_ext = Extension('cptrace', sources=SOURCES) 31 | 32 | cptrace = load_source("version", path.join("cptrace", "version.py")) 33 | 34 | install_options = { 35 | "name": cptrace.PACKAGE, 36 | "version": cptrace.VERSION, 37 | "url": cptrace.WEBSITE, 38 | "download_url": cptrace.WEBSITE, 39 | "license": cptrace.LICENSE, 40 | "author": "Victor Stinner", 41 | "description": "python binding of ptrace written in C", 42 | "long_description": LONG_DESCRIPTION, 43 | "classifiers": CLASSIFIERS, 44 | "ext_modules": [cptrace_ext], 45 | } 46 | setup(**install_options) 47 | 48 | 49 | if __name__ == "__main__": 50 | main() 51 | -------------------------------------------------------------------------------- /launcher/babymalloc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/launcher/babymalloc -------------------------------------------------------------------------------- /launcher/babymalloc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define N 20 4 | 5 | int main(){ 6 | puts("starting testmalloc"); 7 | 8 | float junk=0.1f; 9 | 10 | for (volatile int i=0; i<0x1FffFFff;i++){ 11 | junk*= (0.45f-junk); 12 | } 13 | 14 | puts("after loop"); 15 | 16 | 17 | 18 | puts("gonna malloc N"); 19 | 20 | int* buf= malloc(sizeof(int) * N); 21 | 22 | printf("buf= %llx",buf); 23 | 24 | for (volatile int i=0; i<0x1FffFFff;i++){ 25 | junk*= (0.45f-junk); 26 | } 27 | 28 | 29 | } 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /launcher/dummylauncher: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haxkor/forkever/ddfc10577155c0e1b5e0ce2fd07ad3ebc455fbc4/launcher/dummylauncher -------------------------------------------------------------------------------- /launcher/launcher.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define NO_CHANGE 0xffffffff 8 | 9 | volatile int go=0; 10 | volatile int current_personality=0; 11 | volatile int add_personality= NO_CHANGE; 12 | 13 | int main(int argc, char** argv){ 14 | struct rlimit rlim; 15 | int ret= getrlimit(RLIMIT_NPROC, &rlim); 16 | 17 | if (ret){ 18 | perror("getrlimit"); 19 | exit(1); 20 | } 21 | 22 | rlim.rlim_cur = rlim.rlim_max; 23 | ret = setrlimit(RLIMIT_NPROC, &rlim); 24 | 25 | //printf("flag= %x\n", ADDR_NO_RANDOMIZE); 26 | 27 | current_personality=personality(NO_CHANGE); 28 | while( add_personality == NO_CHANGE){} 29 | personality(current_personality | add_personality); 30 | 31 | //puts("go"); 32 | execve(argv[1],argv + 1,0); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /launcher/makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | CFLAGS = -g -Wall -pedantic -no-pie 3 | 4 | program: dummy.c 5 | $(CC) $(CFLAGS) -o dummylauncher dummy.c 6 | 7 | -------------------------------------------------------------------------------- /logging2.py: -------------------------------------------------------------------------------- 1 | # 2 | # This is a very dirty hack 3 | # Because pwntools uses its own logging implementation, things get messy 4 | # when ptrace.debugger wants to make use of the standard module. 5 | # This logging2 module is a proxy that forwards the "critical imports" 6 | # by python-ptrace to pwntools 7 | # 8 | 9 | from logging import * 10 | from pwnlib.log import getLogger 11 | 12 | logger = getLogger("pwnlib") 13 | 14 | 15 | def info(msg): 16 | logger.info(msg) 17 | 18 | def debug(msg): 19 | logger.debug(msg) 20 | 21 | 22 | def warning(msg): 23 | logger.warning(msg) 24 | 25 | 26 | def error(msg): 27 | logger.error(msg) 28 | 29 | 30 | def log(msg): 31 | logger.log(msg) 32 | -------------------------------------------------------------------------------- /ptrace/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.signames import SIGNAMES, signalName # noqa 2 | from ptrace.error import PtraceError # noqa 3 | -------------------------------------------------------------------------------- /ptrace/binding/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.binding.func import ( # noqa 2 | HAS_PTRACE_SINGLESTEP, HAS_PTRACE_EVENTS, 3 | HAS_PTRACE_IO, HAS_PTRACE_SIGINFO, HAS_PTRACE_GETREGS, 4 | REGISTER_NAMES, 5 | ptrace_attach, ptrace_traceme, 6 | ptrace_detach, ptrace_kill, 7 | ptrace_cont, ptrace_syscall, 8 | ptrace_setregs, 9 | ptrace_peektext, ptrace_poketext, 10 | ptrace_peekuser, 11 | ptrace_seize, ptrace_interrupt, ptrace_listen, #added by jasper 12 | ptrace_registers_t) 13 | if HAS_PTRACE_EVENTS: 14 | from ptrace.binding.func import (WPTRACEEVENT, # noqa 15 | PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK, PTRACE_EVENT_CLONE, 16 | PTRACE_EVENT_EXEC, PTRACE_EVENT_STOP, 17 | ptrace_setoptions, ptrace_geteventmsg) 18 | if HAS_PTRACE_SINGLESTEP: 19 | from ptrace.binding.func import ptrace_singlestep # noqa 20 | if HAS_PTRACE_SIGINFO: 21 | from ptrace.binding.func import ptrace_getsiginfo # noqa 22 | if HAS_PTRACE_IO: 23 | from ptrace.binding.func import ptrace_io # noqa 24 | from ptrace.binding.freebsd_struct import ( # noqa 25 | ptrace_io_desc, 26 | PIOD_READ_D, PIOD_WRITE_D, 27 | PIOD_READ_I, PIOD_WRITE_I) 28 | if HAS_PTRACE_GETREGS: 29 | from ptrace.binding.func import ptrace_getregs # noqa 30 | -------------------------------------------------------------------------------- /ptrace/binding/cpu.py: -------------------------------------------------------------------------------- 1 | from ptrace.cpu_info import ( 2 | CPU_POWERPC, CPU_INTEL, CPU_X86_64, CPU_I386, CPU_ARM) 3 | 4 | CPU_INSTR_POINTER = None 5 | CPU_STACK_POINTER = None 6 | CPU_FRAME_POINTER = None 7 | CPU_SUB_REGISTERS = {} 8 | 9 | if CPU_POWERPC: 10 | CPU_INSTR_POINTER = "nip" 11 | # FIXME: Is it the right register? 12 | CPU_STACK_POINTER = 'gpr1' 13 | elif CPU_ARM: 14 | CPU_INSTR_POINTER = 'r15' 15 | CPU_STACK_POINTER = 'r14' 16 | CPU_FRAME_POINTER = 'r11' 17 | elif CPU_X86_64: 18 | CPU_INSTR_POINTER = "rip" 19 | CPU_STACK_POINTER = "rsp" 20 | CPU_FRAME_POINTER = "rbp" 21 | CPU_SUB_REGISTERS = { 22 | # main register name, shift, mask 23 | 'al': ('rax', 0, 0xff), 24 | 'bl': ('rbx', 0, 0xff), 25 | 'cl': ('rcx', 0, 0xff), 26 | 'dl': ('rdx', 0, 0xff), 27 | 'ah': ('rax', 8, 0xff), 28 | 'bh': ('rbx', 8, 0xff), 29 | 'ch': ('rcx', 8, 0xff), 30 | 'dh': ('rdx', 8, 0xff), 31 | 'ax': ('rax', 0, 0xffff), 32 | 'bx': ('rbx', 0, 0xffff), 33 | 'cx': ('rcx', 0, 0xffff), 34 | 'dx': ('rdx', 0, 0xffff), 35 | 'eax': ('rax', 32, None), 36 | 'ebx': ('rbx', 32, None), 37 | 'ecx': ('rcx', 32, None), 38 | 'edx': ('rdx', 32, None), 39 | } 40 | elif CPU_I386: 41 | CPU_INSTR_POINTER = "eip" 42 | CPU_STACK_POINTER = "esp" 43 | CPU_FRAME_POINTER = "ebp" 44 | CPU_SUB_REGISTERS = { 45 | 'al': ('eax', 0, 0xff), 46 | 'bl': ('ebx', 0, 0xff), 47 | 'cl': ('ecx', 0, 0xff), 48 | 'dl': ('edx', 0, 0xff), 49 | 'ah': ('eax', 8, 0xff), 50 | 'bh': ('ebx', 8, 0xff), 51 | 'ch': ('ecx', 8, 0xff), 52 | 'dh': ('edx', 8, 0xff), 53 | 'ax': ('eax', 0, 0xffff), 54 | 'bx': ('ebx', 0, 0xffff), 55 | 'cx': ('ecx', 0, 0xffff), 56 | 'dx': ('edx', 0, 0xffff), 57 | } 58 | 59 | if CPU_INTEL: 60 | CPU_SUB_REGISTERS.update({ 61 | 'cf': ('eflags', 0, 1), 62 | 'pf': ('eflags', 2, 1), 63 | 'af': ('eflags', 4, 1), 64 | 'zf': ('eflags', 6, 1), 65 | 'sf': ('eflags', 7, 1), 66 | 'tf': ('eflags', 8, 1), 67 | 'if': ('eflags', 9, 1), 68 | 'df': ('eflags', 10, 1), 69 | 'of': ('eflags', 11, 1), 70 | 'iopl': ('eflags', 12, 2), 71 | }) 72 | -------------------------------------------------------------------------------- /ptrace/binding/freebsd_struct.py: -------------------------------------------------------------------------------- 1 | from ctypes import (Structure, 2 | c_int, c_uint, c_ulong, c_void_p, 3 | c_uint16, c_uint32, c_size_t) 4 | from ptrace.cpu_info import CPU_X86_64 5 | 6 | PIOD_READ_D = 1 7 | PIOD_WRITE_D = 2 8 | PIOD_READ_I = 3 9 | PIOD_WRITE_I = 4 10 | 11 | # /usr/include/machine/reg.h 12 | if CPU_X86_64: 13 | register_t = c_ulong 14 | 15 | class reg(Structure): 16 | _fields_ = ( 17 | ("r15", register_t), 18 | ("r14", register_t), 19 | ("r13", register_t), 20 | ("r12", register_t), 21 | ("r11", register_t), 22 | ("r10", register_t), 23 | ("r9", register_t), 24 | ("r8", register_t), 25 | ("rdi", register_t), 26 | ("rsi", register_t), 27 | ("rbp", register_t), 28 | ("rbx", register_t), 29 | ("rdx", register_t), 30 | ("rcx", register_t), 31 | ("rax", register_t), 32 | ("trapno", c_uint32), 33 | ("fs", c_uint16), 34 | ("gs", c_uint16), 35 | ("err", c_uint32), 36 | ("es", c_uint16), 37 | ("ds", c_uint16), 38 | ("rip", register_t), 39 | ("cs", register_t), 40 | ("rflags", register_t), 41 | ("rsp", register_t), 42 | ("ss", register_t), 43 | ) 44 | else: 45 | class reg(Structure): 46 | _fields_ = ( 47 | ("fs", c_uint), 48 | ("es", c_uint), 49 | ("ds", c_uint), 50 | ("edi", c_uint), 51 | ("esi", c_uint), 52 | ("ebp", c_uint), 53 | ("isp", c_uint), 54 | ("ebx", c_uint), 55 | ("edx", c_uint), 56 | ("ecx", c_uint), 57 | ("eax", c_uint), 58 | ("trapno", c_uint), 59 | ("err", c_uint), 60 | ("eip", c_uint), 61 | ("cs", c_uint), 62 | ("eflags", c_uint), 63 | ("esp", c_uint), 64 | ("ss", c_uint), 65 | ("gs", c_uint), 66 | ) 67 | 68 | 69 | class ptrace_io_desc(Structure): 70 | _fields_ = ( 71 | ("piod_op", c_int), 72 | ("piod_offs", c_void_p), 73 | ("piod_addr", c_void_p), 74 | ("piod_len", c_size_t), 75 | ) 76 | -------------------------------------------------------------------------------- /ptrace/binding/openbsd_struct.py: -------------------------------------------------------------------------------- 1 | from ctypes import Structure, c_int, c_uint, c_ulong, c_void_p, c_char 2 | 3 | PIOD_READ_D = 1 4 | PIOD_WRITE_D = 2 5 | PIOD_READ_I = 3 6 | PIOD_WRITE_I = 4 7 | 8 | size_t = c_ulong 9 | pid_t = c_int 10 | 11 | # /usr/include/machine/reg.h 12 | 13 | 14 | class reg(Structure): 15 | _fields_ = ( 16 | ("eax", c_uint), 17 | ("ecx", c_uint), 18 | ("edx", c_uint), 19 | ("ebx", c_uint), 20 | ("esp", c_uint), 21 | ("ebp", c_uint), 22 | ("esi", c_uint), 23 | ("edi", c_uint), 24 | ("eip", c_uint), 25 | ("eflags", c_uint), 26 | ("cs", c_uint), 27 | ("ss", c_uint), 28 | ("ds", c_uint), 29 | ("es", c_uint), 30 | ("fs", c_uint), 31 | ("gs", c_uint), 32 | ) 33 | 34 | 35 | class fpreg(Structure): 36 | _fields_ = ( 37 | ("__data", c_char * 116), 38 | ) 39 | 40 | 41 | class ptrace_io_desc(Structure): 42 | _fields_ = ( 43 | ("piod_op", c_int), 44 | ("piod_offs", c_void_p), 45 | ("piod_addr", c_void_p), 46 | ("piod_len", size_t), 47 | ) 48 | -------------------------------------------------------------------------------- /ptrace/cpu_info.py: -------------------------------------------------------------------------------- 1 | """ 2 | Constants about the CPU: 3 | 4 | - CPU_BIGENDIAN (bool) 5 | - CPU_64BITS (bool) 6 | - CPU_WORD_SIZE (int) 7 | - CPU_MAX_UINT (int) 8 | - CPU_PPC32 (bool) 9 | - CPU_PPC64 (bool) 10 | - CPU_I386 (bool) 11 | - CPU_X86_64 (bool) 12 | - CPU_INTEL (bool) 13 | - CPU_POWERPC (bool) 14 | """ 15 | 16 | try: 17 | from os import uname 18 | HAS_UNAME = True 19 | except ImportError: 20 | HAS_UNAME = False 21 | from platform import architecture 22 | from sys import byteorder 23 | from ctypes import sizeof, c_void_p 24 | 25 | CPU_BIGENDIAN = (byteorder == 'big') 26 | CPU_64BITS = (sizeof(c_void_p) == 8) 27 | 28 | if CPU_64BITS: 29 | CPU_WORD_SIZE = 8 # bytes 30 | CPU_MAX_UINT = 0xffffffffffffffff 31 | else: 32 | CPU_WORD_SIZE = 4 # bytes 33 | CPU_MAX_UINT = 0xffffffff 34 | 35 | if HAS_UNAME: 36 | # guess machine type using uname() 37 | _machine = uname()[4] 38 | CPU_PPC32 = (_machine == 'ppc') 39 | CPU_PPC64 = (_machine == 'ppc64') 40 | CPU_I386 = (_machine in ("i386", "i686")) # compatible Intel 32 bits 41 | CPU_X86_64 = (_machine in ("x86_64", "amd64")) # compatible Intel 64 bits 42 | CPU_ARM = _machine.startswith('arm') 43 | del _machine 44 | else: 45 | # uname() fallback for Windows 46 | # I hope that your Windows doesn't run on PPC32/PPC64 47 | CPU_PPC32 = False 48 | CPU_PPC64 = False 49 | CPU_I386 = False 50 | CPU_X86_64 = False 51 | CPU_ARM = False 52 | bits, linkage = architecture() 53 | if bits == '32bit': 54 | CPU_I386 = True 55 | elif bits == '64bit': 56 | CPU_X86_64 = True 57 | else: 58 | raise ValueError("Unknown architecture bits: %r" % bits) 59 | 60 | CPU_INTEL = (CPU_I386 or CPU_X86_64) 61 | CPU_POWERPC = (CPU_PPC32 or CPU_PPC64) 62 | -------------------------------------------------------------------------------- /ptrace/ctypes_libc.py: -------------------------------------------------------------------------------- 1 | """ 2 | Load the system C library. Variables: 3 | - LIBC_FILENAME: the C library filename 4 | - libc: the loaded library 5 | """ 6 | 7 | from ctypes import CDLL 8 | from ctypes.util import find_library 9 | 10 | LIBC_FILENAME = find_library('c') 11 | libc = CDLL(LIBC_FILENAME, use_errno=True) 12 | -------------------------------------------------------------------------------- /ptrace/debugger/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.debugger.breakpoint import Breakpoint # noqa 2 | from ptrace.debugger.process_event import (ProcessEvent, ProcessExit, # noqa 3 | NewProcessEvent, ProcessExecution) 4 | from ptrace.debugger.ptrace_signal import ProcessSignal # noqa 5 | from ptrace.debugger.process_error import ProcessError # noqa 6 | from ptrace.debugger.child import ChildError # noqa 7 | from ptrace.debugger.process import PtraceProcess # noqa 8 | from ptrace.debugger.debugger import PtraceDebugger, DebuggerError # noqa 9 | from ptrace.debugger.application import Application # noqa 10 | -------------------------------------------------------------------------------- /ptrace/debugger/breakpoint.py: -------------------------------------------------------------------------------- 1 | from ptrace.ctypes_tools import formatAddress 2 | from ptrace import PtraceError 3 | from logging2 import info 4 | from weakref import ref 5 | from ptrace.cpu_info import CPU_POWERPC, CPU_WORD_SIZE 6 | from ptrace.ctypes_tools import word2bytes 7 | from six import b 8 | 9 | 10 | class Breakpoint(object): 11 | """ 12 | Software breakpoint. 13 | 14 | Use desinstall() method to remove the breakpoint from the process. 15 | """ 16 | 17 | def __init__(self, process, address, size=None): 18 | self._installed = False 19 | self.process = ref(process) 20 | self.address = address 21 | if CPU_POWERPC: 22 | size = CPU_WORD_SIZE 23 | elif size is None: 24 | size = 1 25 | self.size = size 26 | 27 | # Store instruction bytes 28 | info("Install %s" % self) 29 | self.old_bytes = process.readBytes(address, size) 30 | 31 | if CPU_POWERPC: 32 | # Replace instruction with "TRAP" 33 | new_bytes = word2bytes(0x0cc00000) 34 | else: 35 | # Replace instruction with "INT 3" 36 | new_bytes = b("\xCC") * size 37 | process.writeBytes(address, new_bytes) 38 | self._installed = True 39 | 40 | def desinstall(self, set_ip=False): 41 | """ 42 | Remove the breakpoint from the associated process. If set_ip is True, 43 | restore the instruction pointer to the address of the breakpoint. 44 | """ 45 | if not self._installed: 46 | return 47 | self._installed = False 48 | info("Desinstall %s" % self) 49 | process = self.process() 50 | if not process: 51 | return 52 | if process.running: 53 | process.writeBytes(self.address, self.old_bytes) 54 | if set_ip: 55 | process.setInstrPointer(self.address) 56 | process.removeBreakpoint(self) 57 | 58 | def __str__(self): 59 | return "" % ( 60 | formatAddress(self.address), 61 | formatAddress(self.address + self.size - 1)) 62 | 63 | def __del__(self): 64 | try: 65 | self.desinstall(False) 66 | except PtraceError: 67 | pass 68 | -------------------------------------------------------------------------------- /ptrace/debugger/parse_expr.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | # Match a register name: $eax, $gp0, $orig_eax 4 | REGISTER_REGEX = re.compile(r"([a-z]+[a-z0-9_]+)") 5 | 6 | # Hexadecimal number (e.g. 0xa) 7 | HEXADECIMAL_REGEX = re.compile(r"0x[0-9a-f]+") 8 | 9 | # Make sure that the expression does not contain invalid characters 10 | # Examples: 11 | # (1-2)<<5 12 | # 340&91 13 | EXPR_REGEX = re.compile(r"^[()<>+*/&0-9-]+$") 14 | 15 | 16 | def replaceHexadecimal(regs): 17 | """ 18 | Convert an hexadecimal number to decimal number (as string). 19 | Callback used by parseExpression(). 20 | """ 21 | text = regs.group(0) 22 | if text.startswith("0x"): 23 | text = text[2:] 24 | elif not re.search("[a-f]", text): 25 | return text 26 | value = int(text, 16) 27 | return str(value) 28 | 29 | 30 | def parseExpression(process, text): 31 | """ 32 | Parse an expression. Syntax: 33 | - "10": decimal number 34 | - "0x10": hexadecimal number 35 | - "eax": register value 36 | - "a+b", "a-b", "a*b", "a/b", "a**b", "a<>b": operators 37 | 38 | >>> from ptrace.mockup import FakeProcess 39 | >>> process = FakeProcess() 40 | >>> parseExpression(process, "1+1") 41 | 2 42 | >>> process.setreg("eax", 3) 43 | >>> parseExpression(process, "eax*0x10") 44 | 48 45 | """ 46 | # Remove spaces and convert to lower case 47 | text = text.strip() 48 | orig_text = text 49 | if " " in text: 50 | raise ValueError("Space are forbidden: %r" % text) 51 | text = text.lower() 52 | 53 | def readRegister(regs): 54 | name = regs.group(1) 55 | value = process.getreg(name) 56 | return str(value) 57 | 58 | # Replace hexadecimal by decimal 59 | text = HEXADECIMAL_REGEX.sub(replaceHexadecimal, text) 60 | 61 | # Replace registers by their value 62 | text = REGISTER_REGEX.sub(readRegister, text) 63 | 64 | # Reject invalid characters 65 | if not EXPR_REGEX.match(text): 66 | raise ValueError("Invalid expression: %r" % orig_text) 67 | 68 | # Use integer division (a//b) instead of float division (a/b) 69 | text = text.replace("/", "//") 70 | 71 | # Finally, evaluate the expression 72 | try: 73 | value = eval(text) 74 | except SyntaxError: 75 | raise ValueError("Invalid expression: %r" % orig_text) 76 | return value 77 | -------------------------------------------------------------------------------- /ptrace/debugger/process_error.py: -------------------------------------------------------------------------------- 1 | from ptrace.error import PtraceError 2 | 3 | 4 | class ProcessError(PtraceError): 5 | 6 | def __init__(self, process, message): 7 | PtraceError.__init__(self, message, pid=process.pid) 8 | self.process = process 9 | -------------------------------------------------------------------------------- /ptrace/debugger/syscall_state.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall import PtraceSyscall 2 | from signal import SIGTRAP 3 | 4 | 5 | class SyscallState(object): 6 | 7 | def __init__(self, process): 8 | self.process = process 9 | self.ignore_exec_trap = True 10 | self.ignore_callback = None 11 | self.clear() 12 | 13 | def event(self, options): 14 | if self.next_event == "exit": 15 | return self.exit() 16 | else: 17 | return self.enter(options) 18 | 19 | def enter(self, options): 20 | # syscall enter 21 | regs = self.process.getregs() 22 | self.syscall = PtraceSyscall(self.process, options, regs) 23 | self.name = self.syscall.name 24 | if (not self.ignore_callback) \ 25 | or (not self.ignore_callback(self.syscall)): 26 | self.syscall.enter(regs) 27 | else: 28 | self.syscall = None 29 | self.next_event = "exit" 30 | return self.syscall 31 | 32 | def exit(self): 33 | if self.syscall: 34 | self.syscall.exit() 35 | if self.ignore_exec_trap \ 36 | and self.name == "execve" \ 37 | and not self.process.debugger.trace_exec: 38 | # Ignore the SIGTRAP after exec() syscall exit 39 | self.process.syscall() 40 | self.process.waitSignals(SIGTRAP) 41 | syscall = self.syscall 42 | self.clear() 43 | return syscall 44 | 45 | def clear(self): 46 | self.syscall = None 47 | self.name = None 48 | self.next_event = "enter" 49 | -------------------------------------------------------------------------------- /ptrace/error.py: -------------------------------------------------------------------------------- 1 | from sys import exc_info 2 | from traceback import format_exception 3 | from logging2 import ERROR, getLogger, WARNING 4 | from ptrace.logging_tools import getLogFunc, changeLogLevel 5 | 6 | PTRACE_ERRORS = Exception 7 | 8 | 9 | def writeBacktrace(logger, log_level=ERROR): 10 | """ 11 | Write a backtrace into the logger with the specified log level. 12 | """ 13 | log_func = getLogFunc(logger, log_level) 14 | try: 15 | info = exc_info() 16 | trace = format_exception(*info) 17 | if trace[0] != "None\n": 18 | trace = ''.join(trace).rstrip() 19 | for line in trace.split("\n"): 20 | log_func(line.rstrip()) 21 | return 22 | except Exception: 23 | pass 24 | log_func("Unable to get backtrace") 25 | 26 | 27 | def formatError(error): 28 | """ 29 | Format an error as a string. Write the error type as prefix. 30 | Eg. "[ValueError] invalid value". 31 | """ 32 | return "[%s] %s" % (error.__class__.__name__, error) 33 | 34 | 35 | def writeError(logger, error, title="ERROR", log_level=ERROR): 36 | """ 37 | Write an error into the logger: 38 | - logger: the logger (if None, use getLogger()) 39 | - error: the exception object 40 | - title: error message prefix (e.g. title="Initialization error") 41 | - log_level: log level of the error 42 | 43 | If the exception is a SystemExit or a KeyboardInterrupt, re-emit 44 | (raise) the exception and don't write it. 45 | """ 46 | if not logger: 47 | logger = getLogger("error") 48 | if error.__class__ in (SystemExit, KeyboardInterrupt): 49 | raise error 50 | log_level=WARNING # to avoid a pwnlib exception raise 51 | log_func = getLogFunc(logger, log_level) 52 | log_func("%s: %s" % (title, formatError(error))) 53 | writeBacktrace(logger, log_level=changeLogLevel(log_level, -1)) 54 | 55 | 56 | class PtraceError(Exception): 57 | """ 58 | Ptrace error: have the optional attributes errno and pid. 59 | """ 60 | 61 | def __init__(self, message, errno=None, pid=None): 62 | Exception.__init__(self, message) 63 | self.errno = errno 64 | self.pid = pid 65 | -------------------------------------------------------------------------------- /ptrace/logging_tools.py: -------------------------------------------------------------------------------- 1 | from ptrace.tools import minmax 2 | from logging2 import ERROR, WARNING, INFO, DEBUG 3 | 4 | 5 | def getLogFunc(logger, level): 6 | """ 7 | Get the logger function for the specified logging level. 8 | """ 9 | if level == ERROR: 10 | return logger.error 11 | elif level == WARNING: 12 | return logger.warning 13 | elif level == INFO: 14 | return logger.info 15 | elif level == DEBUG: 16 | return logger.debug 17 | else: 18 | return logger.error 19 | 20 | 21 | def changeLogLevel(level, delta): 22 | """ 23 | Compute log level and make sure that the result is in DEBUG..ERROR. 24 | 25 | >>> changeLogLevel(ERROR, -1) == WARNING 26 | True 27 | >>> changeLogLevel(DEBUG, 1) == INFO 28 | True 29 | """ 30 | return minmax(DEBUG, level + delta * 10, ERROR) 31 | -------------------------------------------------------------------------------- /ptrace/mockup.py: -------------------------------------------------------------------------------- 1 | """ 2 | Mockup classes used in unit tests. 3 | """ 4 | 5 | 6 | class FakeProcess(object): 7 | 8 | def __init__(self): 9 | self.regs = {} 10 | 11 | def setreg(self, name, value): 12 | self.regs[name] = value 13 | 14 | def getreg(self, name): 15 | return self.regs[name] 16 | -------------------------------------------------------------------------------- /ptrace/os_tools.py: -------------------------------------------------------------------------------- 1 | """ 2 | Constants about the operating system: 3 | 4 | - RUNNING_PYPY (bool) 5 | - RUNNING_WINDOWS (bool) 6 | - RUNNING_LINUX (bool) 7 | - RUNNING_FREEBSD (bool) 8 | - RUNNING_OPENBSD (bool) 9 | - RUNNING_MACOSX (bool) 10 | - RUNNING_BSD (bool) 11 | - HAS_PROC (bool) 12 | - HAS_PTRACE (bool) 13 | """ 14 | 15 | from sys import platform, version, version_info 16 | 17 | RUNNING_PYTHON3 = version_info[0] == 3 18 | RUNNING_PYPY = ("pypy" in version.lower()) 19 | RUNNING_WINDOWS = (platform == 'win32') 20 | RUNNING_LINUX = platform.startswith('linux') 21 | RUNNING_FREEBSD = (platform.startswith('freebsd') 22 | or platform.startswith('gnukfreebsd')) 23 | RUNNING_OPENBSD = platform.startswith('openbsd') 24 | RUNNING_MACOSX = (platform == 'darwin') 25 | RUNNING_BSD = RUNNING_FREEBSD or RUNNING_MACOSX or RUNNING_OPENBSD 26 | 27 | HAS_PROC = RUNNING_LINUX 28 | HAS_PTRACE = (RUNNING_BSD or RUNNING_LINUX) 29 | -------------------------------------------------------------------------------- /ptrace/profiler.py: -------------------------------------------------------------------------------- 1 | from hotshot import Profile 2 | from hotshot.stats import load as loadStats 3 | from os import unlink 4 | from io import StringIO 5 | 6 | 7 | def runProfiler(logger, func, args=tuple(), kw={}, 8 | verbose=True, nb_func=25, 9 | sort_by=('time',)): 10 | """ 11 | Run a function in a profiler and then display the functions sorted by time. 12 | """ 13 | profile_filename = "/tmp/profiler" 14 | prof = Profile(profile_filename) 15 | try: 16 | logger.warning("Run profiler") 17 | result = prof.runcall(func, *args, **kw) 18 | prof.close() 19 | logger.error("Profiler: Process data...") 20 | stat = loadStats(profile_filename) 21 | stat.strip_dirs() 22 | stat.sort_stats(*sort_by) 23 | 24 | logger.error("Profiler: Result:") 25 | log = StringIO() 26 | stat.stream = log 27 | stat.print_stats(nb_func) 28 | log.seek(0) 29 | for line in log: 30 | logger.error(line.rstrip()) 31 | return result 32 | finally: 33 | unlink(profile_filename) 34 | -------------------------------------------------------------------------------- /ptrace/signames.py: -------------------------------------------------------------------------------- 1 | """ 2 | Name of process signals. 3 | 4 | SIGNAMES contains a dictionary mapping a signal number to it's name. But you 5 | should better use signalName() instead of SIGNAMES since it returns a string 6 | even if the signal is unknown. 7 | """ 8 | 9 | PREFERRED_NAMES = ("SIGABRT", "SIGHUP", "SIGCHLD", "SIGPOLL") 10 | 11 | 12 | def getSignalNames(): 13 | """ 14 | Create signal names dictionary (e.g. 9 => 'SIGKILL') using dir(signal). 15 | If multiple signal names have the same number, use the first matching name 16 | in PREFERRED_NAME to select preferred name (e.g. SIGIOT=SIGABRT=17). 17 | """ 18 | import signal 19 | allnames = {} 20 | for name in dir(signal): 21 | if not name.startswith("SIG"): 22 | continue 23 | signum = getattr(signal, name) 24 | try: 25 | allnames[signum].append(name) 26 | except KeyError: 27 | allnames[signum] = [name] 28 | signames = {} 29 | for signum, names in allnames.items(): 30 | if not signum: 31 | # Skip signal 0 32 | continue 33 | name = None 34 | for preferred in PREFERRED_NAMES: 35 | if preferred in names: 36 | name = preferred 37 | break 38 | if not name: 39 | name = names[0] 40 | signames[signum] = name 41 | return signames 42 | 43 | 44 | SIGNAMES = getSignalNames() 45 | 46 | 47 | def signalName(signum): 48 | """ 49 | Get the name of a signal 50 | 51 | >>> from signal import SIGINT 52 | >>> signalName(SIGINT) 53 | 'SIGINT' 54 | >>> signalName(404) 55 | 'signal<404>' 56 | """ 57 | try: 58 | return SIGNAMES[signum] 59 | except KeyError: 60 | return "signal<%s>" % signum 61 | -------------------------------------------------------------------------------- /ptrace/syscall/__init__.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.names import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES # noqa 2 | from ptrace.syscall.prototypes import SYSCALL_PROTOTYPES, FILENAME_ARGUMENTS, DIRFD_ARGUMENTS # noqa 3 | from ptrace.syscall.syscall_argument import SyscallArgument # noqa 4 | from ptrace.syscall.ptrace_syscall import PtraceSyscall, SYSCALL_REGISTER, RETURN_VALUE_REGISTER # noqa 5 | -------------------------------------------------------------------------------- /ptrace/syscall/freebsd_constants.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.posix_constants import SYSCALL_ARG_DICT 2 | 3 | RLIMIT_RESOURCE = { 4 | 0: "RLIMIT_CPU", 5 | 1: "RLIMIT_FSIZE", 6 | 2: "RLIMIT_DATA", 7 | 3: "RLIMIT_STACK", 8 | 4: "RLIMIT_CORE", 9 | 5: "RLIMIT_RSS", 10 | 6: "RLIMIT_MEMLOCK", 11 | 7: "RLIMIT_NPROC", 12 | 8: "RLIMIT_NOFILE", 13 | 9: "RLIMIT_SBSIZE", 14 | 10: "RLIMIT_VMEM", 15 | } 16 | 17 | SIGPROCMASK_HOW = {1: " SIG_BLOCK", 2: "SIG_UNBLOCK", 3: "SIG_SETMASK"} 18 | 19 | SYSCALL_ARG_DICT.update({ 20 | "getrlimit": {"resource": RLIMIT_RESOURCE}, 21 | "setrlimit": {"resource": RLIMIT_RESOURCE}, 22 | "sigprocmask": {"how": SIGPROCMASK_HOW}, 23 | "rt_sigprocmask": {"how": SIGPROCMASK_HOW}, 24 | }) 25 | -------------------------------------------------------------------------------- /ptrace/syscall/linux_constants.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.posix_constants import SYSCALL_ARG_DICT 2 | 3 | SIGSET_SIZE = 64 4 | FD_SETSIZE = 1024 5 | 6 | RLIMIT_RESOURCE = { 7 | 0: "RLIMIT_CPU", 8 | 1: "RLIMIT_FSIZE", 9 | 2: "RLIMIT_DATA", 10 | 3: "RLIMIT_STACK", 11 | 4: "RLIMIT_CORE", 12 | 5: "RLIMIT_RSS", 13 | 6: "RLIMIT_NPROC", 14 | 7: "RLIMIT_NOFILE", 15 | 8: "RLIMIT_MEMLOCK", 16 | 9: "RLIMIT_AS", 17 | 10: "RLIMIT_LOCKS", 18 | 11: "RLIMIT_SIGPENDING", 19 | 12: "RLIMIT_MSGQUEUE", 20 | 13: "RLIMIT_NICE", 21 | 14: "RLIMIT_RTPRIO", 22 | 15: "RLIMIT_NLIMITS", 23 | } 24 | 25 | SIGPROCMASK_HOW = {0: "SIG_BLOCK", 1: "SIG_UNBLOCK", 2: "SIG_SETMASK"} 26 | 27 | SYSCALL_ARG_DICT.update({ 28 | "getrlimit": {"resource": RLIMIT_RESOURCE}, 29 | "setrlimit": {"resource": RLIMIT_RESOURCE}, 30 | "sigprocmask": {"how": SIGPROCMASK_HOW}, 31 | "rt_sigprocmask": {"how": SIGPROCMASK_HOW}, 32 | }) 33 | -------------------------------------------------------------------------------- /ptrace/syscall/linux_struct.py: -------------------------------------------------------------------------------- 1 | from ctypes import (Structure, 2 | c_char, c_short, c_int, c_uint, c_long, c_ulong) 3 | 4 | time_t = c_long 5 | suseconds_t = c_long 6 | rlim_t = c_long 7 | 8 | 9 | class timeval(Structure): 10 | _fields_ = ( 11 | ("tv_sec", time_t), 12 | ("tv_usec", suseconds_t), 13 | ) 14 | 15 | 16 | class timespec(Structure): 17 | _fields_ = ( 18 | ("tv_sec", time_t), 19 | ("tv_nsec", c_long), 20 | ) 21 | 22 | 23 | class pollfd(Structure): 24 | _fields_ = ( 25 | ("fd", c_int), 26 | ("events", c_short), 27 | ("revents", c_short), 28 | ) 29 | 30 | 31 | class rlimit(Structure): 32 | _fields_ = ( 33 | ("rlim_cur", rlim_t), 34 | ("rlim_max", rlim_t), 35 | ) 36 | 37 | 38 | class new_utsname(Structure): 39 | _fields_ = ( 40 | ("sysname", c_char * 65), 41 | ("nodename", c_char * 65), 42 | ("release", c_char * 65), 43 | ("version", c_char * 65), 44 | ("machine", c_char * 65), 45 | ("domainname", c_char * 65), 46 | ) 47 | 48 | # Arch depend 49 | 50 | 51 | class user_desc(Structure): 52 | _fields_ = ( 53 | ("entry_number", c_uint), 54 | ("base_addr", c_ulong), 55 | ("limit", c_uint), 56 | ("_bits_", c_char), 57 | # unsigned int seg_32bit:1; 58 | # unsigned int contents:2; 59 | # unsigned int read_exec_only:1; 60 | # unsigned int limit_in_pages:1; 61 | # unsigned int seg_not_present:1; 62 | # unsigned int useable:1; 63 | ) 64 | -------------------------------------------------------------------------------- /ptrace/syscall/names.py: -------------------------------------------------------------------------------- 1 | from ptrace.cpu_info import CPU_64BITS 2 | from ptrace.os_tools import RUNNING_LINUX, RUNNING_FREEBSD 3 | if RUNNING_LINUX: 4 | if CPU_64BITS: 5 | from ptrace.syscall.linux_syscall64 import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES 6 | else: 7 | from ptrace.syscall.linux_syscall32 import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES 8 | elif RUNNING_FREEBSD: 9 | from ptrace.syscall.freebsd_syscall import SYSCALL_NAMES, SOCKET_SYSCALL_NAMES 10 | else: 11 | SYSCALL_NAMES = {} 12 | SOCKET_SYSCALL_NAMES = set() 13 | -------------------------------------------------------------------------------- /ptrace/syscall/posix_constants.py: -------------------------------------------------------------------------------- 1 | from ptrace.syscall.socketcall_constants import ( 2 | SOCKET_FAMILY, SOCKET_PROTOCOL, 3 | SETSOCKOPT_LEVEL, SETSOCKOPT_OPTNAME) 4 | 5 | SYSCALL_ARG_DICT = { 6 | "lseek": { 7 | "origin": {0: "SEEK_SET", 1: "SEEK_CUR", 2: "SEEK_END"}, 8 | }, 9 | "futex": { 10 | "op": { 11 | 0: "FUTEX_WAIT", 12 | 1: "FUTEX_WAKE", 13 | 2: "FUTEX_FD", 14 | 3: "FUTEX_REQUEUE", 15 | 4: "FUTEX_CMP_REQUEUE", 16 | 5: "FUTEX_WAKE_OP", 17 | 6: "FUTEX_LOCK_PI", 18 | 7: "FUTEX_UNLOCK_PI", 19 | 8: "FUTEX_TRYLOCK_PI", 20 | }, 21 | }, 22 | "fcntl": { 23 | "cmd": { 24 | 0: "F_DUPFD", 25 | 1: "F_GETFD", 26 | 2: "F_SETFD", 27 | 3: "F_GETFL", 28 | 4: "F_SETFL", 29 | 5: "F_GETOWN", 30 | 6: "F_SETOWN", 31 | 7: "F_GETLK", 32 | 8: "F_SETLK", 33 | 9: "F_SETLKW", 34 | }, 35 | }, 36 | "ipc": { 37 | "call": { 38 | 1: "SEMOP", 39 | 2: "SEMGET", 40 | 3: "SEMCTL", 41 | 4: "SEMTIMEDOP", 42 | 11: "MSGSND", 43 | 12: "MSGRCV", 44 | 13: "MSGGET", 45 | 14: "MSGCTL", 46 | 21: "SHMAT", 47 | 22: "SHMDT", 48 | 23: "SHMGET", 49 | 24: "SHMCTL", 50 | }, 51 | }, 52 | "socket": { 53 | "domain": SOCKET_FAMILY, 54 | "protocol": SOCKET_PROTOCOL, 55 | }, 56 | "getsockopt": { 57 | "level": SETSOCKOPT_LEVEL, 58 | "optname": SETSOCKOPT_OPTNAME, 59 | }, 60 | } 61 | 62 | SYSCALL_ARG_DICT["setsockopt"] = SYSCALL_ARG_DICT["getsockopt"] 63 | -------------------------------------------------------------------------------- /ptrace/syscall/socketcall_constants.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | SOCKETCALL = { 4 | 1: "socket", 5 | 2: "bind", 6 | 3: "connect", 7 | 4: "listen", 8 | 5: "accept", 9 | 6: "getsockname", 10 | 7: "getpeername", 11 | 8: "socketpair", 12 | 9: "send", 13 | 10: "recv", 14 | 11: "sendto", 15 | 12: "recvfrom", 16 | 13: "shutdown", 17 | 14: "setsockopt", 18 | 15: "getsockopt", 19 | 16: "sendmsg", 20 | 17: "recvmsg", 21 | } 22 | 23 | SOCKET_FAMILY = { 24 | 0: "AF_UNSPEC", 25 | 1: "AF_FILE", 26 | 2: "AF_INET", 27 | 3: "AF_AX25", 28 | 4: "AF_IPX", 29 | 5: "AF_APPLETALK", 30 | 6: "AF_NETROM", 31 | 7: "AF_BRIDGE", 32 | 8: "AF_ATMPVC", 33 | 9: "AF_X25", 34 | 10: "AF_INET6", 35 | 11: "AF_ROSE", 36 | 12: "AF_DECnet", 37 | 13: "AF_NETBEUI", 38 | 14: "AF_SECURITY", 39 | 15: "AF_KEY", 40 | 16: "AF_NETLINK", 41 | 17: "AF_PACKET", 42 | 18: "AF_ASH", 43 | 19: "AF_ECONET", 44 | 20: "AF_ATMSVC", 45 | 22: "AF_SNA", 46 | 23: "AF_IRDA", 47 | 24: "AF_PPPOX", 48 | 25: "AF_WANPIPE", 49 | 31: "AF_BLUETOOTH", 50 | } 51 | 52 | SOCKET_TYPE = { 53 | 1: "SOCK_STREAM", 54 | 2: "SOCK_DGRAM", 55 | 3: "SOCK_RAW", 56 | 4: "SOCK_RDM", 57 | 5: "SOCK_SEQPACKET", 58 | 10: "SOCK_PACKET", 59 | } 60 | 61 | 62 | def formatSocketType(argument): 63 | value = argument.value 64 | text = [] 65 | if hasattr(socket, 'SOCK_CLOEXEC'): 66 | cloexec = value & socket.SOCK_CLOEXEC 67 | value &= ~socket.SOCK_CLOEXEC 68 | else: 69 | cloexec = False 70 | text = SOCKET_TYPE.get(value, str(value)) 71 | if cloexec: 72 | text += '|SOCK_CLOEXEC' 73 | return text 74 | 75 | 76 | SOCKET_PROTOCOL = { 77 | 1: "IPPROTO_ICMP", 78 | 58: "IPPROTO_ICMPV6", 79 | } 80 | 81 | SETSOCKOPT_LEVEL = { 82 | 0: "SOL_IP", 83 | 1: "SOL_SOCKET", 84 | } 85 | 86 | SETSOCKOPT_OPTNAME = { 87 | # level 0 (SOL_IP) 88 | 1: "IP_TOS", 89 | # level 1 (SOL_SOCKET) 90 | 2: "SO_REUSEADDR", 91 | 9: "SO_KEEPALIVE", 92 | 20: "SO_RCVTIMEO", 93 | 21: "SO_SNDTIMEO", 94 | } 95 | -------------------------------------------------------------------------------- /ptrace/terminal.py: -------------------------------------------------------------------------------- 1 | """ 2 | Terminal functions. 3 | """ 4 | 5 | from termios import tcgetattr, tcsetattr, ECHO, TCSADRAIN, TIOCGWINSZ 6 | from sys import stdin, stdout 7 | from fcntl import ioctl 8 | from struct import unpack 9 | import os 10 | 11 | TERMIO_LFLAGS = 3 12 | 13 | 14 | def _terminalSize(): 15 | fd = stdout.fileno() 16 | size = ioctl(fd, TIOCGWINSZ, '1234') 17 | height, width = unpack('hh', size) 18 | return (width, height) 19 | 20 | 21 | def terminalWidth(): 22 | """ 23 | Get the terminal width in characters. 24 | """ 25 | return _terminalSize()[0] 26 | 27 | 28 | def enableEchoMode(): 29 | """ 30 | Enable echo mode in the terminal. Return True if the echo mode is set 31 | correctly, or False if the mode was already set. 32 | """ 33 | fd = stdin.fileno() 34 | if not os.isatty(fd): 35 | return False 36 | state = tcgetattr(fd) 37 | if state[TERMIO_LFLAGS] & ECHO: 38 | return False 39 | state[TERMIO_LFLAGS] = state[TERMIO_LFLAGS] | ECHO 40 | tcsetattr(fd, TCSADRAIN, state) 41 | return True 42 | -------------------------------------------------------------------------------- /ptrace/version.py: -------------------------------------------------------------------------------- 1 | PACKAGE = "python-ptrace" 2 | VERSION = "0.9.4" 3 | WEBSITE = "http://python-ptrace.readthedocs.io/" 4 | LICENSE = "GNU GPL v2" 5 | -------------------------------------------------------------------------------- /utilsFolder/Helper.py: -------------------------------------------------------------------------------- 1 | from ProcessWrapper import ProcessWrapper 2 | from ProcessManager import ProcessManager 3 | from HyxTalker import HyxTalker 4 | 5 | help_dict = { 6 | "fork": ProcessWrapper.forkProcess, 7 | "continue": ProcessWrapper.cont, 8 | "single": ProcessWrapper.singlestep, 9 | "call": ProcessWrapper.callFunction, 10 | "print": ProcessWrapper.print, 11 | "xamine": ProcessWrapper.examine, 12 | "malloc": ProcessWrapper.malloc, 13 | "free": ProcessWrapper.free, 14 | "breakpoint": ProcessWrapper.insertBreakpoint, 15 | "family": ProcessWrapper.getFamily, 16 | "write": ProcessWrapper.writeToBuf, 17 | 18 | "maps": ProcessManager.dumpMaps, 19 | "trace": ProcessManager.trace_syscall, 20 | "switch": ProcessManager.switchProcess, 21 | 22 | "hyx": HyxTalker.launchHyx, 23 | } 24 | 25 | 26 | def available_commands(): 27 | """ 28 | continue (c) 29 | single (si) 30 | write (w) 31 | 32 | breakpoint (b) 33 | remove breakpoint (rb) 34 | 35 | fork 36 | switch 37 | family 38 | tree 39 | 40 | call 41 | malloc 42 | free 43 | 44 | print (p) 45 | xamine (x) 46 | maps 47 | trace 48 | hyx 49 | 50 | Type ?command to get a detailed description""" 51 | 52 | pass 53 | 54 | 55 | def my_help(cmd: str): 56 | _, _, cmd = cmd.partition("?") 57 | cmd = cmd.strip() 58 | 59 | if cmd in help_dict: 60 | help(help_dict[cmd]) 61 | else: 62 | help(available_commands) 63 | -------------------------------------------------------------------------------- /utilsFolder/InputReader.py: -------------------------------------------------------------------------------- 1 | import os 2 | import socket 3 | from functools import partial 4 | from sys import stdin 5 | from threading import Thread 6 | 7 | from Constants import HOST, PORT 8 | from logging2 import debug 9 | from utilsFolder.PollableQueue import PollableQueue 10 | 11 | 12 | class InputReader(Thread): 13 | """listens for userinput""" 14 | 15 | def __init__(self, stdinQ: PollableQueue, startupfile=None): 16 | Thread.__init__(self, daemon=True) 17 | self.stdinQ = stdinQ 18 | if startupfile: 19 | self.startup(startupfile) 20 | 21 | self.start() 22 | 23 | def startup(self, file): 24 | with open(file, "r") as f: 25 | for line in f.readlines(): 26 | if len(line) > 0: 27 | self.stdinQ.put(line) 28 | debug("put %s" % line) 29 | 30 | def run(self): 31 | lastcmd = b"" 32 | for line in iter(stdin.readline, ""): 33 | if line == b"\n": 34 | line = lastcmd 35 | elif not line.startswith(b"?"): 36 | lastcmd = line 37 | self.stdinQ.put(line.decode()) 38 | 39 | 40 | class InputSockReader(Thread): 41 | """Listens for input for processes STDIN. 42 | Output will be sent to the socket as well.""" 43 | 44 | def __init__(self, stdinQ: PollableQueue): 45 | Thread.__init__(self, daemon=True) 46 | self.stdinQ = stdinQ 47 | self.sock = socket.socket() 48 | 49 | self.start() 50 | 51 | def run(self): 52 | try: 53 | os.unlink(HOST) 54 | except FileNotFoundError: 55 | pass 56 | 57 | self.sock.bind((HOST, PORT)) 58 | self.sock.listen(1) 59 | acc_sock, _ = self.sock.accept() 60 | 61 | f = partial(acc_sock.recv, 0x1000) 62 | for line_bytes in iter(f, b""): 63 | line = "write %s \n" % str(line_bytes) 64 | self.stdinQ.put(line) 65 | -------------------------------------------------------------------------------- /utilsFolder/PaulaPipe.py: -------------------------------------------------------------------------------- 1 | import pty 2 | import os 3 | import subprocess 4 | 5 | PIPE_BUFSIZE = 4096 6 | 7 | 8 | class Pipe: 9 | 10 | def __init__(self, flags=0, terminal=False): 11 | """Creates a Pipe you can easily write to and read from. Default is to open up a regular pipe.""" 12 | 13 | if flags or not terminal: 14 | self._readfd, self._writefd = os.pipe2(flags) 15 | else: # terminal 16 | self._readfd, self._writefd = pty.openpty() 17 | 18 | os.set_inheritable(self._readfd, True) 19 | os.set_inheritable(self._writefd, True) 20 | 21 | self.readobj = open(self._readfd, "rb", 0) 22 | self.writeobj = open(self._writefd, "wb", 0) 23 | 24 | def fileno(self, which): 25 | if which == "read": 26 | return self._readfd 27 | elif which == "write": 28 | return self._writefd 29 | else: 30 | raise KeyError 31 | 32 | def write(self, text): 33 | if isinstance(text, str): 34 | text = text.encode() 35 | 36 | result = self.writeobj.write(text) 37 | self.writeobj.flush() 38 | return result 39 | 40 | def read(self, n): 41 | self.writeobj.flush() 42 | return self.readobj.read(n) 43 | -------------------------------------------------------------------------------- /utilsFolder/PaulaPoll.py: -------------------------------------------------------------------------------- 1 | from select import poll, POLLIN, POLLPRI 2 | 3 | 4 | # https://stackoverflow.com/questions/1456373/two-way-reverse-map 5 | class BiDict(dict): 6 | def __setitem__(self, key, value): 7 | # Remove any previous connections with these values 8 | if key in self or value in self: 9 | raise KeyError("key or value already present!") 10 | 11 | dict.__setitem__(self, key, value) 12 | dict.__setitem__(self, value, key) 13 | 14 | def __delitem__(self, key): 15 | dict.__delitem__(self, self[key]) 16 | dict.__delitem__(self, key) 17 | 18 | def __len__(self): 19 | """Returns the number of connections""" 20 | return dict.__len__(self) // 2 21 | 22 | 23 | class PaulaPoll: 24 | 25 | def __init__(self): 26 | self.pollObj = poll() 27 | self.name_dict = BiDict() 28 | self.mask = POLLIN | POLLPRI 29 | 30 | def register(self, fd, name, mask=None): 31 | if mask is None: 32 | mask = self.mask 33 | 34 | name_in = name in self.name_dict 35 | fd_in = fd in self.name_dict 36 | if name_in != fd_in: 37 | raise KeyError("only one of (key,value) is already present") 38 | 39 | if not name_in: 40 | self.name_dict[fd] = name 41 | return self.pollObj.register(fd, mask) 42 | 43 | def unregister(self, name_or_fd): 44 | assert isinstance(name_or_fd, int) or isinstance(name_or_fd, str) 45 | assert name_or_fd in self.name_dict 46 | 47 | if isinstance(name_or_fd,str): 48 | unreg=self.name_dict[name_or_fd] 49 | else: 50 | unreg=name_or_fd 51 | 52 | self.pollObj.unregister(unreg) 53 | del self.name_dict[name_or_fd] 54 | 55 | def poll(self,timeout=None): # get name, fd and event 56 | ret = self.pollObj.poll(timeout) 57 | return list((self.name_dict[fd], fd, event) for fd, event in ret) 58 | -------------------------------------------------------------------------------- /utilsFolder/PollableQueue.py: -------------------------------------------------------------------------------- 1 | import queue 2 | import socket 3 | import os 4 | 5 | # https://stackoverflow.com/questions/17495877/ 6 | # python-how-to-wait-on-both-queue-and-a-socket-on-same-time 7 | 8 | class PollableQueue(queue.Queue): 9 | def __init__(self): 10 | super().__init__() 11 | # Create a pair of connected sockets 12 | if os.name == 'posix': 13 | self._putsocket, self._getsocket = socket.socketpair() 14 | else: 15 | print("i only work on posix") 16 | exit(3) 17 | 18 | def fileno(self): 19 | return self._getsocket.fileno() 20 | 21 | def put(self, item): 22 | super().put(item) 23 | self._putsocket.send(b'x') 24 | 25 | def get(self): 26 | self._getsocket.recv(1) 27 | return super().get() 28 | -------------------------------------------------------------------------------- /utilsFolder/utils.py: -------------------------------------------------------------------------------- 1 | import os 2 | import time 3 | import datetime 4 | 5 | 6 | def timestamp(): 7 | timestamp = time.time() 8 | value = datetime.datetime.fromtimestamp(timestamp) 9 | return str(value.strftime('%H:%M:%S')) 10 | 11 | 12 | tmppath = "/tmp/forkever-%s/" % timestamp() 13 | os.mkdir(tmppath) 14 | --------------------------------------------------------------------------------