From 14ccfb0426e4d115989eeca92384add5544a3418 Mon Sep 17 00:00:00 2001 From: Gaulthier Gain Date: Wed, 3 Feb 2021 20:08:38 +0100 Subject: [PATCH] Review syscalls list and minor fixes Signed-off-by: Gaulthier Gain --- srcs/common/utils.go | 7 +- srcs/dependtool/run_deptool.go | 2 +- srcs/dependtool/system_calls.go | 445 +++++++++++++++++++++++--------- 3 files changed, 324 insertions(+), 130 deletions(-) diff --git a/srcs/common/utils.go b/srcs/common/utils.go index 4e3af70..2c18d6f 100644 --- a/srcs/common/utils.go +++ b/srcs/common/utils.go @@ -7,6 +7,7 @@ package common import ( + "bytes" "encoding/json" "io/ioutil" "net/http" @@ -167,7 +168,11 @@ func RecordDataJson(filename string, data *Data) error { return err } - if err = ioutil.WriteFile(filename+".json", b, os.ModePerm); err != nil { + var prettyJSON bytes.Buffer + if err = json.Indent(&prettyJSON, b, "", "\t"); err != nil { + return err + } + if err = ioutil.WriteFile(filename+".json", prettyJSON.Bytes(), os.ModePerm); err != nil { return err } diff --git a/srcs/dependtool/run_deptool.go b/srcs/dependtool/run_deptool.go index 8473454..e7176e3 100644 --- a/srcs/dependtool/run_deptool.go +++ b/srcs/dependtool/run_deptool.go @@ -62,7 +62,7 @@ func RunAnalyserTool(homeDir string, data *u.Data) { runDynamicAnalyser(args, programName, programPath, outFolder, data) } else { // dtruss/dtrace on mac needs to disable system integrity protection - u.PrintWarning("Dynamic analysis is not supported on mac") + u.PrintWarning("Dynamic analysis is not currently supported on macOS") } // Save Data to JSON diff --git a/srcs/dependtool/system_calls.go b/srcs/dependtool/system_calls.go index e76d78e..78ec9f0 100644 --- a/srcs/dependtool/system_calls.go +++ b/srcs/dependtool/system_calls.go @@ -10,132 +10,321 @@ package dependtool // // It returns a map of all system calls. func initSystemCalls() map[string]*string { - return map[string]*string{"_llseek": nil, "_newselect": nil, "_sysctl": nil, - "accept": nil, "accept4": nil, "access": nil, "acct": nil, - "add_key": nil, "adjtimex": nil, "alarm": nil, "alloc_hugepages": nil, - "arc_gettls": nil, "arc_settls": nil, "arc_usr_cmpxchg": nil, - "arch_prctl": nil, "atomic_barrier": nil, "atomic_cmpxchg_32": nil, - "bdflush": nil, "bfin_spinlock": nil, "bind": nil, "bpf": nil, - "brk": nil, "breakpoint": nil, "cacheflush": nil, "capget": nil, - "capset": nil, "chdir": nil, "chmod": nil, "chown": nil, "chown32": nil, - "chroot": nil, "clock_adjtime": nil, "clock_getres": nil, - "clock_gettime": nil, "clock_nanosleep": nil, "connect": nil, - "copy_file_range": nil, "creat": nil, "create_module": nil, - "delete_module": nil, "dma_memcpy": nil, "dup": nil, "dup2": nil, - "dup3": nil, "epoll_create": nil, "epoll_create1": nil, - "epoll_ctl": nil, "epoll_pwait": nil, "epoll_wait": nil, "eventfd": nil, - "eventfd2": nil, "execv": nil, "execve": nil, "execveat": nil, - "exit": nil, "exit_group": nil, "faccessat": nil, "fadvise64": nil, - "fadvise64_64": nil, "fallocate": nil, "fanotify_init": nil, - "fanotify_mark": nil, "fchdir": nil, "fchmod": nil, - "fchmodat": nil, "fchown": nil, "fchown32": nil, "fchownat": nil, - "fcntl": nil, "fcntl64": nil, "fdatasync": nil, "fgetxattr": nil, - "finit_module": nil, "flistxattr": nil, "flock": nil, "fork": nil, - "free_hugepages": nil, "fremovexattr": nil, "fsetxattr": nil, - "fstat": nil, "fstat64": nil, "fstatat64": nil, "fstatfs": nil, - "fstatfs64": nil, "fsync": nil, "ftruncate": nil, "ftruncate64": nil, - "futex": nil, "futimesat": nil, "get_kernel_syms": nil, - "get_mempolicy": nil, "get_robust_list": nil, "get_thread_area": nil, - "get_tls": nil, "getcpu": nil, "getcwd": nil, "getdents": nil, - "getdents64": nil, "getdomainname": nil, "getdtablesize": nil, - "getegid": nil, "getegid32": nil, "geteuid": nil, "geteuid32": nil, - "getgid": nil, "getgid32": nil, "getgroups": nil, "getgroups32": nil, - "gethostname": nil, "getitimer": nil, "getpeername": nil, - "getpagesize": nil, "getpgid": nil, "getpgrp": nil, "getpid": nil, - "getppid": nil, "getpriority": nil, "getrandom": nil, "getresgid": nil, - "getresgid32": nil, "getresuid": nil, "getresuid32": nil, - "getrlimit": nil, "getrusage": nil, "getsid": nil, "getsockname": nil, - "getsockopt": nil, "gettid": nil, "gettimeofday": nil, "getuid": nil, - "getuid32": nil, "getunwind": nil, "getxattr": nil, "getxgid": nil, - "getxpid": nil, "getxuid": nil, "init_module": nil, - "inotify_add_watch": nil, "inotify_init": nil, "inotify_init1": nil, - "inotify_rm_watch": nil, "io_cancel": nil, "io_destroy": nil, - "io_getevents": nil, "io_pgetevents": nil, "io_setup": nil, - "io_submit": nil, "ioctl": nil, "ioperm": nil, "iopl": nil, - "ioprio_get": nil, "ioprio_set": nil, "ipc": nil, "kcmp": nil, - "kern_features": nil, "kexec_file_load": nil, "kexec_load": nil, - "keyctl": nil, "kill": nil, "lchown": nil, "lchown32": nil, - "lgetxattr": nil, "link": nil, "linkat": nil, "listen": nil, - "listxattr": nil, "llistxattr": nil, "lookup_dcookie": nil, - "lremovexattr": nil, "lseek": nil, "lsetxattr": nil, "lstat": nil, - "lstat64": nil, "madvise": nil, "mbind": nil, "memory_ordering": nil, - "metag_get_tls": nil, "metag_set_fpu_flags": nil, "metag_set_tls": nil, - "metag_setglobalbit": nil, "membarrier": nil, "memfd_create": nil, - "migrate_pages": nil, "mincore": nil, "mkdir": nil, - "mkdirat": nil, "mknod": nil, "mknodat": nil, "mlock": nil, - "mlock2": nil, "mlockall": nil, "mmap": nil, "mmap2": nil, - "modify_ldt": nil, "mount": nil, "move_pages": nil, "mprotect": nil, - "mq_getsetattr": nil, "mq_notify": nil, "mq_open": nil, - "mq_timedreceive": nil, "mq_timedsend": nil, "mq_unlink": nil, - "mremap": nil, "msgctl": nil, "msgget": nil, "msgrcv": nil, - "msgsnd": nil, "msync": nil, "munlock": nil, "munlockall": nil, - "munmap": nil, "name_to_handle_at": nil, "nanosleep": nil, - "newfstatat": nil, "nfsservctl": nil, "nice": nil, "old_adjtimex": nil, - "old_getrlimit": nil, "oldfstat": nil, "oldlstat": nil, - "oldolduname": nil, "oldstat": nil, "oldumount": nil, "olduname": nil, - "open": nil, "open_by_handle_at": nil, "openat": nil, - "or1k_atomic": nil, "pause": nil, "pciconfig_iobase": nil, - "pciconfig_read": nil, "pciconfig_write": nil, "perf_event_open": nil, - "personality": nil, "perfctr": nil, "perfmonctl": nil, "pipe": nil, - "pipe2": nil, "pivot_root": nil, "pkey_alloc": nil, "pkey_free": nil, - "pkey_mprotect": nil, "poll": nil, "ppoll": nil, "prctl": nil, - "pread": nil, "pread64": nil, "preadv": nil, "preadv2": nil, - "prlimit64": nil, "process_vm_readv": nil, "process_vm_writev": nil, - "pselect6": nil, "ptrace": nil, "pwrite": nil, "pwrite64": nil, - "pwritev": nil, "pwritev2": nil, "query_module": nil, "quotactl": nil, - "read": nil, "readahead": nil, "readdir": nil, "readlink": nil, - "readlinkat": nil, "readv": nil, "reboot": nil, "recv": nil, - "recvfrom": nil, "recvmsg": nil, "recvmmsg": nil, - "remap_file_pages": nil, "removexattr": nil, "rename": nil, - "renameat": nil, "renameat2": nil, "request_key": nil, - "restart_syscall": nil, "riscv_flush_icache": nil, "rmdir": nil, - "rseq": nil, "rt_sigaction": nil, "rt_sigpending": nil, - "rt_sigprocmask": nil, "rt_sigqueueinfo": nil, "rt_sigreturn": nil, - "rt_sigsuspend": nil, "rt_sigtimedwait": nil, "rt_tgsigqueueinfo": nil, - "rtas": nil, "s390_runtime_instr": nil, "s390_pci_mmio_read": nil, - "s390_pci_mmio_write": nil, "s390_sthyi": nil, - "s390_guarded_storage": nil, "sched_get_affinity": nil, - "sched_get_priority_max": nil, "sched_get_priority_min": nil, - "sched_getaffinity": nil, "sched_getattr": nil, "sched_getparam": nil, - "sched_getscheduler": nil, "sched_rr_get_interval": nil, - "sched_set_affinity": nil, "sched_setaffinity": nil, - "sched_setattr": nil, "sched_setparam": nil, "sched_setscheduler": nil, - "sched_yield": nil, "seccomp": nil, "select": nil, "semctl": nil, - "semget": nil, "semop": nil, "semtimedop": nil, "send": nil, - "sendfile": nil, "sendfile64": nil, "sendmmsg": nil, "sendmsg": nil, - "sendto": nil, "set_mempolicy": nil, "set_robust_list": nil, - "set_thread_area": nil, "set_tid_address": nil, "set_tls": nil, - "setdomainname": nil, "setfsgid": nil, "setfsgid32": nil, - "setfsuid": nil, "setfsuid32": nil, "setgid": nil, "setgid32": nil, - "setgroups": nil, "setgroups32": nil, "sethae": nil, "sethostname": nil, - "setitimer": nil, "setns": nil, "setpgid": nil, "setpgrp": nil, - "setpriority": nil, "setregid": nil, "setregid32": nil, - "setresgid": nil, "setresgid32": nil, "setresuid": nil, - "setresuid32": nil, "setreuid": nil, "setreuid32": nil, - "setrlimit": nil, "setsid": nil, "setsockopt": nil, "settimeofday": nil, - "setuid": nil, "setuid32": nil, "setup": nil, "setxattr": nil, - "sgetmask": nil, "shmat": nil, "shmctl": nil, "shmdt": nil, - "shmget": nil, "shutdown": nil, "sigaction": nil, "sigaltstack": nil, - "signal": nil, "signalfd": nil, "signalfd4": nil, "sigpending": nil, - "sigprocmask": nil, "sigreturn": nil, "sigsuspend": nil, "socket": nil, - "socketcall": nil, "socketpair": nil, "spill": nil, "splice": nil, - "spu_create": nil, "spu_run": nil, "sram_alloc": nil, "sram_free": nil, - "ssetmask": nil, "stat": nil, "stat64": nil, "statfs": nil, - "statfs64": nil, "statx": nil, "stime": nil, "subpage_prot": nil, - "switch_endian": nil, "swapcontext": nil, "swapoff": nil, "swapon": nil, - "symlink": nil, "symlinkat": nil, "sync": nil, "sync_file_range": nil, - "sync_file_range2": nil, "syncfs": nil, "sys_debug_setcontext": nil, - "syscall": nil, "sysfs": nil, "sysinfo": nil, "syslog": nil, - "sysmips": nil, "tee": nil, "tgkill": nil, "time": nil, - "timer_create": nil, "timer_delete": nil, "timer_getoverrun": nil, - "timer_gettime": nil, "timer_settime": nil, - "timerfd_create": nil, "timerfd_gettime": nil, "timerfd_settime": nil, - "times": nil, "tkill": nil, "truncate": nil, "truncate64": nil, - "ugetrlimit": nil, "umask": nil, "umount": nil, "umount2": nil, - "uname": nil, "unlink": nil, "unlinkat": nil, "unshare": nil, - "uselib": nil, "ustat": nil, "userfaultfd": nil, "usr26": nil, - "usr32": nil, "utime": nil, "utimensat": nil, "utimes": nil, - "utrap_install": nil, "vfork": nil, "vhangup": nil, "vm86old": nil, - "vm86": nil, "vmsplice": nil, "wait4": nil, "waitid": nil, - "waitpid": nil, "write": nil, "writev": nil, "xtensa": nil} + return map[string]*string{ + "read": nil, + "write": nil, + "open": nil, + "close": nil, + "stat": nil, + "fstat": nil, + "lstat": nil, + "poll": nil, + "lseek": nil, + "mmap": nil, + "mprotect": nil, + "munmap": nil, + "brk": nil, + "rt_sigaction": nil, + "rt_sigprocmask": nil, + "rt_sigreturn": nil, + "ioctl": nil, + "pread64": nil, + "pwrite64": nil, + "readv": nil, + "writev": nil, + "access": nil, + "pipe": nil, + "select": nil, + "sched_yield": nil, + "mremap": nil, + "msync": nil, + "mincore": nil, + "madvise": nil, + "shmget": nil, + "shmat": nil, + "shmctl": nil, + "dup": nil, + "dup2": nil, + "pause": nil, + "nanosleep": nil, + "getitimer": nil, + "alarm": nil, + "setitimer": nil, + "getpid": nil, + "sendfile": nil, + "socket": nil, + "connect": nil, + "accept": nil, + "sendto": nil, + "recvfrom": nil, + "sendmsg": nil, + "recvmsg": nil, + "shutdown": nil, + "bind": nil, + "listen": nil, + "getsockname": nil, + "getpeername": nil, + "socketpair": nil, + "setsockopt": nil, + "getsockopt": nil, + "clone": nil, + "fork": nil, + "vfork": nil, + "execve": nil, + "exit": nil, + "wait4": nil, + "kill": nil, + "uname": nil, + "semget": nil, + "semop": nil, + "semctl": nil, + "shmdt": nil, + "msgget": nil, + "msgsnd": nil, + "msgrcv": nil, + "msgctl": nil, + "fcntl": nil, + "flock": nil, + "fsync": nil, + "fdatasync": nil, + "truncate": nil, + "ftruncate": nil, + "getdents": nil, + "getcwd": nil, + "chdir": nil, + "fchdir": nil, + "rename": nil, + "mkdir": nil, + "rmdir": nil, + "creat": nil, + "link": nil, + "unlink": nil, + "symlink": nil, + "readlink": nil, + "chmod": nil, + "fchmod": nil, + "chown": nil, + "fchown": nil, + "lchown": nil, + "umask": nil, + "gettimeofday": nil, + "getrlimit": nil, + "getrusage": nil, + "sysinfo": nil, + "times": nil, + "ptrace": nil, + "getuid": nil, + "syslog": nil, + "getgid": nil, + "setuid": nil, + "setgid": nil, + "geteuid": nil, + "getegid": nil, + "setpgid": nil, + "getppid": nil, + "getpgrp": nil, + "setsid": nil, + "setreuid": nil, + "setregid": nil, + "getgroups": nil, + "setgroups": nil, + "setresuid": nil, + "getresuid": nil, + "setresgid": nil, + "getresgid": nil, + "getpgid": nil, + "setfsuid": nil, + "setfsgid": nil, + "getsid": nil, + "capget": nil, + "capset": nil, + "rt_sigpending": nil, + "rt_sigtimedwait": nil, + "rt_sigqueueinfo": nil, + "rt_sigsuspend": nil, + "sigaltstack": nil, + "utime": nil, + "mknod": nil, + "uselib": nil, + "personality": nil, + "ustat": nil, + "statfs": nil, + "fstatfs": nil, + "sysfs": nil, + "getpriority": nil, + "setpriority": nil, + "sched_setparam": nil, + "sched_getparam": nil, + "sched_setscheduler": nil, + "sched_getscheduler": nil, + "sched_get_priority_max": nil, + "sched_get_priority_min": nil, + "sched_rr_get_interval": nil, + "mlock": nil, + "munlock": nil, + "mlockall": nil, + "munlockall": nil, + "vhangup": nil, + "modify_ldt": nil, + "pivot_root": nil, + "_sysctl": nil, + "prctl": nil, + "arch_prctl": nil, + "adjtimex": nil, + "setrlimit": nil, + "chroot": nil, + "sync": nil, + "acct": nil, + "settimeofday": nil, + "mount": nil, + "umount2": nil, + "swapon": nil, + "swapoff": nil, + "reboot": nil, + "sethostname": nil, + "setdomainname": nil, + "iopl": nil, + "ioperm": nil, + "create_module": nil, + "init_module": nil, + "delete_module": nil, + "get_kernel_syms": nil, + "query_module": nil, + "quotactl": nil, + "nfsservctl": nil, + "getpmsg": nil, + "putpmsg": nil, + "afs_syscall": nil, + "tuxcall": nil, + "security": nil, + "gettid": nil, + "readahead": nil, + "setxattr": nil, + "lsetxattr": nil, + "fsetxattr": nil, + "getxattr": nil, + "lgetxattr": nil, + "fgetxattr": nil, + "listxattr": nil, + "llistxattr": nil, + "flistxattr": nil, + "removexattr": nil, + "lremovexattr": nil, + "fremovexattr": nil, + "tkill": nil, + "time": nil, + "futex": nil, + "sched_setaffinity": nil, + "sched_getaffinity": nil, + "set_thread_area": nil, + "io_setup": nil, + "io_destroy": nil, + "io_getevents": nil, + "io_submit": nil, + "io_cancel": nil, + "get_thread_area": nil, + "lookup_dcookie": nil, + "epoll_create": nil, + "epoll_ctl_old": nil, + "epoll_wait_old": nil, + "remap_file_pages": nil, + "getdents64": nil, + "set_tid_address": nil, + "restart_syscall": nil, + "semtimedop": nil, + "fadvise64": nil, + "timer_create": nil, + "timer_settime": nil, + "timer_gettime": nil, + "timer_getoverrun": nil, + "timer_delete": nil, + "clock_settime": nil, + "clock_gettime": nil, + "clock_getres": nil, + "clock_nanosleep": nil, + "exit_group": nil, + "epoll_wait": nil, + "epoll_ctl": nil, + "tgkill": nil, + "utimes": nil, + "vserver": nil, + "mbind": nil, + "set_mempolicy": nil, + "get_mempolicy": nil, + "mq_open": nil, + "mq_unlink": nil, + "mq_timedsend": nil, + "mq_timedreceive": nil, + "mq_notify": nil, + "mq_getsetattr": nil, + "kexec_load": nil, + "waitid": nil, + "add_key": nil, + "request_key": nil, + "keyctl": nil, + "ioprio_set": nil, + "ioprio_get": nil, + "inotify_init": nil, + "inotify_add_watch": nil, + "inotify_rm_watch": nil, + "migrate_pages": nil, + "openat": nil, + "mkdirat": nil, + "mknodat": nil, + "fchownat": nil, + "futimesat": nil, + "newfstatat": nil, + "unlinkat": nil, + "renameat": nil, + "linkat": nil, + "symlinkat": nil, + "readlinkat": nil, + "fchmodat": nil, + "faccessat": nil, + "pselect6": nil, + "ppoll": nil, + "unshare": nil, + "set_robust_list": nil, + "get_robust_list": nil, + "splice": nil, + "tee": nil, + "sync_file_range": nil, + "vmsplice": nil, + "move_pages": nil, + "utimensat": nil, + "epoll_pwait": nil, + "signalfd": nil, + "timerfd_create": nil, + "eventfd": nil, + "fallocate": nil, + "timerfd_settime": nil, + "timerfd_gettime": nil, + "accept4": nil, + "signalfd4": nil, + "eventfd2": nil, + "epoll_create1": nil, + "dup3": nil, + "pipe2": nil, + "inotify_init1": nil, + "preadv": nil, + "pwritev": nil, + "rt_tgsigqueueinfo": nil, + "perf_event_open": nil, + "recvmmsg": nil, + "fanotify_init": nil, + "fanotify_mark": nil, + "prlimit64": nil, + "name_to_handle_at": nil, + "open_by_handle_at": nil, + "clock_adjtime": nil, + "syncfs": nil, + "sendmmsg": nil, + "setns": nil, + "getcpu": nil, + "process_vm_readv": nil, + "process_vm_writev": nil, + "kcmp": nil, + "finit_module": nil, + "getrandom": nil, + } }