diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cfe71039..145b668e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,6 +78,7 @@ jobs: binutils-powerpc-linux-gnu \ binutils-s390x-linux-gnu \ binutils-sparc64-linux-gnu \ + binutils-riscv64-linux-gnu \ gcc-multilib \ libc6-dbg \ elfutils \ diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dc7ad8d5..347a26c66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,11 +75,13 @@ The table below shows which release corresponds to each branch, and what date th - [#2356][2356] Add local libc database provider for libcdb - [#2374][2374] libcdb.unstrip_libc: debug symbols are fetched only if not present - [#2327][2327] Add basic support to debug processes on Windows +- [#2322][2322] Add basic RISCV64 shellcraft support [2360]: https://github.com/Gallopsled/pwntools/pull/2360 [2356]: https://github.com/Gallopsled/pwntools/pull/2356 [2374]: https://github.com/Gallopsled/pwntools/pull/2374 [2327]: https://github.com/Gallopsled/pwntools/pull/2327 +[2322]: https://github.com/Gallopsled/pwntools/pull/2322 ## 4.13.0 (`beta`) diff --git a/docs/source/shellcraft/riscv64.rst b/docs/source/shellcraft/riscv64.rst new file mode 100644 index 000000000..47b484af7 --- /dev/null +++ b/docs/source/shellcraft/riscv64.rst @@ -0,0 +1,19 @@ +.. testsetup:: * + + from pwn import * + context.clear(arch='riscv64') + +:mod:`pwnlib.shellcraft.riscv64` --- Shellcode for RISCV64 +=========================================================== + +:mod:`pwnlib.shellcraft.riscv64` +------------------------------- + +.. automodule:: pwnlib.shellcraft.riscv64 + :members: + +:mod:`pwnlib.shellcraft.riscv64.linux` +--------------------------------------- + +.. automodule:: pwnlib.shellcraft.riscv64.linux + :members: diff --git a/pwnlib/constants/linux/riscv64.py b/pwnlib/constants/linux/riscv64.py new file mode 100644 index 000000000..d7ac82417 --- /dev/null +++ b/pwnlib/constants/linux/riscv64.py @@ -0,0 +1,1306 @@ +from pwnlib.constants.constant import Constant +__NR_io_setup = Constant('__NR_io_setup',0) +__NR_io_destroy = Constant('__NR_io_destroy',1) +__NR_io_submit = Constant('__NR_io_submit',2) +__NR_io_cancel = Constant('__NR_io_cancel',3) +__NR_io_getevents = Constant('__NR_io_getevents',4) +__NR_setxattr = Constant('__NR_setxattr',5) +__NR_lsetxattr = Constant('__NR_lsetxattr',6) +__NR_fsetxattr = Constant('__NR_fsetxattr',7) +__NR_getxattr = Constant('__NR_getxattr',8) +__NR_lgetxattr = Constant('__NR_lgetxattr',9) +__NR_fgetxattr = Constant('__NR_fgetxattr',10) +__NR_listxattr = Constant('__NR_listxattr',11) +__NR_llistxattr = Constant('__NR_llistxattr',12) +__NR_flistxattr = Constant('__NR_flistxattr',13) +__NR_removexattr = Constant('__NR_removexattr',14) +__NR_lremovexattr = Constant('__NR_lremovexattr',15) +__NR_fremovexattr = Constant('__NR_fremovexattr',16) +__NR_getcwd = Constant('__NR_getcwd',17) +__NR_lookup_dcookie = Constant('__NR_lookup_dcookie',18) +__NR_eventfd2 = Constant('__NR_eventfd2',19) +__NR_epoll_create1 = Constant('__NR_epoll_create1',20) +__NR_epoll_ctl = Constant('__NR_epoll_ctl',21) +__NR_epoll_pwait = Constant('__NR_epoll_pwait',22) +__NR_dup = Constant('__NR_dup',23) +__NR_dup3 = Constant('__NR_dup3',24) +__NR_fcntl = Constant('__NR_fcntl',25) +__NR_inotify_init1 = Constant('__NR_inotify_init1',26) +__NR_inotify_add_watch = Constant('__NR_inotify_add_watch',27) +__NR_inotify_rm_watch = Constant('__NR_inotify_rm_watch',28) +__NR_ioctl = Constant('__NR_ioctl',29) +__NR_ioprio_set = Constant('__NR_ioprio_set',30) +__NR_ioprio_get = Constant('__NR_ioprio_get',31) +__NR_flock = Constant('__NR_flock',32) +__NR_mknodat = Constant('__NR_mknodat',33) +__NR_mkdirat = Constant('__NR_mkdirat',34) +__NR_unlinkat = Constant('__NR_unlinkat',35) +__NR_symlinkat = Constant('__NR_symlinkat',36) +__NR_linkat = Constant('__NR_linkat',37) +__NR_umount2 = Constant('__NR_umount2',39) +__NR_mount = Constant('__NR_mount',40) +__NR_pivot_root = Constant('__NR_pivot_root',41) +__NR_nfsservctl = Constant('__NR_nfsservctl',42) +__NR_statfs = Constant('__NR_statfs',43) +__NR_fstatfs = Constant('__NR_fstatfs',44) +__NR_truncate = Constant('__NR_truncate',45) +__NR_ftruncate = Constant('__NR_ftruncate',46) +__NR_fallocate = Constant('__NR_fallocate',47) +__NR_faccessat = Constant('__NR_faccessat',48) +__NR_chdir = Constant('__NR_chdir',49) +__NR_fchdir = Constant('__NR_fchdir',50) +__NR_chroot = Constant('__NR_chroot',51) +__NR_fchmod = Constant('__NR_fchmod',52) +__NR_fchmodat = Constant('__NR_fchmodat',53) +__NR_fchownat = Constant('__NR_fchownat',54) +__NR_fchown = Constant('__NR_fchown',55) +__NR_openat = Constant('__NR_openat',56) +__NR_close = Constant('__NR_close',57) +__NR_vhangup = Constant('__NR_vhangup',58) +__NR_pipe2 = Constant('__NR_pipe2',59) +__NR_quotactl = Constant('__NR_quotactl',60) +__NR_getdents64 = Constant('__NR_getdents64',61) +__NR_lseek = Constant('__NR_lseek',62) +__NR_read = Constant('__NR_read',63) +__NR_write = Constant('__NR_write',64) +__NR_readv = Constant('__NR_readv',65) +__NR_writev = Constant('__NR_writev',66) +__NR_pread64 = Constant('__NR_pread64',67) +__NR_pwrite64 = Constant('__NR_pwrite64',68) +__NR_preadv = Constant('__NR_preadv',69) +__NR_pwritev = Constant('__NR_pwritev',70) +__NR_sendfile = Constant('__NR_sendfile',71) +__NR_pselect6 = Constant('__NR_pselect6',72) +__NR_ppoll = Constant('__NR_ppoll',73) +__NR_signalfd4 = Constant('__NR_signalfd4',74) +__NR_vmsplice = Constant('__NR_vmsplice',75) +__NR_splice = Constant('__NR_splice',76) +__NR_tee = Constant('__NR_tee',77) +__NR_readlinkat = Constant('__NR_readlinkat',78) +__NR_newfstatat = Constant('__NR_newfstatat',79) +__NR_fstat = Constant('__NR_fstat',80) +__NR_sync = Constant('__NR_sync',81) +__NR_fsync = Constant('__NR_fsync',82) +__NR_fdatasync = Constant('__NR_fdatasync',83) +__NR_sync_file_range = Constant('__NR_sync_file_range',84) +__NR_timerfd_create = Constant('__NR_timerfd_create',85) +__NR_timerfd_settime = Constant('__NR_timerfd_settime',86) +__NR_timerfd_gettime = Constant('__NR_timerfd_gettime',87) +__NR_utimensat = Constant('__NR_utimensat',88) +__NR_acct = Constant('__NR_acct',89) +__NR_capget = Constant('__NR_capget',90) +__NR_capset = Constant('__NR_capset',91) +__NR_personality = Constant('__NR_personality',92) +__NR_exit = Constant('__NR_exit',93) +__NR_exit_group = Constant('__NR_exit_group',94) +__NR_waitid = Constant('__NR_waitid',95) +__NR_set_tid_address = Constant('__NR_set_tid_address',96) +__NR_unshare = Constant('__NR_unshare',97) +__NR_futex = Constant('__NR_futex',98) +__NR_set_robust_list = Constant('__NR_set_robust_list',99) +__NR_get_robust_list = Constant('__NR_get_robust_list',100) +__NR_nanosleep = Constant('__NR_nanosleep',101) +__NR_getitimer = Constant('__NR_getitimer',102) +__NR_setitimer = Constant('__NR_setitimer',103) +__NR_kexec_load = Constant('__NR_kexec_load',104) +__NR_init_module = Constant('__NR_init_module',105) +__NR_delete_module = Constant('__NR_delete_module',106) +__NR_timer_create = Constant('__NR_timer_create',107) +__NR_timer_gettime = Constant('__NR_timer_gettime',108) +__NR_timer_getoverrun = Constant('__NR_timer_getoverrun',109) +__NR_timer_settime = Constant('__NR_timer_settime',110) +__NR_timer_delete = Constant('__NR_timer_delete',111) +__NR_clock_settime = Constant('__NR_clock_settime',112) +__NR_clock_gettime = Constant('__NR_clock_gettime',113) +__NR_clock_getres = Constant('__NR_clock_getres',114) +__NR_clock_nanosleep = Constant('__NR_clock_nanosleep',115) +__NR_syslog = Constant('__NR_syslog',116) +__NR_ptrace = Constant('__NR_ptrace',117) +__NR_sched_setparam = Constant('__NR_sched_setparam',118) +__NR_sched_setscheduler = Constant('__NR_sched_setscheduler',119) +__NR_sched_getscheduler = Constant('__NR_sched_getscheduler',120) +__NR_sched_getparam = Constant('__NR_sched_getparam',121) +__NR_sched_setaffinity = Constant('__NR_sched_setaffinity',122) +__NR_sched_getaffinity = Constant('__NR_sched_getaffinity',123) +__NR_sched_yield = Constant('__NR_sched_yield',124) +__NR_sched_get_priority_max = Constant('__NR_sched_get_priority_max',125) +__NR_sched_get_priority_min = Constant('__NR_sched_get_priority_min',126) +__NR_sched_rr_get_interval = Constant('__NR_sched_rr_get_interval',127) +__NR_restart_syscall = Constant('__NR_restart_syscall',128) +__NR_kill = Constant('__NR_kill',129) +__NR_tkill = Constant('__NR_tkill',130) +__NR_tgkill = Constant('__NR_tgkill',131) +__NR_sigaltstack = Constant('__NR_sigaltstack',132) +__NR_rt_sigsuspend = Constant('__NR_rt_sigsuspend',133) +__NR_rt_sigaction = Constant('__NR_rt_sigaction',134) +__NR_rt_sigprocmask = Constant('__NR_rt_sigprocmask',135) +__NR_rt_sigpending = Constant('__NR_rt_sigpending',136) +__NR_rt_sigtimedwait = Constant('__NR_rt_sigtimedwait',137) +__NR_rt_sigqueueinfo = Constant('__NR_rt_sigqueueinfo',138) +__NR_rt_sigreturn = Constant('__NR_rt_sigreturn',139) +__NR_setpriority = Constant('__NR_setpriority',140) +__NR_getpriority = Constant('__NR_getpriority',141) +__NR_reboot = Constant('__NR_reboot',142) +__NR_setregid = Constant('__NR_setregid',143) +__NR_setgid = Constant('__NR_setgid',144) +__NR_setreuid = Constant('__NR_setreuid',145) +__NR_setuid = Constant('__NR_setuid',146) +__NR_setresuid = Constant('__NR_setresuid',147) +__NR_getresuid = Constant('__NR_getresuid',148) +__NR_setresgid = Constant('__NR_setresgid',149) +__NR_getresgid = Constant('__NR_getresgid',150) +__NR_setfsuid = Constant('__NR_setfsuid',151) +__NR_setfsgid = Constant('__NR_setfsgid',152) +__NR_times = Constant('__NR_times',153) +__NR_setpgid = Constant('__NR_setpgid',154) +__NR_getpgid = Constant('__NR_getpgid',155) +__NR_getsid = Constant('__NR_getsid',156) +__NR_setsid = Constant('__NR_setsid',157) +__NR_getgroups = Constant('__NR_getgroups',158) +__NR_setgroups = Constant('__NR_setgroups',159) +__NR_uname = Constant('__NR_uname',160) +__NR_sethostname = Constant('__NR_sethostname',161) +__NR_setdomainname = Constant('__NR_setdomainname',162) +__NR_getrlimit = Constant('__NR_getrlimit',163) +__NR_setrlimit = Constant('__NR_setrlimit',164) +__NR_getrusage = Constant('__NR_getrusage',165) +__NR_umask = Constant('__NR_umask',166) +__NR_prctl = Constant('__NR_prctl',167) +__NR_getcpu = Constant('__NR_getcpu',168) +__NR_gettimeofday = Constant('__NR_gettimeofday',169) +__NR_settimeofday = Constant('__NR_settimeofday',170) +__NR_adjtimex = Constant('__NR_adjtimex',171) +__NR_getpid = Constant('__NR_getpid',172) +__NR_getppid = Constant('__NR_getppid',173) +__NR_getuid = Constant('__NR_getuid',174) +__NR_geteuid = Constant('__NR_geteuid',175) +__NR_getgid = Constant('__NR_getgid',176) +__NR_getegid = Constant('__NR_getegid',177) +__NR_gettid = Constant('__NR_gettid',178) +__NR_sysinfo = Constant('__NR_sysinfo',179) +__NR_mq_open = Constant('__NR_mq_open',180) +__NR_mq_unlink = Constant('__NR_mq_unlink',181) +__NR_mq_timedsend = Constant('__NR_mq_timedsend',182) +__NR_mq_timedreceive = Constant('__NR_mq_timedreceive',183) +__NR_mq_notify = Constant('__NR_mq_notify',184) +__NR_mq_getsetattr = Constant('__NR_mq_getsetattr',185) +__NR_msgget = Constant('__NR_msgget',186) +__NR_msgctl = Constant('__NR_msgctl',187) +__NR_msgrcv = Constant('__NR_msgrcv',188) +__NR_msgsnd = Constant('__NR_msgsnd',189) +__NR_semget = Constant('__NR_semget',190) +__NR_semctl = Constant('__NR_semctl',191) +__NR_semtimedop = Constant('__NR_semtimedop',192) +__NR_semop = Constant('__NR_semop',193) +__NR_shmget = Constant('__NR_shmget',194) +__NR_shmctl = Constant('__NR_shmctl',195) +__NR_shmat = Constant('__NR_shmat',196) +__NR_shmdt = Constant('__NR_shmdt',197) +__NR_socket = Constant('__NR_socket',198) +__NR_socketpair = Constant('__NR_socketpair',199) +__NR_bind = Constant('__NR_bind',200) +__NR_listen = Constant('__NR_listen',201) +__NR_accept = Constant('__NR_accept',202) +__NR_connect = Constant('__NR_connect',203) +__NR_getsockname = Constant('__NR_getsockname',204) +__NR_getpeername = Constant('__NR_getpeername',205) +__NR_sendto = Constant('__NR_sendto',206) +__NR_recvfrom = Constant('__NR_recvfrom',207) +__NR_setsockopt = Constant('__NR_setsockopt',208) +__NR_getsockopt = Constant('__NR_getsockopt',209) +__NR_shutdown = Constant('__NR_shutdown',210) +__NR_sendmsg = Constant('__NR_sendmsg',211) +__NR_recvmsg = Constant('__NR_recvmsg',212) +__NR_readahead = Constant('__NR_readahead',213) +__NR_brk = Constant('__NR_brk',214) +__NR_munmap = Constant('__NR_munmap',215) +__NR_mremap = Constant('__NR_mremap',216) +__NR_add_key = Constant('__NR_add_key',217) +__NR_request_key = Constant('__NR_request_key',218) +__NR_keyctl = Constant('__NR_keyctl',219) +__NR_clone = Constant('__NR_clone',220) +__NR_execve = Constant('__NR_execve',221) +__NR_mmap = Constant('__NR_mmap',222) +__NR_fadvise64 = Constant('__NR_fadvise64',223) +__NR_swapon = Constant('__NR_swapon',224) +__NR_swapoff = Constant('__NR_swapoff',225) +__NR_mprotect = Constant('__NR_mprotect',226) +__NR_msync = Constant('__NR_msync',227) +__NR_mlock = Constant('__NR_mlock',228) +__NR_munlock = Constant('__NR_munlock',229) +__NR_mlockall = Constant('__NR_mlockall',230) +__NR_munlockall = Constant('__NR_munlockall',231) +__NR_mincore = Constant('__NR_mincore',232) +__NR_madvise = Constant('__NR_madvise',233) +__NR_remap_file_pages = Constant('__NR_remap_file_pages',234) +__NR_mbind = Constant('__NR_mbind',235) +__NR_get_mempolicy = Constant('__NR_get_mempolicy',236) +__NR_set_mempolicy = Constant('__NR_set_mempolicy',237) +__NR_migrate_pages = Constant('__NR_migrate_pages',238) +__NR_move_pages = Constant('__NR_move_pages',239) +__NR_rt_tgsigqueueinfo = Constant('__NR_rt_tgsigqueueinfo',240) +__NR_perf_event_open = Constant('__NR_perf_event_open',241) +__NR_accept4 = Constant('__NR_accept4',242) +__NR_recvmmsg = Constant('__NR_recvmmsg',243) +__NR_arch_specific_syscall = Constant('__NR_arch_specific_syscall',244) +__NR_wait4 = Constant('__NR_wait4',260) +__NR_prlimit64 = Constant('__NR_prlimit64',261) +__NR_fanotify_init = Constant('__NR_fanotify_init',262) +__NR_fanotify_mark = Constant('__NR_fanotify_mark',263) +__NR_name_to_handle_at = Constant('__NR_name_to_handle_at',264) +__NR_open_by_handle_at = Constant('__NR_open_by_handle_at',265) +__NR_clock_adjtime = Constant('__NR_clock_adjtime',266) +__NR_syncfs = Constant('__NR_syncfs',267) +__NR_setns = Constant('__NR_setns',268) +__NR_sendmmsg = Constant('__NR_sendmmsg',269) +__NR_process_vm_readv = Constant('__NR_process_vm_readv',270) +__NR_process_vm_writev = Constant('__NR_process_vm_writev',271) +__NR_kcmp = Constant('__NR_kcmp',272) +__NR_finit_module = Constant('__NR_finit_module',273) +__NR_sched_setattr = Constant('__NR_sched_setattr',274) +__NR_sched_getattr = Constant('__NR_sched_getattr',275) +__NR_renameat2 = Constant('__NR_renameat2',276) +__NR_seccomp = Constant('__NR_seccomp',277) +__NR_getrandom = Constant('__NR_getrandom',278) +__NR_memfd_create = Constant('__NR_memfd_create',279) +__NR_bpf = Constant('__NR_bpf',280) +__NR_execveat = Constant('__NR_execveat',281) +__NR_userfaultfd = Constant('__NR_userfaultfd',282) +__NR_membarrier = Constant('__NR_membarrier',283) +__NR_mlock2 = Constant('__NR_mlock2',284) +__NR_copy_file_range = Constant('__NR_copy_file_range',285) +__NR_preadv2 = Constant('__NR_preadv2',286) +__NR_pwritev2 = Constant('__NR_pwritev2',287) +__NR_pkey_mprotect = Constant('__NR_pkey_mprotect',288) +__NR_pkey_alloc = Constant('__NR_pkey_alloc',289) +__NR_pkey_free = Constant('__NR_pkey_free',290) +__NR_statx = Constant('__NR_statx',291) +__NR_io_pgetevents = Constant('__NR_io_pgetevents',292) +__NR_rseq = Constant('__NR_rseq',293) +__NR_kexec_file_load = Constant('__NR_kexec_file_load',294) +__NR_pidfd_send_signal = Constant('__NR_pidfd_send_signal',424) +__NR_io_uring_setup = Constant('__NR_io_uring_setup',425) +__NR_io_uring_enter = Constant('__NR_io_uring_enter',426) +__NR_io_uring_register = Constant('__NR_io_uring_register',427) +__NR_open_tree = Constant('__NR_open_tree',428) +__NR_move_mount = Constant('__NR_move_mount',429) +__NR_fsopen = Constant('__NR_fsopen',430) +__NR_fsconfig = Constant('__NR_fsconfig',431) +__NR_fsmount = Constant('__NR_fsmount',432) +__NR_fspick = Constant('__NR_fspick',433) +__NR_pidfd_open = Constant('__NR_pidfd_open',434) +__NR_clone3 = Constant('__NR_clone3',435) +__NR_close_range = Constant('__NR_close_range',436) +__NR_openat2 = Constant('__NR_openat2',437) +__NR_pidfd_getfd = Constant('__NR_pidfd_getfd',438) +__NR_faccessat2 = Constant('__NR_faccessat2',439) +__NR_process_madvise = Constant('__NR_process_madvise',440) +__NR_epoll_pwait2 = Constant('__NR_epoll_pwait2',441) +__NR_mount_setattr = Constant('__NR_mount_setattr',442) +__NR_landlock_create_ruleset = Constant('__NR_landlock_create_ruleset',444) +__NR_landlock_add_rule = Constant('__NR_landlock_add_rule',445) +__NR_landlock_restrict_self = Constant('__NR_landlock_restrict_self',446) +__NR_sysriscv = Constant('__NR_sysriscv',244) +__NR_riscv_flush_icache = Constant('__NR_riscv_flush_icache',(244 + 15)) +MAP_32BIT = Constant('MAP_32BIT',0x40) +INADDR_ANY = Constant('INADDR_ANY',0) +INADDR_BROADCAST = Constant('INADDR_BROADCAST',0xffffffff) +INADDR_NONE = Constant('INADDR_NONE',0xffffffff) +INADDR_LOOPBACK = Constant('INADDR_LOOPBACK',0x7f000001) +EPERM = Constant('EPERM',1) +ENOENT = Constant('ENOENT',2) +ESRCH = Constant('ESRCH',3) +EINTR = Constant('EINTR',4) +EIO = Constant('EIO',5) +ENXIO = Constant('ENXIO',6) +E2BIG = Constant('E2BIG',7) +ENOEXEC = Constant('ENOEXEC',8) +EBADF = Constant('EBADF',9) +ECHILD = Constant('ECHILD',10) +EAGAIN = Constant('EAGAIN',11) +ENOMEM = Constant('ENOMEM',12) +EACCES = Constant('EACCES',13) +EFAULT = Constant('EFAULT',14) +ENOTBLK = Constant('ENOTBLK',15) +EBUSY = Constant('EBUSY',16) +EEXIST = Constant('EEXIST',17) +EXDEV = Constant('EXDEV',18) +ENODEV = Constant('ENODEV',19) +ENOTDIR = Constant('ENOTDIR',20) +EISDIR = Constant('EISDIR',21) +EINVAL = Constant('EINVAL',22) +ENFILE = Constant('ENFILE',23) +EMFILE = Constant('EMFILE',24) +ENOTTY = Constant('ENOTTY',25) +ETXTBSY = Constant('ETXTBSY',26) +EFBIG = Constant('EFBIG',27) +ENOSPC = Constant('ENOSPC',28) +ESPIPE = Constant('ESPIPE',29) +EROFS = Constant('EROFS',30) +EMLINK = Constant('EMLINK',31) +EPIPE = Constant('EPIPE',32) +EDOM = Constant('EDOM',33) +ERANGE = Constant('ERANGE',34) +EDEADLK = Constant('EDEADLK',35) +ENAMETOOLONG = Constant('ENAMETOOLONG',36) +ENOLCK = Constant('ENOLCK',37) +ENOSYS = Constant('ENOSYS',38) +ENOTEMPTY = Constant('ENOTEMPTY',39) +ELOOP = Constant('ELOOP',40) +EWOULDBLOCK = Constant('EWOULDBLOCK',11) +ENOMSG = Constant('ENOMSG',42) +EIDRM = Constant('EIDRM',43) +ECHRNG = Constant('ECHRNG',44) +EL2NSYNC = Constant('EL2NSYNC',45) +EL3HLT = Constant('EL3HLT',46) +EL3RST = Constant('EL3RST',47) +ELNRNG = Constant('ELNRNG',48) +EUNATCH = Constant('EUNATCH',49) +ENOCSI = Constant('ENOCSI',50) +EL2HLT = Constant('EL2HLT',51) +EBADE = Constant('EBADE',52) +EBADR = Constant('EBADR',53) +EXFULL = Constant('EXFULL',54) +ENOANO = Constant('ENOANO',55) +EBADRQC = Constant('EBADRQC',56) +EBADSLT = Constant('EBADSLT',57) +EDEADLOCK = Constant('EDEADLOCK',35) +EBFONT = Constant('EBFONT',59) +ENOSTR = Constant('ENOSTR',60) +ENODATA = Constant('ENODATA',61) +ETIME = Constant('ETIME',62) +ENOSR = Constant('ENOSR',63) +ENONET = Constant('ENONET',64) +ENOPKG = Constant('ENOPKG',65) +EREMOTE = Constant('EREMOTE',66) +ENOLINK = Constant('ENOLINK',67) +EADV = Constant('EADV',68) +ESRMNT = Constant('ESRMNT',69) +ECOMM = Constant('ECOMM',70) +EPROTO = Constant('EPROTO',71) +EMULTIHOP = Constant('EMULTIHOP',72) +EDOTDOT = Constant('EDOTDOT',73) +EBADMSG = Constant('EBADMSG',74) +EOVERFLOW = Constant('EOVERFLOW',75) +ENOTUNIQ = Constant('ENOTUNIQ',76) +EBADFD = Constant('EBADFD',77) +EREMCHG = Constant('EREMCHG',78) +ELIBACC = Constant('ELIBACC',79) +ELIBBAD = Constant('ELIBBAD',80) +ELIBSCN = Constant('ELIBSCN',81) +ELIBMAX = Constant('ELIBMAX',82) +ELIBEXEC = Constant('ELIBEXEC',83) +EILSEQ = Constant('EILSEQ',84) +ERESTART = Constant('ERESTART',85) +ESTRPIPE = Constant('ESTRPIPE',86) +EUSERS = Constant('EUSERS',87) +ENOTSOCK = Constant('ENOTSOCK',88) +EDESTADDRREQ = Constant('EDESTADDRREQ',89) +EMSGSIZE = Constant('EMSGSIZE',90) +EPROTOTYPE = Constant('EPROTOTYPE',91) +ENOPROTOOPT = Constant('ENOPROTOOPT',92) +EPROTONOSUPPORT = Constant('EPROTONOSUPPORT',93) +ESOCKTNOSUPPORT = Constant('ESOCKTNOSUPPORT',94) +EOPNOTSUPP = Constant('EOPNOTSUPP',95) +ENOTSUP = Constant('ENOTSUP',95) +EPFNOSUPPORT = Constant('EPFNOSUPPORT',96) +EAFNOSUPPORT = Constant('EAFNOSUPPORT',97) +EADDRINUSE = Constant('EADDRINUSE',98) +EADDRNOTAVAIL = Constant('EADDRNOTAVAIL',99) +ENETDOWN = Constant('ENETDOWN',100) +ENETUNREACH = Constant('ENETUNREACH',101) +ENETRESET = Constant('ENETRESET',102) +ECONNABORTED = Constant('ECONNABORTED',103) +ECONNRESET = Constant('ECONNRESET',104) +ENOBUFS = Constant('ENOBUFS',105) +EISCONN = Constant('EISCONN',106) +ENOTCONN = Constant('ENOTCONN',107) +ESHUTDOWN = Constant('ESHUTDOWN',108) +ETOOMANYREFS = Constant('ETOOMANYREFS',109) +ETIMEDOUT = Constant('ETIMEDOUT',110) +ECONNREFUSED = Constant('ECONNREFUSED',111) +EHOSTDOWN = Constant('EHOSTDOWN',112) +EHOSTUNREACH = Constant('EHOSTUNREACH',113) +EALREADY = Constant('EALREADY',114) +EINPROGRESS = Constant('EINPROGRESS',115) +ESTALE = Constant('ESTALE',116) +EUCLEAN = Constant('EUCLEAN',117) +ENOTNAM = Constant('ENOTNAM',118) +ENAVAIL = Constant('ENAVAIL',119) +EISNAM = Constant('EISNAM',120) +EREMOTEIO = Constant('EREMOTEIO',121) +EDQUOT = Constant('EDQUOT',122) +ENOMEDIUM = Constant('ENOMEDIUM',123) +EMEDIUMTYPE = Constant('EMEDIUMTYPE',124) +ECANCELED = Constant('ECANCELED',125) +ENOKEY = Constant('ENOKEY',126) +EKEYEXPIRED = Constant('EKEYEXPIRED',127) +EKEYREVOKED = Constant('EKEYREVOKED',128) +EKEYREJECTED = Constant('EKEYREJECTED',129) +EOWNERDEAD = Constant('EOWNERDEAD',130) +ENOTRECOVERABLE = Constant('ENOTRECOVERABLE',131) +ERFKILL = Constant('ERFKILL',132) +EHWPOISON = Constant('EHWPOISON',133) +__SYS_NERR = Constant('__SYS_NERR',((133) + 1)) +__LITTLE_ENDIAN = Constant('__LITTLE_ENDIAN',1234) +__BIG_ENDIAN = Constant('__BIG_ENDIAN',4321) +__BYTE_ORDER = Constant('__BYTE_ORDER',4321) +__FLOAT_WORD_ORDER = Constant('__FLOAT_WORD_ORDER',4321) +LITTLE_ENDIAN = Constant('LITTLE_ENDIAN',1234) +BIG_ENDIAN = Constant('BIG_ENDIAN',4321) +BYTE_ORDER = Constant('BYTE_ORDER',4321) +__WORDSIZE = Constant('__WORDSIZE',32) +INT8_MAX = Constant('INT8_MAX',(127)) +INT16_MAX = Constant('INT16_MAX',(32767)) +INT32_MAX = Constant('INT32_MAX',(2147483647)) +INT64_MAX = Constant('INT64_MAX',(9223372036854775807)) +INT8_MIN = Constant('INT8_MIN',(-1 - (127))) +INT16_MIN = Constant('INT16_MIN',(-1 - (32767))) +INT32_MIN = Constant('INT32_MIN',(-1 - (2147483647))) +INT64_MIN = Constant('INT64_MIN',(-1 - (9223372036854775807))) +INT_LEAST8_MAX = Constant('INT_LEAST8_MAX',(127)) +INT_LEAST8_MIN = Constant('INT_LEAST8_MIN',(-1 - (127))) +INT_LEAST16_MAX = Constant('INT_LEAST16_MAX',(32767)) +INT_LEAST16_MIN = Constant('INT_LEAST16_MIN',(-1 - (32767))) +INT_LEAST32_MAX = Constant('INT_LEAST32_MAX',(2147483647)) +INT_LEAST32_MIN = Constant('INT_LEAST32_MIN',(-1 - (2147483647))) +INT_LEAST64_MAX = Constant('INT_LEAST64_MAX',(9223372036854775807)) +INT_LEAST64_MIN = Constant('INT_LEAST64_MIN',(-1 - (9223372036854775807))) +UINT8_MAX = Constant('UINT8_MAX',0xff) +UINT16_MAX = Constant('UINT16_MAX',0xffff) +UINT32_MAX = Constant('UINT32_MAX',0xffffffff) +UINT64_MAX = Constant('UINT64_MAX',0xffffffffffffffff) +UINT_LEAST8_MAX = Constant('UINT_LEAST8_MAX',0xff) +UINT_LEAST16_MAX = Constant('UINT_LEAST16_MAX',0xffff) +UINT_LEAST32_MAX = Constant('UINT_LEAST32_MAX',0xffffffff) +UINT_LEAST64_MAX = Constant('UINT_LEAST64_MAX',0xffffffffffffffff) +INTPTR_MIN = Constant('INTPTR_MIN',(-1 - (2147483647))) +INTPTR_MAX = Constant('INTPTR_MAX',(2147483647)) +UINTPTR_MAX = Constant('UINTPTR_MAX',0xffffffff) +SIZE_MAX = Constant('SIZE_MAX',0xffffffff) +PTRDIFF_MIN = Constant('PTRDIFF_MIN',(-1 - (2147483647))) +PTRDIFF_MAX = Constant('PTRDIFF_MAX',(2147483647)) +INTMAX_MIN = Constant('INTMAX_MIN',(-1 - (9223372036854775807))) +INTMAX_MAX = Constant('INTMAX_MAX',(9223372036854775807)) +UINTMAX_MAX = Constant('UINTMAX_MAX',0xffffffffffffffff) +INT_FAST8_MIN = Constant('INT_FAST8_MIN',(-1 - (127))) +INT_FAST8_MAX = Constant('INT_FAST8_MAX',(127)) +INT_FAST64_MIN = Constant('INT_FAST64_MIN',(-1 - (9223372036854775807))) +INT_FAST64_MAX = Constant('INT_FAST64_MAX',(9223372036854775807)) +UINT_FAST8_MAX = Constant('UINT_FAST8_MAX',0xff) +UINT_FAST64_MAX = Constant('UINT_FAST64_MAX',0xffffffffffffffff) +INT_FAST16_MIN = Constant('INT_FAST16_MIN',(-1 - (2147483647))) +INT_FAST16_MAX = Constant('INT_FAST16_MAX',(2147483647)) +UINT_FAST16_MAX = Constant('UINT_FAST16_MAX',0xffffffff) +INT_FAST32_MIN = Constant('INT_FAST32_MIN',(-1 - (2147483647))) +INT_FAST32_MAX = Constant('INT_FAST32_MAX',(2147483647)) +UINT_FAST32_MAX = Constant('UINT_FAST32_MAX',0xffffffff) +WINT_MIN = Constant('WINT_MIN',0) +__FSUID_H = Constant('__FSUID_H',1) +NSIG = Constant('NSIG',32) +_NSIG = Constant('_NSIG',65) +SIGHUP = Constant('SIGHUP',1) +SIGINT = Constant('SIGINT',2) +SIGQUIT = Constant('SIGQUIT',3) +SIGILL = Constant('SIGILL',4) +SIGTRAP = Constant('SIGTRAP',5) +SIGABRT = Constant('SIGABRT',6) +SIGIOT = Constant('SIGIOT',6) +SIGFPE = Constant('SIGFPE',8) +SIGKILL = Constant('SIGKILL',9) +SIGSEGV = Constant('SIGSEGV',11) +SIGPIPE = Constant('SIGPIPE',13) +SIGALRM = Constant('SIGALRM',14) +SIGTERM = Constant('SIGTERM',15) +SIGUNUSED = Constant('SIGUNUSED',31) +SIGRTMIN = Constant('SIGRTMIN',32) +SIGRTMAX = Constant('SIGRTMAX',(65-1)) +SA_NOCLDSTOP = Constant('SA_NOCLDSTOP',0x00000001) +SA_NOCLDWAIT = Constant('SA_NOCLDWAIT',0x00000002) +SA_SIGINFO = Constant('SA_SIGINFO',0x00000004) +SA_RESTORER = Constant('SA_RESTORER',0x04000000) +SA_ONSTACK = Constant('SA_ONSTACK',0x08000000) +SA_RESTART = Constant('SA_RESTART',0x10000000) +SA_INTERRUPT = Constant('SA_INTERRUPT',0x20000000) +SA_NODEFER = Constant('SA_NODEFER',0x40000000) +SA_RESETHAND = Constant('SA_RESETHAND',0x80000000) +SA_NOMASK = Constant('SA_NOMASK',0x40000000) +SA_ONESHOT = Constant('SA_ONESHOT',0x80000000) +SS_ONSTACK = Constant('SS_ONSTACK',1) +SS_DISABLE = Constant('SS_DISABLE',2) +MINSIGSTKSZ = Constant('MINSIGSTKSZ',2048) +SIGSTKSZ = Constant('SIGSTKSZ',8192) +SIG_BLOCK = Constant('SIG_BLOCK',0) +SIG_UNBLOCK = Constant('SIG_UNBLOCK',1) +SIG_SETMASK = Constant('SIG_SETMASK',2) +SI_MAX_SIZE = Constant('SI_MAX_SIZE',128) +SIGEV_SIGNAL = Constant('SIGEV_SIGNAL',0) +SIGEV_NONE = Constant('SIGEV_NONE',1) +SIGEV_THREAD = Constant('SIGEV_THREAD',2) +SIGEV_THREAD_ID = Constant('SIGEV_THREAD_ID',4) +SIGEV_MAX_SIZE = Constant('SIGEV_MAX_SIZE',64) +_SYS_TIME_H = Constant('_SYS_TIME_H',1) +ITIMER_REAL = Constant('ITIMER_REAL',0) +ITIMER_VIRTUAL = Constant('ITIMER_VIRTUAL',1) +ITIMER_PROF = Constant('ITIMER_PROF',2) +FD_SETSIZE = Constant('FD_SETSIZE',1024) +R_OK = Constant('R_OK',4) +W_OK = Constant('W_OK',2) +X_OK = Constant('X_OK',1) +F_OK = Constant('F_OK',0) +SEEK_SET = Constant('SEEK_SET',0) +SEEK_CUR = Constant('SEEK_CUR',1) +SEEK_END = Constant('SEEK_END',2) +STDIN_FILENO = Constant('STDIN_FILENO',0) +STDOUT_FILENO = Constant('STDOUT_FILENO',1) +STDERR_FILENO = Constant('STDERR_FILENO',2) +_CS_PATH = Constant('_CS_PATH',1) +_SC_CLK_TCK = Constant('_SC_CLK_TCK',1) +_SC_ARG_MAX = Constant('_SC_ARG_MAX',2) +_SC_NGROUPS_MAX = Constant('_SC_NGROUPS_MAX',3) +_SC_OPEN_MAX = Constant('_SC_OPEN_MAX',4) +_SC_PAGESIZE = Constant('_SC_PAGESIZE',5) +_SC_NPROCESSORS_ONLN = Constant('_SC_NPROCESSORS_ONLN',6) +_SC_NPROCESSORS_CONF = Constant('_SC_NPROCESSORS_CONF',6) +_SC_PHYS_PAGES = Constant('_SC_PHYS_PAGES',7) +_SC_GETPW_R_SIZE_MAX = Constant('_SC_GETPW_R_SIZE_MAX',8) +_SC_GETGR_R_SIZE_MAX = Constant('_SC_GETGR_R_SIZE_MAX',9) +_PC_PATH_MAX = Constant('_PC_PATH_MAX',1) +_PC_VDISABLE = Constant('_PC_VDISABLE',2) +L_cuserid = Constant('L_cuserid',17) +_POSIX_VERSION = Constant('_POSIX_VERSION',199506) +F_ULOCK = Constant('F_ULOCK',0) +F_LOCK = Constant('F_LOCK',1) +F_TLOCK = Constant('F_TLOCK',2) +F_TEST = Constant('F_TEST',3) +_POSIX_MAPPED_FILES = Constant('_POSIX_MAPPED_FILES',200809) +S_IFMT = Constant('S_IFMT',0o0170000) +S_IFSOCK = Constant('S_IFSOCK',0o140000) +S_IFLNK = Constant('S_IFLNK',0o120000) +S_IFREG = Constant('S_IFREG',0o100000) +S_IFBLK = Constant('S_IFBLK',0o060000) +S_IFDIR = Constant('S_IFDIR',0o040000) +S_IFCHR = Constant('S_IFCHR',0o020000) +S_IFIFO = Constant('S_IFIFO',0o010000) +S_ISUID = Constant('S_ISUID',0o004000) +S_ISGID = Constant('S_ISGID',0o002000) +S_ISVTX = Constant('S_ISVTX',0o001000) +S_IRWXU = Constant('S_IRWXU',0o0700) +S_IRUSR = Constant('S_IRUSR',0o0400) +S_IWUSR = Constant('S_IWUSR',0o0200) +S_IXUSR = Constant('S_IXUSR',0o0100) +S_IRWXG = Constant('S_IRWXG',0o0070) +S_IRGRP = Constant('S_IRGRP',0o0040) +S_IWGRP = Constant('S_IWGRP',0o0020) +S_IXGRP = Constant('S_IXGRP',0o0010) +S_IRWXO = Constant('S_IRWXO',0o0007) +S_IROTH = Constant('S_IROTH',0o0004) +S_IWOTH = Constant('S_IWOTH',0o0002) +S_IXOTH = Constant('S_IXOTH',0o0001) +S_IREAD = Constant('S_IREAD',0o0400) +S_IWRITE = Constant('S_IWRITE',0o0200) +S_IEXEC = Constant('S_IEXEC',0o0100) +_SYS_UIO = Constant('_SYS_UIO',1) +SOL_SOCKET = Constant('SOL_SOCKET',1) +SO_DEBUG = Constant('SO_DEBUG',1) +SO_REUSEADDR = Constant('SO_REUSEADDR',2) +SO_TYPE = Constant('SO_TYPE',3) +SO_ERROR = Constant('SO_ERROR',4) +SO_DONTROUTE = Constant('SO_DONTROUTE',5) +SO_BROADCAST = Constant('SO_BROADCAST',6) +SO_SNDBUF = Constant('SO_SNDBUF',7) +SO_RCVBUF = Constant('SO_RCVBUF',8) +SO_KEEPALIVE = Constant('SO_KEEPALIVE',9) +SO_OOBINLINE = Constant('SO_OOBINLINE',10) +SO_NO_CHECK = Constant('SO_NO_CHECK',11) +SO_PRIORITY = Constant('SO_PRIORITY',12) +SO_LINGER = Constant('SO_LINGER',13) +SO_BSDCOMPAT = Constant('SO_BSDCOMPAT',14) +SO_REUSEPORT = Constant('SO_REUSEPORT',15) +SO_PASSCRED = Constant('SO_PASSCRED',16) +SO_PEERCRED = Constant('SO_PEERCRED',17) +SO_RCVLOWAT = Constant('SO_RCVLOWAT',18) +SO_SNDLOWAT = Constant('SO_SNDLOWAT',19) +SO_RCVTIMEO = Constant('SO_RCVTIMEO',20) +SO_SNDTIMEO = Constant('SO_SNDTIMEO',21) +SO_SECURITY_AUTHENTICATION = Constant('SO_SECURITY_AUTHENTICATION',22) +SO_SECURITY_ENCRYPTION_TRANSPORT = Constant('SO_SECURITY_ENCRYPTION_TRANSPORT',23) +SO_SECURITY_ENCRYPTION_NETWORK = Constant('SO_SECURITY_ENCRYPTION_NETWORK',24) +SO_BINDTODEVICE = Constant('SO_BINDTODEVICE',25) +SO_ATTACH_FILTER = Constant('SO_ATTACH_FILTER',26) +SO_DETACH_FILTER = Constant('SO_DETACH_FILTER',27) +SO_GET_FILTER = Constant('SO_GET_FILTER',26) +SO_PEERNAME = Constant('SO_PEERNAME',28) +SO_TIMESTAMP = Constant('SO_TIMESTAMP',29) +SCM_TIMESTAMP = Constant('SCM_TIMESTAMP',29) +SO_ACCEPTCONN = Constant('SO_ACCEPTCONN',30) +SO_PEERSEC = Constant('SO_PEERSEC',31) +SO_SNDBUFFORCE = Constant('SO_SNDBUFFORCE',32) +SO_RCVBUFFORCE = Constant('SO_RCVBUFFORCE',33) +SO_PASSSEC = Constant('SO_PASSSEC',34) +SO_TIMESTAMPNS = Constant('SO_TIMESTAMPNS',35) +SCM_TIMESTAMPNS = Constant('SCM_TIMESTAMPNS',35) +SO_MARK = Constant('SO_MARK',36) +SO_TIMESTAMPING = Constant('SO_TIMESTAMPING',37) +SCM_TIMESTAMPING = Constant('SCM_TIMESTAMPING',37) +SO_PROTOCOL = Constant('SO_PROTOCOL',38) +SO_DOMAIN = Constant('SO_DOMAIN',39) +SO_RXQ_OVFL = Constant('SO_RXQ_OVFL',40) +SO_WIFI_STATUS = Constant('SO_WIFI_STATUS',41) +SCM_WIFI_STATUS = Constant('SCM_WIFI_STATUS',41) +SO_PEEK_OFF = Constant('SO_PEEK_OFF',42) +SO_NOFCS = Constant('SO_NOFCS',43) +SO_LOCK_FILTER = Constant('SO_LOCK_FILTER',44) +SO_SELECT_ERR_QUEUE = Constant('SO_SELECT_ERR_QUEUE',45) +SO_BUSY_POLL = Constant('SO_BUSY_POLL',46) +SO_MAX_PACING_RATE = Constant('SO_MAX_PACING_RATE',47) +SO_BPF_EXTENSIONS = Constant('SO_BPF_EXTENSIONS',48) +SO_INCOMING_CPU = Constant('SO_INCOMING_CPU',49) +SO_ATTACH_BPF = Constant('SO_ATTACH_BPF',50) +SO_DETACH_BPF = Constant('SO_DETACH_BPF',27) +SO_ATTACH_REUSEPORT_CBPF = Constant('SO_ATTACH_REUSEPORT_CBPF',51) +SO_ATTACH_REUSEPORT_EBPF = Constant('SO_ATTACH_REUSEPORT_EBPF',52) +SO_CNX_ADVICE = Constant('SO_CNX_ADVICE',53) +SCM_TIMESTAMPING_OPT_STATS = Constant('SCM_TIMESTAMPING_OPT_STATS',54) +SO_MEMINFO = Constant('SO_MEMINFO',55) +SO_INCOMING_NAPI_ID = Constant('SO_INCOMING_NAPI_ID',56) +SO_COOKIE = Constant('SO_COOKIE',57) +SCM_TIMESTAMPING_PKTINFO = Constant('SCM_TIMESTAMPING_PKTINFO',58) +SO_PEERGROUPS = Constant('SO_PEERGROUPS',59) +SO_ZEROCOPY = Constant('SO_ZEROCOPY',60) +SOCK_STREAM = Constant('SOCK_STREAM',1) +SOCK_DGRAM = Constant('SOCK_DGRAM',2) +SOCK_RAW = Constant('SOCK_RAW',3) +SOCK_RDM = Constant('SOCK_RDM',4) +SOCK_SEQPACKET = Constant('SOCK_SEQPACKET',5) +SOCK_DCCP = Constant('SOCK_DCCP',6) +SOCK_PACKET = Constant('SOCK_PACKET',10) +UIO_FASTIOV = Constant('UIO_FASTIOV',8) +UIO_MAXIOV = Constant('UIO_MAXIOV',1024) +SCM_RIGHTS = Constant('SCM_RIGHTS',0x01) +SCM_CREDENTIALS = Constant('SCM_CREDENTIALS',0x02) +SCM_CONNECT = Constant('SCM_CONNECT',0x03) +AF_UNSPEC = Constant('AF_UNSPEC',0) +AF_UNIX = Constant('AF_UNIX',1) +AF_LOCAL = Constant('AF_LOCAL',1) +AF_INET = Constant('AF_INET',2) +AF_AX25 = Constant('AF_AX25',3) +AF_IPX = Constant('AF_IPX',4) +AF_APPLETALK = Constant('AF_APPLETALK',5) +AF_NETROM = Constant('AF_NETROM',6) +AF_BRIDGE = Constant('AF_BRIDGE',7) +AF_ATMPVC = Constant('AF_ATMPVC',8) +AF_X25 = Constant('AF_X25',9) +AF_INET6 = Constant('AF_INET6',10) +AF_ROSE = Constant('AF_ROSE',11) +AF_DECnet = Constant('AF_DECnet',12) +AF_NETBEUI = Constant('AF_NETBEUI',13) +AF_SECURITY = Constant('AF_SECURITY',14) +AF_KEY = Constant('AF_KEY',15) +AF_NETLINK = Constant('AF_NETLINK',16) +AF_ROUTE = Constant('AF_ROUTE',16) +AF_PACKET = Constant('AF_PACKET',17) +AF_ASH = Constant('AF_ASH',18) +AF_ECONET = Constant('AF_ECONET',19) +AF_ATMSVC = Constant('AF_ATMSVC',20) +AF_SNA = Constant('AF_SNA',22) +AF_IRDA = Constant('AF_IRDA',23) +AF_PPPOX = Constant('AF_PPPOX',24) +AF_WANPIPE = Constant('AF_WANPIPE',25) +AF_LLC = Constant('AF_LLC',26) +AF_IB = Constant('AF_IB',27) +AF_MPLS = Constant('AF_MPLS',28) +AF_CAN = Constant('AF_CAN',29) +AF_TIPC = Constant('AF_TIPC',30) +AF_BLUETOOTH = Constant('AF_BLUETOOTH',31) +AF_IUCV = Constant('AF_IUCV',32) +AF_RXRPC = Constant('AF_RXRPC',33) +AF_ISDN = Constant('AF_ISDN',34) +AF_PHONET = Constant('AF_PHONET',35) +AF_IEEE802154 = Constant('AF_IEEE802154',36) +AF_CAIF = Constant('AF_CAIF',37) +AF_ALG = Constant('AF_ALG',38) +AF_NFC = Constant('AF_NFC',39) +AF_VSOCK = Constant('AF_VSOCK',40) +AF_KCM = Constant('AF_KCM',41) +AF_QIPCRTR = Constant('AF_QIPCRTR',42) +AF_SMC = Constant('AF_SMC',43) +AF_MAX = Constant('AF_MAX',44) +PF_UNSPEC = Constant('PF_UNSPEC',0) +PF_UNIX = Constant('PF_UNIX',1) +PF_LOCAL = Constant('PF_LOCAL',1) +PF_INET = Constant('PF_INET',2) +PF_AX25 = Constant('PF_AX25',3) +PF_IPX = Constant('PF_IPX',4) +PF_APPLETALK = Constant('PF_APPLETALK',5) +PF_NETROM = Constant('PF_NETROM',6) +PF_BRIDGE = Constant('PF_BRIDGE',7) +PF_ATMPVC = Constant('PF_ATMPVC',8) +PF_X25 = Constant('PF_X25',9) +PF_INET6 = Constant('PF_INET6',10) +PF_ROSE = Constant('PF_ROSE',11) +PF_DECnet = Constant('PF_DECnet',12) +PF_NETBEUI = Constant('PF_NETBEUI',13) +PF_SECURITY = Constant('PF_SECURITY',14) +PF_KEY = Constant('PF_KEY',15) +PF_NETLINK = Constant('PF_NETLINK',16) +PF_ROUTE = Constant('PF_ROUTE',16) +PF_PACKET = Constant('PF_PACKET',17) +PF_ASH = Constant('PF_ASH',18) +PF_ECONET = Constant('PF_ECONET',19) +PF_ATMSVC = Constant('PF_ATMSVC',20) +PF_SNA = Constant('PF_SNA',22) +PF_IRDA = Constant('PF_IRDA',23) +PF_PPPOX = Constant('PF_PPPOX',24) +PF_WANPIPE = Constant('PF_WANPIPE',25) +PF_LLC = Constant('PF_LLC',26) +PF_IB = Constant('PF_IB',27) +PF_MPLS = Constant('PF_MPLS',28) +PF_CAN = Constant('PF_CAN',29) +PF_TIPC = Constant('PF_TIPC',30) +PF_BLUETOOTH = Constant('PF_BLUETOOTH',31) +PF_IUCV = Constant('PF_IUCV',32) +PF_RXRPC = Constant('PF_RXRPC',33) +PF_ISDN = Constant('PF_ISDN',34) +PF_PHONET = Constant('PF_PHONET',35) +PF_IEEE802154 = Constant('PF_IEEE802154',36) +PF_CAIF = Constant('PF_CAIF',37) +PF_ALG = Constant('PF_ALG',38) +PF_NFC = Constant('PF_NFC',39) +PF_VSOCK = Constant('PF_VSOCK',40) +PF_KCM = Constant('PF_KCM',41) +PF_QIPCRTR = Constant('PF_QIPCRTR',42) +PF_SMC = Constant('PF_SMC',43) +PF_MAX = Constant('PF_MAX',44) +SOMAXCONN = Constant('SOMAXCONN',128) +MSG_OOB = Constant('MSG_OOB',1) +MSG_PEEK = Constant('MSG_PEEK',2) +MSG_DONTROUTE = Constant('MSG_DONTROUTE',4) +MSG_TRYHARD = Constant('MSG_TRYHARD',4) +MSG_CTRUNC = Constant('MSG_CTRUNC',8) +MSG_PROBE = Constant('MSG_PROBE',0x10) +MSG_TRUNC = Constant('MSG_TRUNC',0x20) +MSG_DONTWAIT = Constant('MSG_DONTWAIT',0x40) +MSG_EOR = Constant('MSG_EOR',0x80) +MSG_WAITALL = Constant('MSG_WAITALL',0x100) +MSG_FIN = Constant('MSG_FIN',0x200) +MSG_SYN = Constant('MSG_SYN',0x400) +MSG_CONFIRM = Constant('MSG_CONFIRM',0x800) +MSG_RST = Constant('MSG_RST',0x1000) +MSG_ERRQUEUE = Constant('MSG_ERRQUEUE',0x2000) +MSG_NOSIGNAL = Constant('MSG_NOSIGNAL',0x4000) +MSG_MORE = Constant('MSG_MORE',0x8000) +MSG_WAITFORONE = Constant('MSG_WAITFORONE',0x10000) +MSG_SENDPAGE_NOTLAST = Constant('MSG_SENDPAGE_NOTLAST',0x20000) +MSG_BATCH = Constant('MSG_BATCH',0x40000) +MSG_EOF = Constant('MSG_EOF',0x200) +MSG_ZEROCOPY = Constant('MSG_ZEROCOPY',0x4000000) +MSG_FASTOPEN = Constant('MSG_FASTOPEN',0x20000000) +MSG_CMSG_CLOEXEC = Constant('MSG_CMSG_CLOEXEC',0x40000000) +SOL_IP = Constant('SOL_IP',0) +SOL_TCP = Constant('SOL_TCP',6) +SOL_UDP = Constant('SOL_UDP',17) +SOL_IPV6 = Constant('SOL_IPV6',41) +SOL_ICMPV6 = Constant('SOL_ICMPV6',58) +SOL_SCTP = Constant('SOL_SCTP',132) +SOL_UDPLITE = Constant('SOL_UDPLITE',136) +SOL_RAW = Constant('SOL_RAW',255) +SOL_IPX = Constant('SOL_IPX',256) +SOL_AX25 = Constant('SOL_AX25',257) +SOL_ATALK = Constant('SOL_ATALK',258) +SOL_NETROM = Constant('SOL_NETROM',259) +SOL_ROSE = Constant('SOL_ROSE',260) +SOL_DECNET = Constant('SOL_DECNET',261) +SOL_X25 = Constant('SOL_X25',262) +SOL_PACKET = Constant('SOL_PACKET',263) +SOL_ATM = Constant('SOL_ATM',264) +SOL_AAL = Constant('SOL_AAL',265) +SOL_IRDA = Constant('SOL_IRDA',266) +SOL_NETBEUI = Constant('SOL_NETBEUI',267) +SOL_LLC = Constant('SOL_LLC',268) +SOL_DCCP = Constant('SOL_DCCP',269) +SOL_NETLINK = Constant('SOL_NETLINK',270) +SOL_TIPC = Constant('SOL_TIPC',271) +SOL_RXRPC = Constant('SOL_RXRPC',272) +SOL_PPPOL2TP = Constant('SOL_PPPOL2TP',273) +SOL_BLUETOOTH = Constant('SOL_BLUETOOTH',274) +SOL_PNPIPE = Constant('SOL_PNPIPE',275) +SOL_RDS = Constant('SOL_RDS',276) +SOL_IUCV = Constant('SOL_IUCV',277) +SOL_CAIF = Constant('SOL_CAIF',278) +SOL_ALG = Constant('SOL_ALG',279) +SOL_NFC = Constant('SOL_NFC',280) +SOL_KCM = Constant('SOL_KCM',281) +SOL_TLS = Constant('SOL_TLS',282) +IPX_TYPE = Constant('IPX_TYPE',1) +SHUT_RD = Constant('SHUT_RD',0) +SHUT_WR = Constant('SHUT_WR',1) +SHUT_RDWR = Constant('SHUT_RDWR',2) +NI_NOFQDN = Constant('NI_NOFQDN',1) +NI_NUMERICHOST = Constant('NI_NUMERICHOST',2) +NI_NAMEREQD = Constant('NI_NAMEREQD',4) +NI_NUMERICSERV = Constant('NI_NUMERICSERV',8) +NI_DGRAM = Constant('NI_DGRAM',16) +EAI_FAMILY = Constant('EAI_FAMILY',-1) +EAI_SOCKTYPE = Constant('EAI_SOCKTYPE',-2) +EAI_BADFLAGS = Constant('EAI_BADFLAGS',-3) +EAI_NONAME = Constant('EAI_NONAME',-4) +EAI_SERVICE = Constant('EAI_SERVICE',-5) +EAI_ADDRFAMILY = Constant('EAI_ADDRFAMILY',-6) +EAI_NODATA = Constant('EAI_NODATA',-7) +EAI_MEMORY = Constant('EAI_MEMORY',-8) +EAI_FAIL = Constant('EAI_FAIL',-9) +EAI_AGAIN = Constant('EAI_AGAIN',-10) +EAI_SYSTEM = Constant('EAI_SYSTEM',-11) +AI_NUMERICHOST = Constant('AI_NUMERICHOST',1) +AI_CANONNAME = Constant('AI_CANONNAME',2) +AI_PASSIVE = Constant('AI_PASSIVE',4) +AI_NUMERICSERV = Constant('AI_NUMERICSERV',8) +AI_ADDRCONFIG = Constant('AI_ADDRCONFIG',16) +AI_V4MAPPED = Constant('AI_V4MAPPED',32) +AI_ALL = Constant('AI_ALL',64) +SIOCADDRT = Constant('SIOCADDRT',0x890B) +SIOCDELRT = Constant('SIOCDELRT',0x890C) +SIOCRTMSG = Constant('SIOCRTMSG',0x890D) +SIOCGIFNAME = Constant('SIOCGIFNAME',0x8910) +SIOCSIFLINK = Constant('SIOCSIFLINK',0x8911) +SIOCGIFCONF = Constant('SIOCGIFCONF',0x8912) +SIOCGIFFLAGS = Constant('SIOCGIFFLAGS',0x8913) +SIOCSIFFLAGS = Constant('SIOCSIFFLAGS',0x8914) +SIOCGIFADDR = Constant('SIOCGIFADDR',0x8915) +SIOCSIFADDR = Constant('SIOCSIFADDR',0x8916) +SIOCGIFDSTADDR = Constant('SIOCGIFDSTADDR',0x8917) +SIOCSIFDSTADDR = Constant('SIOCSIFDSTADDR',0x8918) +SIOCGIFBRDADDR = Constant('SIOCGIFBRDADDR',0x8919) +SIOCSIFBRDADDR = Constant('SIOCSIFBRDADDR',0x891a) +SIOCGIFNETMASK = Constant('SIOCGIFNETMASK',0x891b) +SIOCSIFNETMASK = Constant('SIOCSIFNETMASK',0x891c) +SIOCGIFMETRIC = Constant('SIOCGIFMETRIC',0x891d) +SIOCSIFMETRIC = Constant('SIOCSIFMETRIC',0x891e) +SIOCGIFMEM = Constant('SIOCGIFMEM',0x891f) +SIOCSIFMEM = Constant('SIOCSIFMEM',0x8920) +SIOCGIFMTU = Constant('SIOCGIFMTU',0x8921) +SIOCSIFMTU = Constant('SIOCSIFMTU',0x8922) +SIOCSIFNAME = Constant('SIOCSIFNAME',0x8923) +SIOCSIFHWADDR = Constant('SIOCSIFHWADDR',0x8924) +SIOCGIFENCAP = Constant('SIOCGIFENCAP',0x8925) +SIOCSIFENCAP = Constant('SIOCSIFENCAP',0x8926) +SIOCGIFHWADDR = Constant('SIOCGIFHWADDR',0x8927) +SIOCGIFSLAVE = Constant('SIOCGIFSLAVE',0x8929) +SIOCSIFSLAVE = Constant('SIOCSIFSLAVE',0x8930) +SIOCADDMULTI = Constant('SIOCADDMULTI',0x8931) +SIOCDELMULTI = Constant('SIOCDELMULTI',0x8932) +SIOCGIFINDEX = Constant('SIOCGIFINDEX',0x8933) +SIOGIFINDEX = Constant('SIOGIFINDEX',0x8933) +SIOCSIFPFLAGS = Constant('SIOCSIFPFLAGS',0x8934) +SIOCGIFPFLAGS = Constant('SIOCGIFPFLAGS',0x8935) +SIOCDIFADDR = Constant('SIOCDIFADDR',0x8936) +SIOCSIFHWBROADCAST = Constant('SIOCSIFHWBROADCAST',0x8937) +SIOCGIFCOUNT = Constant('SIOCGIFCOUNT',0x8938) +SIOCGIFBR = Constant('SIOCGIFBR',0x8940) +SIOCSIFBR = Constant('SIOCSIFBR',0x8941) +SIOCGIFTXQLEN = Constant('SIOCGIFTXQLEN',0x8942) +SIOCSIFTXQLEN = Constant('SIOCSIFTXQLEN',0x8943) +SIOCGIFDIVERT = Constant('SIOCGIFDIVERT',0x8944) +SIOCSIFDIVERT = Constant('SIOCSIFDIVERT',0x8945) +SIOCETHTOOL = Constant('SIOCETHTOOL',0x8946) +SIOCDARP = Constant('SIOCDARP',0x8953) +SIOCGARP = Constant('SIOCGARP',0x8954) +SIOCSARP = Constant('SIOCSARP',0x8955) +SIOCDRARP = Constant('SIOCDRARP',0x8960) +SIOCGRARP = Constant('SIOCGRARP',0x8961) +SIOCSRARP = Constant('SIOCSRARP',0x8962) +SIOCGIFMAP = Constant('SIOCGIFMAP',0x8970) +SIOCSIFMAP = Constant('SIOCSIFMAP',0x8971) +SIOCADDDLCI = Constant('SIOCADDDLCI',0x8980) +SIOCDELDLCI = Constant('SIOCDELDLCI',0x8981) +SIOCDEVPRIVATE = Constant('SIOCDEVPRIVATE',0x89F0) +F_LINUX_SPECIFIC_BASE = Constant('F_LINUX_SPECIFIC_BASE',1024) +F_SETOWN_EX = Constant('F_SETOWN_EX',15) +F_GETOWN_EX = Constant('F_GETOWN_EX',16) +F_GETOWNER_UIDS = Constant('F_GETOWNER_UIDS',17) +F_OFD_GETLK = Constant('F_OFD_GETLK',36) +F_OFD_SETLK = Constant('F_OFD_SETLK',37) +F_OFD_SETLKW = Constant('F_OFD_SETLKW',38) +F_OWNER_TID = Constant('F_OWNER_TID',0) +F_OWNER_PID = Constant('F_OWNER_PID',1) +F_OWNER_PGRP = Constant('F_OWNER_PGRP',2) +AT_FDCWD = Constant('AT_FDCWD',-100) +AT_SYMLINK_NOFOLLOW = Constant('AT_SYMLINK_NOFOLLOW',0x100) +AT_REMOVEDIR = Constant('AT_REMOVEDIR',0x200) +AT_SYMLINK_FOLLOW = Constant('AT_SYMLINK_FOLLOW',0x400) +AT_NO_AUTOMOUNT = Constant('AT_NO_AUTOMOUNT',0x800) +AT_EMPTY_PATH = Constant('AT_EMPTY_PATH',0x1000) +AT_EACCESS = Constant('AT_EACCESS',0x200) +MREMAP_MAYMOVE = Constant('MREMAP_MAYMOVE',1) +MREMAP_FIXED = Constant('MREMAP_FIXED',2) +PROT_READ = Constant('PROT_READ',0x1) +PROT_WRITE = Constant('PROT_WRITE',0x2) +PROT_EXEC = Constant('PROT_EXEC',0x4) +PROT_SEM = Constant('PROT_SEM',0x8) +PROT_NONE = Constant('PROT_NONE',0x0) +PROT_GROWSDOWN = Constant('PROT_GROWSDOWN',0x01000000) +PROT_GROWSUP = Constant('PROT_GROWSUP',0x02000000) +MAP_SHARED = Constant('MAP_SHARED',0x01) +MAP_PRIVATE = Constant('MAP_PRIVATE',0x02) +MAP_TYPE = Constant('MAP_TYPE',0xf) +MADV_REMOVE = Constant('MADV_REMOVE',9) +MADV_DONTFORK = Constant('MADV_DONTFORK',10) +MADV_DOFORK = Constant('MADV_DOFORK',11) +MADV_MERGEABLE = Constant('MADV_MERGEABLE',12) +MADV_UNMERGEABLE = Constant('MADV_UNMERGEABLE',13) +MADV_HUGEPAGE = Constant('MADV_HUGEPAGE',14) +MADV_NOHUGEPAGE = Constant('MADV_NOHUGEPAGE',15) +MADV_DONTDUMP = Constant('MADV_DONTDUMP',16) +MADV_DODUMP = Constant('MADV_DODUMP',17) +MADV_HWPOISON = Constant('MADV_HWPOISON',100) +MADV_SOFT_OFFLINE = Constant('MADV_SOFT_OFFLINE',101) +MLOCK_ONFAULT = Constant('MLOCK_ONFAULT',1) +MAP_FILE = Constant('MAP_FILE',0) +PTRACE_TRACEME = Constant('PTRACE_TRACEME',0) +PTRACE_PEEKTEXT = Constant('PTRACE_PEEKTEXT',1) +PTRACE_PEEKDATA = Constant('PTRACE_PEEKDATA',2) +PTRACE_PEEKUSR = Constant('PTRACE_PEEKUSR',3) +PTRACE_PEEKUSER = Constant('PTRACE_PEEKUSER',3) +PTRACE_POKETEXT = Constant('PTRACE_POKETEXT',4) +PTRACE_POKEDATA = Constant('PTRACE_POKEDATA',5) +PTRACE_POKEUSR = Constant('PTRACE_POKEUSR',6) +PTRACE_POKEUSER = Constant('PTRACE_POKEUSER',6) +PTRACE_CONT = Constant('PTRACE_CONT',7) +PTRACE_KILL = Constant('PTRACE_KILL',8) +PTRACE_SINGLESTEP = Constant('PTRACE_SINGLESTEP',9) +PTRACE_ATTACH = Constant('PTRACE_ATTACH',0x10) +PTRACE_DETACH = Constant('PTRACE_DETACH',0x11) +PTRACE_SYSCALL = Constant('PTRACE_SYSCALL',24) +PTRACE_GETEVENTMSG = Constant('PTRACE_GETEVENTMSG',0x4201) +PTRACE_GETSIGINFO = Constant('PTRACE_GETSIGINFO',0x4202) +PTRACE_SETSIGINFO = Constant('PTRACE_SETSIGINFO',0x4203) +PTRACE_O_TRACESYSGOOD = Constant('PTRACE_O_TRACESYSGOOD',0x00000001) +PTRACE_O_TRACEFORK = Constant('PTRACE_O_TRACEFORK',0x00000002) +PTRACE_O_TRACEVFORK = Constant('PTRACE_O_TRACEVFORK',0x00000004) +PTRACE_O_TRACECLONE = Constant('PTRACE_O_TRACECLONE',0x00000008) +PTRACE_O_TRACEEXEC = Constant('PTRACE_O_TRACEEXEC',0x00000010) +PTRACE_O_TRACEVFORKDONE = Constant('PTRACE_O_TRACEVFORKDONE',0x00000020) +PTRACE_O_TRACEEXIT = Constant('PTRACE_O_TRACEEXIT',0x00000040) +PTRACE_O_MASK = Constant('PTRACE_O_MASK',0x0000007f) +PTRACE_EVENT_FORK = Constant('PTRACE_EVENT_FORK',1) +PTRACE_EVENT_VFORK = Constant('PTRACE_EVENT_VFORK',2) +PTRACE_EVENT_CLONE = Constant('PTRACE_EVENT_CLONE',3) +PTRACE_EVENT_EXEC = Constant('PTRACE_EVENT_EXEC',4) +PTRACE_EVENT_VFORK_DONE = Constant('PTRACE_EVENT_VFORK_DONE',5) +PTRACE_EVENT_EXIT = Constant('PTRACE_EVENT_EXIT',6) +PT_TRACE_ME = Constant('PT_TRACE_ME',0) +PT_READ_I = Constant('PT_READ_I',1) +PT_READ_D = Constant('PT_READ_D',2) +PT_READ_U = Constant('PT_READ_U',3) +PT_WRITE_I = Constant('PT_WRITE_I',4) +PT_WRITE_D = Constant('PT_WRITE_D',5) +PT_WRITE_U = Constant('PT_WRITE_U',6) +PT_CONTINUE = Constant('PT_CONTINUE',7) +PT_KILL = Constant('PT_KILL',8) +PT_STEP = Constant('PT_STEP',9) +PT_ATTACH = Constant('PT_ATTACH',0x10) +PT_DETACH = Constant('PT_DETACH',0x11) +SYS_accept = Constant('SYS_accept',202) +SYS_accept4 = Constant('SYS_accept4',242) +SYS_acct = Constant('SYS_acct',89) +SYS_add_key = Constant('SYS_add_key',217) +SYS_adjtimex = Constant('SYS_adjtimex',171) +SYS_arch_specific_syscall = Constant('SYS_arch_specific_syscall',244) +SYS_bind = Constant('SYS_bind',200) +SYS_bpf = Constant('SYS_bpf',280) +SYS_brk = Constant('SYS_brk',214) +SYS_capget = Constant('SYS_capget',90) +SYS_capset = Constant('SYS_capset',91) +SYS_chdir = Constant('SYS_chdir',49) +SYS_chroot = Constant('SYS_chroot',51) +SYS_clock_adjtime = Constant('SYS_clock_adjtime',266) +SYS_clock_getres = Constant('SYS_clock_getres',114) +SYS_clock_gettime = Constant('SYS_clock_gettime',113) +SYS_clock_nanosleep = Constant('SYS_clock_nanosleep',115) +SYS_clock_settime = Constant('SYS_clock_settime',112) +SYS_clone = Constant('SYS_clone',220) +SYS_clone3 = Constant('SYS_clone3',435) +SYS_close = Constant('SYS_close',57) +SYS_close_range = Constant('SYS_close_range',436) +SYS_connect = Constant('SYS_connect',203) +SYS_copy_file_range = Constant('SYS_copy_file_range',285) +SYS_delete_module = Constant('SYS_delete_module',106) +SYS_dup = Constant('SYS_dup',23) +SYS_dup3 = Constant('SYS_dup3',24) +SYS_epoll_create1 = Constant('SYS_epoll_create1',20) +SYS_epoll_ctl = Constant('SYS_epoll_ctl',21) +SYS_epoll_pwait = Constant('SYS_epoll_pwait',22) +SYS_epoll_pwait2 = Constant('SYS_epoll_pwait2',441) +SYS_eventfd2 = Constant('SYS_eventfd2',19) +SYS_execve = Constant('SYS_execve',221) +SYS_execveat = Constant('SYS_execveat',281) +SYS_exit = Constant('SYS_exit',93) +SYS_exit_group = Constant('SYS_exit_group',94) +SYS_faccessat = Constant('SYS_faccessat',48) +SYS_faccessat2 = Constant('SYS_faccessat2',439) +SYS_fadvise64 = Constant('SYS_fadvise64',223) +SYS_fallocate = Constant('SYS_fallocate',47) +SYS_fanotify_init = Constant('SYS_fanotify_init',262) +SYS_fanotify_mark = Constant('SYS_fanotify_mark',263) +SYS_fchdir = Constant('SYS_fchdir',50) +SYS_fchmod = Constant('SYS_fchmod',52) +SYS_fchmodat = Constant('SYS_fchmodat',53) +SYS_fchown = Constant('SYS_fchown',55) +SYS_fchownat = Constant('SYS_fchownat',54) +SYS_fcntl = Constant('SYS_fcntl',25) +SYS_fdatasync = Constant('SYS_fdatasync',83) +SYS_fgetxattr = Constant('SYS_fgetxattr',10) +SYS_finit_module = Constant('SYS_finit_module',273) +SYS_flistxattr = Constant('SYS_flistxattr',13) +SYS_flock = Constant('SYS_flock',32) +SYS_fremovexattr = Constant('SYS_fremovexattr',16) +SYS_fsconfig = Constant('SYS_fsconfig',431) +SYS_fsetxattr = Constant('SYS_fsetxattr',7) +SYS_fsmount = Constant('SYS_fsmount',432) +SYS_fsopen = Constant('SYS_fsopen',430) +SYS_fspick = Constant('SYS_fspick',433) +SYS_fstat = Constant('SYS_fstat',80) +SYS_fstatfs = Constant('SYS_fstatfs',44) +SYS_fsync = Constant('SYS_fsync',82) +SYS_ftruncate = Constant('SYS_ftruncate',46) +SYS_futex = Constant('SYS_futex',98) +SYS_getcpu = Constant('SYS_getcpu',168) +SYS_getcwd = Constant('SYS_getcwd',17) +SYS_getdents64 = Constant('SYS_getdents64',61) +SYS_getegid = Constant('SYS_getegid',177) +SYS_geteuid = Constant('SYS_geteuid',175) +SYS_getgid = Constant('SYS_getgid',176) +SYS_getgroups = Constant('SYS_getgroups',158) +SYS_getitimer = Constant('SYS_getitimer',102) +SYS_get_mempolicy = Constant('SYS_get_mempolicy',236) +SYS_getpeername = Constant('SYS_getpeername',205) +SYS_getpgid = Constant('SYS_getpgid',155) +SYS_getpid = Constant('SYS_getpid',172) +SYS_getppid = Constant('SYS_getppid',173) +SYS_getpriority = Constant('SYS_getpriority',141) +SYS_getrandom = Constant('SYS_getrandom',278) +SYS_getresgid = Constant('SYS_getresgid',150) +SYS_getresuid = Constant('SYS_getresuid',148) +SYS_getrlimit = Constant('SYS_getrlimit',163) +SYS_get_robust_list = Constant('SYS_get_robust_list',100) +SYS_getrusage = Constant('SYS_getrusage',165) +SYS_getsid = Constant('SYS_getsid',156) +SYS_getsockname = Constant('SYS_getsockname',204) +SYS_getsockopt = Constant('SYS_getsockopt',209) +SYS_gettid = Constant('SYS_gettid',178) +SYS_gettimeofday = Constant('SYS_gettimeofday',169) +SYS_getuid = Constant('SYS_getuid',174) +SYS_getxattr = Constant('SYS_getxattr',8) +SYS_init_module = Constant('SYS_init_module',105) +SYS_inotify_add_watch = Constant('SYS_inotify_add_watch',27) +SYS_inotify_init1 = Constant('SYS_inotify_init1',26) +SYS_inotify_rm_watch = Constant('SYS_inotify_rm_watch',28) +SYS_io_cancel = Constant('SYS_io_cancel',3) +SYS_ioctl = Constant('SYS_ioctl',29) +SYS_io_destroy = Constant('SYS_io_destroy',1) +SYS_io_getevents = Constant('SYS_io_getevents',4) +SYS_io_pgetevents = Constant('SYS_io_pgetevents',292) +SYS_ioprio_get = Constant('SYS_ioprio_get',31) +SYS_ioprio_set = Constant('SYS_ioprio_set',30) +SYS_io_setup = Constant('SYS_io_setup',0) +SYS_io_submit = Constant('SYS_io_submit',2) +SYS_io_uring_enter = Constant('SYS_io_uring_enter',426) +SYS_io_uring_register = Constant('SYS_io_uring_register',427) +SYS_io_uring_setup = Constant('SYS_io_uring_setup',425) +SYS_kcmp = Constant('SYS_kcmp',272) +SYS_kexec_file_load = Constant('SYS_kexec_file_load',294) +SYS_kexec_load = Constant('SYS_kexec_load',104) +SYS_keyctl = Constant('SYS_keyctl',219) +SYS_kill = Constant('SYS_kill',129) +SYS_landlock_add_rule = Constant('SYS_landlock_add_rule',445) +SYS_landlock_create_ruleset = Constant('SYS_landlock_create_ruleset',444) +SYS_landlock_restrict_self = Constant('SYS_landlock_restrict_self',446) +SYS_lgetxattr = Constant('SYS_lgetxattr',9) +SYS_linkat = Constant('SYS_linkat',37) +SYS_listen = Constant('SYS_listen',201) +SYS_listxattr = Constant('SYS_listxattr',11) +SYS_llistxattr = Constant('SYS_llistxattr',12) +SYS_lookup_dcookie = Constant('SYS_lookup_dcookie',18) +SYS_lremovexattr = Constant('SYS_lremovexattr',15) +SYS_lseek = Constant('SYS_lseek',62) +SYS_lsetxattr = Constant('SYS_lsetxattr',6) +SYS_madvise = Constant('SYS_madvise',233) +SYS_mbind = Constant('SYS_mbind',235) +SYS_membarrier = Constant('SYS_membarrier',283) +SYS_memfd_create = Constant('SYS_memfd_create',279) +SYS_migrate_pages = Constant('SYS_migrate_pages',238) +SYS_mincore = Constant('SYS_mincore',232) +SYS_mkdirat = Constant('SYS_mkdirat',34) +SYS_mknodat = Constant('SYS_mknodat',33) +SYS_mlock = Constant('SYS_mlock',228) +SYS_mlock2 = Constant('SYS_mlock2',284) +SYS_mlockall = Constant('SYS_mlockall',230) +SYS_mmap = Constant('SYS_mmap',222) +SYS_mount = Constant('SYS_mount',40) +SYS_mount_setattr = Constant('SYS_mount_setattr',442) +SYS_move_mount = Constant('SYS_move_mount',429) +SYS_move_pages = Constant('SYS_move_pages',239) +SYS_mprotect = Constant('SYS_mprotect',226) +SYS_mq_getsetattr = Constant('SYS_mq_getsetattr',185) +SYS_mq_notify = Constant('SYS_mq_notify',184) +SYS_mq_open = Constant('SYS_mq_open',180) +SYS_mq_timedreceive = Constant('SYS_mq_timedreceive',183) +SYS_mq_timedsend = Constant('SYS_mq_timedsend',182) +SYS_mq_unlink = Constant('SYS_mq_unlink',181) +SYS_mremap = Constant('SYS_mremap',216) +SYS_msgctl = Constant('SYS_msgctl',187) +SYS_msgget = Constant('SYS_msgget',186) +SYS_msgrcv = Constant('SYS_msgrcv',188) +SYS_msgsnd = Constant('SYS_msgsnd',189) +SYS_msync = Constant('SYS_msync',227) +SYS_munlock = Constant('SYS_munlock',229) +SYS_munlockall = Constant('SYS_munlockall',231) +SYS_munmap = Constant('SYS_munmap',215) +SYS_name_to_handle_at = Constant('SYS_name_to_handle_at',264) +SYS_nanosleep = Constant('SYS_nanosleep',101) +SYS_newfstatat = Constant('SYS_newfstatat',79) +SYS_nfsservctl = Constant('SYS_nfsservctl',42) +SYS_openat = Constant('SYS_openat',56) +SYS_openat2 = Constant('SYS_openat2',437) +SYS_open_by_handle_at = Constant('SYS_open_by_handle_at',265) +SYS_open_tree = Constant('SYS_open_tree',428) +SYS_perf_event_open = Constant('SYS_perf_event_open',241) +SYS_personality = Constant('SYS_personality',92) +SYS_pidfd_getfd = Constant('SYS_pidfd_getfd',438) +SYS_pidfd_open = Constant('SYS_pidfd_open',434) +SYS_pidfd_send_signal = Constant('SYS_pidfd_send_signal',424) +SYS_pipe2 = Constant('SYS_pipe2',59) +SYS_pivot_root = Constant('SYS_pivot_root',41) +SYS_pkey_alloc = Constant('SYS_pkey_alloc',289) +SYS_pkey_free = Constant('SYS_pkey_free',290) +SYS_pkey_mprotect = Constant('SYS_pkey_mprotect',288) +SYS_ppoll = Constant('SYS_ppoll',73) +SYS_prctl = Constant('SYS_prctl',167) +SYS_pread64 = Constant('SYS_pread64',67) +SYS_preadv = Constant('SYS_preadv',69) +SYS_preadv2 = Constant('SYS_preadv2',286) +SYS_prlimit64 = Constant('SYS_prlimit64',261) +SYS_process_madvise = Constant('SYS_process_madvise',440) +SYS_process_vm_readv = Constant('SYS_process_vm_readv',270) +SYS_process_vm_writev = Constant('SYS_process_vm_writev',271) +SYS_pselect6 = Constant('SYS_pselect6',72) +SYS_ptrace = Constant('SYS_ptrace',117) +SYS_pwrite64 = Constant('SYS_pwrite64',68) +SYS_pwritev = Constant('SYS_pwritev',70) +SYS_pwritev2 = Constant('SYS_pwritev2',287) +SYS_quotactl = Constant('SYS_quotactl',60) +SYS_read = Constant('SYS_read',63) +SYS_readahead = Constant('SYS_readahead',213) +SYS_readlinkat = Constant('SYS_readlinkat',78) +SYS_readv = Constant('SYS_readv',65) +SYS_reboot = Constant('SYS_reboot',142) +SYS_recvfrom = Constant('SYS_recvfrom',207) +SYS_recvmmsg = Constant('SYS_recvmmsg',243) +SYS_recvmsg = Constant('SYS_recvmsg',212) +SYS_remap_file_pages = Constant('SYS_remap_file_pages',234) +SYS_removexattr = Constant('SYS_removexattr',14) +SYS_renameat2 = Constant('SYS_renameat2',276) +SYS_request_key = Constant('SYS_request_key',218) +SYS_restart_syscall = Constant('SYS_restart_syscall',128) +SYS_riscv_flush_icache = Constant('SYS_riscv_flush_icache',(244 + 15)) +SYS_rseq = Constant('SYS_rseq',293) +SYS_rt_sigaction = Constant('SYS_rt_sigaction',134) +SYS_rt_sigpending = Constant('SYS_rt_sigpending',136) +SYS_rt_sigprocmask = Constant('SYS_rt_sigprocmask',135) +SYS_rt_sigqueueinfo = Constant('SYS_rt_sigqueueinfo',138) +SYS_rt_sigreturn = Constant('SYS_rt_sigreturn',139) +SYS_rt_sigsuspend = Constant('SYS_rt_sigsuspend',133) +SYS_rt_sigtimedwait = Constant('SYS_rt_sigtimedwait',137) +SYS_rt_tgsigqueueinfo = Constant('SYS_rt_tgsigqueueinfo',240) +SYS_sched_getaffinity = Constant('SYS_sched_getaffinity',123) +SYS_sched_getattr = Constant('SYS_sched_getattr',275) +SYS_sched_getparam = Constant('SYS_sched_getparam',121) +SYS_sched_get_priority_max = Constant('SYS_sched_get_priority_max',125) +SYS_sched_get_priority_min = Constant('SYS_sched_get_priority_min',126) +SYS_sched_getscheduler = Constant('SYS_sched_getscheduler',120) +SYS_sched_rr_get_interval = Constant('SYS_sched_rr_get_interval',127) +SYS_sched_setaffinity = Constant('SYS_sched_setaffinity',122) +SYS_sched_setattr = Constant('SYS_sched_setattr',274) +SYS_sched_setparam = Constant('SYS_sched_setparam',118) +SYS_sched_setscheduler = Constant('SYS_sched_setscheduler',119) +SYS_sched_yield = Constant('SYS_sched_yield',124) +SYS_seccomp = Constant('SYS_seccomp',277) +SYS_semctl = Constant('SYS_semctl',191) +SYS_semget = Constant('SYS_semget',190) +SYS_semop = Constant('SYS_semop',193) +SYS_semtimedop = Constant('SYS_semtimedop',192) +SYS_sendfile = Constant('SYS_sendfile',71) +SYS_sendmmsg = Constant('SYS_sendmmsg',269) +SYS_sendmsg = Constant('SYS_sendmsg',211) +SYS_sendto = Constant('SYS_sendto',206) +SYS_setdomainname = Constant('SYS_setdomainname',162) +SYS_setfsgid = Constant('SYS_setfsgid',152) +SYS_setfsuid = Constant('SYS_setfsuid',151) +SYS_setgid = Constant('SYS_setgid',144) +SYS_setgroups = Constant('SYS_setgroups',159) +SYS_sethostname = Constant('SYS_sethostname',161) +SYS_setitimer = Constant('SYS_setitimer',103) +SYS_set_mempolicy = Constant('SYS_set_mempolicy',237) +SYS_setns = Constant('SYS_setns',268) +SYS_setpgid = Constant('SYS_setpgid',154) +SYS_setpriority = Constant('SYS_setpriority',140) +SYS_setregid = Constant('SYS_setregid',143) +SYS_setresgid = Constant('SYS_setresgid',149) +SYS_setresuid = Constant('SYS_setresuid',147) +SYS_setreuid = Constant('SYS_setreuid',145) +SYS_setrlimit = Constant('SYS_setrlimit',164) +SYS_set_robust_list = Constant('SYS_set_robust_list',99) +SYS_setsid = Constant('SYS_setsid',157) +SYS_setsockopt = Constant('SYS_setsockopt',208) +SYS_set_tid_address = Constant('SYS_set_tid_address',96) +SYS_settimeofday = Constant('SYS_settimeofday',170) +SYS_setuid = Constant('SYS_setuid',146) +SYS_setxattr = Constant('SYS_setxattr',5) +SYS_shmat = Constant('SYS_shmat',196) +SYS_shmctl = Constant('SYS_shmctl',195) +SYS_shmdt = Constant('SYS_shmdt',197) +SYS_shmget = Constant('SYS_shmget',194) +SYS_shutdown = Constant('SYS_shutdown',210) +SYS_sigaltstack = Constant('SYS_sigaltstack',132) +SYS_signalfd4 = Constant('SYS_signalfd4',74) +SYS_socket = Constant('SYS_socket',198) +SYS_socketpair = Constant('SYS_socketpair',199) +SYS_splice = Constant('SYS_splice',76) +SYS_statfs = Constant('SYS_statfs',43) +SYS_statx = Constant('SYS_statx',291) +SYS_swapoff = Constant('SYS_swapoff',225) +SYS_swapon = Constant('SYS_swapon',224) +SYS_symlinkat = Constant('SYS_symlinkat',36) +SYS_sync = Constant('SYS_sync',81) +SYS_sync_file_range = Constant('SYS_sync_file_range',84) +SYS_syncfs = Constant('SYS_syncfs',267) +SYS_sysinfo = Constant('SYS_sysinfo',179) +SYS_syslog = Constant('SYS_syslog',116) +SYS_sysriscv = Constant('SYS_sysriscv',244) +SYS_tee = Constant('SYS_tee',77) +SYS_tgkill = Constant('SYS_tgkill',131) +SYS_timer_create = Constant('SYS_timer_create',107) +SYS_timer_delete = Constant('SYS_timer_delete',111) +SYS_timerfd_create = Constant('SYS_timerfd_create',85) +SYS_timerfd_gettime = Constant('SYS_timerfd_gettime',87) +SYS_timerfd_settime = Constant('SYS_timerfd_settime',86) +SYS_timer_getoverrun = Constant('SYS_timer_getoverrun',109) +SYS_timer_gettime = Constant('SYS_timer_gettime',108) +SYS_timer_settime = Constant('SYS_timer_settime',110) +SYS_times = Constant('SYS_times',153) +SYS_tkill = Constant('SYS_tkill',130) +SYS_truncate = Constant('SYS_truncate',45) +SYS_umask = Constant('SYS_umask',166) +SYS_umount2 = Constant('SYS_umount2',39) +SYS_uname = Constant('SYS_uname',160) +SYS_unlinkat = Constant('SYS_unlinkat',35) +SYS_unshare = Constant('SYS_unshare',97) +SYS_userfaultfd = Constant('SYS_userfaultfd',282) +SYS_utimensat = Constant('SYS_utimensat',88) +SYS_vhangup = Constant('SYS_vhangup',58) +SYS_vmsplice = Constant('SYS_vmsplice',75) +SYS_wait4 = Constant('SYS_wait4',260) +SYS_waitid = Constant('SYS_waitid',95) +SYS_write = Constant('SYS_write',64) +SYS_writev = Constant('SYS_writev',66) diff --git a/pwnlib/data/includes/generator/linux/diet/riscv64/syscalls.h b/pwnlib/data/includes/generator/linux/diet/riscv64/syscalls.h new file mode 100644 index 000000000..b534afe81 --- /dev/null +++ b/pwnlib/data/includes/generator/linux/diet/riscv64/syscalls.h @@ -0,0 +1,304 @@ +#define __NR_io_setup 0 +#define __NR_io_destroy 1 +#define __NR_io_submit 2 +#define __NR_io_cancel 3 +#define __NR_io_getevents 4 +#define __NR_setxattr 5 +#define __NR_lsetxattr 6 +#define __NR_fsetxattr 7 +#define __NR_getxattr 8 +#define __NR_lgetxattr 9 +#define __NR_fgetxattr 10 +#define __NR_listxattr 11 +#define __NR_llistxattr 12 +#define __NR_flistxattr 13 +#define __NR_removexattr 14 +#define __NR_lremovexattr 15 +#define __NR_fremovexattr 16 +#define __NR_getcwd 17 +#define __NR_lookup_dcookie 18 +#define __NR_eventfd2 19 +#define __NR_epoll_create1 20 +#define __NR_epoll_ctl 21 +#define __NR_epoll_pwait 22 +#define __NR_dup 23 +#define __NR_dup3 24 +#define __NR_fcntl 25 +#define __NR_inotify_init1 26 +#define __NR_inotify_add_watch 27 +#define __NR_inotify_rm_watch 28 +#define __NR_ioctl 29 +#define __NR_ioprio_set 30 +#define __NR_ioprio_get 31 +#define __NR_flock 32 +#define __NR_mknodat 33 +#define __NR_mkdirat 34 +#define __NR_unlinkat 35 +#define __NR_symlinkat 36 +#define __NR_linkat 37 +#define __NR_umount2 39 +#define __NR_mount 40 +#define __NR_pivot_root 41 +#define __NR_nfsservctl 42 +#define __NR_statfs 43 +#define __NR_fstatfs 44 +#define __NR_truncate 45 +#define __NR_ftruncate 46 +#define __NR_fallocate 47 +#define __NR_faccessat 48 +#define __NR_chdir 49 +#define __NR_fchdir 50 +#define __NR_chroot 51 +#define __NR_fchmod 52 +#define __NR_fchmodat 53 +#define __NR_fchownat 54 +#define __NR_fchown 55 +#define __NR_openat 56 +#define __NR_close 57 +#define __NR_vhangup 58 +#define __NR_pipe2 59 +#define __NR_quotactl 60 +#define __NR_getdents64 61 +#define __NR_lseek 62 +#define __NR_read 63 +#define __NR_write 64 +#define __NR_readv 65 +#define __NR_writev 66 +#define __NR_pread64 67 +#define __NR_pwrite64 68 +#define __NR_preadv 69 +#define __NR_pwritev 70 +#define __NR_sendfile 71 +#define __NR_pselect6 72 +#define __NR_ppoll 73 +#define __NR_signalfd4 74 +#define __NR_vmsplice 75 +#define __NR_splice 76 +#define __NR_tee 77 +#define __NR_readlinkat 78 +#define __NR_newfstatat 79 +#define __NR_fstat 80 +#define __NR_sync 81 +#define __NR_fsync 82 +#define __NR_fdatasync 83 +#define __NR_sync_file_range 84 +#define __NR_timerfd_create 85 +#define __NR_timerfd_settime 86 +#define __NR_timerfd_gettime 87 +#define __NR_utimensat 88 +#define __NR_acct 89 +#define __NR_capget 90 +#define __NR_capset 91 +#define __NR_personality 92 +#define __NR_exit 93 +#define __NR_exit_group 94 +#define __NR_waitid 95 +#define __NR_set_tid_address 96 +#define __NR_unshare 97 +#define __NR_futex 98 +#define __NR_set_robust_list 99 +#define __NR_get_robust_list 100 +#define __NR_nanosleep 101 +#define __NR_getitimer 102 +#define __NR_setitimer 103 +#define __NR_kexec_load 104 +#define __NR_init_module 105 +#define __NR_delete_module 106 +#define __NR_timer_create 107 +#define __NR_timer_gettime 108 +#define __NR_timer_getoverrun 109 +#define __NR_timer_settime 110 +#define __NR_timer_delete 111 +#define __NR_clock_settime 112 +#define __NR_clock_gettime 113 +#define __NR_clock_getres 114 +#define __NR_clock_nanosleep 115 +#define __NR_syslog 116 +#define __NR_ptrace 117 +#define __NR_sched_setparam 118 +#define __NR_sched_setscheduler 119 +#define __NR_sched_getscheduler 120 +#define __NR_sched_getparam 121 +#define __NR_sched_setaffinity 122 +#define __NR_sched_getaffinity 123 +#define __NR_sched_yield 124 +#define __NR_sched_get_priority_max 125 +#define __NR_sched_get_priority_min 126 +#define __NR_sched_rr_get_interval 127 +#define __NR_restart_syscall 128 +#define __NR_kill 129 +#define __NR_tkill 130 +#define __NR_tgkill 131 +#define __NR_sigaltstack 132 +#define __NR_rt_sigsuspend 133 +#define __NR_rt_sigaction 134 +#define __NR_rt_sigprocmask 135 +#define __NR_rt_sigpending 136 +#define __NR_rt_sigtimedwait 137 +#define __NR_rt_sigqueueinfo 138 +#define __NR_rt_sigreturn 139 +#define __NR_setpriority 140 +#define __NR_getpriority 141 +#define __NR_reboot 142 +#define __NR_setregid 143 +#define __NR_setgid 144 +#define __NR_setreuid 145 +#define __NR_setuid 146 +#define __NR_setresuid 147 +#define __NR_getresuid 148 +#define __NR_setresgid 149 +#define __NR_getresgid 150 +#define __NR_setfsuid 151 +#define __NR_setfsgid 152 +#define __NR_times 153 +#define __NR_setpgid 154 +#define __NR_getpgid 155 +#define __NR_getsid 156 +#define __NR_setsid 157 +#define __NR_getgroups 158 +#define __NR_setgroups 159 +#define __NR_uname 160 +#define __NR_sethostname 161 +#define __NR_setdomainname 162 +#define __NR_getrlimit 163 +#define __NR_setrlimit 164 +#define __NR_getrusage 165 +#define __NR_umask 166 +#define __NR_prctl 167 +#define __NR_getcpu 168 +#define __NR_gettimeofday 169 +#define __NR_settimeofday 170 +#define __NR_adjtimex 171 +#define __NR_getpid 172 +#define __NR_getppid 173 +#define __NR_getuid 174 +#define __NR_geteuid 175 +#define __NR_getgid 176 +#define __NR_getegid 177 +#define __NR_gettid 178 +#define __NR_sysinfo 179 +#define __NR_mq_open 180 +#define __NR_mq_unlink 181 +#define __NR_mq_timedsend 182 +#define __NR_mq_timedreceive 183 +#define __NR_mq_notify 184 +#define __NR_mq_getsetattr 185 +#define __NR_msgget 186 +#define __NR_msgctl 187 +#define __NR_msgrcv 188 +#define __NR_msgsnd 189 +#define __NR_semget 190 +#define __NR_semctl 191 +#define __NR_semtimedop 192 +#define __NR_semop 193 +#define __NR_shmget 194 +#define __NR_shmctl 195 +#define __NR_shmat 196 +#define __NR_shmdt 197 +#define __NR_socket 198 +#define __NR_socketpair 199 +#define __NR_bind 200 +#define __NR_listen 201 +#define __NR_accept 202 +#define __NR_connect 203 +#define __NR_getsockname 204 +#define __NR_getpeername 205 +#define __NR_sendto 206 +#define __NR_recvfrom 207 +#define __NR_setsockopt 208 +#define __NR_getsockopt 209 +#define __NR_shutdown 210 +#define __NR_sendmsg 211 +#define __NR_recvmsg 212 +#define __NR_readahead 213 +#define __NR_brk 214 +#define __NR_munmap 215 +#define __NR_mremap 216 +#define __NR_add_key 217 +#define __NR_request_key 218 +#define __NR_keyctl 219 +#define __NR_clone 220 +#define __NR_execve 221 +#define __NR_mmap 222 +#define __NR_fadvise64 223 +#define __NR_swapon 224 +#define __NR_swapoff 225 +#define __NR_mprotect 226 +#define __NR_msync 227 +#define __NR_mlock 228 +#define __NR_munlock 229 +#define __NR_mlockall 230 +#define __NR_munlockall 231 +#define __NR_mincore 232 +#define __NR_madvise 233 +#define __NR_remap_file_pages 234 +#define __NR_mbind 235 +#define __NR_get_mempolicy 236 +#define __NR_set_mempolicy 237 +#define __NR_migrate_pages 238 +#define __NR_move_pages 239 +#define __NR_rt_tgsigqueueinfo 240 +#define __NR_perf_event_open 241 +#define __NR_accept4 242 +#define __NR_recvmmsg 243 +#define __NR_arch_specific_syscall 244 +#define __NR_wait4 260 +#define __NR_prlimit64 261 +#define __NR_fanotify_init 262 +#define __NR_fanotify_mark 263 +#define __NR_name_to_handle_at 264 +#define __NR_open_by_handle_at 265 +#define __NR_clock_adjtime 266 +#define __NR_syncfs 267 +#define __NR_setns 268 +#define __NR_sendmmsg 269 +#define __NR_process_vm_readv 270 +#define __NR_process_vm_writev 271 +#define __NR_kcmp 272 +#define __NR_finit_module 273 +#define __NR_sched_setattr 274 +#define __NR_sched_getattr 275 +#define __NR_renameat2 276 +#define __NR_seccomp 277 +#define __NR_getrandom 278 +#define __NR_memfd_create 279 +#define __NR_bpf 280 +#define __NR_execveat 281 +#define __NR_userfaultfd 282 +#define __NR_membarrier 283 +#define __NR_mlock2 284 +#define __NR_copy_file_range 285 +#define __NR_preadv2 286 +#define __NR_pwritev2 287 +#define __NR_pkey_mprotect 288 +#define __NR_pkey_alloc 289 +#define __NR_pkey_free 290 +#define __NR_statx 291 +#define __NR_io_pgetevents 292 +#define __NR_rseq 293 +#define __NR_kexec_file_load 294 +#define __NR_pidfd_send_signal 424 +#define __NR_io_uring_setup 425 +#define __NR_io_uring_enter 426 +#define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 +#define __NR_process_madvise 440 +#define __NR_epoll_pwait2 441 +#define __NR_mount_setattr 442 +#define __NR_landlock_create_ruleset 444 +#define __NR_landlock_add_rule 445 +#define __NR_landlock_restrict_self 446 + +#define __NR_sysriscv __NR_arch_specific_syscall +#define __NR_riscv_flush_icache (__NR_sysriscv + 15) diff --git a/pwnlib/data/includes/generator/linux/riscv64.h b/pwnlib/data/includes/generator/linux/riscv64.h new file mode 100644 index 000000000..125c50648 --- /dev/null +++ b/pwnlib/data/includes/generator/linux/riscv64.h @@ -0,0 +1,4 @@ +// https://git.musl-libc.org/cgit/musl/plain/arch/riscv64/bits/syscall.h.in +#define __riscv64__ +#include +#include diff --git a/pwnlib/data/includes/generator/linux/syscall_map.h b/pwnlib/data/includes/generator/linux/syscall_map.h index 028ae0bfa..ec8bd658f 100644 --- a/pwnlib/data/includes/generator/linux/syscall_map.h +++ b/pwnlib/data/includes/generator/linux/syscall_map.h @@ -44,6 +44,7 @@ #define SYS_clone2 __NR_clone2 #define SYS_clone3 __NR_clone3 #define SYS_close __NR_close +#define SYS_close_range __NR_close_range #define SYS_connect __NR_connect #define SYS_copy_file_range __NR_copy_file_range #define SYS_creat __NR_creat @@ -58,6 +59,7 @@ #define SYS_epoll_ctl __NR_epoll_ctl #define SYS_epoll_ctl_old __NR_epoll_ctl_old #define SYS_epoll_pwait __NR_epoll_pwait +#define SYS_epoll_pwait2 __NR_epoll_pwait2 #define SYS_epoll_wait __NR_epoll_wait #define SYS_epoll_wait_old __NR_epoll_wait_old #define SYS_eventfd __NR_eventfd @@ -69,6 +71,7 @@ #define SYS_exit __NR_exit #define SYS_exit_group __NR_exit_group #define SYS_faccessat __NR_faccessat +#define SYS_faccessat2 __NR_faccessat2 #define SYS_fadvise64 __NR_fadvise64 #define SYS_fadvise64_64 __NR_fadvise64_64 #define SYS_fallocate __NR_fallocate @@ -191,6 +194,9 @@ #define SYS_kexec_load __NR_kexec_load #define SYS_keyctl __NR_keyctl #define SYS_kill __NR_kill +#define SYS_landlock_add_rule __NR_landlock_add_rule +#define SYS_landlock_create_ruleset __NR_landlock_create_ruleset +#define SYS_landlock_restrict_self __NR_landlock_restrict_self #define SYS_lchown __NR_lchown #define SYS_lchown32 __NR_lchown32 #define SYS_lgetxattr __NR_lgetxattr @@ -228,6 +234,7 @@ #define SYS_mmap2 __NR_mmap2 #define SYS_modify_ldt __NR_modify_ldt #define SYS_mount __NR_mount +#define SYS_mount_setattr __NR_mount_setattr #define SYS_move_mount __NR_move_mount #define SYS_move_pages __NR_move_pages #define SYS_mprotect __NR_mprotect @@ -402,6 +409,7 @@ #define SYS_preadv __NR_preadv #define SYS_preadv2 __NR_preadv2 #define SYS_prlimit64 __NR_prlimit64 +#define SYS_process_madvise __NR_process_madvise #define SYS_process_vm_readv __NR_process_vm_readv #define SYS_process_vm_writev __NR_process_vm_writev #define SYS_prof __NR_prof @@ -440,6 +448,7 @@ #define SYS_reserved221 __NR_reserved221 #define SYS_reserved82 __NR_reserved82 #define SYS_restart_syscall __NR_restart_syscall +#define SYS_riscv_flush_icache __NR_riscv_flush_icache #define SYS_rmdir __NR_rmdir #define SYS_rseq __NR_rseq #define SYS_rtas __NR_rtas @@ -572,6 +581,7 @@ #define SYS_sys_kexec_load __NR_sys_kexec_load #define SYS_syslog __NR_syslog #define SYS_sysmips __NR_sysmips +#define SYS_sysriscv __NR_sysriscv #define SYS_sys_setaltroot __NR_sys_setaltroot #define SYS_tee __NR_tee #define SYS_tgkill __NR_tgkill diff --git a/pwnlib/data/includes/linux/riscv64.h b/pwnlib/data/includes/linux/riscv64.h new file mode 100644 index 000000000..8151f8bd3 --- /dev/null +++ b/pwnlib/data/includes/linux/riscv64.h @@ -0,0 +1,1305 @@ +#define __NR_io_setup 0 +#define __NR_io_destroy 1 +#define __NR_io_submit 2 +#define __NR_io_cancel 3 +#define __NR_io_getevents 4 +#define __NR_setxattr 5 +#define __NR_lsetxattr 6 +#define __NR_fsetxattr 7 +#define __NR_getxattr 8 +#define __NR_lgetxattr 9 +#define __NR_fgetxattr 10 +#define __NR_listxattr 11 +#define __NR_llistxattr 12 +#define __NR_flistxattr 13 +#define __NR_removexattr 14 +#define __NR_lremovexattr 15 +#define __NR_fremovexattr 16 +#define __NR_getcwd 17 +#define __NR_lookup_dcookie 18 +#define __NR_eventfd2 19 +#define __NR_epoll_create1 20 +#define __NR_epoll_ctl 21 +#define __NR_epoll_pwait 22 +#define __NR_dup 23 +#define __NR_dup3 24 +#define __NR_fcntl 25 +#define __NR_inotify_init1 26 +#define __NR_inotify_add_watch 27 +#define __NR_inotify_rm_watch 28 +#define __NR_ioctl 29 +#define __NR_ioprio_set 30 +#define __NR_ioprio_get 31 +#define __NR_flock 32 +#define __NR_mknodat 33 +#define __NR_mkdirat 34 +#define __NR_unlinkat 35 +#define __NR_symlinkat 36 +#define __NR_linkat 37 +#define __NR_umount2 39 +#define __NR_mount 40 +#define __NR_pivot_root 41 +#define __NR_nfsservctl 42 +#define __NR_statfs 43 +#define __NR_fstatfs 44 +#define __NR_truncate 45 +#define __NR_ftruncate 46 +#define __NR_fallocate 47 +#define __NR_faccessat 48 +#define __NR_chdir 49 +#define __NR_fchdir 50 +#define __NR_chroot 51 +#define __NR_fchmod 52 +#define __NR_fchmodat 53 +#define __NR_fchownat 54 +#define __NR_fchown 55 +#define __NR_openat 56 +#define __NR_close 57 +#define __NR_vhangup 58 +#define __NR_pipe2 59 +#define __NR_quotactl 60 +#define __NR_getdents64 61 +#define __NR_lseek 62 +#define __NR_read 63 +#define __NR_write 64 +#define __NR_readv 65 +#define __NR_writev 66 +#define __NR_pread64 67 +#define __NR_pwrite64 68 +#define __NR_preadv 69 +#define __NR_pwritev 70 +#define __NR_sendfile 71 +#define __NR_pselect6 72 +#define __NR_ppoll 73 +#define __NR_signalfd4 74 +#define __NR_vmsplice 75 +#define __NR_splice 76 +#define __NR_tee 77 +#define __NR_readlinkat 78 +#define __NR_newfstatat 79 +#define __NR_fstat 80 +#define __NR_sync 81 +#define __NR_fsync 82 +#define __NR_fdatasync 83 +#define __NR_sync_file_range 84 +#define __NR_timerfd_create 85 +#define __NR_timerfd_settime 86 +#define __NR_timerfd_gettime 87 +#define __NR_utimensat 88 +#define __NR_acct 89 +#define __NR_capget 90 +#define __NR_capset 91 +#define __NR_personality 92 +#define __NR_exit 93 +#define __NR_exit_group 94 +#define __NR_waitid 95 +#define __NR_set_tid_address 96 +#define __NR_unshare 97 +#define __NR_futex 98 +#define __NR_set_robust_list 99 +#define __NR_get_robust_list 100 +#define __NR_nanosleep 101 +#define __NR_getitimer 102 +#define __NR_setitimer 103 +#define __NR_kexec_load 104 +#define __NR_init_module 105 +#define __NR_delete_module 106 +#define __NR_timer_create 107 +#define __NR_timer_gettime 108 +#define __NR_timer_getoverrun 109 +#define __NR_timer_settime 110 +#define __NR_timer_delete 111 +#define __NR_clock_settime 112 +#define __NR_clock_gettime 113 +#define __NR_clock_getres 114 +#define __NR_clock_nanosleep 115 +#define __NR_syslog 116 +#define __NR_ptrace 117 +#define __NR_sched_setparam 118 +#define __NR_sched_setscheduler 119 +#define __NR_sched_getscheduler 120 +#define __NR_sched_getparam 121 +#define __NR_sched_setaffinity 122 +#define __NR_sched_getaffinity 123 +#define __NR_sched_yield 124 +#define __NR_sched_get_priority_max 125 +#define __NR_sched_get_priority_min 126 +#define __NR_sched_rr_get_interval 127 +#define __NR_restart_syscall 128 +#define __NR_kill 129 +#define __NR_tkill 130 +#define __NR_tgkill 131 +#define __NR_sigaltstack 132 +#define __NR_rt_sigsuspend 133 +#define __NR_rt_sigaction 134 +#define __NR_rt_sigprocmask 135 +#define __NR_rt_sigpending 136 +#define __NR_rt_sigtimedwait 137 +#define __NR_rt_sigqueueinfo 138 +#define __NR_rt_sigreturn 139 +#define __NR_setpriority 140 +#define __NR_getpriority 141 +#define __NR_reboot 142 +#define __NR_setregid 143 +#define __NR_setgid 144 +#define __NR_setreuid 145 +#define __NR_setuid 146 +#define __NR_setresuid 147 +#define __NR_getresuid 148 +#define __NR_setresgid 149 +#define __NR_getresgid 150 +#define __NR_setfsuid 151 +#define __NR_setfsgid 152 +#define __NR_times 153 +#define __NR_setpgid 154 +#define __NR_getpgid 155 +#define __NR_getsid 156 +#define __NR_setsid 157 +#define __NR_getgroups 158 +#define __NR_setgroups 159 +#define __NR_uname 160 +#define __NR_sethostname 161 +#define __NR_setdomainname 162 +#define __NR_getrlimit 163 +#define __NR_setrlimit 164 +#define __NR_getrusage 165 +#define __NR_umask 166 +#define __NR_prctl 167 +#define __NR_getcpu 168 +#define __NR_gettimeofday 169 +#define __NR_settimeofday 170 +#define __NR_adjtimex 171 +#define __NR_getpid 172 +#define __NR_getppid 173 +#define __NR_getuid 174 +#define __NR_geteuid 175 +#define __NR_getgid 176 +#define __NR_getegid 177 +#define __NR_gettid 178 +#define __NR_sysinfo 179 +#define __NR_mq_open 180 +#define __NR_mq_unlink 181 +#define __NR_mq_timedsend 182 +#define __NR_mq_timedreceive 183 +#define __NR_mq_notify 184 +#define __NR_mq_getsetattr 185 +#define __NR_msgget 186 +#define __NR_msgctl 187 +#define __NR_msgrcv 188 +#define __NR_msgsnd 189 +#define __NR_semget 190 +#define __NR_semctl 191 +#define __NR_semtimedop 192 +#define __NR_semop 193 +#define __NR_shmget 194 +#define __NR_shmctl 195 +#define __NR_shmat 196 +#define __NR_shmdt 197 +#define __NR_socket 198 +#define __NR_socketpair 199 +#define __NR_bind 200 +#define __NR_listen 201 +#define __NR_accept 202 +#define __NR_connect 203 +#define __NR_getsockname 204 +#define __NR_getpeername 205 +#define __NR_sendto 206 +#define __NR_recvfrom 207 +#define __NR_setsockopt 208 +#define __NR_getsockopt 209 +#define __NR_shutdown 210 +#define __NR_sendmsg 211 +#define __NR_recvmsg 212 +#define __NR_readahead 213 +#define __NR_brk 214 +#define __NR_munmap 215 +#define __NR_mremap 216 +#define __NR_add_key 217 +#define __NR_request_key 218 +#define __NR_keyctl 219 +#define __NR_clone 220 +#define __NR_execve 221 +#define __NR_mmap 222 +#define __NR_fadvise64 223 +#define __NR_swapon 224 +#define __NR_swapoff 225 +#define __NR_mprotect 226 +#define __NR_msync 227 +#define __NR_mlock 228 +#define __NR_munlock 229 +#define __NR_mlockall 230 +#define __NR_munlockall 231 +#define __NR_mincore 232 +#define __NR_madvise 233 +#define __NR_remap_file_pages 234 +#define __NR_mbind 235 +#define __NR_get_mempolicy 236 +#define __NR_set_mempolicy 237 +#define __NR_migrate_pages 238 +#define __NR_move_pages 239 +#define __NR_rt_tgsigqueueinfo 240 +#define __NR_perf_event_open 241 +#define __NR_accept4 242 +#define __NR_recvmmsg 243 +#define __NR_arch_specific_syscall 244 +#define __NR_wait4 260 +#define __NR_prlimit64 261 +#define __NR_fanotify_init 262 +#define __NR_fanotify_mark 263 +#define __NR_name_to_handle_at 264 +#define __NR_open_by_handle_at 265 +#define __NR_clock_adjtime 266 +#define __NR_syncfs 267 +#define __NR_setns 268 +#define __NR_sendmmsg 269 +#define __NR_process_vm_readv 270 +#define __NR_process_vm_writev 271 +#define __NR_kcmp 272 +#define __NR_finit_module 273 +#define __NR_sched_setattr 274 +#define __NR_sched_getattr 275 +#define __NR_renameat2 276 +#define __NR_seccomp 277 +#define __NR_getrandom 278 +#define __NR_memfd_create 279 +#define __NR_bpf 280 +#define __NR_execveat 281 +#define __NR_userfaultfd 282 +#define __NR_membarrier 283 +#define __NR_mlock2 284 +#define __NR_copy_file_range 285 +#define __NR_preadv2 286 +#define __NR_pwritev2 287 +#define __NR_pkey_mprotect 288 +#define __NR_pkey_alloc 289 +#define __NR_pkey_free 290 +#define __NR_statx 291 +#define __NR_io_pgetevents 292 +#define __NR_rseq 293 +#define __NR_kexec_file_load 294 +#define __NR_pidfd_send_signal 424 +#define __NR_io_uring_setup 425 +#define __NR_io_uring_enter 426 +#define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 +#define __NR_process_madvise 440 +#define __NR_epoll_pwait2 441 +#define __NR_mount_setattr 442 +#define __NR_landlock_create_ruleset 444 +#define __NR_landlock_add_rule 445 +#define __NR_landlock_restrict_self 446 +#define __NR_sysriscv 244 +#define __NR_riscv_flush_icache (244 + 15) +#define MAP_32BIT 0x40 +#define INADDR_ANY 0 +#define INADDR_BROADCAST 0xffffffff +#define INADDR_NONE 0xffffffff +#define INADDR_LOOPBACK 0x7f000001 +#define EPERM 1 +#define ENOENT 2 +#define ESRCH 3 +#define EINTR 4 +#define EIO 5 +#define ENXIO 6 +#define E2BIG 7 +#define ENOEXEC 8 +#define EBADF 9 +#define ECHILD 10 +#define EAGAIN 11 +#define ENOMEM 12 +#define EACCES 13 +#define EFAULT 14 +#define ENOTBLK 15 +#define EBUSY 16 +#define EEXIST 17 +#define EXDEV 18 +#define ENODEV 19 +#define ENOTDIR 20 +#define EISDIR 21 +#define EINVAL 22 +#define ENFILE 23 +#define EMFILE 24 +#define ENOTTY 25 +#define ETXTBSY 26 +#define EFBIG 27 +#define ENOSPC 28 +#define ESPIPE 29 +#define EROFS 30 +#define EMLINK 31 +#define EPIPE 32 +#define EDOM 33 +#define ERANGE 34 +#define EDEADLK 35 +#define ENAMETOOLONG 36 +#define ENOLCK 37 +#define ENOSYS 38 +#define ENOTEMPTY 39 +#define ELOOP 40 +#define EWOULDBLOCK 11 +#define ENOMSG 42 +#define EIDRM 43 +#define ECHRNG 44 +#define EL2NSYNC 45 +#define EL3HLT 46 +#define EL3RST 47 +#define ELNRNG 48 +#define EUNATCH 49 +#define ENOCSI 50 +#define EL2HLT 51 +#define EBADE 52 +#define EBADR 53 +#define EXFULL 54 +#define ENOANO 55 +#define EBADRQC 56 +#define EBADSLT 57 +#define EDEADLOCK 35 +#define EBFONT 59 +#define ENOSTR 60 +#define ENODATA 61 +#define ETIME 62 +#define ENOSR 63 +#define ENONET 64 +#define ENOPKG 65 +#define EREMOTE 66 +#define ENOLINK 67 +#define EADV 68 +#define ESRMNT 69 +#define ECOMM 70 +#define EPROTO 71 +#define EMULTIHOP 72 +#define EDOTDOT 73 +#define EBADMSG 74 +#define EOVERFLOW 75 +#define ENOTUNIQ 76 +#define EBADFD 77 +#define EREMCHG 78 +#define ELIBACC 79 +#define ELIBBAD 80 +#define ELIBSCN 81 +#define ELIBMAX 82 +#define ELIBEXEC 83 +#define EILSEQ 84 +#define ERESTART 85 +#define ESTRPIPE 86 +#define EUSERS 87 +#define ENOTSOCK 88 +#define EDESTADDRREQ 89 +#define EMSGSIZE 90 +#define EPROTOTYPE 91 +#define ENOPROTOOPT 92 +#define EPROTONOSUPPORT 93 +#define ESOCKTNOSUPPORT 94 +#define EOPNOTSUPP 95 +#define ENOTSUP 95 +#define EPFNOSUPPORT 96 +#define EAFNOSUPPORT 97 +#define EADDRINUSE 98 +#define EADDRNOTAVAIL 99 +#define ENETDOWN 100 +#define ENETUNREACH 101 +#define ENETRESET 102 +#define ECONNABORTED 103 +#define ECONNRESET 104 +#define ENOBUFS 105 +#define EISCONN 106 +#define ENOTCONN 107 +#define ESHUTDOWN 108 +#define ETOOMANYREFS 109 +#define ETIMEDOUT 110 +#define ECONNREFUSED 111 +#define EHOSTDOWN 112 +#define EHOSTUNREACH 113 +#define EALREADY 114 +#define EINPROGRESS 115 +#define ESTALE 116 +#define EUCLEAN 117 +#define ENOTNAM 118 +#define ENAVAIL 119 +#define EISNAM 120 +#define EREMOTEIO 121 +#define EDQUOT 122 +#define ENOMEDIUM 123 +#define EMEDIUMTYPE 124 +#define ECANCELED 125 +#define ENOKEY 126 +#define EKEYEXPIRED 127 +#define EKEYREVOKED 128 +#define EKEYREJECTED 129 +#define EOWNERDEAD 130 +#define ENOTRECOVERABLE 131 +#define ERFKILL 132 +#define EHWPOISON 133 +#define __SYS_NERR ((133) + 1) +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __BYTE_ORDER 4321 +#define __FLOAT_WORD_ORDER 4321 +#define LITTLE_ENDIAN 1234 +#define BIG_ENDIAN 4321 +#define BYTE_ORDER 4321 +#define __WORDSIZE 32 +#define INT8_MAX (127) +#define INT16_MAX (32767) +#define INT32_MAX (2147483647) +#define INT64_MAX (9223372036854775807) +#define INT8_MIN (-1 - (127)) +#define INT16_MIN (-1 - (32767)) +#define INT32_MIN (-1 - (2147483647)) +#define INT64_MIN (-1 - (9223372036854775807)) +#define INT_LEAST8_MAX (127) +#define INT_LEAST8_MIN (-1 - (127)) +#define INT_LEAST16_MAX (32767) +#define INT_LEAST16_MIN (-1 - (32767)) +#define INT_LEAST32_MAX (2147483647) +#define INT_LEAST32_MIN (-1 - (2147483647)) +#define INT_LEAST64_MAX (9223372036854775807) +#define INT_LEAST64_MIN (-1 - (9223372036854775807)) +#define UINT8_MAX 0xff +#define UINT16_MAX 0xffff +#define UINT32_MAX 0xffffffff +#define UINT64_MAX 0xffffffffffffffff +#define UINT_LEAST8_MAX 0xff +#define UINT_LEAST16_MAX 0xffff +#define UINT_LEAST32_MAX 0xffffffff +#define UINT_LEAST64_MAX 0xffffffffffffffff +#define INTPTR_MIN (-1 - (2147483647)) +#define INTPTR_MAX (2147483647) +#define UINTPTR_MAX 0xffffffff +#define SIZE_MAX 0xffffffff +#define PTRDIFF_MIN (-1 - (2147483647)) +#define PTRDIFF_MAX (2147483647) +#define INTMAX_MIN (-1 - (9223372036854775807)) +#define INTMAX_MAX (9223372036854775807) +#define UINTMAX_MAX 0xffffffffffffffff +#define INT_FAST8_MIN (-1 - (127)) +#define INT_FAST8_MAX (127) +#define INT_FAST64_MIN (-1 - (9223372036854775807)) +#define INT_FAST64_MAX (9223372036854775807) +#define UINT_FAST8_MAX 0xff +#define UINT_FAST64_MAX 0xffffffffffffffff +#define INT_FAST16_MIN (-1 - (2147483647)) +#define INT_FAST16_MAX (2147483647) +#define UINT_FAST16_MAX 0xffffffff +#define INT_FAST32_MIN (-1 - (2147483647)) +#define INT_FAST32_MAX (2147483647) +#define UINT_FAST32_MAX 0xffffffff +#define WINT_MIN 0 +#define __FSUID_H 1 +#define NSIG 32 +#define _NSIG 65 +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT 6 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGSEGV 11 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGUNUSED 31 +#define SIGRTMIN 32 +#define SIGRTMAX (65-1) +#define SA_NOCLDSTOP 0x00000001 +#define SA_NOCLDWAIT 0x00000002 +#define SA_SIGINFO 0x00000004 +#define SA_RESTORER 0x04000000 +#define SA_ONSTACK 0x08000000 +#define SA_RESTART 0x10000000 +#define SA_INTERRUPT 0x20000000 +#define SA_NODEFER 0x40000000 +#define SA_RESETHAND 0x80000000 +#define SA_NOMASK 0x40000000 +#define SA_ONESHOT 0x80000000 +#define SS_ONSTACK 1 +#define SS_DISABLE 2 +#define MINSIGSTKSZ 2048 +#define SIGSTKSZ 8192 +#define SIG_BLOCK 0 +#define SIG_UNBLOCK 1 +#define SIG_SETMASK 2 +#define SI_MAX_SIZE 128 +#define SIGEV_SIGNAL 0 +#define SIGEV_NONE 1 +#define SIGEV_THREAD 2 +#define SIGEV_THREAD_ID 4 +#define SIGEV_MAX_SIZE 64 +#define _SYS_TIME_H 1 +#define ITIMER_REAL 0 +#define ITIMER_VIRTUAL 1 +#define ITIMER_PROF 2 +#define FD_SETSIZE 1024 +#define R_OK 4 +#define W_OK 2 +#define X_OK 1 +#define F_OK 0 +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#define _CS_PATH 1 +#define _SC_CLK_TCK 1 +#define _SC_ARG_MAX 2 +#define _SC_NGROUPS_MAX 3 +#define _SC_OPEN_MAX 4 +#define _SC_PAGESIZE 5 +#define _SC_NPROCESSORS_ONLN 6 +#define _SC_NPROCESSORS_CONF 6 +#define _SC_PHYS_PAGES 7 +#define _SC_GETPW_R_SIZE_MAX 8 +#define _SC_GETGR_R_SIZE_MAX 9 +#define _PC_PATH_MAX 1 +#define _PC_VDISABLE 2 +#define L_cuserid 17 +#define _POSIX_VERSION 199506 +#define F_ULOCK 0 +#define F_LOCK 1 +#define F_TLOCK 2 +#define F_TEST 3 +#define _POSIX_MAPPED_FILES 200809 +#define S_IFMT 0xf000 +#define S_IFSOCK 0xc000 +#define S_IFLNK 0xa000 +#define S_IFREG 0x8000 +#define S_IFBLK 0x6000 +#define S_IFDIR 0x4000 +#define S_IFCHR 0x2000 +#define S_IFIFO 0x1000 +#define S_ISUID 0x800 +#define S_ISGID 0x400 +#define S_ISVTX 0x200 +#define S_IRWXU 0x1c0 +#define S_IRUSR 0x100 +#define S_IWUSR 0x80 +#define S_IXUSR 0x40 +#define S_IRWXG 0x38 +#define S_IRGRP 0x20 +#define S_IWGRP 0x10 +#define S_IXGRP 0x8 +#define S_IRWXO 0x7 +#define S_IROTH 0x4 +#define S_IWOTH 0x2 +#define S_IXOTH 0x1 +#define S_IREAD 0x100 +#define S_IWRITE 0x80 +#define S_IEXEC 0x40 +#define _SYS_UIO 1 +#define SOL_SOCKET 1 +#define SO_DEBUG 1 +#define SO_REUSEADDR 2 +#define SO_TYPE 3 +#define SO_ERROR 4 +#define SO_DONTROUTE 5 +#define SO_BROADCAST 6 +#define SO_SNDBUF 7 +#define SO_RCVBUF 8 +#define SO_KEEPALIVE 9 +#define SO_OOBINLINE 10 +#define SO_NO_CHECK 11 +#define SO_PRIORITY 12 +#define SO_LINGER 13 +#define SO_BSDCOMPAT 14 +#define SO_REUSEPORT 15 +#define SO_PASSCRED 16 +#define SO_PEERCRED 17 +#define SO_RCVLOWAT 18 +#define SO_SNDLOWAT 19 +#define SO_RCVTIMEO 20 +#define SO_SNDTIMEO 21 +#define SO_SECURITY_AUTHENTICATION 22 +#define SO_SECURITY_ENCRYPTION_TRANSPORT 23 +#define SO_SECURITY_ENCRYPTION_NETWORK 24 +#define SO_BINDTODEVICE 25 +#define SO_ATTACH_FILTER 26 +#define SO_DETACH_FILTER 27 +#define SO_GET_FILTER 26 +#define SO_PEERNAME 28 +#define SO_TIMESTAMP 29 +#define SCM_TIMESTAMP 29 +#define SO_ACCEPTCONN 30 +#define SO_PEERSEC 31 +#define SO_SNDBUFFORCE 32 +#define SO_RCVBUFFORCE 33 +#define SO_PASSSEC 34 +#define SO_TIMESTAMPNS 35 +#define SCM_TIMESTAMPNS 35 +#define SO_MARK 36 +#define SO_TIMESTAMPING 37 +#define SCM_TIMESTAMPING 37 +#define SO_PROTOCOL 38 +#define SO_DOMAIN 39 +#define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS 41 +#define SO_PEEK_OFF 42 +#define SO_NOFCS 43 +#define SO_LOCK_FILTER 44 +#define SO_SELECT_ERR_QUEUE 45 +#define SO_BUSY_POLL 46 +#define SO_MAX_PACING_RATE 47 +#define SO_BPF_EXTENSIONS 48 +#define SO_INCOMING_CPU 49 +#define SO_ATTACH_BPF 50 +#define SO_DETACH_BPF 27 +#define SO_ATTACH_REUSEPORT_CBPF 51 +#define SO_ATTACH_REUSEPORT_EBPF 52 +#define SO_CNX_ADVICE 53 +#define SCM_TIMESTAMPING_OPT_STATS 54 +#define SO_MEMINFO 55 +#define SO_INCOMING_NAPI_ID 56 +#define SO_COOKIE 57 +#define SCM_TIMESTAMPING_PKTINFO 58 +#define SO_PEERGROUPS 59 +#define SO_ZEROCOPY 60 +#define SOCK_STREAM 1 +#define SOCK_DGRAM 2 +#define SOCK_RAW 3 +#define SOCK_RDM 4 +#define SOCK_SEQPACKET 5 +#define SOCK_DCCP 6 +#define SOCK_PACKET 10 +#define UIO_FASTIOV 8 +#define UIO_MAXIOV 1024 +#define SCM_RIGHTS 0x01 +#define SCM_CREDENTIALS 0x02 +#define SCM_CONNECT 0x03 +#define AF_UNSPEC 0 +#define AF_UNIX 1 +#define AF_LOCAL 1 +#define AF_INET 2 +#define AF_AX25 3 +#define AF_IPX 4 +#define AF_APPLETALK 5 +#define AF_NETROM 6 +#define AF_BRIDGE 7 +#define AF_ATMPVC 8 +#define AF_X25 9 +#define AF_INET6 10 +#define AF_ROSE 11 +#define AF_DECnet 12 +#define AF_NETBEUI 13 +#define AF_SECURITY 14 +#define AF_KEY 15 +#define AF_NETLINK 16 +#define AF_ROUTE 16 +#define AF_PACKET 17 +#define AF_ASH 18 +#define AF_ECONET 19 +#define AF_ATMSVC 20 +#define AF_SNA 22 +#define AF_IRDA 23 +#define AF_PPPOX 24 +#define AF_WANPIPE 25 +#define AF_LLC 26 +#define AF_IB 27 +#define AF_MPLS 28 +#define AF_CAN 29 +#define AF_TIPC 30 +#define AF_BLUETOOTH 31 +#define AF_IUCV 32 +#define AF_RXRPC 33 +#define AF_ISDN 34 +#define AF_PHONET 35 +#define AF_IEEE802154 36 +#define AF_CAIF 37 +#define AF_ALG 38 +#define AF_NFC 39 +#define AF_VSOCK 40 +#define AF_KCM 41 +#define AF_QIPCRTR 42 +#define AF_SMC 43 +#define AF_MAX 44 +#define PF_UNSPEC 0 +#define PF_UNIX 1 +#define PF_LOCAL 1 +#define PF_INET 2 +#define PF_AX25 3 +#define PF_IPX 4 +#define PF_APPLETALK 5 +#define PF_NETROM 6 +#define PF_BRIDGE 7 +#define PF_ATMPVC 8 +#define PF_X25 9 +#define PF_INET6 10 +#define PF_ROSE 11 +#define PF_DECnet 12 +#define PF_NETBEUI 13 +#define PF_SECURITY 14 +#define PF_KEY 15 +#define PF_NETLINK 16 +#define PF_ROUTE 16 +#define PF_PACKET 17 +#define PF_ASH 18 +#define PF_ECONET 19 +#define PF_ATMSVC 20 +#define PF_SNA 22 +#define PF_IRDA 23 +#define PF_PPPOX 24 +#define PF_WANPIPE 25 +#define PF_LLC 26 +#define PF_IB 27 +#define PF_MPLS 28 +#define PF_CAN 29 +#define PF_TIPC 30 +#define PF_BLUETOOTH 31 +#define PF_IUCV 32 +#define PF_RXRPC 33 +#define PF_ISDN 34 +#define PF_PHONET 35 +#define PF_IEEE802154 36 +#define PF_CAIF 37 +#define PF_ALG 38 +#define PF_NFC 39 +#define PF_VSOCK 40 +#define PF_KCM 41 +#define PF_QIPCRTR 42 +#define PF_SMC 43 +#define PF_MAX 44 +#define SOMAXCONN 128 +#define MSG_OOB 1 +#define MSG_PEEK 2 +#define MSG_DONTROUTE 4 +#define MSG_TRYHARD 4 +#define MSG_CTRUNC 8 +#define MSG_PROBE 0x10 +#define MSG_TRUNC 0x20 +#define MSG_DONTWAIT 0x40 +#define MSG_EOR 0x80 +#define MSG_WAITALL 0x100 +#define MSG_FIN 0x200 +#define MSG_SYN 0x400 +#define MSG_CONFIRM 0x800 +#define MSG_RST 0x1000 +#define MSG_ERRQUEUE 0x2000 +#define MSG_NOSIGNAL 0x4000 +#define MSG_MORE 0x8000 +#define MSG_WAITFORONE 0x10000 +#define MSG_SENDPAGE_NOTLAST 0x20000 +#define MSG_BATCH 0x40000 +#define MSG_EOF 0x200 +#define MSG_ZEROCOPY 0x4000000 +#define MSG_FASTOPEN 0x20000000 +#define MSG_CMSG_CLOEXEC 0x40000000 +#define SOL_IP 0 +#define SOL_TCP 6 +#define SOL_UDP 17 +#define SOL_IPV6 41 +#define SOL_ICMPV6 58 +#define SOL_SCTP 132 +#define SOL_UDPLITE 136 +#define SOL_RAW 255 +#define SOL_IPX 256 +#define SOL_AX25 257 +#define SOL_ATALK 258 +#define SOL_NETROM 259 +#define SOL_ROSE 260 +#define SOL_DECNET 261 +#define SOL_X25 262 +#define SOL_PACKET 263 +#define SOL_ATM 264 +#define SOL_AAL 265 +#define SOL_IRDA 266 +#define SOL_NETBEUI 267 +#define SOL_LLC 268 +#define SOL_DCCP 269 +#define SOL_NETLINK 270 +#define SOL_TIPC 271 +#define SOL_RXRPC 272 +#define SOL_PPPOL2TP 273 +#define SOL_BLUETOOTH 274 +#define SOL_PNPIPE 275 +#define SOL_RDS 276 +#define SOL_IUCV 277 +#define SOL_CAIF 278 +#define SOL_ALG 279 +#define SOL_NFC 280 +#define SOL_KCM 281 +#define SOL_TLS 282 +#define IPX_TYPE 1 +#define SHUT_RD 0 +#define SHUT_WR 1 +#define SHUT_RDWR 2 +#define NI_NOFQDN 1 +#define NI_NUMERICHOST 2 +#define NI_NAMEREQD 4 +#define NI_NUMERICSERV 8 +#define NI_DGRAM 16 +#define EAI_FAMILY -1 +#define EAI_SOCKTYPE -2 +#define EAI_BADFLAGS -3 +#define EAI_NONAME -4 +#define EAI_SERVICE -5 +#define EAI_ADDRFAMILY -6 +#define EAI_NODATA -7 +#define EAI_MEMORY -8 +#define EAI_FAIL -9 +#define EAI_AGAIN -10 +#define EAI_SYSTEM -11 +#define AI_NUMERICHOST 1 +#define AI_CANONNAME 2 +#define AI_PASSIVE 4 +#define AI_NUMERICSERV 8 +#define AI_ADDRCONFIG 16 +#define AI_V4MAPPED 32 +#define AI_ALL 64 +#define SIOCADDRT 0x890B +#define SIOCDELRT 0x890C +#define SIOCRTMSG 0x890D +#define SIOCGIFNAME 0x8910 +#define SIOCSIFLINK 0x8911 +#define SIOCGIFCONF 0x8912 +#define SIOCGIFFLAGS 0x8913 +#define SIOCSIFFLAGS 0x8914 +#define SIOCGIFADDR 0x8915 +#define SIOCSIFADDR 0x8916 +#define SIOCGIFDSTADDR 0x8917 +#define SIOCSIFDSTADDR 0x8918 +#define SIOCGIFBRDADDR 0x8919 +#define SIOCSIFBRDADDR 0x891a +#define SIOCGIFNETMASK 0x891b +#define SIOCSIFNETMASK 0x891c +#define SIOCGIFMETRIC 0x891d +#define SIOCSIFMETRIC 0x891e +#define SIOCGIFMEM 0x891f +#define SIOCSIFMEM 0x8920 +#define SIOCGIFMTU 0x8921 +#define SIOCSIFMTU 0x8922 +#define SIOCSIFNAME 0x8923 +#define SIOCSIFHWADDR 0x8924 +#define SIOCGIFENCAP 0x8925 +#define SIOCSIFENCAP 0x8926 +#define SIOCGIFHWADDR 0x8927 +#define SIOCGIFSLAVE 0x8929 +#define SIOCSIFSLAVE 0x8930 +#define SIOCADDMULTI 0x8931 +#define SIOCDELMULTI 0x8932 +#define SIOCGIFINDEX 0x8933 +#define SIOGIFINDEX 0x8933 +#define SIOCSIFPFLAGS 0x8934 +#define SIOCGIFPFLAGS 0x8935 +#define SIOCDIFADDR 0x8936 +#define SIOCSIFHWBROADCAST 0x8937 +#define SIOCGIFCOUNT 0x8938 +#define SIOCGIFBR 0x8940 +#define SIOCSIFBR 0x8941 +#define SIOCGIFTXQLEN 0x8942 +#define SIOCSIFTXQLEN 0x8943 +#define SIOCGIFDIVERT 0x8944 +#define SIOCSIFDIVERT 0x8945 +#define SIOCETHTOOL 0x8946 +#define SIOCDARP 0x8953 +#define SIOCGARP 0x8954 +#define SIOCSARP 0x8955 +#define SIOCDRARP 0x8960 +#define SIOCGRARP 0x8961 +#define SIOCSRARP 0x8962 +#define SIOCGIFMAP 0x8970 +#define SIOCSIFMAP 0x8971 +#define SIOCADDDLCI 0x8980 +#define SIOCDELDLCI 0x8981 +#define SIOCDEVPRIVATE 0x89F0 +#define F_LINUX_SPECIFIC_BASE 1024 +#define F_SETOWN_EX 15 +#define F_GETOWN_EX 16 +#define F_GETOWNER_UIDS 17 +#define F_OFD_GETLK 36 +#define F_OFD_SETLK 37 +#define F_OFD_SETLKW 38 +#define F_OWNER_TID 0 +#define F_OWNER_PID 1 +#define F_OWNER_PGRP 2 +#define AT_FDCWD -100 +#define AT_SYMLINK_NOFOLLOW 0x100 +#define AT_REMOVEDIR 0x200 +#define AT_SYMLINK_FOLLOW 0x400 +#define AT_NO_AUTOMOUNT 0x800 +#define AT_EMPTY_PATH 0x1000 +#define AT_EACCESS 0x200 +#define MREMAP_MAYMOVE 1 +#define MREMAP_FIXED 2 +#define PROT_READ 0x1 +#define PROT_WRITE 0x2 +#define PROT_EXEC 0x4 +#define PROT_SEM 0x8 +#define PROT_NONE 0x0 +#define PROT_GROWSDOWN 0x01000000 +#define PROT_GROWSUP 0x02000000 +#define MAP_SHARED 0x01 +#define MAP_PRIVATE 0x02 +#define MAP_TYPE 0xf +#define MADV_REMOVE 9 +#define MADV_DONTFORK 10 +#define MADV_DOFORK 11 +#define MADV_MERGEABLE 12 +#define MADV_UNMERGEABLE 13 +#define MADV_HUGEPAGE 14 +#define MADV_NOHUGEPAGE 15 +#define MADV_DONTDUMP 16 +#define MADV_DODUMP 17 +#define MADV_HWPOISON 100 +#define MADV_SOFT_OFFLINE 101 +#define MLOCK_ONFAULT 1 +#define MAP_FILE 0 +#define PTRACE_TRACEME 0 +#define PTRACE_PEEKTEXT 1 +#define PTRACE_PEEKDATA 2 +#define PTRACE_PEEKUSR 3 +#define PTRACE_PEEKUSER 3 +#define PTRACE_POKETEXT 4 +#define PTRACE_POKEDATA 5 +#define PTRACE_POKEUSR 6 +#define PTRACE_POKEUSER 6 +#define PTRACE_CONT 7 +#define PTRACE_KILL 8 +#define PTRACE_SINGLESTEP 9 +#define PTRACE_ATTACH 0x10 +#define PTRACE_DETACH 0x11 +#define PTRACE_SYSCALL 24 +#define PTRACE_GETEVENTMSG 0x4201 +#define PTRACE_GETSIGINFO 0x4202 +#define PTRACE_SETSIGINFO 0x4203 +#define PTRACE_O_TRACESYSGOOD 0x00000001 +#define PTRACE_O_TRACEFORK 0x00000002 +#define PTRACE_O_TRACEVFORK 0x00000004 +#define PTRACE_O_TRACECLONE 0x00000008 +#define PTRACE_O_TRACEEXEC 0x00000010 +#define PTRACE_O_TRACEVFORKDONE 0x00000020 +#define PTRACE_O_TRACEEXIT 0x00000040 +#define PTRACE_O_MASK 0x0000007f +#define PTRACE_EVENT_FORK 1 +#define PTRACE_EVENT_VFORK 2 +#define PTRACE_EVENT_CLONE 3 +#define PTRACE_EVENT_EXEC 4 +#define PTRACE_EVENT_VFORK_DONE 5 +#define PTRACE_EVENT_EXIT 6 +#define PT_TRACE_ME 0 +#define PT_READ_I 1 +#define PT_READ_D 2 +#define PT_READ_U 3 +#define PT_WRITE_I 4 +#define PT_WRITE_D 5 +#define PT_WRITE_U 6 +#define PT_CONTINUE 7 +#define PT_KILL 8 +#define PT_STEP 9 +#define PT_ATTACH 0x10 +#define PT_DETACH 0x11 +#define SYS_accept 202 +#define SYS_accept4 242 +#define SYS_acct 89 +#define SYS_add_key 217 +#define SYS_adjtimex 171 +#define SYS_arch_specific_syscall 244 +#define SYS_bind 200 +#define SYS_bpf 280 +#define SYS_brk 214 +#define SYS_capget 90 +#define SYS_capset 91 +#define SYS_chdir 49 +#define SYS_chroot 51 +#define SYS_clock_adjtime 266 +#define SYS_clock_getres 114 +#define SYS_clock_gettime 113 +#define SYS_clock_nanosleep 115 +#define SYS_clock_settime 112 +#define SYS_clone 220 +#define SYS_clone3 435 +#define SYS_close 57 +#define SYS_close_range 436 +#define SYS_connect 203 +#define SYS_copy_file_range 285 +#define SYS_delete_module 106 +#define SYS_dup 23 +#define SYS_dup3 24 +#define SYS_epoll_create1 20 +#define SYS_epoll_ctl 21 +#define SYS_epoll_pwait 22 +#define SYS_epoll_pwait2 441 +#define SYS_eventfd2 19 +#define SYS_execve 221 +#define SYS_execveat 281 +#define SYS_exit 93 +#define SYS_exit_group 94 +#define SYS_faccessat 48 +#define SYS_faccessat2 439 +#define SYS_fadvise64 223 +#define SYS_fallocate 47 +#define SYS_fanotify_init 262 +#define SYS_fanotify_mark 263 +#define SYS_fchdir 50 +#define SYS_fchmod 52 +#define SYS_fchmodat 53 +#define SYS_fchown 55 +#define SYS_fchownat 54 +#define SYS_fcntl 25 +#define SYS_fdatasync 83 +#define SYS_fgetxattr 10 +#define SYS_finit_module 273 +#define SYS_flistxattr 13 +#define SYS_flock 32 +#define SYS_fremovexattr 16 +#define SYS_fsconfig 431 +#define SYS_fsetxattr 7 +#define SYS_fsmount 432 +#define SYS_fsopen 430 +#define SYS_fspick 433 +#define SYS_fstat 80 +#define SYS_fstatfs 44 +#define SYS_fsync 82 +#define SYS_ftruncate 46 +#define SYS_futex 98 +#define SYS_getcpu 168 +#define SYS_getcwd 17 +#define SYS_getdents64 61 +#define SYS_getegid 177 +#define SYS_geteuid 175 +#define SYS_getgid 176 +#define SYS_getgroups 158 +#define SYS_getitimer 102 +#define SYS_get_mempolicy 236 +#define SYS_getpeername 205 +#define SYS_getpgid 155 +#define SYS_getpid 172 +#define SYS_getppid 173 +#define SYS_getpriority 141 +#define SYS_getrandom 278 +#define SYS_getresgid 150 +#define SYS_getresuid 148 +#define SYS_getrlimit 163 +#define SYS_get_robust_list 100 +#define SYS_getrusage 165 +#define SYS_getsid 156 +#define SYS_getsockname 204 +#define SYS_getsockopt 209 +#define SYS_gettid 178 +#define SYS_gettimeofday 169 +#define SYS_getuid 174 +#define SYS_getxattr 8 +#define SYS_init_module 105 +#define SYS_inotify_add_watch 27 +#define SYS_inotify_init1 26 +#define SYS_inotify_rm_watch 28 +#define SYS_io_cancel 3 +#define SYS_ioctl 29 +#define SYS_io_destroy 1 +#define SYS_io_getevents 4 +#define SYS_io_pgetevents 292 +#define SYS_ioprio_get 31 +#define SYS_ioprio_set 30 +#define SYS_io_setup 0 +#define SYS_io_submit 2 +#define SYS_io_uring_enter 426 +#define SYS_io_uring_register 427 +#define SYS_io_uring_setup 425 +#define SYS_kcmp 272 +#define SYS_kexec_file_load 294 +#define SYS_kexec_load 104 +#define SYS_keyctl 219 +#define SYS_kill 129 +#define SYS_landlock_add_rule 445 +#define SYS_landlock_create_ruleset 444 +#define SYS_landlock_restrict_self 446 +#define SYS_lgetxattr 9 +#define SYS_linkat 37 +#define SYS_listen 201 +#define SYS_listxattr 11 +#define SYS_llistxattr 12 +#define SYS_lookup_dcookie 18 +#define SYS_lremovexattr 15 +#define SYS_lseek 62 +#define SYS_lsetxattr 6 +#define SYS_madvise 233 +#define SYS_mbind 235 +#define SYS_membarrier 283 +#define SYS_memfd_create 279 +#define SYS_migrate_pages 238 +#define SYS_mincore 232 +#define SYS_mkdirat 34 +#define SYS_mknodat 33 +#define SYS_mlock 228 +#define SYS_mlock2 284 +#define SYS_mlockall 230 +#define SYS_mmap 222 +#define SYS_mount 40 +#define SYS_mount_setattr 442 +#define SYS_move_mount 429 +#define SYS_move_pages 239 +#define SYS_mprotect 226 +#define SYS_mq_getsetattr 185 +#define SYS_mq_notify 184 +#define SYS_mq_open 180 +#define SYS_mq_timedreceive 183 +#define SYS_mq_timedsend 182 +#define SYS_mq_unlink 181 +#define SYS_mremap 216 +#define SYS_msgctl 187 +#define SYS_msgget 186 +#define SYS_msgrcv 188 +#define SYS_msgsnd 189 +#define SYS_msync 227 +#define SYS_munlock 229 +#define SYS_munlockall 231 +#define SYS_munmap 215 +#define SYS_name_to_handle_at 264 +#define SYS_nanosleep 101 +#define SYS_newfstatat 79 +#define SYS_nfsservctl 42 +#define SYS_openat 56 +#define SYS_openat2 437 +#define SYS_open_by_handle_at 265 +#define SYS_open_tree 428 +#define SYS_perf_event_open 241 +#define SYS_personality 92 +#define SYS_pidfd_getfd 438 +#define SYS_pidfd_open 434 +#define SYS_pidfd_send_signal 424 +#define SYS_pipe2 59 +#define SYS_pivot_root 41 +#define SYS_pkey_alloc 289 +#define SYS_pkey_free 290 +#define SYS_pkey_mprotect 288 +#define SYS_ppoll 73 +#define SYS_prctl 167 +#define SYS_pread64 67 +#define SYS_preadv 69 +#define SYS_preadv2 286 +#define SYS_prlimit64 261 +#define SYS_process_madvise 440 +#define SYS_process_vm_readv 270 +#define SYS_process_vm_writev 271 +#define SYS_pselect6 72 +#define SYS_ptrace 117 +#define SYS_pwrite64 68 +#define SYS_pwritev 70 +#define SYS_pwritev2 287 +#define SYS_quotactl 60 +#define SYS_read 63 +#define SYS_readahead 213 +#define SYS_readlinkat 78 +#define SYS_readv 65 +#define SYS_reboot 142 +#define SYS_recvfrom 207 +#define SYS_recvmmsg 243 +#define SYS_recvmsg 212 +#define SYS_remap_file_pages 234 +#define SYS_removexattr 14 +#define SYS_renameat2 276 +#define SYS_request_key 218 +#define SYS_restart_syscall 128 +#define SYS_riscv_flush_icache (244 + 15) +#define SYS_rseq 293 +#define SYS_rt_sigaction 134 +#define SYS_rt_sigpending 136 +#define SYS_rt_sigprocmask 135 +#define SYS_rt_sigqueueinfo 138 +#define SYS_rt_sigreturn 139 +#define SYS_rt_sigsuspend 133 +#define SYS_rt_sigtimedwait 137 +#define SYS_rt_tgsigqueueinfo 240 +#define SYS_sched_getaffinity 123 +#define SYS_sched_getattr 275 +#define SYS_sched_getparam 121 +#define SYS_sched_get_priority_max 125 +#define SYS_sched_get_priority_min 126 +#define SYS_sched_getscheduler 120 +#define SYS_sched_rr_get_interval 127 +#define SYS_sched_setaffinity 122 +#define SYS_sched_setattr 274 +#define SYS_sched_setparam 118 +#define SYS_sched_setscheduler 119 +#define SYS_sched_yield 124 +#define SYS_seccomp 277 +#define SYS_semctl 191 +#define SYS_semget 190 +#define SYS_semop 193 +#define SYS_semtimedop 192 +#define SYS_sendfile 71 +#define SYS_sendmmsg 269 +#define SYS_sendmsg 211 +#define SYS_sendto 206 +#define SYS_setdomainname 162 +#define SYS_setfsgid 152 +#define SYS_setfsuid 151 +#define SYS_setgid 144 +#define SYS_setgroups 159 +#define SYS_sethostname 161 +#define SYS_setitimer 103 +#define SYS_set_mempolicy 237 +#define SYS_setns 268 +#define SYS_setpgid 154 +#define SYS_setpriority 140 +#define SYS_setregid 143 +#define SYS_setresgid 149 +#define SYS_setresuid 147 +#define SYS_setreuid 145 +#define SYS_setrlimit 164 +#define SYS_set_robust_list 99 +#define SYS_setsid 157 +#define SYS_setsockopt 208 +#define SYS_set_tid_address 96 +#define SYS_settimeofday 170 +#define SYS_setuid 146 +#define SYS_setxattr 5 +#define SYS_shmat 196 +#define SYS_shmctl 195 +#define SYS_shmdt 197 +#define SYS_shmget 194 +#define SYS_shutdown 210 +#define SYS_sigaltstack 132 +#define SYS_signalfd4 74 +#define SYS_socket 198 +#define SYS_socketpair 199 +#define SYS_splice 76 +#define SYS_statfs 43 +#define SYS_statx 291 +#define SYS_swapoff 225 +#define SYS_swapon 224 +#define SYS_symlinkat 36 +#define SYS_sync 81 +#define SYS_sync_file_range 84 +#define SYS_syncfs 267 +#define SYS_sysinfo 179 +#define SYS_syslog 116 +#define SYS_sysriscv 244 +#define SYS_tee 77 +#define SYS_tgkill 131 +#define SYS_timer_create 107 +#define SYS_timer_delete 111 +#define SYS_timerfd_create 85 +#define SYS_timerfd_gettime 87 +#define SYS_timerfd_settime 86 +#define SYS_timer_getoverrun 109 +#define SYS_timer_gettime 108 +#define SYS_timer_settime 110 +#define SYS_times 153 +#define SYS_tkill 130 +#define SYS_truncate 45 +#define SYS_umask 166 +#define SYS_umount2 39 +#define SYS_uname 160 +#define SYS_unlinkat 35 +#define SYS_unshare 97 +#define SYS_userfaultfd 282 +#define SYS_utimensat 88 +#define SYS_vhangup 58 +#define SYS_vmsplice 75 +#define SYS_wait4 260 +#define SYS_waitid 95 +#define SYS_write 64 +#define SYS_writev 66 diff --git a/pwnlib/shellcraft/registers.py b/pwnlib/shellcraft/registers.py index fcc42d717..fe366f70c 100644 --- a/pwnlib/shellcraft/registers.py +++ b/pwnlib/shellcraft/registers.py @@ -73,7 +73,42 @@ sparc += ["pc", "sp", "fp", "psr" ] sparc = list(map('%{}'.format, sparc)) +riscv = { + 'x0' : 0, 'zero': 0, + 'x1' : 1, 'ra': 1, + 'x2' : 2, 'sp': 2, + 'x3' : 3, 'gp': 3, + 'x4' : 4, 'tp': 4, + 'x5' : 5, 't0': 5, + 'x6' : 6, 't1': 6, + 'x7' : 7, 't2': 7, + 'x8' : 8, 's0': 8, 'fp': 8, + 'x9' : 9, 's1': 9, + 'x10': 10, 'a0': 10, + 'x11': 11, 'a1': 11, + 'x12': 12, 'a2': 12, + 'x13': 13, 'a3': 13, + 'x14': 14, 'a4': 14, + 'x15': 15, 'a5': 15, + 'x16': 16, 'a6': 16, + 'x17': 17, 'a7': 17, + 'x18': 18, 's2': 18, + 'x19': 19, 's3': 19, + 'x20': 20, 's4': 20, + 'x21': 21, 's5': 21, + 'x22': 22, 's6': 22, + 'x23': 23, 's7': 23, + 'x24': 24, 's8': 24, + 'x25': 25, 's9': 25, + 'x26': 26, 's10': 26, + 'x27': 27, 's11': 27, + 'x28': 28, 't3': 28, + 'x29': 29, 't4': 29, + 'x30': 30, 't5': 30, + 'x31': 31, 't6': 31, +} +riscv_list = list(riscv) # x86/amd64 registers in decreasing size i386_ordered = [ @@ -215,7 +250,9 @@ def current(): 'thumb': arm, 'aarch64': aarch64, 'mips': mips_list, - 'powerpc': powerpc + 'powerpc': powerpc, + 'riscv32': riscv, + 'riscv64': riscv, }[context.arch] # def is_register(sz): diff --git a/pwnlib/shellcraft/templates/common/linux/syscalls/close_range.asm b/pwnlib/shellcraft/templates/common/linux/syscalls/close_range.asm new file mode 100644 index 000000000..ecb77a9b6 --- /dev/null +++ b/pwnlib/shellcraft/templates/common/linux/syscalls/close_range.asm @@ -0,0 +1,101 @@ +<% +import collections +import pwnlib.abi +import pwnlib.constants +import pwnlib.shellcraft +import six +%> +<%docstring>close_range(vararg_0, vararg_1, vararg_2, vararg_3, vararg_4) -> str + +Invokes the syscall close_range. + +See 'man 2 close_range' for more information. + +Arguments: + vararg(int): vararg +Returns: + long + +<%page args="vararg_0=None, vararg_1=None, vararg_2=None, vararg_3=None, vararg_4=None"/> +<% + abi = pwnlib.abi.ABI.syscall() + stack = abi.stack + regs = abi.register_arguments[1:] + allregs = pwnlib.shellcraft.registers.current() + + can_pushstr = [] + can_pushstr_array = [] + + argument_names = ['vararg_0', 'vararg_1', 'vararg_2', 'vararg_3', 'vararg_4'] + argument_values = [vararg_0, vararg_1, vararg_2, vararg_3, vararg_4] + + # Load all of the arguments into their destination registers / stack slots. + register_arguments = dict() + stack_arguments = collections.OrderedDict() + string_arguments = dict() + dict_arguments = dict() + array_arguments = dict() + syscall_repr = [] + + for name, arg in zip(argument_names, argument_values): + if arg is not None: + syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False))) + + # If the argument itself (input) is a register... + if arg in allregs: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[index] = arg + + # The argument is not a register. It is a string value, and we + # are expecting a string value + elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): + if isinstance(arg, six.text_type): + arg = arg.encode('utf-8') + string_arguments[name] = arg + + # The argument is not a register. It is a dictionary, and we are + # expecting K:V paris. + elif name in can_pushstr_array and isinstance(arg, dict): + array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] + + # The arguent is not a register. It is a list, and we are expecting + # a list of arguments. + elif name in can_pushstr_array and isinstance(arg, (list, tuple)): + array_arguments[name] = arg + + # The argument is not a register, string, dict, or list. + # It could be a constant string ('O_RDONLY') for an integer argument, + # an actual integer value, or a constant. + else: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[target] = arg + + # Some syscalls have different names on various architectures. + # Determine which syscall number to use for the current architecture. + for syscall in ['SYS_close_range']: + if hasattr(pwnlib.constants, syscall): + break + else: + raise Exception("Could not locate any syscalls: %r" % syscalls) +%> + /* close_range(${', '.join(syscall_repr)}) */ +%for name, arg in string_arguments.items(): + ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} + ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} +%endfor +%for name, arg in array_arguments.items(): + ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} +%endfor +%for name, arg in stack_arguments.items(): + ${pwnlib.shellcraft.push(arg)} +%endfor + ${pwnlib.shellcraft.setregs(register_arguments)} + ${pwnlib.shellcraft.syscall(syscall)} diff --git a/pwnlib/shellcraft/templates/common/linux/syscalls/epoll_pwait2.asm b/pwnlib/shellcraft/templates/common/linux/syscalls/epoll_pwait2.asm new file mode 100644 index 000000000..a06777704 --- /dev/null +++ b/pwnlib/shellcraft/templates/common/linux/syscalls/epoll_pwait2.asm @@ -0,0 +1,101 @@ +<% +import collections +import pwnlib.abi +import pwnlib.constants +import pwnlib.shellcraft +import six +%> +<%docstring>epoll_pwait2(vararg_0, vararg_1, vararg_2, vararg_3, vararg_4) -> str + +Invokes the syscall epoll_pwait2. + +See 'man 2 epoll_pwait2' for more information. + +Arguments: + vararg(int): vararg +Returns: + long + +<%page args="vararg_0=None, vararg_1=None, vararg_2=None, vararg_3=None, vararg_4=None"/> +<% + abi = pwnlib.abi.ABI.syscall() + stack = abi.stack + regs = abi.register_arguments[1:] + allregs = pwnlib.shellcraft.registers.current() + + can_pushstr = [] + can_pushstr_array = [] + + argument_names = ['vararg_0', 'vararg_1', 'vararg_2', 'vararg_3', 'vararg_4'] + argument_values = [vararg_0, vararg_1, vararg_2, vararg_3, vararg_4] + + # Load all of the arguments into their destination registers / stack slots. + register_arguments = dict() + stack_arguments = collections.OrderedDict() + string_arguments = dict() + dict_arguments = dict() + array_arguments = dict() + syscall_repr = [] + + for name, arg in zip(argument_names, argument_values): + if arg is not None: + syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False))) + + # If the argument itself (input) is a register... + if arg in allregs: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[index] = arg + + # The argument is not a register. It is a string value, and we + # are expecting a string value + elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): + if isinstance(arg, six.text_type): + arg = arg.encode('utf-8') + string_arguments[name] = arg + + # The argument is not a register. It is a dictionary, and we are + # expecting K:V paris. + elif name in can_pushstr_array and isinstance(arg, dict): + array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] + + # The arguent is not a register. It is a list, and we are expecting + # a list of arguments. + elif name in can_pushstr_array and isinstance(arg, (list, tuple)): + array_arguments[name] = arg + + # The argument is not a register, string, dict, or list. + # It could be a constant string ('O_RDONLY') for an integer argument, + # an actual integer value, or a constant. + else: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[target] = arg + + # Some syscalls have different names on various architectures. + # Determine which syscall number to use for the current architecture. + for syscall in ['SYS_epoll_pwait2']: + if hasattr(pwnlib.constants, syscall): + break + else: + raise Exception("Could not locate any syscalls: %r" % syscalls) +%> + /* epoll_pwait2(${', '.join(syscall_repr)}) */ +%for name, arg in string_arguments.items(): + ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} + ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} +%endfor +%for name, arg in array_arguments.items(): + ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} +%endfor +%for name, arg in stack_arguments.items(): + ${pwnlib.shellcraft.push(arg)} +%endfor + ${pwnlib.shellcraft.setregs(register_arguments)} + ${pwnlib.shellcraft.syscall(syscall)} diff --git a/pwnlib/shellcraft/templates/common/linux/syscalls/faccessat2.asm b/pwnlib/shellcraft/templates/common/linux/syscalls/faccessat2.asm new file mode 100644 index 000000000..5d6f05d18 --- /dev/null +++ b/pwnlib/shellcraft/templates/common/linux/syscalls/faccessat2.asm @@ -0,0 +1,101 @@ +<% +import collections +import pwnlib.abi +import pwnlib.constants +import pwnlib.shellcraft +import six +%> +<%docstring>faccessat2(vararg_0, vararg_1, vararg_2, vararg_3, vararg_4) -> str + +Invokes the syscall faccessat2. + +See 'man 2 faccessat2' for more information. + +Arguments: + vararg(int): vararg +Returns: + long + +<%page args="vararg_0=None, vararg_1=None, vararg_2=None, vararg_3=None, vararg_4=None"/> +<% + abi = pwnlib.abi.ABI.syscall() + stack = abi.stack + regs = abi.register_arguments[1:] + allregs = pwnlib.shellcraft.registers.current() + + can_pushstr = [] + can_pushstr_array = [] + + argument_names = ['vararg_0', 'vararg_1', 'vararg_2', 'vararg_3', 'vararg_4'] + argument_values = [vararg_0, vararg_1, vararg_2, vararg_3, vararg_4] + + # Load all of the arguments into their destination registers / stack slots. + register_arguments = dict() + stack_arguments = collections.OrderedDict() + string_arguments = dict() + dict_arguments = dict() + array_arguments = dict() + syscall_repr = [] + + for name, arg in zip(argument_names, argument_values): + if arg is not None: + syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False))) + + # If the argument itself (input) is a register... + if arg in allregs: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[index] = arg + + # The argument is not a register. It is a string value, and we + # are expecting a string value + elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): + if isinstance(arg, six.text_type): + arg = arg.encode('utf-8') + string_arguments[name] = arg + + # The argument is not a register. It is a dictionary, and we are + # expecting K:V paris. + elif name in can_pushstr_array and isinstance(arg, dict): + array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] + + # The arguent is not a register. It is a list, and we are expecting + # a list of arguments. + elif name in can_pushstr_array and isinstance(arg, (list, tuple)): + array_arguments[name] = arg + + # The argument is not a register, string, dict, or list. + # It could be a constant string ('O_RDONLY') for an integer argument, + # an actual integer value, or a constant. + else: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[target] = arg + + # Some syscalls have different names on various architectures. + # Determine which syscall number to use for the current architecture. + for syscall in ['SYS_faccessat2']: + if hasattr(pwnlib.constants, syscall): + break + else: + raise Exception("Could not locate any syscalls: %r" % syscalls) +%> + /* faccessat2(${', '.join(syscall_repr)}) */ +%for name, arg in string_arguments.items(): + ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} + ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} +%endfor +%for name, arg in array_arguments.items(): + ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} +%endfor +%for name, arg in stack_arguments.items(): + ${pwnlib.shellcraft.push(arg)} +%endfor + ${pwnlib.shellcraft.setregs(register_arguments)} + ${pwnlib.shellcraft.syscall(syscall)} diff --git a/pwnlib/shellcraft/templates/common/linux/syscalls/landlock_add_rule.asm b/pwnlib/shellcraft/templates/common/linux/syscalls/landlock_add_rule.asm new file mode 100644 index 000000000..920d91e97 --- /dev/null +++ b/pwnlib/shellcraft/templates/common/linux/syscalls/landlock_add_rule.asm @@ -0,0 +1,101 @@ +<% +import collections +import pwnlib.abi +import pwnlib.constants +import pwnlib.shellcraft +import six +%> +<%docstring>landlock_add_rule(vararg_0, vararg_1, vararg_2, vararg_3, vararg_4) -> str + +Invokes the syscall landlock_add_rule. + +See 'man 2 landlock_add_rule' for more information. + +Arguments: + vararg(int): vararg +Returns: + long + +<%page args="vararg_0=None, vararg_1=None, vararg_2=None, vararg_3=None, vararg_4=None"/> +<% + abi = pwnlib.abi.ABI.syscall() + stack = abi.stack + regs = abi.register_arguments[1:] + allregs = pwnlib.shellcraft.registers.current() + + can_pushstr = [] + can_pushstr_array = [] + + argument_names = ['vararg_0', 'vararg_1', 'vararg_2', 'vararg_3', 'vararg_4'] + argument_values = [vararg_0, vararg_1, vararg_2, vararg_3, vararg_4] + + # Load all of the arguments into their destination registers / stack slots. + register_arguments = dict() + stack_arguments = collections.OrderedDict() + string_arguments = dict() + dict_arguments = dict() + array_arguments = dict() + syscall_repr = [] + + for name, arg in zip(argument_names, argument_values): + if arg is not None: + syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False))) + + # If the argument itself (input) is a register... + if arg in allregs: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[index] = arg + + # The argument is not a register. It is a string value, and we + # are expecting a string value + elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): + if isinstance(arg, six.text_type): + arg = arg.encode('utf-8') + string_arguments[name] = arg + + # The argument is not a register. It is a dictionary, and we are + # expecting K:V paris. + elif name in can_pushstr_array and isinstance(arg, dict): + array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] + + # The arguent is not a register. It is a list, and we are expecting + # a list of arguments. + elif name in can_pushstr_array and isinstance(arg, (list, tuple)): + array_arguments[name] = arg + + # The argument is not a register, string, dict, or list. + # It could be a constant string ('O_RDONLY') for an integer argument, + # an actual integer value, or a constant. + else: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[target] = arg + + # Some syscalls have different names on various architectures. + # Determine which syscall number to use for the current architecture. + for syscall in ['SYS_landlock_add_rule']: + if hasattr(pwnlib.constants, syscall): + break + else: + raise Exception("Could not locate any syscalls: %r" % syscalls) +%> + /* landlock_add_rule(${', '.join(syscall_repr)}) */ +%for name, arg in string_arguments.items(): + ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} + ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} +%endfor +%for name, arg in array_arguments.items(): + ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} +%endfor +%for name, arg in stack_arguments.items(): + ${pwnlib.shellcraft.push(arg)} +%endfor + ${pwnlib.shellcraft.setregs(register_arguments)} + ${pwnlib.shellcraft.syscall(syscall)} diff --git a/pwnlib/shellcraft/templates/common/linux/syscalls/landlock_create_ruleset.asm b/pwnlib/shellcraft/templates/common/linux/syscalls/landlock_create_ruleset.asm new file mode 100644 index 000000000..179d2f7f7 --- /dev/null +++ b/pwnlib/shellcraft/templates/common/linux/syscalls/landlock_create_ruleset.asm @@ -0,0 +1,101 @@ +<% +import collections +import pwnlib.abi +import pwnlib.constants +import pwnlib.shellcraft +import six +%> +<%docstring>landlock_create_ruleset(vararg_0, vararg_1, vararg_2, vararg_3, vararg_4) -> str + +Invokes the syscall landlock_create_ruleset. + +See 'man 2 landlock_create_ruleset' for more information. + +Arguments: + vararg(int): vararg +Returns: + long + +<%page args="vararg_0=None, vararg_1=None, vararg_2=None, vararg_3=None, vararg_4=None"/> +<% + abi = pwnlib.abi.ABI.syscall() + stack = abi.stack + regs = abi.register_arguments[1:] + allregs = pwnlib.shellcraft.registers.current() + + can_pushstr = [] + can_pushstr_array = [] + + argument_names = ['vararg_0', 'vararg_1', 'vararg_2', 'vararg_3', 'vararg_4'] + argument_values = [vararg_0, vararg_1, vararg_2, vararg_3, vararg_4] + + # Load all of the arguments into their destination registers / stack slots. + register_arguments = dict() + stack_arguments = collections.OrderedDict() + string_arguments = dict() + dict_arguments = dict() + array_arguments = dict() + syscall_repr = [] + + for name, arg in zip(argument_names, argument_values): + if arg is not None: + syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False))) + + # If the argument itself (input) is a register... + if arg in allregs: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[index] = arg + + # The argument is not a register. It is a string value, and we + # are expecting a string value + elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): + if isinstance(arg, six.text_type): + arg = arg.encode('utf-8') + string_arguments[name] = arg + + # The argument is not a register. It is a dictionary, and we are + # expecting K:V paris. + elif name in can_pushstr_array and isinstance(arg, dict): + array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] + + # The arguent is not a register. It is a list, and we are expecting + # a list of arguments. + elif name in can_pushstr_array and isinstance(arg, (list, tuple)): + array_arguments[name] = arg + + # The argument is not a register, string, dict, or list. + # It could be a constant string ('O_RDONLY') for an integer argument, + # an actual integer value, or a constant. + else: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[target] = arg + + # Some syscalls have different names on various architectures. + # Determine which syscall number to use for the current architecture. + for syscall in ['SYS_landlock_create_ruleset']: + if hasattr(pwnlib.constants, syscall): + break + else: + raise Exception("Could not locate any syscalls: %r" % syscalls) +%> + /* landlock_create_ruleset(${', '.join(syscall_repr)}) */ +%for name, arg in string_arguments.items(): + ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} + ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} +%endfor +%for name, arg in array_arguments.items(): + ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} +%endfor +%for name, arg in stack_arguments.items(): + ${pwnlib.shellcraft.push(arg)} +%endfor + ${pwnlib.shellcraft.setregs(register_arguments)} + ${pwnlib.shellcraft.syscall(syscall)} diff --git a/pwnlib/shellcraft/templates/common/linux/syscalls/landlock_restrict_self.asm b/pwnlib/shellcraft/templates/common/linux/syscalls/landlock_restrict_self.asm new file mode 100644 index 000000000..0a138bcc2 --- /dev/null +++ b/pwnlib/shellcraft/templates/common/linux/syscalls/landlock_restrict_self.asm @@ -0,0 +1,101 @@ +<% +import collections +import pwnlib.abi +import pwnlib.constants +import pwnlib.shellcraft +import six +%> +<%docstring>landlock_restrict_self(vararg_0, vararg_1, vararg_2, vararg_3, vararg_4) -> str + +Invokes the syscall landlock_restrict_self. + +See 'man 2 landlock_restrict_self' for more information. + +Arguments: + vararg(int): vararg +Returns: + long + +<%page args="vararg_0=None, vararg_1=None, vararg_2=None, vararg_3=None, vararg_4=None"/> +<% + abi = pwnlib.abi.ABI.syscall() + stack = abi.stack + regs = abi.register_arguments[1:] + allregs = pwnlib.shellcraft.registers.current() + + can_pushstr = [] + can_pushstr_array = [] + + argument_names = ['vararg_0', 'vararg_1', 'vararg_2', 'vararg_3', 'vararg_4'] + argument_values = [vararg_0, vararg_1, vararg_2, vararg_3, vararg_4] + + # Load all of the arguments into their destination registers / stack slots. + register_arguments = dict() + stack_arguments = collections.OrderedDict() + string_arguments = dict() + dict_arguments = dict() + array_arguments = dict() + syscall_repr = [] + + for name, arg in zip(argument_names, argument_values): + if arg is not None: + syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False))) + + # If the argument itself (input) is a register... + if arg in allregs: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[index] = arg + + # The argument is not a register. It is a string value, and we + # are expecting a string value + elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): + if isinstance(arg, six.text_type): + arg = arg.encode('utf-8') + string_arguments[name] = arg + + # The argument is not a register. It is a dictionary, and we are + # expecting K:V paris. + elif name in can_pushstr_array and isinstance(arg, dict): + array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] + + # The arguent is not a register. It is a list, and we are expecting + # a list of arguments. + elif name in can_pushstr_array and isinstance(arg, (list, tuple)): + array_arguments[name] = arg + + # The argument is not a register, string, dict, or list. + # It could be a constant string ('O_RDONLY') for an integer argument, + # an actual integer value, or a constant. + else: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[target] = arg + + # Some syscalls have different names on various architectures. + # Determine which syscall number to use for the current architecture. + for syscall in ['SYS_landlock_restrict_self']: + if hasattr(pwnlib.constants, syscall): + break + else: + raise Exception("Could not locate any syscalls: %r" % syscalls) +%> + /* landlock_restrict_self(${', '.join(syscall_repr)}) */ +%for name, arg in string_arguments.items(): + ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} + ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} +%endfor +%for name, arg in array_arguments.items(): + ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} +%endfor +%for name, arg in stack_arguments.items(): + ${pwnlib.shellcraft.push(arg)} +%endfor + ${pwnlib.shellcraft.setregs(register_arguments)} + ${pwnlib.shellcraft.syscall(syscall)} diff --git a/pwnlib/shellcraft/templates/common/linux/syscalls/mount_setattr.asm b/pwnlib/shellcraft/templates/common/linux/syscalls/mount_setattr.asm new file mode 100644 index 000000000..33cc2f5af --- /dev/null +++ b/pwnlib/shellcraft/templates/common/linux/syscalls/mount_setattr.asm @@ -0,0 +1,101 @@ +<% +import collections +import pwnlib.abi +import pwnlib.constants +import pwnlib.shellcraft +import six +%> +<%docstring>mount_setattr(vararg_0, vararg_1, vararg_2, vararg_3, vararg_4) -> str + +Invokes the syscall mount_setattr. + +See 'man 2 mount_setattr' for more information. + +Arguments: + vararg(int): vararg +Returns: + long + +<%page args="vararg_0=None, vararg_1=None, vararg_2=None, vararg_3=None, vararg_4=None"/> +<% + abi = pwnlib.abi.ABI.syscall() + stack = abi.stack + regs = abi.register_arguments[1:] + allregs = pwnlib.shellcraft.registers.current() + + can_pushstr = [] + can_pushstr_array = [] + + argument_names = ['vararg_0', 'vararg_1', 'vararg_2', 'vararg_3', 'vararg_4'] + argument_values = [vararg_0, vararg_1, vararg_2, vararg_3, vararg_4] + + # Load all of the arguments into their destination registers / stack slots. + register_arguments = dict() + stack_arguments = collections.OrderedDict() + string_arguments = dict() + dict_arguments = dict() + array_arguments = dict() + syscall_repr = [] + + for name, arg in zip(argument_names, argument_values): + if arg is not None: + syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False))) + + # If the argument itself (input) is a register... + if arg in allregs: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[index] = arg + + # The argument is not a register. It is a string value, and we + # are expecting a string value + elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): + if isinstance(arg, six.text_type): + arg = arg.encode('utf-8') + string_arguments[name] = arg + + # The argument is not a register. It is a dictionary, and we are + # expecting K:V paris. + elif name in can_pushstr_array and isinstance(arg, dict): + array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] + + # The arguent is not a register. It is a list, and we are expecting + # a list of arguments. + elif name in can_pushstr_array and isinstance(arg, (list, tuple)): + array_arguments[name] = arg + + # The argument is not a register, string, dict, or list. + # It could be a constant string ('O_RDONLY') for an integer argument, + # an actual integer value, or a constant. + else: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[target] = arg + + # Some syscalls have different names on various architectures. + # Determine which syscall number to use for the current architecture. + for syscall in ['SYS_mount_setattr']: + if hasattr(pwnlib.constants, syscall): + break + else: + raise Exception("Could not locate any syscalls: %r" % syscalls) +%> + /* mount_setattr(${', '.join(syscall_repr)}) */ +%for name, arg in string_arguments.items(): + ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} + ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} +%endfor +%for name, arg in array_arguments.items(): + ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} +%endfor +%for name, arg in stack_arguments.items(): + ${pwnlib.shellcraft.push(arg)} +%endfor + ${pwnlib.shellcraft.setregs(register_arguments)} + ${pwnlib.shellcraft.syscall(syscall)} diff --git a/pwnlib/shellcraft/templates/common/linux/syscalls/process_madvise.asm b/pwnlib/shellcraft/templates/common/linux/syscalls/process_madvise.asm new file mode 100644 index 000000000..6a6357a2c --- /dev/null +++ b/pwnlib/shellcraft/templates/common/linux/syscalls/process_madvise.asm @@ -0,0 +1,101 @@ +<% +import collections +import pwnlib.abi +import pwnlib.constants +import pwnlib.shellcraft +import six +%> +<%docstring>process_madvise(vararg_0, vararg_1, vararg_2, vararg_3, vararg_4) -> str + +Invokes the syscall process_madvise. + +See 'man 2 process_madvise' for more information. + +Arguments: + vararg(int): vararg +Returns: + long + +<%page args="vararg_0=None, vararg_1=None, vararg_2=None, vararg_3=None, vararg_4=None"/> +<% + abi = pwnlib.abi.ABI.syscall() + stack = abi.stack + regs = abi.register_arguments[1:] + allregs = pwnlib.shellcraft.registers.current() + + can_pushstr = [] + can_pushstr_array = [] + + argument_names = ['vararg_0', 'vararg_1', 'vararg_2', 'vararg_3', 'vararg_4'] + argument_values = [vararg_0, vararg_1, vararg_2, vararg_3, vararg_4] + + # Load all of the arguments into their destination registers / stack slots. + register_arguments = dict() + stack_arguments = collections.OrderedDict() + string_arguments = dict() + dict_arguments = dict() + array_arguments = dict() + syscall_repr = [] + + for name, arg in zip(argument_names, argument_values): + if arg is not None: + syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False))) + + # If the argument itself (input) is a register... + if arg in allregs: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[index] = arg + + # The argument is not a register. It is a string value, and we + # are expecting a string value + elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): + if isinstance(arg, six.text_type): + arg = arg.encode('utf-8') + string_arguments[name] = arg + + # The argument is not a register. It is a dictionary, and we are + # expecting K:V paris. + elif name in can_pushstr_array and isinstance(arg, dict): + array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] + + # The arguent is not a register. It is a list, and we are expecting + # a list of arguments. + elif name in can_pushstr_array and isinstance(arg, (list, tuple)): + array_arguments[name] = arg + + # The argument is not a register, string, dict, or list. + # It could be a constant string ('O_RDONLY') for an integer argument, + # an actual integer value, or a constant. + else: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[target] = arg + + # Some syscalls have different names on various architectures. + # Determine which syscall number to use for the current architecture. + for syscall in ['SYS_process_madvise']: + if hasattr(pwnlib.constants, syscall): + break + else: + raise Exception("Could not locate any syscalls: %r" % syscalls) +%> + /* process_madvise(${', '.join(syscall_repr)}) */ +%for name, arg in string_arguments.items(): + ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} + ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} +%endfor +%for name, arg in array_arguments.items(): + ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} +%endfor +%for name, arg in stack_arguments.items(): + ${pwnlib.shellcraft.push(arg)} +%endfor + ${pwnlib.shellcraft.setregs(register_arguments)} + ${pwnlib.shellcraft.syscall(syscall)} diff --git a/pwnlib/shellcraft/templates/common/linux/syscalls/riscv_flush_icache.asm b/pwnlib/shellcraft/templates/common/linux/syscalls/riscv_flush_icache.asm new file mode 100644 index 000000000..532c6802b --- /dev/null +++ b/pwnlib/shellcraft/templates/common/linux/syscalls/riscv_flush_icache.asm @@ -0,0 +1,101 @@ +<% +import collections +import pwnlib.abi +import pwnlib.constants +import pwnlib.shellcraft +import six +%> +<%docstring>riscv_flush_icache(vararg_0, vararg_1, vararg_2, vararg_3, vararg_4) -> str + +Invokes the syscall riscv_flush_icache. + +See 'man 2 riscv_flush_icache' for more information. + +Arguments: + vararg(int): vararg +Returns: + long + +<%page args="vararg_0=None, vararg_1=None, vararg_2=None, vararg_3=None, vararg_4=None"/> +<% + abi = pwnlib.abi.ABI.syscall() + stack = abi.stack + regs = abi.register_arguments[1:] + allregs = pwnlib.shellcraft.registers.current() + + can_pushstr = [] + can_pushstr_array = [] + + argument_names = ['vararg_0', 'vararg_1', 'vararg_2', 'vararg_3', 'vararg_4'] + argument_values = [vararg_0, vararg_1, vararg_2, vararg_3, vararg_4] + + # Load all of the arguments into their destination registers / stack slots. + register_arguments = dict() + stack_arguments = collections.OrderedDict() + string_arguments = dict() + dict_arguments = dict() + array_arguments = dict() + syscall_repr = [] + + for name, arg in zip(argument_names, argument_values): + if arg is not None: + syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False))) + + # If the argument itself (input) is a register... + if arg in allregs: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[index] = arg + + # The argument is not a register. It is a string value, and we + # are expecting a string value + elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): + if isinstance(arg, six.text_type): + arg = arg.encode('utf-8') + string_arguments[name] = arg + + # The argument is not a register. It is a dictionary, and we are + # expecting K:V paris. + elif name in can_pushstr_array and isinstance(arg, dict): + array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] + + # The arguent is not a register. It is a list, and we are expecting + # a list of arguments. + elif name in can_pushstr_array and isinstance(arg, (list, tuple)): + array_arguments[name] = arg + + # The argument is not a register, string, dict, or list. + # It could be a constant string ('O_RDONLY') for an integer argument, + # an actual integer value, or a constant. + else: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[target] = arg + + # Some syscalls have different names on various architectures. + # Determine which syscall number to use for the current architecture. + for syscall in ['SYS_riscv_flush_icache']: + if hasattr(pwnlib.constants, syscall): + break + else: + raise Exception("Could not locate any syscalls: %r" % syscalls) +%> + /* riscv_flush_icache(${', '.join(syscall_repr)}) */ +%for name, arg in string_arguments.items(): + ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} + ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} +%endfor +%for name, arg in array_arguments.items(): + ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} +%endfor +%for name, arg in stack_arguments.items(): + ${pwnlib.shellcraft.push(arg)} +%endfor + ${pwnlib.shellcraft.setregs(register_arguments)} + ${pwnlib.shellcraft.syscall(syscall)} diff --git a/pwnlib/shellcraft/templates/common/linux/syscalls/sysriscv.asm b/pwnlib/shellcraft/templates/common/linux/syscalls/sysriscv.asm new file mode 100644 index 000000000..d65886016 --- /dev/null +++ b/pwnlib/shellcraft/templates/common/linux/syscalls/sysriscv.asm @@ -0,0 +1,101 @@ +<% +import collections +import pwnlib.abi +import pwnlib.constants +import pwnlib.shellcraft +import six +%> +<%docstring>sysriscv(vararg_0, vararg_1, vararg_2, vararg_3, vararg_4) -> str + +Invokes the syscall sysriscv. + +See 'man 2 sysriscv' for more information. + +Arguments: + vararg(int): vararg +Returns: + long + +<%page args="vararg_0=None, vararg_1=None, vararg_2=None, vararg_3=None, vararg_4=None"/> +<% + abi = pwnlib.abi.ABI.syscall() + stack = abi.stack + regs = abi.register_arguments[1:] + allregs = pwnlib.shellcraft.registers.current() + + can_pushstr = [] + can_pushstr_array = [] + + argument_names = ['vararg_0', 'vararg_1', 'vararg_2', 'vararg_3', 'vararg_4'] + argument_values = [vararg_0, vararg_1, vararg_2, vararg_3, vararg_4] + + # Load all of the arguments into their destination registers / stack slots. + register_arguments = dict() + stack_arguments = collections.OrderedDict() + string_arguments = dict() + dict_arguments = dict() + array_arguments = dict() + syscall_repr = [] + + for name, arg in zip(argument_names, argument_values): + if arg is not None: + syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False))) + + # If the argument itself (input) is a register... + if arg in allregs: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[index] = arg + + # The argument is not a register. It is a string value, and we + # are expecting a string value + elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): + if isinstance(arg, six.text_type): + arg = arg.encode('utf-8') + string_arguments[name] = arg + + # The argument is not a register. It is a dictionary, and we are + # expecting K:V paris. + elif name in can_pushstr_array and isinstance(arg, dict): + array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] + + # The arguent is not a register. It is a list, and we are expecting + # a list of arguments. + elif name in can_pushstr_array and isinstance(arg, (list, tuple)): + array_arguments[name] = arg + + # The argument is not a register, string, dict, or list. + # It could be a constant string ('O_RDONLY') for an integer argument, + # an actual integer value, or a constant. + else: + index = argument_names.index(name) + if index < len(regs): + target = regs[index] + register_arguments[target] = arg + elif arg is not None: + stack_arguments[target] = arg + + # Some syscalls have different names on various architectures. + # Determine which syscall number to use for the current architecture. + for syscall in ['SYS_sysriscv']: + if hasattr(pwnlib.constants, syscall): + break + else: + raise Exception("Could not locate any syscalls: %r" % syscalls) +%> + /* sysriscv(${', '.join(syscall_repr)}) */ +%for name, arg in string_arguments.items(): + ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} + ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} +%endfor +%for name, arg in array_arguments.items(): + ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} +%endfor +%for name, arg in stack_arguments.items(): + ${pwnlib.shellcraft.push(arg)} +%endfor + ${pwnlib.shellcraft.setregs(register_arguments)} + ${pwnlib.shellcraft.syscall(syscall)} diff --git a/pwnlib/shellcraft/templates/riscv64/__doc__ b/pwnlib/shellcraft/templates/riscv64/__doc__ new file mode 100644 index 000000000..a5420bbe2 --- /dev/null +++ b/pwnlib/shellcraft/templates/riscv64/__doc__ @@ -0,0 +1 @@ +Shellcraft module containing generic RISCV64 shellcodes. diff --git a/pwnlib/shellcraft/templates/riscv64/linux/__doc__ b/pwnlib/shellcraft/templates/riscv64/linux/__doc__ new file mode 100644 index 000000000..af7cba2ce --- /dev/null +++ b/pwnlib/shellcraft/templates/riscv64/linux/__doc__ @@ -0,0 +1 @@ +Shellcraft module containing RISCV64 shellcodes for Linux. diff --git a/pwnlib/shellcraft/templates/riscv64/linux/syscall.asm b/pwnlib/shellcraft/templates/riscv64/linux/syscall.asm new file mode 100644 index 000000000..85bd4bdd1 --- /dev/null +++ b/pwnlib/shellcraft/templates/riscv64/linux/syscall.asm @@ -0,0 +1,109 @@ +<% + from pwnlib.shellcraft import riscv64, pretty + from pwnlib.constants import Constant + from pwnlib.abi import linux_riscv64_syscall as abi + from six import text_type +%> +<%page args="syscall = None, arg0 = None, arg1 = None, arg2 = None, arg3 = None, arg4=None, arg5=None"/> +<%docstring> +Args: [syscall_number, \*args] + Does a syscall + +Any of the arguments can be expressions to be evaluated by :func:`pwnlib.constants.eval`. + +Example: + + >>> print(pwnlib.shellcraft.riscv64.linux.syscall('SYS_execve', 1, 'sp', 2, 0).rstrip()) + /* call execve(1, 'sp', 2, 0) */ + c.li a0, 1 + c.mv a1, sp + c.li a2, 2 + c.li a3, 0 + /* mv a7, 0xdd */ + xori a7, zero, 0x722 + xori a7, a7, 0x7ff + ecall + >>> print(pwnlib.shellcraft.riscv64.linux.syscall('SYS_execve', 2, 1, 0, 20).rstrip()) + /* call execve(2, 1, 0, 0x14) */ + c.li a0, 2 + c.li a1, 1 + c.li a2, 0 + c.li a3, 0x14 + /* mv a7, 0xdd */ + xori a7, zero, 0x722 + xori a7, a7, 0x7ff + ecall + >>> print(pwnlib.shellcraft.riscv64.linux.syscall().rstrip()) + /* call syscall() */ + ecall + >>> print(pwnlib.shellcraft.riscv64.linux.syscall('a7', 'a0', 'a1').rstrip()) + /* call syscall('a7', 'a0', 'a1') */ + /* setregs noop */ + ecall + >>> print(pwnlib.shellcraft.riscv64.linux.syscall('a3', None, None, 1).rstrip()) + /* call syscall('a3', ?, ?, 1) */ + c.li a2, 1 + c.mv a7, a3 + ecall + >>> print(pwnlib.shellcraft.riscv64.linux.syscall( + ... 'SYS_mmap', 0, 0x1000, + ... 'PROT_READ | PROT_WRITE | PROT_EXEC', + ... 'MAP_PRIVATE', + ... -1, 0).rstrip()) + /* call mmap(0, 0x1000, 'PROT_READ | PROT_WRITE | PROT_EXEC', 'MAP_PRIVATE', -1, 0) */ + c.li a0, 0 + c.lui a1, 1 /* mv a1, 0x1000 */ + c.li a2, 7 + c.li a3, 2 + c.li a4, 0xffffffffffffffff + c.li a5, 0 + /* mv a7, 0xde */ + xori a7, zero, 0x721 + xori a7, a7, 0x7ff + ecall + >>> print(pwnlib.shellcraft.openat('AT_FDCWD', '/home/pwn/flag').rstrip()) + /* openat(fd='AT_FDCWD', file='/home/pwn/flag', oflag=0) */ + /* push b'/home/pwn/flag\x00' */ + li t4, 0x77702f656d6f682f + sd t4, -16(sp) + li t4, 0x67616c662f6e + sd t4, -8(sp) + addi sp, sp, -16 + c.mv a1, sp + xori a0, zero, 0xffffffffffffff9c + c.li a2, 0 + /* call openat() */ + /* mv a7, 0x38 */ + xori a7, zero, 0x7c7 + xori a7, a7, 0x7ff + ecall + +<% + if isinstance(syscall, (str, text_type, Constant)) and str(syscall).startswith('SYS_'): + syscall_repr = str(syscall)[4:] + "(%s)" + args = [] + else: + syscall_repr = 'syscall(%s)' + if syscall is None: + args = ['?'] + else: + args = [pretty(syscall, False)] + + for arg in [arg0, arg1, arg2, arg3, arg4, arg5]: + if arg is None: + args.append('?') + else: + args.append(pretty(arg, False)) + while args and args[-1] == '?': + args.pop() + syscall_repr = syscall_repr % ', '.join(args) + + registers = abi.register_arguments + arguments = [syscall, arg0, arg1, arg2, arg3, arg4, arg5] + regctx = dict(zip(registers, arguments)) +%>\ + /* call ${syscall_repr} */ +%if any(a is not None for a in arguments): + ${riscv64.setregs(regctx)} +%endif + ecall diff --git a/pwnlib/shellcraft/templates/riscv64/linux/syscalls b/pwnlib/shellcraft/templates/riscv64/linux/syscalls new file mode 120000 index 000000000..82bc97edb --- /dev/null +++ b/pwnlib/shellcraft/templates/riscv64/linux/syscalls @@ -0,0 +1 @@ +../../common/linux/syscalls \ No newline at end of file diff --git a/pwnlib/shellcraft/templates/riscv64/mov.asm b/pwnlib/shellcraft/templates/riscv64/mov.asm new file mode 100644 index 000000000..8005b47d1 --- /dev/null +++ b/pwnlib/shellcraft/templates/riscv64/mov.asm @@ -0,0 +1,131 @@ +<% + from pwnlib.util import lists, packing, fiddling, misc + from pwnlib.constants import eval, Constant + from pwnlib.context import context as ctx # Ugly hack, mako will not let it be called context + from pwnlib.log import getLogger + from pwnlib.shellcraft import riscv64, registers, pretty, okay + import six + log = getLogger('pwnlib.shellcraft.riscv64.mov') +%> +<%page args="dst, src"/> +<%docstring> +Move src into dst without newlines and null bytes. + +Registers t4 and t6 are not guaranteed to be preserved. + +If src is a string that is not a register, then it will locally set +`context.arch` to `'riscv64'` and use :func:`pwnlib.constants.eval` to evaluate the +string. Note that this means that this shellcode can change behavior depending +on the value of `context.os`. + +Args: + + dst (str): The destination register. + src (str): Either the input register, or an immediate value. + +Example: + + >>> print(shellcraft.riscv64.mov('t0', 0).rstrip()) + c.li t0, 0 + >>> print(shellcraft.riscv64.mov('t0', 0x2000).rstrip()) + c.lui t0, 2 /* mv t0, 0x2000 */ + >>> print(shellcraft.riscv64.mov('t5', 0x601).rstrip()) + xori t5, zero, 0x601 + >>> print(shellcraft.riscv64.mov('t5', 0x600).rstrip()) + /* mv t5, 0x600 */ + xori t5, zero, 0x1ff + xori t5, t5, 0x7ff + >>> print(shellcraft.riscv64.mov('t6', 0x181f).rstrip()) + /* mv t6, 0x181f */ + lui t6, 0xffffe + xori t6, t6, 0xfffffffffffff81f + >>> print(shellcraft.riscv64.mov('t5', 0x40b561f).rstrip()) + /* mv t5, 0x40b561f */ + lui t5, 0x40b5 + xori t5, t5, 0x61f + >>> print(shellcraft.riscv64.mov('t0', 0xcafebabe).rstrip()) + li t0, 0xcafebabe + >>> print(shellcraft.riscv64.mov('a0', 't2').rstrip()) + c.mv a0, t2 + >>> print(shellcraft.riscv64.mov('t1', 'sp').rstrip()) + c.mv t6, sp + c.mv t1, t6 /* mv t1, sp */ + + +<% +if not isinstance(dst, str) or dst not in registers.riscv: + log.error("Unknown register %r", dst) + return + +if isinstance(src, str) and src not in registers.riscv: + src = eval(src) + +if isinstance(src, str) and src not in registers.riscv: + log.error("Unknown register %r", src) + return + +src_reg = registers.riscv.get(src, None) +dst_reg = registers.riscv[dst] +tmp = 't6' if dst_reg != registers.riscv['t6'] else 't4' + +# If source register is zero, treat it as immediate 0 +if src_reg == 0: + src = 0 + src_reg = None + +encodes_no_newline = lambda a, not_a: not (a & 0xf == 0 or (a & 0xff0) >> 8 in [0, 10]) and not (((not_a & 0xf000) >> 8 | (dst_reg >> 1) in [0, 10]) or (not_a & 0xff0000) >> 16 in [0, 10] or not_a >> 24 in [0, 10]) +%> + +% if dst_reg == 0 or dst_reg == src_reg: + /* mv ${dst}, ${src} is a noop */ + +% elif src_reg is not None: +## Source is a register +## Special case where c.mv would produce a newline +% if src_reg == 2 and dst_reg % 2 == 0: + c.mv ${tmp}, ${src} + c.mv ${dst}, ${tmp} /* mv ${dst}, ${src} */ +% else: + c.mv ${dst}, ${src} +% endif +% else: +## Source is an immediate, normalize to [0, 2**64) + +<% src = packing.unpack(packing.pack(src, word_size=64), word_size=64, sign=False) %> +## Immediates are always sign-extended to 64-bit + +## 6-bit immediate for c.li +% if src < 0x20 or src >= 0xffffffffffffffe0: + c.li ${dst}, ${pretty(src)} + +## 6-bit immediate for c.lui +% elif dst_reg != 2 and src & 0xfff == 0 and ((src>>12) < 0x20 or (src>>12) >= 0xffffffffffffffe0): + c.lui ${dst}, ${pretty(src>>12)} /* mv ${dst}, ${pretty(src)} */ + +## 12-bit immediate +% elif src < 0x800 or src >= 0xfffffffffffff800: + % if src & 0xf == 0 or (src & 0xfff) >> 8 in [0, 10]: + /* mv ${dst}, ${pretty(src)} */ + xori ${dst}, zero, ${pretty(src ^ 0x7ff)} + xori ${dst}, ${dst}, ${pretty(0x7ff)} + % else: + xori ${dst}, zero, ${pretty(src)} + % endif + +## 32-bit immediate with lui and xori +% elif (src < 0x80000000 or src >= 0xffffffff80000000) and src & 0x800 == 0 and encodes_no_newline(src, src): + /* mv ${dst}, ${pretty(src)} */ + lui ${dst}, ${pretty(src >> 12)} + xori ${dst}, ${dst}, ${pretty(src & 0xfff)} +% elif (src < 0x80000000 or src >= 0xffffffff80000000) and src & 0x800 == 0x800 and encodes_no_newline(src, ~src): + /* mv ${dst}, ${pretty(src)} */ + lui ${dst}, ${pretty((~src >> 12) & 0xfffff)} + xori ${dst}, ${dst}, ${pretty(src & 0xfff | 0xfffffffffffff000)} + +## 64-bit immediate with lui, addi, and slli +## FIXME: Make this null and newline free +% else: + li ${dst}, ${pretty(src)} + +% endif +% endif diff --git a/pwnlib/shellcraft/templates/riscv64/nop.asm b/pwnlib/shellcraft/templates/riscv64/nop.asm new file mode 100644 index 000000000..dbb731dd4 --- /dev/null +++ b/pwnlib/shellcraft/templates/riscv64/nop.asm @@ -0,0 +1,2 @@ +<%docstring>RISCV64 nop instruction. + add x31, x0, x31 diff --git a/pwnlib/shellcraft/templates/riscv64/push.asm b/pwnlib/shellcraft/templates/riscv64/push.asm new file mode 100644 index 000000000..0a9f97adc --- /dev/null +++ b/pwnlib/shellcraft/templates/riscv64/push.asm @@ -0,0 +1,27 @@ +<% + from pwnlib.shellcraft import riscv64 + from pwnlib import constants + from pwnlib.shellcraft import registers + from six import text_type, binary_type +%> +<%page args="value"/> +<%docstring> +Pushes a value onto the stack. + +Register t4 is not guaranteed to be preserved. + +<% +is_reg = value in registers.riscv + +if not is_reg and isinstance(value, (binary_type, text_type)): + try: + value = constants.eval(value) + except (ValueError, AttributeError): + pass +%> +% if not is_reg: + ${riscv64.mov('t4', value)} + <% value = 't4' %>\ +%endif + sd ${value}, -8(sp) + addi sp, sp, -8 diff --git a/pwnlib/shellcraft/templates/riscv64/pushstr.asm b/pwnlib/shellcraft/templates/riscv64/pushstr.asm new file mode 100644 index 000000000..252536e27 --- /dev/null +++ b/pwnlib/shellcraft/templates/riscv64/pushstr.asm @@ -0,0 +1,98 @@ +<% + from pwnlib.util import lists, packing, fiddling + from pwnlib.shellcraft import riscv64, pretty + import six +%>\ +<%page args="string, append_null = True"/> +<%docstring> +Pushes a string onto the stack without using +null bytes or newline characters. + +Example: + + >>> print(shellcraft.riscv64.pushstr('').rstrip()) + /* push b'\x00' */ + sw zero, -8(sp) + addi sp, sp, -8 + >>> print(shellcraft.riscv64.pushstr('a').rstrip()) + /* push b'a\x00' */ + /* mv t4, 0x61 */ + xori t4, zero, 0x79e + xori t4, t4, 0x7ff + sd t4, -8(sp) + addi sp, sp, -8 + >>> print(shellcraft.riscv64.pushstr('aa').rstrip()) + /* push b'aa\x00' */ + li t4, 0x6161 + sd t4, -8(sp) + addi sp, sp, -8 + >>> print(shellcraft.riscv64.pushstr('aaaa').rstrip()) + /* push b'aaaa\x00' */ + /* mv t4, 0x61616161 */ + lui t4, 0x61616 + xori t4, t4, 0x161 + sd t4, -8(sp) + addi sp, sp, -8 + >>> print(shellcraft.riscv64.pushstr('aaaaa').rstrip()) + /* push b'aaaaa\x00' */ + li t4, 0x6161616161 + sd t4, -8(sp) + addi sp, sp, -8 + >>> print(shellcraft.riscv64.pushstr('aaaa', append_null = False).rstrip()) + /* push b'aaaa' */ + /* mv t4, 0x61616161 */ + lui t4, 0x61616 + xori t4, t4, 0x161 + sd t4, -8(sp) + addi sp, sp, -8 + >>> print(shellcraft.riscv64.pushstr(b'\xc3').rstrip()) + /* push b'\xc3\x00' */ + /* mv t4, 0xc3 */ + xori t4, zero, 0x73c + xori t4, t4, 0x7ff + sd t4, -8(sp) + addi sp, sp, -8 + >>> print(shellcraft.riscv64.pushstr(b'\xc3', append_null = False).rstrip()) + /* push b'\xc3' */ + /* mv t4, 0xc3 */ + xori t4, zero, 0x73c + xori t4, t4, 0x7ff + sd t4, -8(sp) + addi sp, sp, -8 + >>> print(enhex(asm(shellcraft.riscv64.pushstr("/bin/sh")))) + b79e39349b8e7e7bb20e938ebe34b60e938efe22233cd1ff6111 + >>> print(enhex(asm(shellcraft.riscv64.pushstr("")))) + 232c01fe6111 + >>> print(enhex(asm(shellcraft.riscv64.pushstr("\x00", append_null = False)))) + 232c01fe6111 + +Args: + string (str): The string to push. + append_null (bool): Whether to append a single NULL-byte before pushing. + +<% + if isinstance(string, six.text_type): + string = string.encode('utf-8') + if append_null: + string += b'\x00' + if not string: + return + + split_string = lists.group(8, string, 'fill', b'\x00') + stack_offset = len(split_string) * -8 +%>\ + /* push ${pretty(string, False)} */ +% for index, word in enumerate(split_string): +% if word == b'\x00\x00\x00\x00\x00\x00\x00\x00': + sw zero, ${stack_offset+(8 * index)}(sp) +<% + continue +%>\ +% endif +<% + word = packing.u64(word, sign=True) +%>\ + ${riscv64.mov('t4', word)} + sd t4, ${stack_offset+(8 * index)}(sp) +% endfor + addi sp, sp, ${stack_offset} diff --git a/pwnlib/shellcraft/templates/riscv64/pushstr_array.asm b/pwnlib/shellcraft/templates/riscv64/pushstr_array.asm new file mode 100644 index 000000000..a7a40fd52 --- /dev/null +++ b/pwnlib/shellcraft/templates/riscv64/pushstr_array.asm @@ -0,0 +1,38 @@ +<% from pwnlib.shellcraft import riscv64, pretty %> +<%docstring> +Pushes an array/envp-style array of pointers onto the stack. + +Arguments: + reg(str): + Destination register to hold the pointer. + array(str,list): + Single argument or list of arguments to push. + NULL termination is normalized so that each argument + ends with exactly one NULL byte. + +<%page args="reg, array"/> +<% +if isinstance(array, (str)): + array = [array] + +array_str = '' + +# Normalize all of the arguments' endings +array = [arg.rstrip('\x00') + '\x00' for arg in array] +array_str = ''.join(array) + +word_size = 8 +offset = len(array_str) + word_size + +%>\ + /* push argument array ${pretty(array, False)} */ + ${riscv64.pushstr(array_str)} + ${riscv64.mov(reg, 0)} + ${riscv64.push(reg)} /* null terminate */ +% for i,arg in enumerate(reversed(array)): + ${riscv64.mov(reg, offset + word_size*i - len(arg))} + add ${reg}, sp, ${reg} + ${riscv64.push(reg)} /* ${pretty(arg, False)} */ + <% offset -= len(arg) %>\ +% endfor + ${riscv64.mov(reg,'sp')} diff --git a/pwnlib/shellcraft/templates/riscv64/setregs.asm b/pwnlib/shellcraft/templates/riscv64/setregs.asm new file mode 100644 index 000000000..90306e106 --- /dev/null +++ b/pwnlib/shellcraft/templates/riscv64/setregs.asm @@ -0,0 +1,46 @@ +<% + from pwnlib.regsort import regsort + from pwnlib.constants import Constant, eval + from pwnlib.shellcraft import registers + from pwnlib.shellcraft import riscv64 +%> +<%page args="reg_context, stack_allowed = True"/> +<%docstring> +Sets multiple registers, taking any register dependencies into account +(i.e., given eax=1,ebx=eax, set ebx first). + +Args: + reg_context (dict): Desired register context + stack_allowed (bool): Can the stack be used? + +Example: + + >>> print(shellcraft.setregs({'t0':1, 'a3':'0'}).rstrip()) + c.li a3, 0 + c.li t0, 1 + >>> print(shellcraft.setregs({'a0':'a1', 'a1':'a0', 'a2':'a1'}).rstrip()) + c.mv a2, a1 + c.mv t4, a1 + xor a1, a0, t4 /* xchg a1, a0 */ + c.mv t4, a0 + xor a0, a1, t4 + c.mv t4, a1 + xor a1, a0, t4 + +<% +reg_context = {k:v for k,v in reg_context.items() if v is not None} +sorted_regs = regsort(reg_context, registers.riscv) +%> +% if not sorted_regs: + /* setregs noop */ +% else: +% for how, src, dst in regsort(reg_context, registers.riscv): +% if how == 'xchg': + ${riscv64.xor(dst, dst, src)} /* xchg ${dst}, ${src} */ + ${riscv64.xor(src, src, dst)} + ${riscv64.xor(dst, dst, src)} +% else: + ${riscv64.mov(src, dst)} +% endif +% endfor +% endif diff --git a/pwnlib/shellcraft/templates/riscv64/trap.asm b/pwnlib/shellcraft/templates/riscv64/trap.asm new file mode 100644 index 000000000..fade233c0 --- /dev/null +++ b/pwnlib/shellcraft/templates/riscv64/trap.asm @@ -0,0 +1,2 @@ +<%docstring>A trap instruction. + ebreak diff --git a/pwnlib/shellcraft/templates/riscv64/xor.asm b/pwnlib/shellcraft/templates/riscv64/xor.asm new file mode 100644 index 000000000..5a506e284 --- /dev/null +++ b/pwnlib/shellcraft/templates/riscv64/xor.asm @@ -0,0 +1,34 @@ +<% + from pwnlib.shellcraft import riscv64 + from pwnlib.shellcraft import registers +%> +<%page args="dst,rs1,rs2"/> +<%docstring> +XOR two registers rs1 and rs2, store result in register dst. + +Register t4 is not guaranteed to be preserved. + +<% +if not isinstance(dst, str) or dst not in registers.riscv: + log.error("Unknown register %r", dst) + return +if not isinstance(rs1, str) or rs1 not in registers.riscv: + log.error("Unknown register %r", rs1) + return +if not isinstance(rs2, str) or rs2 not in registers.riscv: + log.error("Unknown register %r", rs2) + return + +rs1_reg = registers.riscv[rs1] +rs2_reg = registers.riscv[rs2] +%> +## 0000000 rs2 rs1 +## 0000000 00000 0000 +% if rs1_reg & 0x10 > 0 and (rs2_reg > 1 or rs1_reg & 0xf > 0) and (rs1_reg != 0x10 and rs2_reg != 10): + xor ${dst}, ${rs2}, ${rs1} +% elif rs2_reg & 0x10 > 0 and (rs1_reg > 1 or rs2_reg & 0xf > 0) and (rs2_reg != 0x10 and rs1_reg != 10): + xor ${dst}, ${rs1}, ${rs2} +% else: + ${riscv64.mov('t4', rs1)} + xor ${dst}, ${rs2}, t4 +% endif