Skip to content

Instantly share code, notes, and snippets.

@nextsux
Created May 5, 2014 13:31
Show Gist options
  • Save nextsux/08977c196df3784b4997 to your computer and use it in GitHub Desktop.
Save nextsux/08977c196df3784b4997 to your computer and use it in GitHub Desktop.
# cat /mnt/reaver/mnt/data/old/3fault.patch
diff -ruN linux-2.6.13.4/arch/i386/Kconfig.debug linux-2.6.13.4-b/arch/i386/Kconfig.debug
--- linux-2.6.13.4/arch/i386/Kconfig.debug 2005-10-10 20:54:29.000000000 +0200
+++ linux-2.6.13.4-b/arch/i386/Kconfig.debug 2005-11-02 11:25:49.000000000 +0100
@@ -71,5 +71,17 @@
bool
depends on X86_LOCAL_APIC && !X86_VISWS
default y
+
+config X86_TRIPPLEFAULT
+ tristate "Turn on /proc/tripplefault"
+ depends on m && X86_PC && MODULES
+ default m
+ help
+ beware of using this! use this only if you really
+ know what are you fuckin' doing
+
+ AVAILABLE ONLY AS MODULE
+
+ module will be named 3fault.ko
endmenu
diff -ruN linux-2.6.13.4/arch/i386/kernel/Makefile linux-2.6.13.4-b/arch/i386/kernel/Makefile
--- linux-2.6.13.4/arch/i386/kernel/Makefile 2005-10-10 20:54:29.000000000 +0200
+++ linux-2.6.13.4-b/arch/i386/kernel/Makefile 2005-11-02 11:24:33.000000000 +0100
@@ -34,6 +34,7 @@
obj-$(CONFIG_HPET_TIMER) += time_hpet.o
obj-$(CONFIG_EFI) += efi.o efi_stub.o
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
+obj-$(CONFIG_X86_TRIPPLEFAULT) += 3fault.o
EXTRA_AFLAGS := -traditional
diff -ruN linux-2.6.13.4/arch/i386/kernel/3fault.c linux-2.6.13.4-b/arch/i386/kernel/3fault.c
--- linux-2.6.13.4/arch/i386/kernel/3fault.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13.4-b/arch/i386/kernel/3fault.c 2005-11-02 10:27:25.000000000 +0100
@@ -0,0 +1,88 @@
+#include <linux/module.h> /* Needed by all modules */
+#include <linux/kernel.h> /* Needed for KERN_INFO */
+#include <asm/mc146818rtc.h>
+#include <asm/pgtable.h>
+#include <linux/efi.h>
+#include <linux/proc_fs.h> /* Necessary because we use the proc fs */
+#define procfs_name "tripplefault"
+
+
+static unsigned long long
+real_mode_gdt_entries [3] =
+{
+ 0x0000000000000000ULL, /* Null descriptor */
+ 0x00009a000000ffffULL, /* 16-bit real-mode 64k code at 0x00000000 */
+ 0x000092000100ffffULL /* 16-bit real-mode 64k data at 0x00000100 */
+};
+
+static struct
+{
+ unsigned short size __attribute__ ((packed));
+ unsigned long long * base __attribute__ ((packed));
+}
+real_mode_gdt = { sizeof (real_mode_gdt_entries) - 1, real_mode_gdt_entries },
+real_mode_idt = { 0x3ff, NULL },
+no_idt = { 0, NULL };
+
+int
+procfile_read(char *buffer,
+ char **buffer_location,
+ off_t offset, int buffer_length, int *eof, void *data)
+{
+ int ret;
+
+ if (offset > 0) {
+ /* we have finished to read, return 0 */
+ ret = 0;
+ } else {
+ /* fill the buffer, return the buffer size */
+ ret = sprintf(buffer, "Beware of writing here!\n");
+ }
+
+ return ret;
+}
+
+int procfile_write(struct file *file, const char *buffer, unsigned long count,
+ void *data)
+{
+ __asm__ __volatile__("lidt %0": :"m" (no_idt));
+ __asm__ __volatile__("int3");
+
+ return 0;
+}
+
+
+static struct proc_dir_entry *Our_Proc_File;
+
+int init_module(void)
+{
+
+ Our_Proc_File = create_proc_entry(procfs_name, 0644, NULL);
+
+ if (Our_Proc_File == NULL) {
+ remove_proc_entry(procfs_name, &proc_root);
+ printk(KERN_ALERT "Error: Could not initialize /proc/%s\n",
+ procfs_name);
+ return -ENOMEM;
+ }
+
+ Our_Proc_File->read_proc = procfile_read;
+ Our_Proc_File->write_proc = procfile_write;
+ Our_Proc_File->owner = THIS_MODULE;
+ Our_Proc_File->mode = S_IFREG | S_IRUGO;
+ Our_Proc_File->uid = 0;
+ Our_Proc_File->gid = 0;
+ Our_Proc_File->size = 24;
+
+ printk(KERN_INFO "/proc/%s created\n", procfs_name);
+ printk(KERN_INFO "1337 nx tripple fault module loaded! beware!\n");
+ return 0;
+}
+
+
+void cleanup_module(void)
+{
+ remove_proc_entry(procfs_name, &proc_root);
+ printk(KERN_INFO "/proc/%s removed\n", procfs_name);
+ printk(KERN_INFO "your system is safe now ;)\n");
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment