Security isn't a tangible thing, it is applied psychology. | |
| Alec Muffett[author of "Crack"] |
Executive Summary. Computer security is more than network security. All the attention, and, dare we say, hype focussed on recent dramatic events involving hacker exploits on the Internet tend to blur the need for a security policy that only begins with, or, more accurately, only ends at the connection to the Internet backbone. Indeed, according to the Sans Institute's (http://www.sans.org) list of "The Seven Worst Security Mistakes Senior Executives Make," "Relying primarily on a firewall." ranks as number four out of the seven. One recent high-profile exploit that compromised a large commercial colocation facility has been attributed, ultimately, to poor password management (one of the topics covered in this Guide). The catch phrase "If you build it they will come." applies to sloppy internal computer security policy. If you make it easy for the blackhats, they will come; they are going to come anyway! This Guide is an introduction to some selected topics in host-based computer security, with a nod here and there to network-based security. Obviously, there is no clear demarcation between the two, but in the rush to secure information systems from external threats, the requirements of internal security may appear somewhat prosaic if compared to their flashy firewall and network intrusion detection cousins. This Guide is meant to redress this imbalance of emphasis.
The steps outlined below can be implemented by anyone with an elementary knowledge of Linux commands and file handling. However, in some cases the interpretation of the results of the implementation require a fair amount of sophistication and experience. Good security policy can and should begin with simple steps, but if these are not followed up with ongoing learning then the result will very likely be a false sense of security, perhaps the most unwanted of outcomes.
The standard reference is Practical Unix and Internet Security by Simson Garfinkel and Gene Spafford, published by O'Reilly. Required reading.
Armoring Linux by Lance Spitzner. http://www.enteract.com/~lspitz/linux.html
Linux Administrator's Security Guide by Kurt Seifried. http://www.securityportal.com/lasg/
On the Internet:
Chris Nadovich of jtan.com read the manuscript of this Guide and provided helpful feedback as well as pointed constructive criticism. Needless to say, the errors and oversights remaining within are all the author's.
All the procedures in this Guide have been tested on a Pentium 166 system with 64 megs of RAM and an IDE drive.
The procedures outlined in this Guide are compatible with the version 2.2.14 Linux kernel shipped with eServer 2.3.
Several different software packages are described but their use is optional.
Although certain sections of this Guide address specific situations, the problem to be solved might be generally termed "Loss Prevention." Losses can occur due to negligence, accidental mishap, or malice. The topic of computer security encompasses all of these.
This Guide consists of a highly selective set of Topics in computer security. It should not be seen as either exhaustive or authoritative. The aim is to open up for the reader a set of avenues for further exploration. Although examples, and quite detailed ones at that, will be given, it is imperative that these be considered mere examples. It is every system administrator's responsibility to set up a comprehensive security policy that is appropriate for the configuration and use of the particular host or hosts under his or her care. Connecting a computer to the Internet, even if only briefly via a dialup modem connection, entails the immediate possibility of that computer being compromised in some fashion.
Just as the Internet, and Linux itself, are distributed, cooperative ventures, so is computer security. By securing your computer you are contributing to the security of every user of the Internet. Conversely, an insecure Internet host is a threat to everyone, since it can be used as a platform from which to launch attacks in any direction.
One commonplace that has gained currency of late is the notion that "the only secure computer is one not connected to any network." Nothing could be further from the truth. What may be considered "secure" is always a judgment made relative to several factors, among which might be:
The value of certain information or operations to your organization.
The value of that information or operations to certain others, or to unknown others.
The degree, intensity and skillfulness of attacks that might be directed against that information or operations.
The costs of securing systems to varying degrees of 'hardness' commensurate with the above considerations, plus the costs of maintaining security at those levels.
"Secure" should always be taken to mean "secure with regard to this installation, configured in this manner, against these possible threats, as far as these data, operations or services are concerned, as long these specific measures and practices are adopted and maintained, according to the best of our knowledge of current realities, and in light of all sorts of unforeseen and unforeseeable contingencies." The term never means more than this, and almost always quite a bit less.
The aim here is not to instill paranoia, but a balanced "eyes wide open" perspective on certain steps that are simple and inexpensive to take, steps that will produce enhanced security. These are, as this Guide's title suggests, merely some of the "basics." There is little excuse for not considering their implementation, and even less for not going on to learn more.
Caveat: A selected group of software packages will be discussed in this Guide. These packages should never be installed wily-nily on "live" online production machines. Although the initial installation of these packages is for the most part fairly simple, in actual practice a useful, secure configuration may only emerge after testing the package in various ways and learning its idiosyncrasies. Also, these packages come with documentation, some of it rather extensive, and it would be the height of irresponsibility to put any of the packages described herein "online" without becoming quite familiar with its documentation. A dangerous false sense of security is a real possibility. As in most things, the middle road is elusive but surrenders itself on a regular basis to liberal applications of common sense.
Like many buzzwords now current among computing aficionados, the term "security policy" rarely gets spelled out with any specificity. There are "policies," and then there are policies. Some are expensive exercises in bureaucratic deniability. These impressive documents, often termed "security assertions," will lay out some basic measures and practices that need to be followed. Unfortunately, the practical result is that frequently the security needs of a system are never addressed beyond the strict wording of the "assertion." If there's a problem at least we can say, "Well, we followed the assertion, so it must have been faulty; sue the consultant." The consultant can almost always win these cases since he or she is well prepared to demonstrate that 'due diligence' was exercised in the preparation of the assertion. So the entire raison d'etre of the policy is revealed to be no more than an elaborate exercise of "Cover your back side."
Beyond specifying a certain number of protective measures to be taken, a good security policy should in effect draw a complete picture of the operation of the system(s) whose security is at stake, especially with regard to the following:
What are the threats?
A list of all the possible causes of data loss or downtime would be an impressive document indeed. As noted above, nowadays all the hype is focussed on the blackhat crackers. In fact losses due to other causes probably outweigh those brought about by intentionally malicious incursions. Consider, for instance, the role of mistakes. An administrator or user enters an untoward command and presto: instead of backing up a drive it is wiped clean. Or, think about hardware failures; all storage media as of this writing are mortal creatures with finite life spans. Suppose a thorough backup procedure is not in place? The point here is that security threats come in myriad colors: accidents, mistakes, Acts of God, as well as intentional invasion by bad people.
What are relative priorities of these threats?
Yes, you've installed a state of the art smoke detector system, and a similarly modern Halon fire extinguishing system in all parts of the building that house hosts. But, in the event the toilet (water heater, etc.) in the restroom down the hall malfunctions, how many inches of water are required to reach those hosts? Are they on the floor? My money is on the toilet overflowing more often than the building catching fire.
For each specific threat, what is the recovery plan in the event a given threat comes to pass?
How much time will it take to get organized and in gear to repair a problem? Or, will the owner or CEO have to be reached in Santiago because no one else knows who has a copy of the key used to encrypt the backups? How many people know who to order a replacement drive from? Typically the problem with recovery plans is that they get written once, and then gravitate towards the bottom of a bookshelf in someone's office. Eventually no one is sure where it is, or how long it's been since it was reviewed and updated. Sound familiar? ("It's on the bottom shelf of the bookcase behind my desk, under the stack of three year old catalogs I refuse to part with.")
"Hello, I'm the new sysadmin. Could I have your password?"
The term "Social Engineering" is a modern euphemism for "flim-flam." Social engineering is "wetware" engineering, the manipulation of people. It's the old confidence game in cyber-dress. Three card monte with folks sitting at keyboards.
Although the telephone is the classic tool of social engineering, it is not the only one. Suppose someone managed to get the following memo into everyone's mail box:
Hi,
My name is Bob Slickwhistle and I am the network administrator here at
dialupsRus.com. We recently had a security intrusion and are re-assigning
passwords to all users. We would highly recommend that you change
your password as soon as possible to the randomly chosen password below.
Your randomly chosen password is: zrY5yw2P
Thank you,
B. Slickwhistle
Inform your users that a Unix system administrator never needs to ask any user for his or her password. Tell them that you are glad they are nice people, anxious to help their fellow computer users, but that you are paid handsomely to be not nice to unknown callers, and that all requests for help should be redirected to yourself.
Email is convenient but it is trivial to forge 'From:' and 'Reply-To:' headers. Never trust critical matters to email communications unless they are PGP/GnuPG signed and verified, or you have some other way of verifying their authenticity. Sometimes Plain Old Telephone is best.
"Security through obscurity" is a failed paradigm. Trying to make things secure by keeping them secret doesn't work anymore, if it ever did. Now everything is out in the open. Well, not everything. Many security breaches go unreported and many more, UN publicized. Sometimes this is due to an organization's wish to avoid embarrassing notoriety. No doubt intrusions into national security facilities are for the most part kept quiet. To a large degree, though, the bugs, the holes, the exploits, and the tools of both black- and white- hats are posted all over the Internet.
The upside to this arrangement is clear; when a problem or bug surfaces the alerts are sounded and work on the fixes gets underway immediately. The downside may be less obvious: everyone reads the alerts, good guys and bad guys alike. If you are not reading the alerts then the black hats will always be several steps ahead of you. They are counting on you not to pay attention to security matters. Unfortunately, as a rule, you (present company excepted of course) do not disappoint them.
Does this mean you have to subscribe to Bugtraq (http://www.securityfocus.com/forums/bugtraq/intro.html)? Not necessarily, since Caldera's track record for following security issues related to Linux is one of the best among the major Linux distributors. Here is what you ought to do:
Subscribe to the Caldera announcement email list. You will receive notification of new security-related updates to eServer's software packages. For subscription information surf to http://www.calderasystems.com/support/forums/announce.html.
Become familiar with the archive of past security updates. Bookmark it's URL: http://www.calderasystems.com/support/security/.
Learn about the Caldera FTP server. Updated rpm packages for eServer are here: ftp://ftp.calderasystems.com/pub/updates/eServer/. Take the time to become familiar with the directory layout of the ftp site. Note the importance of the 'current/' directory.
Get your system in sync with 'current/'.If you see a package there that you are not using, consider removing it from your system.
Here are some odds 'n ends. That they are located in this section should not be taken as a measure of their importance.
Unfortunately, the default install of eServer is configured to start far too many programs. Use the COAS tool to trim the list of such programs:
K -> COAS -> System -> Daemons -> [enter root passwd] -> Ok
Go through the list carefully looking for programs that have check-marks next to their name. It is likely you can uncheck most of them. A reboot after that is done will put those changes into effect.Hit List: Some members of this list of daemons always seem to pop up in security discussions, and not in a good way. Be sure to turn off "BSD remote user info daemon", "BSD remote who daemon", "rwall daemon", and "Remote kernel statistics server". An alternative is to simply remove them from the system, using "rpm -e <package name>. The appropriate package names can be found like this:
# rpm -qa |grep netkit netkit-base-0.11-6S netkit-ftp-0.10-7 netkit-ntalk-0.11-1 netkit-rsh-0.10-8 netkit-rusers-0.11-2 netkit-rwall-0.10-6 netkit-rwho-0.12-1 netkit-telnet-0.12-5S netkit-tftp-0.10-2 # rpm -qa |grep rstat rstatd-3.03-1 rstatd-devel-3.03-1
eServer installs by default with far too many services "on". Here's a port scan of the default configuration:
Port State Protocol Service 21 open tcp ftp 23 open tcp telnet 25 open tcp smtp 53 open tcp domain 79 open tcp finger 80 open tcp http 109 open tcp pop-2 110 open tcp pop-3 111 open tcp sunrpc 113 open tcp auth 143 open tcp imap2 389 open tcp ldap 622 open tcp unknown 901 open tcp unknown 1000 open tcp cadlock 6000 open tcp X11 |
Open /etc/inetd.conf in your favorite text editor and place a "#" character at the beginning of any line that does not already have one there. After saving the file test your work with the command:
# grep -v '^#' /etc/inetd.conf |
Since the portmapper is started and stopped by the inetd init script, turn off its executable bits. You only need the portmapper if you are running NIS or NFS.
# chmod -x /usr/sbin/rpc.portmap |
Now start and stop the inetd daemon to put the changes just made into effect. (There's no "restart" in the inetd init script.)
# /etc/rc.d/init.d/inet stop # /etc/rc.d/init.d/inet start |
At this point you may find that you haven't broken anything, which will be confirmation that you didn't really need any of the services that were on. This will be the case for a machine that is acting as a client only, a typical desktop workstation on a small office LAN, for example. If the machine was hosting any services they will now be broken, but you need only reverse some of the edits of /etc/inetd.conf to reinstate them.
For a discussion of this method of restricting access (and much more), see Lance Spitzner's article "Armoring Linux" on his security web site at: http://www.enteract.com/~lspitz/pubs.html. Also recommended are all the articles in the "Know Your Enemy" series, also at that site.
If you leave a service "on" in /etc/inetd.conf, then learn about the TCP Wrappers system:
# man 5 hosts_access |
This feature will log a user out of a terminal session after so minutes of keyboard inactivity. It's not a bad idea to enable it for the superuser, i.e. root. An unattended root terminal is an invitation to trouble, and it broadcasts a certain atmosphere of carelessness. Since the default eServer shell (bash) does not support this feature, root's shell needs to be changed.
As root execute the command 'chsh'.
Carefully enter the new shell's pathname: /bin/tcsh A mistake here will leave you without access to the root user, and hence without the means to correct the mistake.
Open the file '/root/.tcshrc' in an editor and at the bottom of it append these two lines:
set autologout=5 echo "autologout set to 5 minutes" |
All subsequent root logins or su's to root will launch the tcsh shell and activate the auto-logout feature.
Two of the most popular Internet protocols are completely insecure: FTP and telnet. Both require plain text passwords be sent over the Internet. For an eavesdropper, sniffing these passwords is easy, and software for doing this abounds on the Internet.(See, for example, the inimitable Dug Song's dsniff at his web site: http://www.monkey.org/~dugsong/dsniff/)
SSH provides replacements for FTP, telnet, and rlogin that negotiate connections via encrypted exchanges. Plain text passwords are not transmitted. The SSH package contains three main programs, ssh, scp, and sshd along with a few utilities. The first two are "client" programs that are substituted for telnet and rlogin (ssh), and FTP (scp); sshd is the "server" program that accepts or denies connections from thoses clients.
OpenSSH is an ongoing project to develop freely distributable SSH software that is not encumbered by either licensing questions or United States export regulations. The current version is 2.1.1p4, and can be downloaded as source code from the project's web site: http://www.openssh.com/. It is easy to install OpenSSH on eServer, but OpenSSL must be installed first:
The current version of OpenSSL is openssl-0.9.5a.tar.gz. It can be downloaded from the project's website: http://www.openssl.org/source/.
Building it is simple; on slower machines it may take a few minutes. Place the tarball in a suitable work directory, /usr/local/src, for example, and then follow these steps:
# tar xzvf openssl-0.9.5a.tar.gz # cd openssl-0.9.5a/ # ./config # make # make test # make install # make clean |
Building OpenSSH is straightforward. The only decision to be made concerns passwords. If you think you are going to implement MD5 password encryption (recommended - see Sec. 4.3.3 below), then OpenSSH should be configured with that option. Apart from that consideration 'configure' can be run without options:
# tar xzvf openssh-2.1.1p4.tar.gz # cd openssh-2.1.1p4/ # ./configure --with-md5-passwords # make # make install # make clean |
# touch /etc/pam.d/sshd |
auth required /lib/security/pam_pwdb.so shadow auth required /lib/security/pam_nologin.so account required /lib/security/pam_pwdb.so password required /lib/security/pam_cracklib.so password required /lib/security/pam_pwdb.so shadow nullok use_authtok md5 session required /lib/security/pam_pwdb.so |
/usr/local/sbin/sshd echo "Starting sshd" |
Some users may not think to use ssh or scp. The latter has a syntax that may not be intuitive for everyone, and it does not offer all the functionality of FTP, in that directories cannot be browsed with it. scp does one thing very efficiently: move files securely from one host to another, and that is all it does. ssh will be more familiar as its syntax resembles rlogin's. That is one good reason for simply disabling rlogin; if it's not available users will turn to ssh. Either turn off the executable bits (chmod -x) or simply rename it (e.g. mv /usr/bin/rlogin /usr/bin/rlogin-kaput)
The manual pages for OpenSSH are above average in quality. This is a powerful suite of applications and a bit of study will likely be necessary to get full mileage out of it. In particular the management of keys ought to be fairly well understood. However, the default configuration will allow for basic operations utilizing ssh and scp
This is an enormous topic, which by its very nature invites encyclopedic treatment. Such a treatment can be found in Simson and Garfinkel, but here are some rambling reflections.
Locks tend to be placed more with convenience in mind than security. Example: your hosts are behind a door that is always locked, but your unencrypted backup tapes are in the unlocked file cabinet in your office, which on a good day resembles Grand Central Station.
You've invested a goodly sum in a UPS, but do you know how long it will keep your system(s) running, and is it set up to shut them down in an orderly fashion? Where is it? Who has access to it?
How many complete sets of backups should you have? Keep in mind that all storage media are fallible, and over time are bound to fail. Where are backups kept? Are they under lock and key at their off-site locations?
Is your data of sufficient value to merit encrypted filesystems, and/or encrypted backups? Have you thought about what it would take to recover in the event that data fell into someone else's hands? What damage could be done with your data in the wrong hands?
If you use encryption in your filesystem or backups, who has the key(s)? Where are their copies kept? Under what conditions? How many copies should be in others' hands?
This topic is closely allied with the preceding, "Physical Security." Clearly one of the threats that enhanced physical security defends against is the unauthorized shutdown or reboot of a computer. Whereas one aim of physical security measures is to control who has actual access to the machine, the current topic addresses measures that control what can and cannot be accomplished by persons who do have such access.
When first installed, eServer is configured to utilize the services of the kdm program to manage logins, reboots and shutdowns. This program is responsible for the initial graphical login screen that appears when the computer has booted and is ready for a login. For secure operations the default install of kdm is unacceptable on two counts.
The monitor displays a list of the usernames for all normal accounts on the system.
Any person, whether a user or not, never mind whether the superuser or not, can shut the machine down or reboot it by clicking on the "Shutdown" button displayed on kdm's screen dialog.
The Username Problem. It is of the nature of almost all Unix systems that a "world readable" file (meaning anyone logged in can view it) containing all usernames exists, usually as /etc/passwd. Although the shadow password system (installed by default in eServer) entails that there are no passwords in this file, nevertheless a fair amount of information about each user account must be here, such as the username, the account's ID and group ID, home directory and command shell. The point here is that it is one thing for any user already logged into the system to have access to all the other usernames, but it is quite another for all these names to be viewed by any person or persons unknown who might chance to stroll by a terminal or do a little "shoulder surfing," as the practice of eavesdropping on a monitor and/or keyboard is termed.
This may seem an ephemeral concern. The consideration is always, however, "How can I make it even a little harder for an attacker, and how I can do that easily?" Hiding kdm's display of usernames is easy, as we shall see. Furthermore, requiring even a casual attacker (if there is such a creature) to guess both a username and a password will slow down such an attack. The indiscriminate and unnecessary display of any system information literally invites attack; it advertises carelessness.
Are there people who will sit at a login prompt and try to guess a username and password? A little history will suffice to answer. Unix systems did not at first have a password protected login system. In the collegial atmosphere of the research and academic facilities in which Unix was developed, a culture of trust and respect permeated the workplace. Obviously it was soon realized that the blessings of such an ethic were not widespread, and the first encrypted password systems were developed. At one interesting turn in this development it was observed that an interloper could determine whether or not a username just entered was a valid username on the system by observing the amount of time required to come back to the login prompt after a login attempt failed. In the earliest configuration of passwords, if the username entered was not valid, the login program would not bother to check the password also entered. Since this checking entailed encrypting the password and comparing it to the system's password file, there was an easily noticeable time differential between the behavior of the login process with a valid username, and without. The obvious conclusion was reached, and the login program was rewritten so that all passwords would be encrypted regardless of whether the username was valid or invalid. The answer to the question above, then, has always been, "Heck yes!" Before proceeding to the fix, we need to address the second concern regarding kdm.
The Shutdown Problem. Apart from programs such as kdm and its forbear xdm, a Linux computer after booting up presents the user a login prompt in a terminal "console," a character-based screen instead of the graphical X-windows based screen that decorates the eServer login dialog. At this console login prompt there is only one option: to log in, or fail to do so. Once logged in a normal user cannot shutdown or reboot the computer by any combination of keystrokes (except, perhaps, the famous "three fingered salute": Ctrl-Alt-Del, about which more later). The commands for shutting down, which include reboot as an option, can only be executed by root, the superuser.
Recall further that, on the KDE desktop, the logout "X" button can similarly be clicked by any person, thus bringing up the kdm dialog. Granted, the screensavers provided by KDE can be configured to require the user's password to regain access to the KDE desktop, but screensavers must tolerate a delay before they are activated, and most users are sufficiently inconvenienced by short delays to avoid them. In fact most users will avoid setting a password on their screensaver because it too is inconvenient. Consequently, it is more than likely that any casual bystander will in short order be able to shutdown or reboot an eServer system.
The Fix. Both of these issues are resolved simply, by editing one file. As root open /opt/kde/share/config/kdmrc in your favorite editor and look for these two lines:
ShutdownButton=ConsoleOnly UserView=true |
Edit them to read:
ShutdownButton=RootOnly UserView=false |
At this point if you log out of the current KDE session you will return to a different kdm dialog. The row of icons representing users will be gone. And, if you click on "Shutdown," you will be asked for the root password.
Note: The behavior of this Shutdown dialog is somewhat non-compliant with other KDE dialogs. Regardless of which radio button you select (Shutdown, Console, etc.), after typing in the root password the "Ok" button will remain grayed-out, that is, inactive, until you press <Return>, at which point the edit box will go blank, and, if the password is correct, the "Ok" button will be activated and able to receive a mouse click.
An alternative to the steps just described is to remove kdm, or, more accurately, circumvent it. This results in eServer behaving in a traditional, "normal", fashion; after booting up the user will be presented with a character-based terminal login prompt. After logging in the KDE desktop can be started with the command "kde".
| Caution |
All the discussions in this Guide assume that the eServer administrator NEVER logs in as "root"! This should always be the case, whether logins are managed by kdm, or handled traditionally from the console. The administrator always logs in with his or her normal user account and only when necessary uses superuser privileges. |
kdm can be removed with a few simple steps:
As root edit the file /etc/inittab. Change the default runlevel from '5' to '3':
# The default runlevel. id:3:initdefault: |
Edit the file /etc/lilo.conf. Comment out this line by prepending the '#' character:
#message = /boot/message |
If your version of lilo.conf contains a line that begins 'vga = ' make it read:
vga = normal |
Update the lilo bootloader by running the command:'/sbin/lilo'.
Note: This command, if executed unwisely, can render a computer inoperable, that is, incapable of being rebooted. Always run it first with these arguments:
This puts lilo into verbose mode and test mode. You will be shown what lilo will do, but no changes will actually be made. It is almost always fatal to ignore any warnings lilo produces here.
# /sbin/lilo -v -t
This step should be taken regardless of whether kdm is used or not used. Although this keystroke combination is not effective while in the KDE desktop, the defaults for eServer's initial install are such that any user in a console session can initiate a shutdown and reboot by pressing the famous three keys at the same time.
There are two possible responses to this situation, depending on the behavior one would like to see. It is possible to completely disable this keystroke combination, and it possible to disable it partially, so that the combination is only effective when root is logged in. In this latter case, as long as root is logged in any user at any console can activate Ctrl-Alt-Del. Superuser logins do not satisfy this condition, only direct logins by root. Since the strong advice here is to never do this, this "partial" method will in almost all cases be tantamount to a "complete" method for disabling the combination.
Both approaches require only a simple edit of /etc/inittab. Look for these lines:
# Trap CTRL-ALT-DEL ca:12345:ctrlaltdel:/sbin/shutdown -t3 -r now |
The "complete" solution is achieved by commenting the line out:
# Trap CTRL-ALT-DEL #ca:12345:ctrlaltdel:/sbin/shutdown -t3 -r now |
# Trap CTRL-ALT-DEL ca:12345:ctrlaltdel:/bin/echo "Ctrl-Alt-Del has been disabled." |
The "partial" solution is achieved by first adding the '-a' argument to the shutdown command (see 'man shutdown'):
ca:12345:ctrlaltdel:/sbin/shutdown -a -t3 -r now |
# echo root > /etc/shutdown.allow |
The command
# telinit q |
This section might easily have come under the rubric "Physical Security," but it concerns specifically how the machine might be rebooted. Obviously, where there is physical access to a host, it will always be subject to unauthorized reboots, if only by the simple expedient of toggling the power switch a couple of times. There is however one contingency that ought to be at least considered as a candidate for preemptive measures.
A Linux boot floppy is a simple enough thing to put together. Diskette images are floating around all over the Internet; the diskettes are shipped with every distribution, and there are software packages available for creating custom diskettes. Some of the latter comprise complete working Linux systems; all they require is a computer that will boot from the floppy drive. And, there are CD versions of the same that can be used with hardware that is bootable from that drive.
It wouldn't be the first time: Just as dangerous as a Linux boot floppy is a DOS bootable floppy. Consider: your brother-in-law brings in his kids for a tour of the shop. One of them has heard about your hot hardware and has brought his favorite game, downloaded from a popular ISP, on a floppy to give it a try. He pops it into a floppy drive and reboots the machine. The boot sector virus on the floppy has its way with your hard drive. It wouldn't be the first time...
Booting via either of these methods provides access to the entire file-system. Any file can be altered, copied, or sent to another host anywhere in the world, depending on the connectivity afforded by the host in question. The usual rebuttal here is "Look, with physical access to the machine all bets are off. Why bother with the boot drives when everything you describe can be accomplished anyway without rebooting?" But this last statement is misleading. An intruder seated at the terminal will have to get past the security built into the system in the form of passwords and file ownerships and permissions. All of these latter are instantly circumvented with a simple floppy reboot, but even a skillful attacker with physical access will require some time to work through the security inherent in the system.
Recall that what is "secure" is a judgment call made by someone in a particular context, a certain time and place. In short, we are always "playing the odds" here, and one might even say that it is ultimately a game of one psychology versus another. Every attacker will, at a certain unknown and unknowable level of frustration, move on. Theoretically, an imaginary "hyper-predator" attacker, capable of tolerating infinite frustration, will always succeed, sooner or later. The aim of all security measures is to make the attacker work harder and harder for a victory. We have to be content with layering one finite measure after another onto the system, and there is no way to predict which measure will in the end succeed in deterring a given attacker on a given day. That is the backdrop to all security policies, and this discussion of boot drives exemplifies it perfectly. The possible steps suggested below are typical of the small incremental actions which, taken together, produce the elusive quality known as "secure."
Nothing says, "Go away; you have no business here." quite like a computer case with no visible drive doors. The "boundary condition" of this phenomena, its ultimate development, can be seen perhaps in the design of remotely administered rack mounted server units. Here are some possibilities:
Remove all floppy, CD, tape and zip drives, replacing them with blank covers. If the host is that important, and at some point needs to be rebooted from the floppy drive, you should have where feasible a drop-in replacement for it handy. In any event reinstalling a floppy drive takes about three minutes.
Open the case and unplug the data and power cables from all of those devices. Always carry a screwdriver. (And, some would add, a good set of wire-cutters capable of dealing with any of your network cables.)
Go into the system BIOS and disable all of those devices.
Do the above but also set a password in the BIOS.
The question isn't "How secure can my system be made?". The question really should be, "How much do I care, how much can I trust?".
The above sentiment, from Alec Muffett, applies very closely to the management of passwords on Unix and Unix-like systems, including Linux. The history of passwords on these systems ranges from no passwords at all initially, to the "shadowed" encrypted passwords used today, with several intermediate stages along the way. This development reflects the growing understanding of Muffett's statement by Unix developers. At the present time all Unix passwords are encrypted and most are "shadowed," or hidden from the view of ordinary users. Still there are important decisions that must be made with regard to their use by administrators concerned with understanding the strengths and weaknesses of their systems.
Note: Alec Muffett's statements in this Guide are from the file /doc/appendix,v4.1.txt in the source code archive crack5.0.tar.gz, kept at ftp.ox.ac.uk/pub/comp/security/software/crackers/.
Passwords function as part of an authentication system. They serve to demonstrate to the computer that the user who logs in is in fact the person that user purports to be. As we noted earlier, the pioneering work on Unix evolved inside workplace subcultures that put a premium on trust and respect for others. Alec Muffett writes:
It is possible to configure user accounts on eServer that do not require passwords, but that is not an avenue that can be recommended. Almost always it will be an unwise choice, say, to set up a "Guest" account. It isn't your guests you need to worry about, but others, who know that accounts without passwords still exist in great numbers, and know that these accounts are easy to find. Keep in mind one of our over-arching concerns: even if your system contains nothing of worth to anyone but yourself, potentially it is a launching platfrom for attacks on other systems whose contents are indeed quite valuable to many.A system can be perfectly secure without any passwords at all, so long as it is in an environment of people who recognize its purpose and depend on it. I say this after having had accounts on several 'public' machines, which could have been taken to bits by any competent Unix person, but were largely safe - because when someone worked out who did anything nasty, the culprit was ostracized from the community.
Although it is no doubt an oversimplification, historically there have been four major stages in the implementation of passwords on Unix systems:
No passwords at all.
This arrangement is now merely an historical curiosity, a vestige of the hallowed times of early Unix development in research and university environments. The day is long gone since this was a reasonable option.
Plain text passwords in world-readable files.
In their landmark essay "Password Security: A Case History," Robert Morris and Ken Thompson described one possible outcome of this technique:
So much for plain text. It is worth taking note of the other feature mentioned, that password files have up until a few years ago always been world-readable on Unix systems. A look at your /etc/passwd file will make clear the reason for this. A typical entry for a normal user, utilizing plain text passwords, might have looked like:...in the early 60's...a system administrator on the CTSS system at MIT was editing the password file and another system administrator was editing the daily message that is printed on everyone's terminal on login. Due to a software design error,the temporary editor files of the two users were interchanged and thus, for a time, the password file was printed on every terminal when it was logged in.
wingnut:fishwrap:1004:1004:Eric 'Alibut,,,:/home/wingnut:/bin/bash |
Encrypted password representations in world-readable files.
This is the contribution described by our two authors, above. When the password for an account is first set, it is used to generate a thirteen character long string that to any human being appears mere gibberish. For example, the same record noted above would now appear something like this:
wingnut:pW5R9RwayjNtw:1004:1004:Eric 'Alibut,,,:/home/wingnut:/bin/bash |
Encrypted password representations in files with restricted read access ("shadowed").
As the speed of computers went up and their price came down, it became clear that world-readable password files were too risky. With this greatly improved "bang per buck" computing factor came much greater likelihoods that any encrypted password file could be "cracked." A way was found to separate out what needed to be in a world-readable file from what could be put be placed a file with restricted read access. This was termed "shadowing" the passwords. Our user wingnut's record in /etc/passwd now looks like this:
wingnut:x:1004:1004:Eric 'Alibut,,,:/home/wingnut:/bin/bash |
We need to define a few basic concepts in cryptography to understand how passwords work. (This will be a highly oversimplified discussion!) The classic scenario for these discussions is transmitting a "coded" message from one party to another, so that if the message is intercepted its contents will be meaningless to all except the party it was intended for. This ancient art has in modern times evolved into systems of mind-boggling complexity. The current system of encrypting Unix passwords has been around about thirty years now, but in the past several years it has undergone yet further steps up in complexity. For now it will be helpful to understand just the basic outlines of how encryption protects on Unix and Unix-like systems.
Password encryption in Unix is an example of single key encryption. The simplest imaginable encryption scheme would not use keys at all, and could be described schematically like this:
+-----------+
| |
Plain text --->| Algorithm |---> Cipher text
| |
+-----------+ |
+-----------+
| |
Cipher text --->| Algorithm |---> Plain text
| |
+-----------+ |
The answer is to design the algorithm so that the cipher text depends not only on the plain text and the algorithm, but on a third entity, known as the key. This allows any number of cipher text results to be produced for any one given plain text input:
+-----------+
Key ---->| |
| Algorithm |---> Cipher text
Plain text --->| |
+-----------+ |
+-----------+
Key ---->| |
| Algorithm |---> Plain text
Cipher text --->| |
+-----------+ |
Note: A modern single key encryption algorithm is the RC4 algorithm. This two way algorithm can be coded with amazing simplicity; even BASIC is suitable for an implementation. See http://www.ciphersaber.gurus.com/. Also useful are the contents of ftp://rtfm.mit.edu/pub/usenet-by-group/news.answers/cryptography-faq/, especially the wonderful Snake_Oil_FAQ.
As noted above, the encryption for Unix passwords follows the model shown here:
+-----------+
Key (Password)---->| |
| Algorithm |---> Cipher text ("encrypted password")
Plain text --->| |
(Numeric constant) +-----------+ |
The algorithm traditionally used for this process is the "DES" algorithm, the "Data Encryption Standard" developed in the 1970's by NIST (National Institute of Standards and Technology) and IBM. This algorithm takes the first eight characters of the user's password for use as the key. The operations described by the algorithm are then applied twenty five times, in a reiterative fashion, using the output of a given "round" as the input of the next. The results are then cast into a final eleven character long string. Note however that wingnut's encrypted password, above, is thirteen characters long. Two characters have been prepended to the eleven; these are termed the "salt." They are randomly selected at the start of the encryption process and enter into it along with the key and plain text constant, so that for a given key (password) a different cipher text is produced for each different salt. To be exact the two character combination yields 4096 distinct possible outcomes for encrypting a single given password. At the conclusion of the twenty five rounds of the DES algorithm the salt is prepended to the result and thus can be retrieved from the password file whenever a login demands that a password be checked for authenticity. Should anyone consider building a complete "dictionary" of all possible eight character passwords in encrypted form, the simple expedient of adding a salt to the process has rendered that job far more difficult. Imagine having to check over four thousand different versions of Webster's Unabridged before finding the word you wanted? Subsequent improvements of the algorithm, which now allow for keys of up to 127 characters length, have pushed the difficulty of such a brute force attack into the realm of the "computationally infeasible."
The weak link in this impressive technical scheme is of course the human one, which will lead us into the next discussion, that of choosing passwords. Luckily for attackers, unluckily for defenders, it isn't necessary in most cases to search the entire universe of possible eight character passwords, since most humans left to their own devices will select passwords that are incredibly easy to guess. Furthermore, the art of guessing passwords has itself been computerized, and goes by the name of "password cracking." Everyone is urged at some point to install a password cracker (described below) and run it on your password files. Few will not be astounded at how easily these programs can work out what were thought to be clever choices for passwords.
The method employed is simplicity itself: by hook or crook one gets possession of either the /etc/passwd or /etc/shadow file, whichever contains the encrypted passwords, and begins an orderly, carefully orchestrated process of trial and error, encrypting test passwords and comparing the results to the contents of the file. Since the plain text constant, the contents of the algorithm, and the salt for each password are known to the viewer of the password file, the exact process that created each encrypted password in the file can be reproduced. When a match is made that password is "cracked." The easiest guesses are tried before the more arcane; accounts with no passwords, or accounts in which the password is the same as the username (these are known as "Joes") are immediately picked up. Alec Muffett, author of "Crack," perhaps the most well known password cracker, reflects on this process:
The whole business of choosing a good password is for the most part just a matter of understanding how bad passwords are found, and found rather easily.Crack is not a program designed to break the password of every user in the file. Rather, it is designed to find weak passwords in the file, by attacking those sorts of bad passwords which are most likely to be used, in the order in which they would most easily be found (ie: are most likely to be used by a moronic user).
Crack is not designed to break user passwords; it is designed to break password files. This is a subtle but important distinction.
If you want to break into a safe, you do not take a hammer at every bit of it in turn; instead, first you try some simple combinations, then you try blowing the hinges off, then you get out an acetylene torch and go for the bolt. If that doesn't work, THEN you start on the walls. You go for the bits which are most likely to be weak first.
The facts are simple. Virtually every word in every written language has been put into machine-readable lists that can potentially find their way into the databases used by password cracking programs. (Most of them already have.) And, virtually no human being is in possession of even a tiny fraction of what's on those lists. Given today's storage technology and processing speeds it is a simple matter to make available to these programs the contents of every dictionary, name list, encyclopedia, gazetteer, geographical atlas and scientific lexicon that one could wish to have. Then leave it to clever programmers who live, eat, and sleep password cracking to code into these programs every imaginable reordering scheme one might ever apply to all of these words. Look at them forwards, backwards, inside-out, upside-down, with a number after them and a number before them. Substitute the obvious and not so obvious numerals for letters (o = 0, l = 1, e = 3, etc.) Then ring changes on capitalization and all of its imaginable variations. You get the idea.
The upshot of all of this is that brute force attacks on passwords never need to be even attempted. A "key search" can restrict itself to a comparatively very narrow subset of all possible passwords, and that subset can be defined and manipulated with all the speed modern computers possess. The one thing no programmer can deliberately set out to snare via any set of rules or patterns is the perfectly randomly chosen password. The secret to secure passwords is the degree of randomness, or "entropy" as it's termed, that is built into the process of selecting that password. But there's no free lunch; random passwords are difficult to remember, and without a bit of education on their care and feeding most users will write a random password down and leave it somewhere, such as the middle top drawer of their desk, if not on a postit note stuck to their monitor.
There are basically only two policy options for managing passwords on a multiuser system:
assign passwords or require users to select from a set of passwords generated by the system
allow users to create their own passwords
Note: eServer's password program includes a password checker based on "Crack," that serves up warnings to a user who attempts to make a poor choice of password. The program will not prevent a poor choice if the user is bent on making one.
If users will be allowed to choose their own passwords, here are The Rules. Following these will take them a fair way towards coming up with a good password, where "good" is defined as "difficult for a password cracker to guess." First the "Don'ts". Some of these are based on social engineering approaches. (In the same sense in which it's been said that the stock market is an exercise in Fear and Greed, so is choosing a password for the ordinary person typically an exercise in Sex, Love and Money. They will always return to these subjects if left to their own dubious devices.)
Do not use any of the following as a password:
Your name or nickname, or any family member's name or nickname.
The name or nickname of a close friend, or anyone you work with or for.
The name of any fantasy, fictional, historical, mythological or biblical character.
The name of your pet or any family member's pet.
Anybody's name: first, middle or last. Any proper name.
The name of your operating system.
Any name!
Your "real name" according to the computer, or any other such information kept in the password file.
Any of the words found in the .plan or .project files that are accessible by the finger command.
Your computer's hostname or domain.
Any phone number or license plate.
Any part of your Social Security number.
Anybody's birthday.
Any part of your address, the name of your alma mater, or any other easily accessible information about you.
Any username on the computer in any form (reversed, capitalized, doubled, etc.)
Any word found in any dictionary of any language.
Any place name.
A password of all the same letters.
Patterns of letters on the keyboard, such as qwerty.
Any of the above spelled backwards.
Any of the above followed or prepended by a single digit.
Any of the above modified by simplistic substitutions, such as certain numerals for letters, e.g. 1 for l, 0 for O, or 3 for E.
Here are some "Do's". These will be augmented in the next section on Password Generators.
Do try to:
use both upper and lowercase letters.
use numbers, spaces and punctuation marks.
use other special characters, avoiding @ and #.
create a password easy for you to memorize.
find out if your computer can use long passwords (more than eight characters) and if so use them.
never use less than seven characters.
invent acronyms based on sayings familiar to you. For example, "Yea though I walk through the valley of" becomes "ytiwttvo." This in turn might be better rendered "yTiwtTvO", or "yTiw->Tv".
Note: These lists are based on Simson Garfinkel and Gene Spafford's "Practical Unix and Internet Security", an O'Reilly publication.
There is an inherent contradiction between the idea of a "password generator," and a "good password," if the latter is understood according to the definition given above ("difficult for a password cracker to guess"). Again, Alec Muffett explains:
If the idea of a password generator is such a bad one, then why discuss them? Try an experiment: sit with a blank piece of paper and try to write down "at random" a dozen eight-character passwords. This is not something you want to do a lot of, and in any case it turns out that people are a relatively poor source of randomness. If you are going to assign passwords to users, or provide them with restricted lists to choose from, or even lists of "suggested" passwords, then a method for generating them will have to be considered. The next three sections provide merely examples of how this task has been approached in the past. This Guide does not recommend any one of these over the others; they are described for educational purposes.You can't say that a certain method will provide secure, random passwords, because, in defining an algorithm to create these passwords, you will use only a subset of all the possible passwords that could ever exist. You have shrunk the 'search space' for the passwords.
There is an incredibly large set of possible passwords in the world, and the best approach toward choosing a password is not to try to find a way to generate 'secure' passwords - there are no such things - but rather you should learn to choose passwords which are not easily searched for. Passwords which are out of the 'search space' of most password crackers like 'Crack'.
This is a fairly old example of a password generator. A copy of the script is in the Appendices to this Guide (and hence can be copied from the pdf version of the Guide, available online at Caldera's web site), or it can be fetched from the URL noted. Once pasted into a text file it can be saved as 'mkpasswd', and placed in a convenient directory. Then, after making the file executable (chmod +x mkpasswd), it can be run from the command line. Note that if you grab the copy on the ftp site you will have to change the first line to read '#!/usr/bin/expect --'. Defaults in the file can be edited to adjust length, minimum number of numerals, and minimum numbers of upper and lower case letters that will be found in the resultant password. The output will look something like this:
$ ./mkpasswd 5mrcy1JQ $ ./mkpasswd rjgBIz29 $ ./mkpasswd Ihw89Njx $ ./mkpasswd 76cfmuHY $ ./mkpasswd u5cKHd4r $ ./mkpasswd mpGasV24 |
Nevertheless, if the decision is made to not allow users to set their own passwords, then another feature of mkpasswd might come in handy. If run by the superuser mkpasswd will generate a password and then call the system's passwd program to actually set that password for the user in question:
# ./mkpasswd -v fred spawn passwd fred New UNIX password: YvnSfd61 password for fred is YvnSfd61 |
Note: There are several ways to prevent normal users from setting their own password. Garfinkel and Spafford's work, cited above, describes some of them.
This program also has a rather ancient lineage. It is an example of a "pronounceable password" generator. gpw is intended to turn out prototypes, as it were, of passwords; the output of the program does not consist of strings one would use verbatim for real passwords. Instead, the user or administrator, whoever is running gpw, picks a word from the program's output and then alters it by the addition and/or substitution of numerals, punctuation marks and special characters.
gpw "learns" about pronunciation from the dictionary already present in virtually all Unix systems, or it can be given a customized set of dictionaries to learn from. The danger here is obvious: gpw learns from the same source or sources used by password cracking programs to make their educated guesses. In fact, gpw at times will turn out a dictionary word, or a word that contains a dictionary word.
gpw is simple to use; with no arguments it prints a list of ten passwords of eight character length, using only lower case letters:
# gpw notician elyinebr ailloove listinep termagel ieterman yinatiwe ingthman ansepall oacterea |
robert:/# gpw 5 10 tionessexp sketencerb emakylsiel fisidscopp vereamerte |
gpw is easily installed on eServer. See the appendix for the needed steps.
The Diceware web site, http://world.std.com/~reinhold/diceware.html describes an extremely sound method for creating passphrases, such as might be used with PGP email encryption. Although the method can be adapted to creating standard Unix eight character passwords (see the appendix), it is geared to turn out passphrases composed of at least five words. The method involves rolling a set of five dies, and then, based on the dice results, making selections from a word list provided at the site.
Since in the next section we will reconfigure eServer's password system to allow passwords of up to 127 characters length, it is worthwhile to become aware of the Diceware system. A password of (potentially) that length is in effect (by inserting spaces) a passphrase.
Note: There are very many password generator programs floating around the Internet. Several of them go by the same name, 'pwgen', but they seem to be of varying quality. Recently a bug report was filed against one of these for producing passwords with too many "oo"s in them. The output looked like this (real data from this program):
This is, obviously, a perfect example of what you don't want. Be careful out there.
$ pwgen 10 10 tafeivoof onogiphosh gerichiph shoopaexoo hiveekugoo ngohokioo shoharash ejanepiya usheinouu pookagijoo
It is possible to leave behind the eight character limitation on the length of passwords used by eServer. Using the 'MD5' cryptographic hash function, passwords of up to 127 characters can be encrypted. With the DES-based password system installed by default in eServer, passwords longer than eight characters will appear to be accepted without complaint; nevertheless only the first eight characters are significant. This can be easily tested, but if you want to do the test do it before carrying out the steps outlined in this section.
The advantage of longer passwords should be clear: they make the job of the cracker enormously more difficult. It's not that password cracking cannot operate on MD5 encrypted password files, but that the universe of likely choices for passwords is larger by several degrees of magnitude. Hence the job of building the word lists that inform the cracking process is that much more difficult. Here are the steps necessary to convert eServer to using MD5 hashed passwords:
In /etc/pam.d make copies of these two files, for safe-keeping:
# cd /etc/pam.d # cp login login.orig # cp passwd passwd.orig |
Edit login and passwd so that the last line of each reads:
password required pam_pwdb.so shadow nullok use_authtok md5 |
The administrator, as superuser, should now run the passwd command for every normal user account, setting an initial password. These need to be communicated to the users with the understanding that they are each to immediately run passwd themselves and change that initial password.
A quick inspection of /etc/shadow will reveal whether all normal user accounts have been converted. Whereas the older encrypted password field was only thirteen characters long, the MD5 hash field is thirty four characters long. If the old one looked like this:
william:1BgLEElfqcmuk:11147:0:30:7:-1:-1:134532316 |
william:$1$cyvp7QvE$Dc8xgr/q8Ml0HcA8Efhg7/:11147:0:30:7:-1:-1:134532316 |
| Caution |
This enhancement is strongly recommended. Once in place however do NOT use the COAS graphical administration tool to manage passwords. There is a risk of losing all your passwords in /etc/shadow. Use the standard passwd command from the command line, or the Webmin administration tool. If you make the change to MD5 passwords the safest bet is to remove the Accounts item from COAS's menu. You can either delete the file /opt/kde/share/applnk/Coas/system/accounts.kdelnk and then restart the KDE session, or use the KDE menu editor to accomplish the same thing. The latter will have to be started by the superuser, and it is likely that the user who launched the KDE session (i.e. the superuser's normal username) will have to execute an 'xhost +' from the command line in order for the superuser to be able to launch kmenuedit. |
Here are two password cracking programs that can be installed on eServer.
This program has a home page at http://www.openwall.com/john/. The current stable archive, john-1.6.tar.gz, can be downloaded from that site. John builds effortlessly on eServer:
Put the archive in an appropriate directory and unzip it:
# cp john-1.6.tar.gz /usr/local/src # tar xzvf john-1.6.tar.gz |
Change to John's src/ directory and run make. A list of build platforms will scroll by. For eServer you will choose one of these three, depending on your hardware:
linux-x86-any-elf linux-x86-mmx-elf linux-x86-k6-elf |
Run make with the appropriate target:
# make linux-x86-any-elf |
When the build is complete the resultant files can be moved to a more appropriate location:
# cd ../run # mkdir /usr/local/john # cp -d * /usr/local/john |
Since we are using shadow passwords, the contents of both password files, /etc/passwd and /etc/shadow have to be merged. John's 'unshadow; utility does this; the resultant file should have limited read access. Then John can be started, and he will display a startup message::
# cd /usr/local/john # ./unshadow /etc/password /etc/shadow > passwd.1 # chmod 400 passwd.1 # ./john passwd.1 Loaded 4 passwords with 4 different salts (FreeBSD MD5 [32/32]) |
# ./john -show passwd.1 |
Several factors will impact John's performance, especially the size of the word list used. John starts with its own list of commonly used passwords (password.lst); some excellent lists are available at http://wordlists.security-on.net. Also, John needs as much CPU time as he can get, so running CPU-intensive applications, such as compilers or multimedia programs, will cut into performance. John comes with fairly good documentation.
Crack can be considered one of the "classic" password crackers.Although its installation is a tad more involved than John's, Crack installs with its own rather extensive wordlists, so the need to augment them is not anywhere as marked as with John's. Crack is now at version 5.0, which can be found at: ftp.ox.ac.uk/pub/comp/security/software/crackers. Here are the steps for installing Crack on eServer.
Note: These steps have been tailored for an eServer installation that has been converted to using MD5 password encryption. Crack includes a manual that describes installation for both DES and MD5 encryption schemes.
After unzipping crack5.0.tar.gz in an appropriate location, such as /usr/local, a source directory named c50a/ will be created. First rename some files in the c50a/src/ subdirectory:
# mv src/libdes src/libdes.orig # cd src/util # cp elcid.c,bsd elcid.c |
Now, back in the c50a/ source directory, edit the main script, Crack. Change the CRACK_PATH line to look like this:
CRACK_PATH=/usr/local/bin:/usr/sbin:/sbin:/usr/bin:/bin:$PATH |
# # now pick your compiler # # vanilla unix cc #CC=cc #CFLAGS="-g -O $C5FLAGS" #LIBS=-lcrypt # uncomment only if necessary to use stdlib crypt(), eg: NetBSD MD5 # gcc 2.7.2 CC=gcc CFLAGS="-g -O2 -Wall $C5FLAGS" LIBS=-lcrypt # uncomment only if necessary to use stdlib crypt(), eg: NetBSD MD5 |
Run the build:
# ./Crack -makeonly # ./Crack -makedict |
Just as with John, Crack requires the two versions of the password file to be merged. Then Crack can be started; it might as well run in the background:
# ./scripts/shadmrg.sv > newpasswd # ./Crack -nice 10 newpasswd |
Here are three additional commands that are helpful while running Crack. From time to time you may wish to check in with Crack to see how it's doing; the 'Reporter' command will list Crack's progress. To halt a Crack session there's the 'plaster' command. And, before starting a new session, clean up the last one with 'make tidy'.
# ./Reporter (view Crack's progress) # ./scripts/plaster (stop a running Crack session) # ./make tidy (clean up; prepare for a new session) |
This topic is really a subset of another: Intrusion Detection. Intrusion detection is conventionally subdivided into host-based ID, and network-based ID. This section of the Guide will focus on a primary concern of host-based ID, the integrity of the filesystem. These discussions are meant only to present examples, and rather simple ones at that, of the use of certain utilities, such as Tripwire and COPS. These are complicated packages capable of being configured in many different ways. The aim here is to demonstrate that useful security auditing tools are near to hand, install fairly easily on eServer, and repay many times over time spent learning their intricacies.
Tripwire has been around for quite some time. Its job is to provide the administrator with information about changes to critical files on the system. Intruders have become quite skilled at covering their tracks, and rootkits as a rule go through log and history files removing mention of the intruder's activities. Typically these attacks feature the substitution of compromised files for standard system files; the most notorious of these being /bin/login. Tripwire can pick up these sorts of changes, and it is well within the realm of possibility that an intrusion could go unnoticed apart from the special scrutiny afforded by Tripwire. The program works by taking a 'snapshot' of the state of the system, its critical files, at a point in time when the system is believed to be secure. It does this by creating a database containing cryptographic signatures of these files. Then, on a regular basis, typically daily, the files' signatures are compared to the contents of the database. Any changes will be noted and reported by Tripwire.
Note: Tripwire is commercial software. There are two versions however that are freely distributed, an older version, the so-called "Academic" version, and a newer version 2.2.1. The discussion in this Guide will describe the latter, which can be downloaded from Tripwire's home page at http://www.tripwire.com/products/ after an EULA is clicked through. The license permits use on one computer for internal business purposes; be sure to check the details. While at Tripwire's website, before leaving the "Downloads" page, scroll down and review the documentation that's available. The Users Manual is highly recommended despite its size.
Tripwire installs easily on eServer. Here are the steps required:
Create a temporary work directory and unzip the tarball in it:
# mkdir /usr/local/src/tw # mv Tripwire_221_for_Linux_x86.tar.gz /usr/local/src/tw # cd /usr/local/src/tw # tar xzvf Tripwire_221_for_Linux_x86.tar.gz |
Make a few changes in Tripwire's configuration file, install.cfg. At the top of the file set the TWROOT variable as shown, and a little further down be sure to set the editor to one you are comfortable with:
TWROOT="/usr/local/TSS" TWEDITOR="/usr/local/bin/jed" |
All that remains, installation-wise, is to run the install script: ./install.sh. Ignore the question that comes up at the beginning about the "supported configurations." You will be asked to enter two different passphrases on several occasions. Pick good ones, using at least four or five words. If you must write them down do not write anything down with them that identifies them as passphrases, and don't leave them anywhere in the workplace. Your wallet is not the worst place for them.
Tripwire reports its findings by email. Test this aspect of the installation with the following command, using your normal username:
#/usr/local/TSS/bin/tripwire -m t -e joe_user@this_host |
An initial 'snapshot' should be taken next. The defaults in the policy file supplied with Tripwire are fine for this purpose. It's not a bad idea to leave the KDE desktop and run this command in a console, with as few other applications running as possible. Creating the database is an extremely drive-intensive operation. The command is:
# /usr/local/TSS/bin/tripwire -m i -v |
After initialization Tripwire will usually be used in two modes, 'Integrity Checking Mode,' and 'Database Update Mode.' The integrity check is the basic operation by which Tripwire protects the filesystem, by scanning it and comparing the results to the data in the database created by the initialization step, as above. Update mode allows the database to be brought up to date with any legitimate changes in the filesystem, such as might occur if a new piece of software is installed, or an old piece removed. Other legitimate system operations will picked up by Tripwire, such as the addition of a new user account. It is possible to combine these two modes, integrity check and database update, by running the integrity checking mode interactively.
The first database created by Tripwire, using the step outlined in the Installation section above, will always be "wrong," that is, contain errors that will show up the first time the integrity check is run. This is simply because that database itself constitutes a change from the initial snapshot. Also, there will typically be files reported as missing; Tripwire's default policy, used for the database initialization, expects to find certain files and they will not all be there. This is normal behavior for Tripwire. To understand this better it makes sense at this point to run the first integrity check, and view the report. To run the check:
# /usr/local/TSS/bin/tripwire -m c -v |
# /usr/local/TSS/bin/twprint -m r -r ../report/[host.domain-timestamp].twr |
At this point it makes sense to simply update the database to accept any differences that were found in the first check after the initialization run. This can be done with one command. In normal operations this wholesale adjustment in one fell swoop would not be used; instead, an interactive mode for the database update for making adjustments on a file-by-file basis. But for this first update using the '-a' option ('all') is appropriate. Tripwire must be pointed at the report that represents the changes it is to make to its database; in our example that will be the report generated by the first integrity check. It will look something like this:
# ./tripwire -m u -a -Z low -r ../report/[host.domain-timestamp].twr |
It's not hard to fix all those missing file errors in the reports we've been getting. These are files that are simply not part of the eServer filesystem; Tripwire's default policy includes candidates from many Unix configurations, not just Linux. This exercise will be a first venture into updating the policy file, which is a regular part of Tripwire operation.
First create a copy of the existing policy file. Keep in mind that the actual policy file is encrypted, and that changes to it are first made to a text file which is then converted by Tripwire into the encrypted version. So, in the TSS/ directory:
# cp policy/twpol.txt policy/twpol2.txt |
# ./twprint -m r -r ../reports/[your_report].twr > my_report.txt # grep Filename: my_report.txt > missing_list |
With that editing chore out of the way all that remains is to run Tripwire in "Policy Update" mode. This updates the database to reflect the new policy and creates a new encrypted policy file for subsequent operations. The command is:
# ./tripwire -m p -Z low ../policy/twpol2.txt |
Important: At this point serious consideration should be given to archiving a copy or two of the entire TSS/ directory, binaries, configuration files, the database, in short, everything. These ought to be stored off site along with your other master backups. In the event of an intrusion you will need to assess the damage. Although an intruder cannot tamper with Tripwire's database and policy files in a way that would cause Tripwire to produce false negatives, i.e. bogus reports that everything is "fine," it is possible that the blackhat could simply delete those files. Ordinarily this sort of blatant vandalism is not part of an intrusion scenario, since it announces in clarion tones that, to borrow a phrase, "Kilroy was here." However, destroying Tripwire could easily be a parting shot as a malefactor, perhaps aware that the authorities were hot on the trail, made his or her final exit. The point is: if you are not in a position to reliably assess the damage to the filesystem then the only response is to wipe the hard drive clean and start over. Tripwire's database can provide an accurate picture of what was done, and not done.
It is easy to set up a cron job that will run Tripwire in integrity check mode on a regular basis, typically daily. eServer's Webmin administration tool can handle this chore :
You need to be in the KDE desktop (or some other X-windows window manager) to use Webmin. Once there launch the Communicator browser and open the location http://localhost:1000/
You should be prompted for a username and password to start Webmin, unless you are returning to a previous Webmin session (or have made the mistake of logging into eServer as root). Enter 'root' and the root password.
On the Webmin home page click on "Scheduled Cron Jobs".
Pause to review this page. Note that next to each cron job is a field in the "Active?" column, which can be toggled between 'Yes' and 'No', giving easy control over each job. Scroll down this page and click on "Create a new scheduled cron job."
Set the field labeled "Execute cron job as" to 'root'. In the command field enter '/usr/local/TSS/bin/tripwire -m c -s'. Leave the other edit box empty.
Further down the page set the time of day Tripwire will run. Leave the columns headed Weekdays, Months, and Days marked 'All'. In the Hours and Minutes columns, click on the value desired (one in each column) and then above each click on 'Selected'.
Click the 'Create' button. When the main Cron Job page comes up you may have to click on 'Reload' to see the results of your work.
Exit the browser completely to end the Webmin session. If all is well Tripwire will execute at the appointed time, and the cron daemon will deliver Tripwire's report to your email inbox. (You have set an alias for root, right?)
If the license restrictions on Tripwire_221 cannot be adhered to, and the commercial version is felt to be too expensive, then the older "Academic" version of Tripwire is available. This solution is not recommended, but if it is adopted then you should be aware that with the Academic version of Tripwire the database, policy and configuration files must be maintained on removable media and kept off the machine, as they are vulnerable to a kind of tampering that the newer version is immune to.
A project is underway to provide a replacement for Tripwire that is licensed under the GPL, the license that has been used for developing and distributing a fair amount of the GNU/Linux system, of which eServer is an instance. Aide (Advanced Intrusion Detection Environment) has a home page at http://www.cs.tut.fi/~rammer/aide.html.
No discussion of file integrity security would be complete without at least a mention of COPS. It is one of the most venerable auditing tools available for the Unix platform. Functionally it overlaps somewhat the ground covered by Tripwire, inasmuch as COPS will report changes made to vital files, for instance system binaries and libraries. COPS's method for this task is not as sophisticated as Tripwire's, and COPS does not have the innate security that is afforded Tripwire by virtue of its extensive use of encryption. But there are two sides to every story, and COPS examines certain aspects of the system that are not examined by Tripwire. For example COPS will look at your password and group files and report any untoward circumstances therein. COPS will report on files that are world-readable but perhaps should not be. And, COPS pays special attention to suid files, listing prominently in its reports all of these files and any changes to them. These are only some of the checks performed by COPS that Tripwire does not encompass. Tripwire does one job, and does it in a sophisticated and secure fashion. COPS, although it spreads its net farther than Tripwire, unfortunately is not as tamper-proof as Tripwire. This makes it perhaps not the tool of choice for routine daily monitoring, but COPS still has a role in assessing the security-related health of a system.
What follows is a description of the steps needed to build COPS and take it out for a first test spin. The discussion will not follow through to a complete system installation of COPS; the documentation included is more than adequate to guide the reader through that process. As noted above, no security tool should be used for serious work without a thorough examination of the relevant documentation.
The version of COPS described here is a recent update of the package specifically for the Linux platform. The source archive is at: http://packetstorm.securify.com/UNIX/audit/cops/; the filename is cops_104_linux.tgz
After moving the tarball into, say, /usr/local/src, carry out the following:
# tar xzvf cops_104_linux.tgz # cd cops_104/ # ./reconfig # make |
At this point COPS hasn't been completely installed, that is, its files have not been placed in their final locations, and the documentation has not been built. But it still can be tested. Determine which user should receive COPS' email reports and then start it up:
# ./cops -v -s . -m some_user |
COPS now goes through its paces. You can observe its progress by running 'tail' on the report being generated in the COPS directory. The format of the filename of this report is 'result.pid' where 'pid' is the process number of the COPS shell instance; an 'ls' will reveal the filename after COPS has started, so the command will look something like:
# tail -f result.23046 |
**** root.chk **** **** dev.chk **** Warning! /dev/fd0 is _World_ writable! Warning! /proc is _World_ readable! Warning! /dev/fd0 is _World_ readable! **** is_able.chk **** Warning! /etc/security is _World_ readable! Warning! /etc/crontab is _World_ readable! Warning! /etc/securetty is _World_ readable! **** rc.chk **** **** cron.chk **** **** group.chk **** **** home.chk **** **** passwd.chk **** **** user.chk **** **** misc.chk **** **** ftp.chk **** **** pass.chk **** **** kuang **** **** crc.chk **** **** bug.chk **** |
Note: In some tests of COPS it was found to hang on 'misc.chk' due to a timeout problem with tftp. Killing tftp will allow COPS to complete its run.
At this point a 'make all; make install' will place the COPS executables in their INSTALL_DIR as set in the makefile; the latter should be edited first using a value such as /usr/local/cops. The man pages in the docs/ have to be copied over into the appropriate directories under /usr/local/man/. And, once some fine-tuning has been done, a cron job could be set for COPS as for Tripwire. The COPS documents and man pages provide ample guidance for configuring COPS. Clearly COPS deserves its longevity.
The table shown is designed for use with a set of 16 dice. Put them all in a can (after closing the blinds and latching the door) and roll them all at once. Then arrange them on your desk in a 2x8 array and pick the eight characters off the table according to that array. Simple, yet almost perfectly random. For a larger set of characters, such as upper and lower case, put eight coins in the can along with the dice: heads for upper, tails for lower case. If the dice call for a number, then heads could mean the number and tails mean "pick a special character".

Here is Don Libes' mkpasswd script, as found at http://www2.informatik.uni-jena.de/docs/Programs/expect/example/mkpasswd. The first line has been changed to reflect expect's path in eServer's filesystem.
#!/usr/bin/expect --
# mkpasswd - make a password, if username given, set it.
# Author: Don Libes, NIST
# defaults
set length 8
set minnum 2
set minlower 2
set minupper 2
set verbose 0
set distribute 0
if [file executable /bin/yppasswd] {
set defaultprog /bin/yppasswd
} elseif [file executable /bin/passwd] {
set defaultprog /bin/passwd
} else {
set defaultprog passwd
}
set prog $defaultprog
while {[llength $argv]>0} {
set flag [lindex $argv 0]
switch -- $flag \
"-l" {
set length [lindex $argv 1]
set argv [lrange $argv 2 end]
} "-d" {
set minnum [lindex $argv 1]
set argv [lrange $argv 2 end]
} "-c" {
set minlower [lindex $argv 1]
set argv [lrange $argv 2 end]
} "-C" {
set minupper [lindex $argv 1]
set argv [lrange $argv 2 end]
} "-v" {
set verbose 1
set argv [lrange $argv 1 end]
} "-p" {
set prog [lindex $argv 1]
set argv [lrange $argv 2 end]
} "-2" {
set distribute 1
set argv [lrange $argv 1 end]
} default {
set user [lindex $argv 0]
set argv [lrange $argv 1 end]
break
}
}
if {[llength $argv]} {
puts "usage: mkpasswd \[args] \[user]"
puts " where arguments are:"
puts " -l # (length of password, default = $length)"
puts " -d # (min # of digits, default = $minnum)"
puts " -c # (min # of lowercase chars, default = $minlower)"
puts " -C # (min # of uppercase chars, default = $minupper)"
puts " -v (verbose, show passwd interaction)"
puts " -p prog (program to set password, default = $defaultprog)"
exit 1
}
if {$minnum + $minlower + $minupper > $length} {
puts "impossible to generate $length-character password\
with $minnum numbers, $minlower lowercase letters,\
and $minupper uppercase letters"
exit 1
}
# if there is any underspecification, use additional lowercase letters
set minlower [expr $length - ($minnum + $minupper)]
set lpass "" ;# password chars typed by left hand
set rpass "" ;# password chars typed by right hand
# insert char into password at a random position
proc insert {pvar char} {
upvar $pvar p
set p [linsert $p [rand [expr 1+[llength $p]]] $char]
}
set _ran [pid]
proc rand {m} {
global _ran
set period 259200
set _ran [expr ($_ran*7141 + 54773) % $period]
expr int($m*($_ran/double($period)))
}
# choose left or right starting hand
set initially_left [set isleft [rand 2]]
# given a size, distribute between left and right hands
# taking into account where we left off
proc psplit {max lvar rvar} {
upvar $lvar left $rvar right
global isleft
if {$isleft} {
set right [expr $max/2]
set left [expr $max-$right]
set isleft [expr !($max%2)]
} else {
set left [expr $max/2]
set right [expr $max-$left]
set isleft [expr $max%2]
}
}
if {$distribute} {
set lkeys {q w e r t a s d f g z x c v b}
set rkeys {y u i o p h j k l n m}
set lnums {1 2 3 4 5 6}
set rnums {7 8 9 0}
} else {
set lkeys {a b c d e f g h i j k l m n o p q r s t u v w x y z}
set rkeys {a b c d e f g h i j k l m n o p q r s t u v w x y z}
set lnums {0 1 2 3 4 5 6 7 8 9}
set rnums {0 1 2 3 4 5 6 7 8 9}
}
set lkeys_length [llength $lkeys]
set rkeys_length [llength $rkeys]
set lnums_length [llength $lnums]
set rnums_length [llength $rnums]
psplit $minnum left right
for {set i 0} {$i<$left} {incr i} {
insert lpass [lindex $lnums [rand $lnums_length]]
}
for {set i 0} {$i<$right} {incr i} {
insert rpass [lindex $rnums [rand $rnums_length]]
}
psplit $minlower left right
for {set i 0} {$i<$left} {incr i} {
insert lpass [lindex $lkeys [rand $lkeys_length]]
}
for {set i 0} {$i<$right} {incr i} {
insert rpass [lindex $rkeys [rand $rkeys_length]]
}
psplit $minupper left right
for {set i 0} {$i<$left} {incr i} {
insert lpass [string toupper [lindex $lkeys [rand $lkeys_length]]]
}
for {set i 0} {$i<$right} {incr i} {
insert rpass [string toupper [lindex $rkeys [rand $rkeys_length]]]
}
# merge results together
if {$initially_left} {
regexp "(\[^ ]*) *(.*)" "$lpass" x password lpass
while {[llength $lpass]} {
regexp "(\[^ ]*) *(.*)" "$password$rpass" x password rpass
regexp "(\[^ ]*) *(.*)" "$password$lpass" x password lpass
}
if {[llength $rpass]} {
append password $rpass
}
} else {
regexp "(\[^ ]*) *(.*)" "$rpass" x password rpass
while {[llength $rpass]} {
regexp "(\[^ ]*) *(.*)" "$password$lpass" x password lpass
regexp "(\[^ ]*) *(.*)" "$password$rpass" x password rpass
}
if {[llength $lpass]} {
append password $lpass
}
}
if {[info exists user]} {
if {!$verbose} {
log_user 0
}
spawn $prog $user
expect {
"assword*:" {
# some systems say "Password (again):"
send "$password\r"
exp_continue
}
}
# if user isn't watching, check status
if {!$verbose} {
if {[lindex [wait] 3]} {
puts -nonewline "$expect_out(buffer)"
exit 1
}
}
}
if {$verbose} {
puts -nonewline "password for $user is "
}
puts "$password" |
Go to Tom Van Vleck's web site http://www.multicians.org/thvv/tvvtools.html and near the bottom of the page find and download these three files: gpw.C loadtris.C gpw.Makefile, placing them in the same directory.
Edit gpw.Makefile to specify the correct compiler:
COMPILER = g++ |
Also in gpw.Makefile, edit the path to 'loadtris', prepending the './':
trigram.h : loadtris
./loadtris /usr/share/dict/american-english | sed "s/, }/}/" > trigram.h |
Run make:
$ make -f gpw.Makefile |
At this point you can either run gpw in the current directory with './gpw', or place a copy where any user can run it:
$ cp gpw /usr/local/bin $ make -f gpw.Makefile clean |