USBArmory: LKMs

Hi! I’m going to show you, how you can write and load your own LKMs for the USBArmory.

1. download the kernel source
2. download the .config file used by InversePath
3. compile the kernel and generate all important files
4. write module & makefile
5. insert & remove the module

1.
If you want to write your own modules you’ll need the kernel headers specifically for your running kernel.
If you’re running the latest image, you just need to download the kernel source for linux-4.2.1.

2.
Now we need to download the .config file and place it into the kernel source directory.

3.
Run ‘sudo make; sudo make modules_prepare’ to create all important files.
This can take up quite some time, so grab a coffee or a book.

4.
Finally we can write our own module:

And our Makefile:

You have to insert your path to the kernel source directory.
The ‘-C’ flag points to the kernel sources ( would be /home/usbarmory/linux-4.2.1/ ) and the ‘M’ variable to the directory of your module ( would be /home/usbarmory ).
The ‘modules’ at the end just shows what to build.

You can now enter ‘sudo make’ to build the LKM:

5.
Now you can insert your module into the kernel.

Look at the the last output of ‘dmesg’ to see our module in action:

Unloading works pretty similar:

Again see the output of ‘dmesg’:

To see list of all modules currently loaded, you can enter ‘lsmod’

Have fun writing your own modules!

Carl Smith

One thought on “USBArmory: LKMs”

Leave a Reply