Git Product home page Git Product logo

casper-fs's Introduction

casper-fs ๐Ÿ‘ป

Casper-fs is a custom Linux Kernel Module generator to work with resources to protect or hide a custom list of files.

Overview

The first point, the user sends input to the Casper-FS the YAML file with rules to generate a custom LKM(Linux kernel module), each generated module works in the file system to protect and hide secret files (Not even the root has permission to see the file, only can see with a proper sending key to the custom device). This program has two principal functions: turning private files hidden. The second function is to protect confidential files to prevent reading, writing and removal.

The motivation: An attacker can read every file in your machine in a bad situation(if he got root). But if you have a Casper-fs custom module, the attacker will not find the hidden kernel module that has functions to protect your private data files such as logs and password vaults.

My beginning purpose at this project is to protect my server, which is to protect my friends' machines. When I talk to friends, I say peoples that don't know how to write low-level code. Using the Casper-fs, you can generate your custom kernel module to protect your secret files. The low-level programmer can write new templates for modules etc.

Video demo:

https://www.youtube.com/watch?v=qxLEkYFicTg

The first step, understand before the run.

Verify if the kernel version is 3.x, 4.x, or 5.x:

$ uname -r

Clone the repository

$ git clone https://github.com/CoolerVoid/casper-fs

Enter the folder and install python3 modules:

$ cd casper-fs/module_generator
$ sudo python3 -m pip install -r requirements.txt

Edit your file rules in directory module_generator/rules/fs-rules.yaml, the python scripts, use that file to generate a new casper-fs custom module.

$ cat module_generator/rules/fs-rules.yaml
binary_name: casperfs
module_name: Casperfs
unhide_module_key: AbraKadabra
hide_module_key: Shazam
fake_device_name: usb15
unhide-hide-file-key: Alakazam
unprotect-protect-file-key: Sesame 
fs-rules: 
- hidden: 
   1: secret.txt
   2: my_vault.db
- protect:
   1: backup_httpd.log

The array is hidden and array protected. You can insert a lot of the elements of another file on context, for example:

- protect:
   1: backup_httpd.log
   2: secret_img.iso
   3: secret_file.img
   4: secret_file2.img
   5: secret_file3.img

If you want to study the static code to generate, look at the directory "templates" content.

The second step, generate your module.

If you want to generate a kernel module following your YAML file of rules, follow that command:

$ python3 casper-fs-gen.py --rules rules/fs-rules.yaml

This action can generate a generic module with the fs-rules.yaml.

The third step, install your module.

If you use Fedora Linux, install kernel packages for the developer:

# dnf update
# dnf install kernel-headers.x86_64 kernel-modules.x86_64 kernel.x86_64 kernel-devel kmod

On Ubuntu Linux:

apt install linux-headers-generic gcc make

To test module:

# cd output; make clean; make
# insmod casperfs.ko

The fourth step runs your custom module.

  • The password to turn casper-fs module visible for lsmod is the key "Shazam".
  • The password to turn the casper-fs invisible is "AbraKadabra".
  • The password to turn the secret files in hidden is "Alakazam", the same to turn to unhidden.
  • The password to protect files or unprotect is "Sesame".

You need to send the password for your fake device, "usb15" for example, to test hidden and unhidden resources on the file system:

$ touch secret.txt
$ ls
-- no results--
$ echo "Alakazam" > /dev/usb15
$ ls
secret.txt
$ echo "Alakazam" > /dev/usb15
$ ls
-- no results--

So this is an example of trying to remove a protected file by Casper-fs:

# ls
test.txt  log.txt backup_httpd.log
# rm backup_httpd.log
# ls 
test.txt  log.txt backup_httpd.log
# echo "Sesame" > /dev/usb15            // to remove protection
# rm backup_httpd.log
# ls
test.txt  log.txt
# echo "Sesame" > /dev/usb15    // to active protection again
  • Note You need to turn casperfs visible at the "lsmod" command. Need this action before removing module
# rmmod casperfs
rmmod: ERROR: ../libkmod/libkmod-module.c:799 kmod_module_remove_module() could not remove 'casperfs': No such file or directory
rmmod: ERROR: could not remove module casperfs: No such file or directory
# lsmod | grep casper
# echo "Shazam" > /dev/usb15
# lsmod | grep casper
casperfs
# rmmod casperfs

Random notes

Tested on ubuntu 16 and fedora 29 at kernels "3.x","4.x" and "5.x".

Point of attention

This tool aims to use in the hardening system context. Pay attention if you have proper authorization before using that. I do not have responsibility for your actions. You can use a hammer to construct a house or destroy it, choose the law path, don't be a bad guy, remember.

References

Wikipedia Netfilter https://en.wikipedia.org/wiki/Netfilter

Linux Device Drivers http://lwn.net/Kernel/LDD3/

M0nad's Diamorphine https://github.com/m0nad/Diamorphine/

casper-fs's People

Watchers

James Cloos avatar

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.