• 一行代码如何隐藏 Linux 进程?


    本文介绍一种将Linux进程小隐于用户的非常规方法,仅仅一行代码:

    修改掉进程的pid即可。

    注意是小隐,所以,不值得反制,逗一下高级会议工程师搞个恶作剧玩玩得了。

    target->pid = 0x7fffffff;

    完整的脚本如下:

    #!/usr/bin/stap -g
    # hide.stp

    global pid;

    function hide(who:long)
    %{
        struct task_struct *target;

        target = pid_task(find_vpid(STAP_ARG_who), PIDTYPE_PID);
        target->pid = 0x7fffffff;
    %}

    probe begin
    {
        pid = $1
        hide(pid);
        exit();
    }
    ff;

    来来来,试一下:

    [root@localhost system]# ./tohide &
    [1] 403
    [root@localhost system]# ./hide.stp
    [root@localhost system]# 

    用下面的命令可以检测所有可显示进程的二进制文件:

    for pid in $(ls /proc|awk '/^[0-9]+/{print $1}'); do 
        ls -l /proc/$pid/exe; 
    done

    procfs里没了,ps当然就检测不到了。

    如果你觉得guru 模式的 stap 怪怪的,那么你完全可以编写自己独立的 Linux kernel module,采用修改完即退的方法:

    target->pid = xxxx;

    return -1;是不是比各种hook法简单多了,所谓的动数据而不要动代码!是不是比各种 hook 法简单多了,所谓的动数据而不要动代码!

    简单的说一下原理:

    task被创建的时候,根据其pid注册procfs目录结构。

    展示procfs目录结构的时候,遍历task list以其pid作为key来查找procfs目录结构。

    0x7fffffff(或者任何其它合理的值)根本没有注册过,当然无法显示。

    有相同爱好的可以进来一起讨论哦:企鹅群号:1046795523

    学习视频资料:http://www.makeru.com.cn/live/1392_1164.html?s=143793

  • 相关阅读:
    Python3 sorted() 函数
    [Python网络编程]一个简单的TCP时间服务器
    [爬虫]统计豆瓣读书中每个标签下的前两百本书
    [leetcode]39. Combination Sum
    [leetcode]18. 4Sum
    [leetcode DP]72. Edit Distance
    [leetcode DP]120. Triangle
    [leetcode DP]91. Decode Ways
    [leetcode DP]70. Climbing Stairs
    [leetcode DP]64. Minimum Path Sum
  • 原文地址:https://www.cnblogs.com/jinwenyi/p/13679952.html
Copyright © 2020-2023  润新知