Skip to content
This repository was archived by the owner on May 3, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

#Ignore thumbnails created by Windows
Thumbs.db
#Ignore files built by Visual Studio
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
[Bb]in
[Dd]ebug*/
*.lib
*.sbr
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
.vs/
#Nuget packages folder
packages/
2 changes: 1 addition & 1 deletion framework/Makefile → Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ L_DIRS := -L. -Llib
LIBS :=

# C++ Flags
CFLAGS := $(I_DIRS) -D_KERNEL -D_DEBUG -std=c11 -O2 -fno-builtin -nostartfiles -nodefaultlibs -nostdlib -nostdinc -fcheck-new -ffreestanding -fno-strict-aliasing -fno-exceptions -fno-asynchronous-unwind-tables -Wall -m64 -fPIC -Werror=implicit-function-declaration -Wno-unknown-pragmas
CFLAGS := $(I_DIRS) -D_KERNEL -D_DEBUG -std=c11 -O2 -fno-builtin -nostartfiles -nodefaultlibs -nostdlib -nostdinc -fcheck-new -ffreestanding -fno-strict-aliasing -fno-exceptions -fno-asynchronous-unwind-tables -Wall -m64 -fPIC -Werror -Wno-unknown-pragmas

# Assembly flags
SFLAGS := -nostartfiles -nodefaultlibs -nostdlib -fPIC
Expand Down
10 changes: 0 additions & 10 deletions framework/src/oni/utils/utils.s

This file was deleted.

19 changes: 17 additions & 2 deletions framework/include/oni/config.h → include/oni/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,23 @@
// 64-bit ARM FreeBSD based device
#define ONI_PLATFORM_AARCH64_BSD 1

// 64-bit x64 FreeBSD orbis based device
#define ONI_PLATFORM_ORBIS_BSD 2

// 64-bit x64 FreeBSD 9 based device
#define ONI_PLATFORM_9_BSD 3

// 32-bit ARM FreeBSD based device
#define ONI_PLATFORM_SAFE_BSD 2
#define ONI_PLATFORM_SAFE_BSD 4

// 4.55 Orbis Firmware
#define ONI_PLATFORM_ORBIS_BSD_455 5

// 5.01 Orbis Firmware
#define ONI_PLATFORM_ORBIS_BSD_501 6

// 5.05 Orbis Firmware
#define ONI_PLATFORM_ORBIS_BSD_505 7

// Unknown device
#define ONI_UNKNOWN_PLATFORM -1
Expand All @@ -16,7 +31,7 @@

// The current platform configured by oni
#ifndef ONI_PLATFORM
#define ONI_PLATFORM ONI_PLATFORM_SAFE_BSD
#define ONI_PLATFORM ONI_PLATFORM_ORBIS_BSD_501
#endif

// The maximum number of plugins for use with oni
Expand Down
3 changes: 3 additions & 0 deletions framework/include/oni/framework.h → include/oni/framework.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ struct framework_t
struct pluginmanager_t* pluginManager;
};

// Framework platform
extern struct framework_t* gFramework;

// Initialization parameters
extern struct initparams_t* gInitParams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// Plugin description length
#define PLUGIN_DESC_LEN 256

struct plugin_t
/*
plugin_t

Plugin structure that all plugins should "inherit" from
*/
struct plugin_t
{
// Name of the plugin
const char* name;
Expand All @@ -21,8 +21,20 @@ struct plugin_t
const char* description;

// Plugin initialization prototype
int32_t(*plugin_init)(void* arg);
uint8_t(*plugin_load)(void* plugin);

// Plugin close prototype
int32_t(*plugin_close)();
uint8_t(*plugin_unload)(void* plugin);
};

struct plugininit_t
/*
plugininit_t

This structure is used for passing "host" information to the plugins to use
*/
{
struct framework_t* framework;
struct logger_t* logger;
uint8_t* kernelBase;
};
4 changes: 4 additions & 0 deletions include/oni/utils/cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

void cpu_enable_wp();
void cpu_disable_wp();
6 changes: 6 additions & 0 deletions include/oni/utils/dynlib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once
#include <oni/utils/types.h>

int64_t sys_dynlib_load_prx(char* prxPath);
int64_t sys_dynlib_unload_prx(int64_t prxID);
int64_t sys_dynlib_dlsym(int64_t moduleHandle, const char* functionName, void *destFuncOffset);
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

