• Stars
    star
    767
  • Rank 59,242 (Top 2 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created almost 8 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Linux rootkit for Ubuntu 16.04 and 10.04 (Linux Kernels 4.4.0 and 2.6.32), both i386 and amd64

Linux Rootkit

A simple Linux kernel rootkit written for fun, not evil.

Functionality

The rootkit can do the following:

  • Grant root privileges to a userland process
  • Hide process by PID
  • Unhide a previously hidden process by PID
  • Hide files or directories by their name
  • Unhide previously hidden files or directories
  • Hide itself
  • Unhide itself
  • Protect against being unloaded by the user
  • Disable the unload protection

Supported Platforms

The rootkit was tested to work on Linux kernels 2.6.32-38 and 4.4.0-22 as provided by Ubuntu in Ubuntu 10.04.4 LTS and Ubuntu 16.04 LTS respectively, but it should be very easy to port to kernels in-between, as well as newer ones.

There is some architecture-specific code in the rootkit which is implemented only for x86 and x86-64 architectures. That's the code for finding the system call table, disabling write-protected memory and one of the two function hooking methods. It should be very easy to port to a new architecture, and some of this code is not strictly necessary for the rootkit to function, e.g. the non-portable hooking method could be stripped away, though you must be a very boring person if you are willing to miss on the fun of function hooking that overwrites machine code of the target kernel function such that it calls our hook function instead.

The rootkit was tested only with 1 CPU core, so it may or may not function correctly on a multi-core system. It likely won't run very well on a multi-core system as the rootkit was written expecting there to be only 1 thread executing anything at any given time, so it lacks atomic writes/reads and mutexes around list data structures.

Build

Setting Up Environment

Warm up your VM of choice.

Grab and install the desired Ubuntu image:

Kernel / arch x86 x86-64
2.6.32 Ubuntu 10.04.4 i386 (694M) [torrent] [iso] Ubuntu 10.04.4 amd64 (681M) [torrent] [iso]
4.4.0 Ubuntu 16.04 i386 (647M) [torrent] [iso] Ubuntu 16.04 amd64 (655M) [torrent] [iso]

For Ubuntu 10.04, patch the package repository address:

sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list

Install a compiler, Linux headers and all other things required for us to build the rootkit:

apt-get update
apt-get install build-essential

Make sure not to call apt-get upgrade, as it would update the kernel, when the rootkit was tested only on the pre-installed kernel version.

Actual Building

make

Use

Load rootkit:

insmod rootkit.ko

Use rootkit:

$ ./client --help
Usage: ./client [OPTION]...

Options:
  --root-shell            Grants you root shell access.
  --hide-pid=PID          Hides the specified PID.
  --unhide-pid=PID        Unhides the specified PID.
  --hide-file=FILENAME    Hides the specified FILENAME globally.
                          Must be a filename without any path.
  --unhide-file=FILENAME  Unhides the specified FILENAME.
  --hide                  Hides the rootkit LKM.
  --unhide                Unhides the rootkit LKM.
  --help                  Print this help message.
  --protect               Protects the rootkit from rmmod.
  --unprotect             Disables the rmmod protection.

Unload rootkit:

./client --unhide
./client --unprotect
rmmod rootkit.ko

YOU ARE OUT OF YOUR MIND TO PUBLICY RELEASE SUCH MALICIOUS CODE ONLINE, YOU ARE LITERALLY ARMING SCRIPT KIDDIES WITH NUKES!!!1

Not really, there are many articles online on how to write a Linux rootkit with the full source code provided, not to mention the countless GitHub repositories.

References

The following materials were used in writing this rootkit:

License

This project is licensed under GPLv2.

More Repositories

1

vlc-pause-click-plugin

Plugin for VLC that pauses/plays video on mouse click
C
897
star
2

ProjectTox-Qt-GUI

A cross-platform front end for ProjectTox Core library, written in C++11 with use of Qt5
C++
341
star
3

chrome-mouse-wheel-tab-scroller

Scroll Google Chrome tabs using mouse wheel
AutoIt
61
star
4

paper-store

Cold store small files on paper as QR codes -- PGP keys, Bitcoin keys, Tox keys or any other small files in general.
Shell
35
star
5

vlc-pause-click-plugin-nightly-builds

Builds of https://github.com/nurupo/vlc-pause-click-plugin targeting the nightly, in-development version of VLC
6
star
6

twitch-prime-offer-claimer

Script for auto-claiming Twitch Prime loot, as well as reporting when new loot appears
Python
6
star
7

ci-release-publisher

A script for publishing Travis-CI build artifacts on GitHub Releases
Python
5
star
8

pia-wg-netns-vpn

A script for setting up and managing a WireGuard VPN in a network namespace
Shell
5
star
9

mpv-scripts

Some mpv scripts and config files
Lua
5
star
10

mpv-url-opener

A small https server that listens for requests to open YouTube URLs in mpv
Python
4
star
11

nfk-lobby

A lobby application for Need For Kill video game
C++
3
star
12

appimage-qt-cross-example

Shell
3
star
13

asm-irc-logger

Simple IRC logger that produces logs that can be processed by irclog2html.py script to generate colorful HTML log pages.
Assembly
2
star
14

test

test
Python
2
star
15

tox-split-message

Library providing split message functionality for sending messages over Tox.
C
1
star
16

qt-nfk-planet

Improved reimplementation of the NFK Planet (https://github.com/NeedForKillTheGame/Planet) in C++ and Qt
C++
1
star
17

vlc-noop-video-filter-plugin

VLC video filter plugin that does nothing
Shell
1
star