cybersecurity · beginner · ~10 min · safe pentest lab
Inspect Unix permission bits with bitmasks.
int audit_mode(unsigned int mode);
Return a bitmask of risky bits in a Unix file mode:
1) — world-writable (0002)2) — setuid (04000)4) — setgid (02000)Examples: 0644 → 0, 0666 → 1, 04755 → 2, 06777 → 7.
mode & 02 → world-writable.mode & 04000 → setuid; mode & 02000 → setgid.World-writable, setuid, and setgid bits are the trio every Linux permission audit (and privilege-escalation check) looks for.
int audit_mode(unsigned int mode) {
/* TODO */
(void)mode;
return 0;
}
Confusing owner/group/other write bits. Decimal instead of octal literals.
A safe 0644. All three risky bits at once (06777).
O(1).
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.