Git Product home page Git Product logo

creating-modules-and-hooking-syscalls's Introduction

Creating-modules-and-Hooking-syscalls

Creating modules

A kernel module create character device for process in user space read a random integer

Environment: Virtual Box with Ubuntu 18.04 (64 bit), kernel version 5.0.0-32-generic.

Setup

  • Open 2 terminal windows.

  • On the first terminal:

    • Compile main.c

      $ gcc -o main main.c
    • Build module hung_chrdev

      $ make
    • Insert moudule into Kernel.

      $ sudo insmod hung_chrdev.ko
    • Run main

      $ ./main
  • On the second terminal: see messages on the logging.

    $ sudo dmesg -c
    $ sudo dmesg -wH
  • Remove module from kernel on the first terminal.

    $ sudo rmmod hung_chrdev

Hooking syscalls

A kernel module hooking onto sys_write and sys_open.

Created in Zorin 12.4 on 64 bit, with kernel version 4.15.0-30-generic.

Setup

  • Open 2 terminals.

  • On the first terminal:

    • Compile test.c.

      $ gcc test.c -o test
    • Compile module hook.

      $ make
    • Insert moudule into Kernel.

      $ sudo insmod hook.ko
    • Run test.

      $ ./test
  • On the second terminal: see messages on the logging.

    $ sudo dmesg -c
    $ sudo dmesg -wH
  • Remove module from kernel on the first terminal.

    $ rm hook

creating-modules-and-hooking-syscalls's People

Contributors

hungcn avatar sasukepn1999 avatar

Watchers

 avatar

Forkers

hungcn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.