#if ONI_PLATFORM==ONI_UNKNOWN_PLATFORM
#include "kdlsym/default.h"
#elif ONI_PLATFORM==ONI_PLATFORM_ORBIS_BSD
#include "kdlsym/orbis.h"
#elif ONI_PLATFORM==ONI_PLATFORM_ORBIS_BSD_455
#include "kdlsym/orbis455.h"
#elif ONI_PLATFORM==ONI_PLATFORM_ORBIS_BSD_501
#include "kdlsym/orbis501.h"
#elif ONI_PLATFORM==ONI_PLATFORM_ORBIS_BSD_505
#include "kdlsym/orbis505.h"
#elif ONI_PLATFORM==ONI_PLATFORM_SAFE_BSD
#include "kdlsym/gunsafe2.h"
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,6 @@ for the platforms that do enable kernel ASLR (Address Space Layout Randomization
#define kdlsym_addr_mtx_init 0xDEADC0DE
#define kdlsym_addr_sys_mlock 0xDEADC0DE
#define kdlsym_addr_sys_kill 0xDEADC0DE
#define kdlsym_addr_sys_mkdir 0xDEADC0DE
#define kdlsym_addr_sys_rmdir 0xDEADC0DE
#endif
89 changes: 89 additions & 0 deletions include/oni/utils/kdlsym/orbis501.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#pragma once
#include <oni/config.h>

#if ONI_PLATFORM==ONI_PLATFORM_ORBIS_BSD_501
/*
These are the required functions in order for the Oni Framework to operate properly
These are all offsets into the base of the kernel. They expect all standard FreeBSD 9 prototypes

The reason we do not hardcode offsets here, is due to the different platforms that are supported, and
for the platforms that do enable kernel ASLR (Address Space Layout Randomization?)
*/

#define kdlsym_addr_allproc 0x02382FF8
#define kdlsym_addr_allproc_lock 0x02382F98

#define kdlsym_addr_critical_enter 0x0028E4D0
#define kdlsym_addr_critical_exit 0x0028E4E0

#define kdlsym_addr_kernel_map 0x01AC60E0
#define kdlsym_addr_kern_reboot 0x0010D280
#define kdlsym_addr_kmem_alloc 0x000fcb70
#define kdlsym_addr_kmem_free 0x000FCD40
#define kdlsym_addr_kproc_create 0x00137CE0

#define kdlsym_addr_sys_mlockall 0x0013E1F0
#define kdlsym_addr_sys_mlock 0x0013E140

#define kdlsym_addr_pfind 0x00403110
#define kdlsym_addr_printf 0x00435c70
#define kdlsym_addr_proc_rwmem 0x0030CDC0
#define kdlsym_addr_pmap_activate 0x002EAC40

#define kdlsym_addr_vmspace_alloc 0x0019EA10
#define kdlsym_addr_vmspace_free 0x0019ECB0

#define kdlsym_addr_snprintf 0x00435F80

#define kdlsym_addr_vsnprintf 0x00436020

#define kdlsym_addr__mtx_lock_flags 0x00401900
#define kdlsym_addr__mtx_unlock_flags 0x00401BD0

#define kdlsym_addr__sx_slock 0x000F5B20
#define kdlsym_addr__sx_sunlock 0x000F5E00

#define kdlsym_addr_vmspace_acquire_ref 0x0019EE80
#define kdlsym_addr__vm_map_lock_read 0x0019F030
#define kdlsym_addr__vm_map_unlock_read 0x0019F080

// TODO: Sort by alpha

#define kdlsym_addr_sys_lseek 0x0033D620
#define kdlsym_addr_sys_mmap 0x0013D120
#define kdlsym_addr_sys_munmap 0x0013D890
#define kdlsym_addr_utilUSleep 0x00658850
#define kdlsym_addr_kthread_exit 0x00138530
#define kdlsym_addr_kthread_add 0x00138250
#define kdlsym_addr_sys_read 0x001529a0
#define kdlsym_addr_sys_fstat 0x000C14B0
#define kdlsym_addr_sys_close 0x000c0f30
#define kdlsym_addr_sys_socket 0x00318b10
#define kdlsym_addr_sys_write 0x00152eb0


#define kdlsym_addr_sys_getdents 0x00340FC0
#define kdlsym_addr_sys_bind 0x00319450
#define kdlsym_addr_sys_listen 0x00319690
#define kdlsym_addr_sys_accept 0x00319da0
#define kdlsym_addr_sys_recvfrom 0x0031B090
#define kdlsym_addr_sys_sendto 0x0031A940
#define kdlsym_addr_sys_open 0x0033B5C0
#define kdlsym_addr_memcpy 0x001ea420
#define kdlsym_addr_memset 0x3201F0
#define kdlsym_addr_sys_stat 0x0033DC10

#define kdlsym_addr_Xfast_syscall 0x000001C0
#define kdlsym_addr_sys_dup2 0x000BF0D0
#define kdlsym_addr_sys_shutdown 0x0031B2D0
#define kdlsym_addr_sys_unlink 0x0033D000
#define kdlsym_addr_sys_setuid 0x00054950
#define kdlsym_addr_sys_ptrace 0x0030D250
#define kdlsym_addr_sscanf 0x001757F0
#define kdlsym_addr_mtx_init 0x004023B0

#define kdlsym_addr_sys_kill 0x000D1A50

#define kdlsym_addr_sys_mkdir 0x00340780
#define kdlsym_addr_sys_rmdir 0x00340B00
#endif
89 changes: 89 additions & 0 deletions include/oni/utils/kdlsym/orbis505.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#pragma once

#if ONI_PLATFORM==ONI_PLATFORM_ORBIS_BSD_505
/*
These are the required functions in order for the Oni Framework to operate properly
These are all offsets into the base of the kernel. They expect all standard FreeBSD 9 prototypes

The reason we do not hardcode offsets here, is due to the different platforms that are supported, and
for the platforms that do enable kernel ASLR (Address Space Layout Randomization?)
*/
#define kdlsym_addr_allproc 0x2382ff8
#define kdlsym_addr_allproc_lock 0x2382f98

#define kdlsym_addr_critical_enter 0x28e7a0
#define kdlsym_addr_critical_exit 0x28e7b0

#define kdlsym_addr_kernel_map 0x1AC60E0
#define kdlsym_addr_kern_reboot 0x0010D390
#define kdlsym_addr_kmem_alloc 0xfcc80
#define kdlsym_addr_kmem_free 0xfce50
#define kdlsym_addr_kproc_create 0x137df0

#define kdlsym_addr_sys_mlock 0x0013E250
#define kdlsym_addr_sys_mlockall 0x0013E300

#define kdlsym_addr_pfind 0x4034e0
#define kdlsym_addr_printf 0x436040
#define kdlsym_addr_proc_rwmem 0x30d150
#define kdlsym_addr_pmap_activate 0x2eafd0

#define kdlsym_addr_vmspace_alloc 0x19eb20
#define kdlsym_addr_vmspace_free 0x19edc0

#define kdlsym_addr_snprintf 0x436350

#define kdlsym_addr_vsnprintf 0x004363F0

#define kdlsym_addr__mtx_lock_flags 0x401cd0
#define kdlsym_addr__mtx_unlock_flags 0x401fa0

#define kdlsym_addr__sx_slock 0xf5c30
#define kdlsym_addr__sx_xlock 0xf5e10
#define kdlsym_addr__sx_sunlock 0xf5f10
#define kdlsym_addr__sx_xunlock 0xf5fd0

#define kdlsym_addr_vmspace_acquire_ref 0x19ef90
#define kdlsym_addr__vm_map_lock_read 0x19f140
#define kdlsym_addr__vm_map_unlock_read 0x19f190

// TODO: Sort by alpha

#define kdlsym_addr_sys_lseek 0x0033D9F0
#define kdlsym_addr_sys_mmap 0x0013D230
#define kdlsym_addr_sys_munmap 0x0013D9A0
#define kdlsym_addr_utilUSleep 0x00658C30
#define kdlsym_addr_kthread_exit 0x138640
#define kdlsym_addr_kthread_add 0x00138360
#define kdlsym_addr_sys_read 0x00152AB0
#define kdlsym_addr_sys_fstat 0x000C1430
#define kdlsym_addr_sys_close 0x000C0EB0
#define kdlsym_addr_sys_socket 0x00318EE0
#define kdlsym_addr_sys_write 0x00152FC0


#define kdlsym_addr_sys_getdents 0x00341390
#define kdlsym_addr_sys_bind 0x00319820
#define kdlsym_addr_sys_listen 0x00319A60
#define kdlsym_addr_sys_accept 0x0031A170
#define kdlsym_addr_sys_recvfrom 0x0031B460
#define kdlsym_addr_sys_sendto 0x0031AD10
#define kdlsym_addr_sys_open 0x0033B990
#define kdlsym_addr_memcpy 0x1ea530
#define kdlsym_addr_memset 0x003205C0
#define kdlsym_addr_sys_stat 0x0033DFE0

#define kdlsym_addr_Xfast_syscall 0x1c0
#define kdlsym_addr_sys_dup2 0x000BF050
#define kdlsym_addr_sys_shutdown 0x0031B6A0
#define kdlsym_addr_sys_unlink 0x0033D3D0
#define kdlsym_addr_sys_setuid 0x00054950
#define kdlsym_addr_sys_ptrace 0x0030D5E0
#define kdlsym_addr_sscanf 0x00175900
#define kdlsym_addr_mtx_init 0x00402780
#define kdlsym_addr_sys_mlock 0x0013E250
#define kdlsym_addr_sys_kill 0x000D19D0
#define kdlsym_addr_sys_mkdir 0x00340B50
#define kdlsym_addr_sys_rmdir 0x00340ED0
#endif

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct logger_t
char finalBuffer[Logger_MaxBuffer];

// Handle to log file on hdd
volatile volatile int logHandle;
volatile int logHandle;

struct lock_t lock;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#include <oni/utils/types.h>

uint8_t SelfElevateAndRun(uint8_t* userlandPayload, uint32_t userlandSize, void(*elevatedEntryPoint)(void* arguments));
uint8_t SelfElevateAndRun(uint8_t* userlandPayload, uint32_t userlandSize, void(*elevatedEntryPoint)(void* arguments));
6 changes: 6 additions & 0 deletions include/oni/utils/patches.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

//
// This will install all of the pre-run patches needed for Mira to operate
//
extern void oni_installPrePatches();
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ extern int kkill(int pid, int signum);
extern int kdup2(int oldd, int newd);
extern int kshutdown(int s, int how);

extern int kmkdir(char* path, int mode);
extern int krmdir(char* path);

extern off_t klseek(int fd, off_t offset, int whence);
extern caddr_t kmmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t pos);
extern int kmunmap(void *addr, size_t len);
Expand Down
Loading