PoC module loading + external relocation resolution

This commit is contained in:
Mark
2020-04-10 11:02:10 +03:00
parent ba01eb3397
commit eebeef2a14
12 changed files with 601 additions and 102 deletions
+1
View File
@@ -52,6 +52,7 @@ int vfs_chown(struct vfs_ioctx *ctx, const char *path, uid_t uid, gid_t gid);
int vfs_ioctl(struct vfs_ioctx *ctx, struct ofile *fd, unsigned int cmd, void *arg);
int vfs_access(struct vfs_ioctx *ctx, const char *path, int accmode);
int vfs_fstat(struct vfs_ioctx *ctx, struct ofile *fd, struct stat *st);
int vfs_stat(struct vfs_ioctx *ctx, const char *path, struct stat *st);
int vfs_access_check(struct vfs_ioctx *ctx, int desm, mode_t mode, uid_t uid, gid_t gid);
int vfs_access_node(struct vfs_ioctx *ctx, struct vnode *vn, int mode);
+1
View File
@@ -40,6 +40,7 @@
void debug_symbol_table_set(uintptr_t symtab, uintptr_t strtab, size_t symtab_size, size_t strtab_size);
int debug_symbol_find(uintptr_t addr, const char **name, uintptr_t *base);
int debug_symbol_find_by_name(const char *name, uintptr_t *value);
void debug_backtrace(uintptr_t rbp, int depth, int limit);
void fmtsiz(char *buf, size_t sz);
+4
View File
@@ -0,0 +1,4 @@
#pragma once
int sys_module_load(const char *path, const char *params);
int sys_module_unload(const char *name);
+14
View File
@@ -0,0 +1,14 @@
#pragma once
struct module_desc {
char name[64];
int version;
};
#define MODULE_ENTRY _mod_entry
#define MODULE_EXIT _mod_exit
#define MODULE_DESC(_name, _version) \
struct module_desc _mod_desc = { \
.name = _name, \
.version = _version, \
}
+50 -48
View File
@@ -1,54 +1,56 @@
#pragma once
#define SYSCALL_NR_READ 0
#define SYSCALL_NR_WRITE 1
#define SYSCALL_NR_OPEN 2
#define SYSCALL_NR_CLOSE 3
#define SYSCALL_NR_STAT 4
#define SYSCALL_NR_LSEEK 8
#define SYSCALL_NR_MMAP 9
#define SYSCALL_NR_MUNMAP 11
#define SYSCALL_NR_IOCTL 16
#define SYSCALL_NR_ACCESS 21
#define SYSCALL_NR_SELECT 23
#define SYSCALL_NR_GETCWD 79
#define SYSCALL_NR_CHDIR 80
#define SYSCALL_NR_MKDIR 83
#define SYSCALL_NR_RMDIR 84
#define SYSCALL_NR_CREAT 85
#define SYSCALL_NR_UNLINK 87
#define SYSCALL_NR_READDIR 89
#define SYSCALL_NR_CHMOD 90
#define SYSCALL_NR_CHOWN 92
#define SYSCALL_NR_READ 0
#define SYSCALL_NR_WRITE 1
#define SYSCALL_NR_OPEN 2
#define SYSCALL_NR_CLOSE 3
#define SYSCALL_NR_STAT 4
#define SYSCALL_NR_LSEEK 8
#define SYSCALL_NR_MMAP 9
#define SYSCALL_NR_MUNMAP 11
#define SYSCALL_NR_IOCTL 16
#define SYSCALL_NR_ACCESS 21
#define SYSCALL_NR_SELECT 23
#define SYSCALL_NR_GETCWD 79
#define SYSCALL_NR_CHDIR 80
#define SYSCALL_NR_MKDIR 83
#define SYSCALL_NR_RMDIR 84
#define SYSCALL_NR_CREAT 85
#define SYSCALL_NR_UNLINK 87
#define SYSCALL_NR_READDIR 89
#define SYSCALL_NR_CHMOD 90
#define SYSCALL_NR_CHOWN 92
#define SYSCALL_NR_NANOSLEEP 35
#define SYSCALL_NR_UNAME 63
#define SYSCALL_NR_GETTIMEOFDAY 96
#define SYSCALL_NR_SYNC 162
#define SYSCALL_NR_MOUNT 165
#define SYSCALL_NRX_UMOUNT 166
#define SYSCALL_NR_REBOOT 169
#define SYSCALL_NR_NANOSLEEP 35
#define SYSCALL_NR_UNAME 63
#define SYSCALL_NR_GETTIMEOFDAY 96
#define SYSCALL_NR_SYNC 162
#define SYSCALL_NR_MOUNT 165
#define SYSCALL_NRX_UMOUNT 166
#define SYSCALL_NR_REBOOT 169
#define SYSCALL_NRX_MODULE_LOAD 175
#define SYSCALL_NRX_MODULE_UNLOAD 176
#define SYSCALL_NRX_SIGENTRY 13
#define SYSCALL_NR_SIGRETURN 15
#define SYSCALL_NR_GETPID 39
#define SYSCALL_NR_FORK 57
#define SYSCALL_NR_EXECVE 59
#define SYSCALL_NR_EXIT 60
#define SYSCALL_NR_KILL 62
#define SYSCALL_NR_GETUID 102
#define SYSCALL_NR_GETGID 104
#define SYSCALL_NR_SETUID 105
#define SYSCALL_NR_SETGID 106
#define SYSCALL_NR_SETPGID 109
#define SYSCALL_NR_GETPGID 121
#define SYSCALL_NRX_WAITPID 247
#define SYSCALL_NRX_SIGENTRY 13
#define SYSCALL_NR_SIGRETURN 15
#define SYSCALL_NR_GETPID 39
#define SYSCALL_NR_FORK 57
#define SYSCALL_NR_EXECVE 59
#define SYSCALL_NR_EXIT 60
#define SYSCALL_NR_KILL 62
#define SYSCALL_NR_GETUID 102
#define SYSCALL_NR_GETGID 104
#define SYSCALL_NR_SETUID 105
#define SYSCALL_NR_SETGID 106
#define SYSCALL_NR_SETPGID 109
#define SYSCALL_NR_GETPGID 121
#define SYSCALL_NRX_WAITPID 247
#define SYSCALL_NR_SOCKET 41
#define SYSCALL_NR_SENDTO 44
#define SYSCALL_NR_RECVFROM 45
#define SYSCALL_NR_BIND 49
#define SYSCALL_NR_SETSOCKOPT 54
#define SYSCALL_NRX_NETCTL 248
#define SYSCALL_NR_SOCKET 41
#define SYSCALL_NR_SENDTO 44
#define SYSCALL_NR_RECVFROM 45
#define SYSCALL_NR_BIND 49
#define SYSCALL_NR_SETSOCKOPT 54
#define SYSCALL_NRX_NETCTL 248
#define SYSCALL_NRX_TRACE 249
#define SYSCALL_NRX_TRACE 249