Writable $PATH
Path Hijacking
Identify the SUID file
For example, we found a file called /usr/bin/sysedit
, and this binary is called from a random task or script that we control or we can execute.
Create a file with malicious content
We need to create a file with the same name as the SUID previously found:
Update the $PATH variable
With that, we are going to position our malicious folder (with the malicious file inside) as the first folder that the system will reach if the (in this case) sysedit
file is invoked.
We need to execute the task or service that is calling that file again. And instead of the normal execution, we are going to see:
If we want a Reverse Shell
In the attack machine, we are going to listen to any port:
Now create the file with the connection towards the attacker listener:
Last updated