Linux ‐ Permission Vulnerabilities - Snowboundport37/champlain GitHub Wiki
Author: Andrei Gorlitsky
Course: SEC-335
Date: April 2025
#include <stdio.h>
#include <unistd.h>
#include <pwd.h>
int main(void) {
uid_t uid = geteuid();
struct passwd *pw = getpwuid(uid);
if (pw)
printf("Effective user: %s\n", pw->pw_name);
else
printf("User not found\n");
return 0;
}gcc effective_user.c -o effective_user
./effective_user
sudo ./effective_userls -l effective_user
stat effective_userI confirmed the octal permissions of the file to be 755 (rwxr-xr-x).
sudo chown root:root effective_user
sudo chmod u+s effective_user
ls -l effective_user
./effective_userThe permission changed to -rwsr-xr-x, confirming the SUID bit is set.
find / -type f -perm -4000 2>/dev/nullThis listed SUID binaries like /usr/bin/passwd, /usr/bin/sudo, and our own effective_user.
✅ Deliverable 5: Hidden SUID Program on Rocky (10.0.17.200)
find / -type f -perm -4000 -name 'b*' 2>/dev/null/usr/bin/booger
Since I did not have sudo privileges on Rocky, I created the file in /tmp:
touch /tmp/worldwrite.txt
chmod 777 /tmp/worldwrite.txt
find /tmp -type f -perm -o=w 2>/dev/null/tmp/worldwrite.txt
✅ Deliverable 7: Hidden World-Writable File on Rocky
find / -path /proc -prune -o -path /sys -prune -o -type f -perm -o=w -name 's*' -print 2>/dev/null/usr/share/games/solitaire
- Use
find / -type f -perm -4000to locate all SUID binaries - Use
-name 'b*'to find specific targets - Use
grepto filter results:
find / -type f -perm -4000 2>/dev/null | grep -i '/b'- Use
find / -type f -perm -o=wto locate globally writable files - Exclude
/procand/systo avoid noise:
find / -path /proc -prune -o -path /sys -prune -o -type f -perm -o=w -print 2>/dev/null- To search for specific filenames:
find / -path /proc -prune -o -path /sys -prune -o -type f -perm -o=w -name 's*' -print 2>/dev/nullThese techniques are useful for identifying privilege escalation vectors and misconfigurations on Linux systems.