Skip to content

Commit

Permalink
Add previous work
Browse files Browse the repository at this point in the history
  • Loading branch information
ttg-public committed Jan 1, 1970
0 parents commit 3e597c5
Show file tree
Hide file tree
Showing 23 changed files with 2,663 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
LINUX_SRC := "./linux-3.10.x-bromolow-25426"
PWD := $(shell pwd)
SRCS = internal/call_protected.c internal/override_symbol.c internal/stealth.c \
config/cmdline_delegate.c config/runtime_config.c \
shim/boot_device_shim.c shim/bios/bios_shims_collection.c shim/bios_shim.c \
redpill_main.c
OBJS = $(SRCS:.c=.o)
#this module name CAN NEVER be the same as the main file (or it will get weird ;)) and the main file has to be included
# in object file. So here we say the module file(s) which will create .ko(s) is "redpill.o" and that other objects which
# must be linked (redpill-objs variable)
obj-m += redpill.o
redpill-objs := $(OBJS)
ccflags-y := -std=gnu99 -fgnu89-inline -Wno-declaration-after-statement -g -fno-inline

all:
make -C $(LINUX_SRC) M=$(PWD) modules
clean:
make -C $(LINUX_SRC) M=$(PWD) clean
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 💊 RedPill LKM

---

## THIS IS WORK IN PROGRESS
There's nothing to run/see here (yet ;)).

---

## What is this?
This is a major part of a tool which will be able to run a DSM instance for research purposes without
engaging your real DS machine and risking your data in the process (ask me how I know...).

## Target audience
This repository is target towards **developers** willing to learn and help with implementation of peculiarities of
Synology's DSM Linux distribution.

Read about the quirk in a separate repo: https://github.com/RedPill-TTG/dsm-research/tree/master/quirks

## How to build?
1. You need Synology's GPL sources for the kernel. Check the [Makefile](Makefile) for details
2. `cd` to kernel sources
3. `cp synconfig/bromolow .config` (or any desired one)
4. `make oldconfig ; make modules_prepare`
5. `cd` back to the module directory
5. `make`
6. You will get a `redpill.ko` module as the result, you can `insmod` it

## Documentation split
The documentation regarding actual quirks/mechanisms/discoveries regarding DSM is present in a dedicated research repo
at https://github.com/RedPill-TTG/dsm-research/. Documentation in this repository is solely aimed to explain
implementation details of the kernel module. It will mostly be available in forms of long(ish) doc blocks.
32 changes: 32 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef REDPILLLKM_COMMON_H
#define REDPILLLKM_COMMON_H

#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/slab.h> //kmalloc
#include <linux/string.h>
#include <linux/types.h> //bool & others

#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)

#ifdef STEALTH_MODE
#define pr_loc_err(fmt, ...)
#define pr_loc_inf(fmt, ...)
#define pr_loc_wrn(fmt, ...)
#define pr_loc_dbg(fmt, ...)
#else
//TODO currently debug is printed with info
#define pr_loc_crt(fmt, ...) pr_crit( "<%s/%s:%d> " pr_fmt(fmt) "\n", KBUILD_MODNAME, __FILENAME__, __LINE__, ##__VA_ARGS__)
#define pr_loc_err(fmt, ...) pr_err ( "<%s/%s:%d> " pr_fmt(fmt) "\n", KBUILD_MODNAME, __FILENAME__, __LINE__, ##__VA_ARGS__)
#define pr_loc_inf(fmt, ...) pr_info( "<%s/%s:%d> " pr_fmt(fmt) "\n", KBUILD_MODNAME, __FILENAME__, __LINE__, ##__VA_ARGS__)
#define pr_loc_wrn(fmt, ...) pr_warn( "<%s/%s:%d> " pr_fmt(fmt) "\n", KBUILD_MODNAME, __FILENAME__, __LINE__, ##__VA_ARGS__)
#define pr_loc_dbg(fmt, ...) pr_info( "<%s/%s:%d> " pr_fmt(fmt) "\n", KBUILD_MODNAME, __FILENAME__, __LINE__, ##__VA_ARGS__)

#define pr_loc_bug(fmt, ...) pr_err ( "<%s/%s:%d> !!BUG!! " pr_fmt(fmt) "\n", KBUILD_MODNAME, __FILENAME__, __LINE__, ##__VA_ARGS__)
#endif //STEALTH_MODE

#define sizeof_str_chunk(param) sizeof(param)-1 //gets the size of a string minus trailing nullbyte (useful for partial matches)

#endif //REDPILLLKM_COMMON_H
Loading

0 comments on commit 3e597c5

Please sign in to comment.