linux下如何隐藏进程(ps/top)
来源:互联网 发布:linux samba rpm 下载 编辑:程序博客网 时间:2024/05/16 05:00
今天看了一篇外国的blog,讲的是如何在2.4内核中隐藏进程。
其核心思想就是把task->pid变成0,就成了0号进程。而在ps,top命令中,是不显示0号进程的相关信息。这么一来,在/proc/文件夹下就不会有该进程的相关信息了。
于是把代码稍微做了一点改动,在2.6.18-308.4.1.el5 内核中还是好使的。
上代码:
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/list.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("JASON.LIN.YU");
static pid_t pid = 0;
static pid_t old_pid = 0;
static struct task_struct *task = NULL;
//static struct task_struct *old_task = NULL;
static char * mystring = NULL;
module_param(pid, int, 0);
module_param(mystring, charp, 0);
MODULE_PARM_DESC(pid, "The pid to hide");
MODULE_PARM_DESC(mystring, "The process's name");
int start_module(void)
{
task = find_task_by_pid(pid);
if(NULL == task){
return 1;
}
old_pid = task->pid;
task->pid = 0;//关键在于改变pid=0
return 0;
}
void clean_module(void)
{
struct list_head* list;
list_for_each(list, ¤t->tasks){
task = list_entry(list, struct task_struct, tasks);
if( 0 == memcmp(mystring, task->comm, strlen(mystring)+1)){
task->pid = old_pid;//替换pid
break;
}
}
return;
}
rmmod后,proc文件夹下该进程有重新出现。
注意:使用这个方法不能ctrl+C,或者exit()调用,否则系统oops。
====================================================================================================================================
另外,还有一种比较简便的方法,就是把int main(int argc, char*argv[])中的参数变成0,那么就在单纯的ps命令中就不会显示进程相关信息,但是/proc/文件夹下,还会存在该进程的相关信息。
代码如下:
/*test.c*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
int i = 0;
memset(argv[i], 0, strlen(argv[i]));
for(;;);
return 0;
}
gcc -o hide test.c
./hide
ps aux| grep hide
>>>root 2437 0.0 0.0 4016 700 pts/1 R+ 13:26 0:00 grep hide
但是top命令会显示出hide进程
以及使用ps -u username -U username会把进程信息出卖。
====================================================================================================================================
- linux下如何隐藏进程(ps/top)
- linux下如何隐藏进程(ps/top)
- linux下如何隐藏进程(ps/top)
- linux下如何隐藏进程(ps/top)(二)
- linux下如何隐藏进程(ps/top) 和找到linux进程路径
- linux ps top查看进程
- linux系统观察进程命令ps、top
- Linux中运行的进程:ps/top
- linux进程查看top与ps
- Linux任务进程管理:top、ps
- Linux下查看进程(ps或者top),或者使用图形化(系统监视器) .
- 查看进程 ps,top
- Linux进程管理命令详解(ps和top)
- Linux进程管理命令详解(ps和top)
- Linux进程管理命令详解(ps和top)
- linux 利用top和ps查找zombie进程
- Linux的进程查看命令ps与top详解
- Linux进程管理命令详解(ps和top)
- DAO设计模式
- C++ : #include "stdafx.h"
- 字符串(string)类型
- ubantu -- NFS -- TFTP
- 从linux0.11学习linux内核设计之模式转换:实模式-保护模式(1)
- linux下如何隐藏进程(ps/top)
- XML解析
- 顺序堆栈
- Go语言入门系列之安装及HelloWorld
- gvim+插件开发,体验
- 【*】POJ-3899(数论很难)(Lucky Numbers——统计)
- 字符串操作
- javabean的继承与反射
- 嵌入式面试题2