m0nad / Diamorphine

LKM rootkit for Linux Kernels 2.6.x/3.x/4.x/5.x/6.x (x86/x86_64 and ARM64)
Other
1.79k stars 425 forks source link

Build doesn't work on Kali GNU/Linux Rolling (9.16.12-Debian - Linux 5.10.0-kali4-amd64 Kernel) #26

Closed TheThingGoesSkra closed 3 years ago

TheThingGoesSkra commented 3 years ago

Hello, I installed linux-headers-(uname -r) and build-essential and I got this error message when I try to build diamorphine:

make -C /lib/modules/5.10.0-kali4-amd64/build M=/opt/infra/install_scripts/install_scripts.d/Diamorphine modules
make[1] : on entre dans le répertoire « /usr/src/linux-headers-5.10.0-kali4-amd64 »
  MODPOST /opt/infra/install_scripts/install_scripts.d/Diamorphine/Module.symvers
ERROR: modpost: "kallsyms_lookup_name" [/opt/infra/install_scripts/install_scripts.d/Diamorphine/diamorphine.ko] undefined!
make[3]: *** [/usr/src/linux-headers-5.10.0-kali4-common/scripts/Makefile.modpost:111 : /opt/infra/install_scripts/install_scripts.d/Diamorphine/Module.symvers] Erreur 1
make[3]: *** Suppression du fichier « /opt/infra/install_scripts/install_scripts.d/Diamorphine/Module.symvers »
make[2]: *** [/usr/src/linux-headers-5.10.0-kali4-common/Makefile:1717 : modules] Erreur 2
make[1]: *** [/usr/src/linux-headers-5.10.0-kali4-common/Makefile:185 : __sub-make] Erreur 2
make[1] : on quitte le répertoire « /usr/src/linux-headers-5.10.0-kali4-amd64 »
make: *** [Makefile:7 : all] Erreur 2

However the process exist :

cat /proc/kallsyms | grep kallsyms_lookup_name
0000000000000000 T module_kallsyms_lookup_name
0000000000000000 T kallsyms_lookup_name

Do you know what the problem is, please?

loresuso commented 3 years ago

Hi, the kallsyms_lookup_name function is unexported in recent kernel versions according to this.

Workaround: as suggested in the article, you can make use of kprobes. See this repository.

awerv commented 3 years ago

@TheThingGoesSkra to get valid addresses from that file, you must run cat as the root user, otherwise you get zeros.

Possible (long term) solutions of this issue:

Both solutions with header generation suffer from the same issue: if KASLR/KAISER is enabled, only offsets are stored, the base address of the kernel must be determined as well.

m0nad commented 3 years ago

It should be fixed now, based on the work from @zizzu0 (https://github.com/zizzu0/LinuxKernelModules/blob/main/FindKallsymsLookupName.c) and @xcellerator (https://xcellerator.github.io/posts/linux_rootkits_11/)