Top Related Projects
PEASS - Privilege Escalation Awesome Scripts SUITE (with colors)
Scripted Local Linux Enumeration & Privilege Escalation Checks
Linux privilege escalation auditing tool
Linux enumeration tool for pentesting and CTFs with verbosity levels
Privilege Escalation Project - Windows / Linux / Mac
Quick Overview
LinuxPrivChecker is a Python script designed to assist in privilege escalation auditing on Linux systems. It automates the process of gathering system information and identifying potential security vulnerabilities that could be exploited for privilege escalation.
Pros
- Comprehensive system information gathering
- Automated vulnerability detection
- Easy to use and requires minimal setup
- Regularly updated to include new privilege escalation techniques
Cons
- May produce false positives
- Requires root access for full functionality
- Can be detected by some security software as potentially malicious
- Limited to Linux systems only
Code Examples
# Example 1: Running a basic system check
import linuxprivchecker
checker = linuxprivchecker.PrivChecker()
results = checker.run_check()
print(results)
# Example 2: Customizing the checks
import linuxprivchecker
checker = linuxprivchecker.PrivChecker()
checker.disable_check('network')
checker.enable_check('suid_files')
results = checker.run_check()
print(results)
# Example 3: Exporting results to a file
import linuxprivchecker
checker = linuxprivchecker.PrivChecker()
results = checker.run_check()
checker.export_results(results, 'privcheck_results.txt')
Getting Started
To use LinuxPrivChecker, follow these steps:
-
Clone the repository:
git clone https://github.com/sleventyeleven/linuxprivchecker.git
-
Navigate to the project directory:
cd linuxprivchecker
-
Run the script with Python:
python linuxprivchecker.py
Note: For full functionality, run the script with root privileges:
sudo python linuxprivchecker.py
The script will automatically gather system information and display potential privilege escalation vectors. Review the output carefully to identify security vulnerabilities in your Linux system.
Competitor Comparisons
PEASS - Privilege Escalation Awesome Scripts SUITE (with colors)
Pros of PEASS-ng
- More comprehensive, covering multiple operating systems (Linux, Windows, macOS)
- Actively maintained with frequent updates
- Includes additional features like automatic exploitation and report generation
Cons of PEASS-ng
- More complex to use due to its extensive feature set
- Larger codebase, potentially slower execution on resource-constrained systems
- May generate more noise in output, requiring more analysis
Code Comparison
PEASS-ng (linpeas.sh):
if [ "$MACPEAS" ]; then
print_2title "System Information"
system_info
else
print_2title "Linux System Information"
debug_print "OS: $OSTYPE"
echo "OS: $OSTYPE"
echo "User & Groups: $USER $UID $(id)"
linuxprivchecker:
def get_system_info():
print("[*] GETTING SYSTEM INFO...\n")
results = []
sysInfo = {}
hostName = os.uname()[1]
osName = os.uname()[0]
kernel = os.uname()[2]
Both scripts aim to gather system information, but PEASS-ng uses shell scripting while linuxprivchecker uses Python. PEASS-ng's approach allows for easier cross-platform compatibility, while linuxprivchecker's Python implementation may offer better performance and easier maintenance.
Scripted Local Linux Enumeration & Privilege Escalation Checks
Pros of LinEnum
- More comprehensive and detailed output, covering a wider range of system information
- Regularly updated with new features and improvements
- Includes colorized output for better readability
Cons of LinEnum
- Larger script size, potentially slower execution on resource-constrained systems
- May produce excessive output, making it harder to identify critical information quickly
Code Comparison
LinEnum:
#!/bin/bash
VERSION="0.982"
# Check if we're being piped
if readlink /proc/$$/fd/1 | grep -q "^pipe:"; then
PIPE=1
fi
linuxprivchecker:
#!/usr/bin/env python
# Import libraries
import os
import subprocess
import sys
LinEnum is written in Bash, while linuxprivchecker is written in Python. LinEnum checks for piped output, which may affect its behavior, while linuxprivchecker focuses on importing necessary libraries for its functionality.
Both tools aim to gather system information for privilege escalation, but LinEnum generally provides more extensive output and is more actively maintained. However, linuxprivchecker's Python implementation may offer better cross-platform compatibility and easier customization for users familiar with Python.
Linux privilege escalation auditing tool
Pros of linux-exploit-suggester
- More actively maintained with recent updates
- Supports a wider range of Linux distributions and versions
- Provides more detailed vulnerability information and exploit suggestions
Cons of linux-exploit-suggester
- Larger script size, potentially slower execution
- May require more dependencies or external resources
- Could generate more false positives due to broader coverage
Code Comparison
linuxprivchecker:
def get_os_info():
os_info = {}
os_info['KERNEL'] = os.uname()[2]
os_info['HOSTNAME'] = os.uname()[1]
return os_info
linux-exploit-suggester:
get_kernel_version() {
kernel_version=$(uname -r)
kernel_version=${kernel_version%%-*}
kernel_major=$(echo "$kernel_version" | cut -d. -f1)
kernel_minor=$(echo "$kernel_version" | cut -d. -f2)
kernel_release=$(echo "$kernel_version" | cut -d. -f3)
}
Both scripts aim to gather system information, but linux-exploit-suggester provides more detailed kernel version parsing, which is crucial for accurate vulnerability matching.
Linux enumeration tool for pentesting and CTFs with verbosity levels
Pros of linux-smart-enumeration
- More actively maintained with recent updates
- Offers color-coded output for better readability
- Includes a "quiet mode" for stealthier operation
Cons of linux-smart-enumeration
- Larger file size, potentially less suitable for quick transfers
- More complex usage with multiple options and modes
- May be overkill for simple enumeration tasks
Code Comparison
linuxprivchecker:
def enum_user_info():
print "\n[*] ENUMERATING USER AND ENVIRONMENTAL INFO...\n"
print "[+] Current user/group info:\n"
os.system("id")
print "\n[+] Users that have previously logged onto the system:\n"
os.system("ls -alh /home/")
linux-smart-enumeration:
lse_user_info() {
lse_test "usr000" "1" \
"Current user groups" \
'groups' \
"" \
"lse_exec groups"
lse_test "usr010" "1" \
"Other users in the system" \
'cat /etc/passwd' \
"" \
"lse_proc_print \"\\nUsername:UID:GID:Home:Shell\n$(cat /etc/passwd | awk -F: '{print \$1\":\"$3\":\"$4\":\"$6\":\"$7}')\""
}
The code comparison shows that linux-smart-enumeration uses more sophisticated bash scripting with functions and parameters, while linuxprivchecker uses simpler Python code with direct system calls. This reflects the overall complexity difference between the two tools.
Privilege Escalation Project - Windows / Linux / Mac
Pros of BeRoot
- Multi-platform support (Windows, Linux, macOS)
- More comprehensive privilege escalation checks
- Active development and regular updates
Cons of BeRoot
- Larger codebase, potentially slower execution
- Requires Python 3, which may not be available on all systems
- More complex to use and interpret results
Code Comparison
BeRoot (Python):
def check_suid_bin():
suid = []
for path in os.environ['PATH'].split(':'):
for file in os.listdir(path):
try:
if os.stat(os.path.join(path, file)).st_mode & stat.S_ISUID:
suid.append(os.path.join(path, file))
except:
pass
return suid
linuxprivchecker (Bash):
find / -perm -4000 -type f -exec ls -la {} 2>/dev/null \;
BeRoot offers a more sophisticated approach to checking SUID binaries, handling potential errors and using Python's built-in functions. linuxprivchecker uses a simple but effective one-line command to achieve a similar result.
Both tools serve the purpose of privilege escalation checking, but BeRoot provides a more comprehensive and multi-platform solution at the cost of increased complexity. linuxprivchecker offers a simpler, lightweight alternative specifically for Linux systems.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Linuxprivchecker.py
A Linux Privilege Escalation Check Script
Orginal Author: Mike Czumak (T_v3rn1x) -- @SecuritySift
Current Maintainer: Michael Contino (@Sleventyeleven)
This script is intended to be executed locally on a Linux box to enumerate basic system info and search for common privilege escalation vectors such as world writable files, misconfigurations, clear-text passwords and applicable exploits.
Linuxprivchecker is designed to identify potential areas to investigate further, not provide direct action or exploitation. This is to help users further learn how these privilege escalations work and keep it in line with the rules, for self directed exploitation, laid out for the OSCP, HTB, and other CTFs/exams.
We will try our best to addtional information and reference where possible. As the current Maintainer, I also plan to accompany new feature adds, with a post on my blog (hackersvanguard.com) to further explain each potential area for privilege escalation and what criteria may be required.
Running on Legacy Python 2.6/2.7 System
To run on legacy python >2.6 systems just get the all in one python script and run it.
wget https://raw.githubusercontent.com/sleventyeleven/linuxprivchecker/master/linuxprivchecker.py
python linuxprivchecker.py -w -o linuxprivchecker.log
Running on Current Python 3.X System (Beta)
Right now Linuxprivchecker for python 3.X should be considered a stable beta versions. Issues can happen with the script and it certainly can miss possible vulnerabilities (open an issue or PR).
To run the python 3 version, just utilize pip.
pip install linuxprivchecker
Then just run via commandline if runpy is available.
linuxprivchecker -w -o linuxprivchecker.log
or if runpy fails to add the script to your path
python3 -m linuxprivchecker -w -o linuxprivchecker.log
Command Options and arguments
If the system your testing has Python 2.6 or high and/or argparser installed, you can utilize the following options. If importing argparser does not work, all checks will be run and no log file will be written. However, you can still use terminal redirection to create a log, such as 'python linuxprivchecker.py > linuxprivchecker.log.'
usage: linuxprivchecker.py [-h] [-s] [-w] [-o OUTFILE]
Try to gather system information and find likely exploits
optional arguments: -h, --help show this help message and exit
-s, --searches Skip time consumming or resource intensive searches
-w, --write Wether to write a log file, can be used with -0 to specify name/location
-o OUTFILE, --outfile OUTFILE The file to write results (needs to be writable for current user)
Warning
This script comes as-is with no promise of functionality or accuracy. I have no plans to maintain updates, I did not write it to be efficient and in some cases you may find the functions may not produce the desired results. For example, the function that links packages to running processes is based on keywords and will not always be accurate. Also, the exploit list included in this function will need to be updated over time. Feel free to change or improve it any way you see fit.
Modification, Distribution, and Attribution
You are free to modify and/or distribute this script as you wish. I only ask that you maintain original author attribution and not attempt to sell it or incorporate it into any commercial offering (as if it's worth anything anyway :)
Top Related Projects
PEASS - Privilege Escalation Awesome Scripts SUITE (with colors)
Scripted Local Linux Enumeration & Privilege Escalation Checks
Linux privilege escalation auditing tool
Linux enumeration tool for pentesting and CTFs with verbosity levels
Privilege Escalation Project - Windows / Linux / Mac
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot