本文介紹一種將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