Looking at Some Real-World Examples
In this section, I’ll show you some practical, real-life things that you can do with some of the techniques that we’ve covered so far. Actually, rather than just showing you, I’ll let you get your hands dirty with some cool hands-on labs.
Hands-on Lab: Using if..then
This is absolutely a real-life example. Several years ago, I created this script as a plug-in for the Nagios network monitoring system. The scenario was that we wanted to make sure that malicious hackers haven’t added a rogue UID 0
account to the /etc/passwd
file on Linux and FreeBSD machines. That’s because any account with a UID setting of 0
in the passwd
file has full root privileges, and we don’t want any unauthorized accounts to have root privileges.
The problem is that on Linux machines there’s only supposed to be one user account with UID 0
, and on FreeBSD there are two accounts with UID 0
. (One UID 0
account is named...