
Automated local privilege escalation exploit for CVE-2024-48990 (needrestart v3.7), leveraging PYTHONPATH hijacking to gain root access.
This tool automates the exploitation of a privilege escalation vulnerability in needrestart version 3.7, identified as CVE-2024-48990.
It achieves root execution by leveraging the insecure use of the PYTHONPATH environment variable when needrestart scans Python processes.
The exploit works by:
__init__.so) that is triggered on import..so via a local HTTP server.PYTHONPATH environment.importlib.needrestart, which inherits the manipulated PYTHONPATH, loads the malicious module, and executes the payload as root./tmp/poc), allowing root shell access.Run the exploit from your attacker machine:
python3 exploit.py --user <ssh_user> --host <target_ip> --att-ip <attacker_ip> --ssh-pass <ssh_password>
Parameters:
needrestart version 3.7To remove exploit traces from the target:
rm -rf /tmp/malicious /tmp/poc /tmp/exploit.sh
pexpect (pip3 install pexpect)gcc (for compiling the payload)python3 -m http.server (automatically started by the script)needrestart (v3.7)sudo NOPASSWD rights for /usr/sbin/needrestartcurl installedThis tool is provided for educational and authorized security testing purposes only. Do not use it on systems you do not own or without explicit permission.