Skip to content

This Linux module discovers the memory positioning of the Linux system_call_table

License

Notifications You must be signed in to change notification settings

x-Ultra/SyscallAdderV2

 
 

Repository files navigation

SyscallAdderV2

Linux kernel module that can be used to add custom system call in a more user-friendly way.

This module will use the following functions:

  1. syscall_adder((void *)custom_syscall_addr, char *syscall_name, int num_parameters): will check if there is a free entry on the syscall table and if so, the syscall will be inserted. There will be inserted a MACRO in a file (located at ~/custom_syscall_macros.h). This macro, when imported in the user c file where the cusom syscall is used, will make possible calling the new syscall like: custom_syscall(...).

  2. syscall_remover(int custom_syscall_name): This function simply delete a custom system call inserted previously.

Usage

Fist of all you have to download and install the syscall_adder module:

  1. git clone https://github.com/x-Ultra/SyscallAdderV2
  2. cd SyscallAdderV2
  3. Edit #define MACRO_DIR "/dir/to/macro/file" at line 8 of constants/constants.h
  4. sudo ./install
  5. To uninstall sudo ./uninstall </dir/to/macro/file>

Then, to add a new system call:

  1. Open the 'your_syscall.c' file in 'template' folder
  2. Edit the template as you need
  3. While adding a new syscall remember to use an integer variable to maintain the index of the added syscall (line 15), to use in the removing procedure.
  4. Rename the your_syscall.c as you want
  5. To install your module (and your system calls): sudo ./insert_syscall
  6. To remove: sudo ./remove_syscall

To use you new systemcall just import the macro file /dir/to/macro/file/custom_syscall_macros.h into your user C file.

The MACRO file

Let's suppose to add the system call 'my_sys(int arg1)', and let's suppose that the syscall_adder will insert it in the (system call table) index 187. The macro file will look like that:

//187
#define my_sys(arg1) syscall(187, arg1)
//end

This means that the syscall_adder has to know the number of parameters in order to create the appropiate macro. That's it.

Note

The previous version worked fine up to Kernel Versions 4.x. Thanks to this project, this module works for every version of the Linux Kernel.

About

This Linux module discovers the memory positioning of the Linux system_call_table

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 95.1%
  • Shell 2.7%
  • Makefile 2.2%