ch11.htm
来自「Maximum Security (First Edition) 网络安全 英文」· HTM 代码 · 共 1,114 行 · 第 1/4 页
HTM
1,114 行
</BLOCKQUOTE><P>As you can see, a trojan might crop up anywhere. Even a file originating froma reasonably trusted source could be trojaned.<H2><FONT COLOR="#000077"><B>Where Might One Find a Trojan?</B></FONT></H2><P>Technically, a trojan could appear almost anywhere, on any operating system orplatform. However, with the exception of the inside job mentioned previously, thespread of trojans works very much like the spread of viruses. Software downloadedfrom the Internet, especially shareware or freeware, is always suspect. Similarly,materials downloaded from underground servers or Usenet newsgroups are also candidates.</P><P>Sometimes, one need not travel down such dark and forbidden alleys to find a trojan.Trojans can be found in major, network-wide distributions. For example, examine thisexcerpt from a CIAC security advisory ("E-14: Wuarchive Ftpd Trojan Horse"),posted to the Net in 1994:<DL> <DD>CIAC has received information that some copies of the wuarchive FTP daemon (ftpd) versions 2.2 and 2.1f have been modified at the source code level to contain a trojan horse. This trojan allows any user, local or remote, to become root on the affected UNIX system. CIAC strongly recommends that all sites running these or older versions of the wuarchive ftpd retrieve and install version 2.3. It is possible that versions previous to 2.2 and 2.1f contain the trojan as well.</DL><P>wftpd is one of the most widely used FTP servers in the world. This advisory affectedthousands of sites, public and private. Many of those sites are still at risk, primarilybecause the system administrators at those locations are not as security consciousas they should be.<BLOCKQUOTE> <P><HR><FONT COLOR="#000077"><B>TIP:</B></FONT><B> </B>Pick 100 random hosts in the void and try their FTP servers. I would wager that out of those hosts, more than 80% are using wftpd. In addition, another 40% of those are probably using older versions that, although they may not be trojaned, have security flaws of some kind. <HR></BLOCKQUOTE><H2><FONT COLOR="#000077"><B>C'mon! How Often Are Trojans Really Discovered?</B></FONT></H2><P>Trojans are discovered often enough that they are a major security concern. Whatmakes trojans so insidious is that even after they are discovered, their influenceis still felt. Trojans are similar to sniffers in that respect. No one can be sureexactly how deep into the system the compromise may have reached. There are severalreasons for this, but I will limit this section to only one.</P><P>As you will soon read, the majority of trojans are nested within compiled binaries.That is to say: The code that houses the trojan is no longer in human-readable formbut has been compiled. Thus, it is in machine language. This language can be examinedin certain raw editors, but even then, only printable character strings are usuallycomprehensible. These most often are error messages, advisories, option flags, orother data printed to <TT>STDOUT</TT> at specified points within the program:</P><PRE><FONT COLOR="#0066FF">my_function() {cout << "The value you have entered is out of range!\n";cout << "Please enter another:"} </FONT></PRE><P>Because the binaries are compiled, they come to the user as (more or less) point-and-shootapplications. In other words, the user takes the file or files as is, without intimateknowledge of their structure.</P><P>When authorities discover that such a binary houses a trojan, security advisoriesare immediately issued. These tend to be preliminary and are later followed by morecomprehensive advisories that may briefly discuss the agenda and method of operationof the trojan code. Unless the user is a programmer, these advisories spell out littlemore than "Get the patch now and replace the bogus binary." Experiencedsystem administrators may clearly understand the meaning of such advisories (or evenclearly understand the purpose of the code, which is usually included with the comprehensiveadvisory). However, even then, assessment of damages can be difficult.</P><P>In some cases, the damage seems simple enough to assess (for example, instanceswhere the trojan's purpose was to mail out the contents of the <TT>passwd</TT> file).The fix is pretty straightforward: Replace the binary with a clean version and haveall users change their passwords. This being the whole of the trojan's function,no further damage or compromise is expected. Simple.</P><P>But suppose the trojan is more complex. Suppose, for example, that its purposeis to open a hole for the intruder, a hole through which he gains root access duringthe wee hours. If the intruder was careful to alter the logs, there might be no wayof knowing the depth of the compromise (especially if you discover the trojan monthsafter it was installed). This type of case might call for reinstallation of the entireoperating system.<BLOCKQUOTE> <P><HR><FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>Reinstallation may be a requisite. Many more of your files might have been trojaned since the initial compromise. Rather than attempt to examine each file (or each file's behavior) closely, it might make better sense to start over. Equally, even if more files haven't been trojaned, it's likely that passwords, personal data, or other sensitive materials have been compromised. <HR></BLOCKQUOTE><P>Conversely, trojans may be found in executable files that are not compiled. Thesemight be shell scripts, or perhaps programs written in Perl, JavaScript, VBScript,Tcl (a popular scripting language), and so forth. There have been few verified casesof this type of trojan. The cracker who places a trojan within a noncompiled executableis risking a great deal. The source is in plain, human-readable text. In a smallprogram, a block of trojan code would stand out dramatically. However, this methodmay not be so ludicrous when dealing with larger programs or in those programs thatincorporate a series of compiled binaries and executable shell scripts nested withinseveral subdirectories. The more complex the structure of the distribution, the lesslikely it is that a human being, using normal methods of investigation, would uncovera trojan.</P><P>Moreover, one must consider the level of the user's knowledge. Users who knowlittle about their operating system are less likely to venture deep into the directorystructure of a given distribution, looking for mysterious or suspicious code (evenif that code is human readable). The reverse is true if the user happens to be aprogrammer. However, the fact that a user is a programmer does not mean he or shewill instantly recognize a trojan. I know many BASIC programmers who have a difficulttime reading code written in Perl. Thus, if the trojan exists in a scripting language,the programmer must first be familiar with that language before he or she can identifyobjectionable code within it. It is equally true that if the language even slightlyresembles a language that the programmer normally uses, he or she may be able toidentify the problem. For example, Perl is sufficiently similar to C that a C programmerwho has never written a line of Perl could effectively identify malicious code withina Perl script. And of course, anyone who writes programs in a shell language or awkwould likewise recognize questionable code in a Perl program.<BLOCKQUOTE> <P><HR><FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>Many Perl programs (or other scripted shell programs) are dynamic; that is, they may change according to certain circumstances. For example, consider a program that, in effect, rewrites itself based on certain conditions specified in the programming code. Such files need to be checked by hand for tampering because integrity checkers will always report that the file has been attacked, even when it has not. Granted, today, there are relatively few dynamic programs, but that is about to change. There is talk on the Internet of using languages like Perl to perform functions in Electronic Data Interchange (EDI). In some instances, these files will perform functions that necessarily require the program file to change. <HR></BLOCKQUOTE><H2><FONT COLOR="#000077"><B>What Level of Risk Do Trojans Represent?</B></FONT></H2><P>Trojans represent a very high level of risk, mainly for reasons already stated:</P><UL> <LI><FONT COLOR="#000000">Trojans are difficult to detect.<BR> <BR> </FONT> <LI><FONT COLOR="#000000">In most cases, trojans are found in binaries, which remain largely in non-human-readable form.<BR> <BR> </FONT> <LI><FONT COLOR="#000000">Trojans can affect many machines.</FONT></UL><PRE></PRE><P>Let me elaborate. Trojans are a perfect example of the type of attack that isfatal to the system administrator who has only a very fleeting knowledge of security.In such a climate, a trojan can lead to total compromise of the system. The trojanmay be in place for weeks or even months before it is discovered. In that time, acracker with root privileges could alter the entire system to suit his or her needs.Thus, even when the trojan is discovered, new holes may exist of which the systemadministrator is completely unaware.<H2><FONT COLOR="#000077"><B>How Does One Detect a Trojan?</B></FONT></H2><P>Detecting trojans is less difficult than it initially seems. But strong knowledgeof your operating system is needed; also, some knowledge of encryption can help.</P><P>If your environment is such that sensitive data resides on your server (whichis never a good idea), you will want to take advanced measures. Conversely, if nosuch information exists on your server, you might feel comfortable employing lessstringent methods. The choice breaks down to need, time, and interest. The firsttwo of these elements represent cost. Time always costs money, and that cost willrise depending on how long it has been since your operating system was installed.This is so because in that length of time, many applications that complicate thereconciliation process have probably been installed. For example, consider updatesand upgrades. Sometimes, libraries (or DLL files) are altered or overwritten withnewer versions. If you were using a file-integrity checker, these files would beidentified as changed. If you were not the person who performed the upgrade or update,and the program is sufficiently obscure, you might end up chasing a phantom trojan.These situations are rare, true, but they do occur.</P><P>Most forms of protection against (and prevention of) trojans are based on a techniquesometimes referred to as <I>object reconciliation</I>. Although the term might soundintimidating, it isn't. It is a fancy way of asking "Are things still just theway I left them?" Here is how it works: <I>Objects</I> are either files or directories.<I>Reconciliation</I> is the process of comparing those objects against themselvesat some earlier (or later) date. For example, take a backup tape and compare thefile PS as it existed in November 1995 to the PS that now resides on your drive.If the two differ, and no change has been made to the operating system, somethingis amiss. This technique is invariably applied to system files that are installedas part of the basic operating system.</P><P>Object reconciliation can be easy understood if you recognize that for each timea file is altered in some way, that file's values change. For example, one way toclock the change in a file is by examining the date it was last modified. Each timethe file is opened, altered, and saved, a new last-modified date emerges. However,this date can be easily manipulated. Consider manipulating this time on the PC platform.How difficult is it? Change the global time setting, apply the desired edits, andarchive the file. The time is now changed. For this reason, time is the least reliableway to reconcile an object (at least, relying on the simple date-last-modified timeis unreliable). Also, the last date of modification reveals nothing if the file wasunaltered (for example, if it was only copied or mailed).<BLOCKQUOTE> <P><HR><FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>PC users who have used older machines can easily understand this. Sometimes, when the CMOS battery fails, the system may temporarily fail. When it is brought back up, you will see that a few files have the date January 1, 1980. <HR></BLOCKQUOTE><P>Another way to check the integrity of a file is by examining its size. However,this method is extremely unreliable because of how easily this value can be manipulated.When editing plain text files, it is simple to start out with a size of, say, 1,024KBand end up with that same size. It takes cutting a bit here and adding a bit there.But the situation changes radically when you want to alter a binary file. Binaryfiles usually involve the inclusion of special function libraries and other moduleswithout which the program will not work. Thus, to alter a binary file (and stillhave the program function) is a more complicated process. The programmer must preserveall the indispensable parts of the program and still find room for his or her owncode. Therefore, size is probably a slightly more reliable index than time. Briefly,before I continue, let me explain the process by which a file becomes trojaned.</P><P>The most common scenario is when a semi-trusted (<I>known</I>) file is the objectof the attack. That is, the file is native to your operating system distribution;it comes from the vendor (such as the file <TT>csh</TT> in UNIX or <TT>command.com</TT>in DOS). These files are written to your drive on the first install, and they havea date and time on them. They also are of a specified size. If the times, dates,or sizes of these files differ from their original values, this raises immediatesuspicion.</P><P>Evil programmers know this. Their job, therefore, is to carefully examine thesource code for the file (usually obtained elsewhere) for items that can be excluded(for example, they may single out commented text or some other, not-so-essentialelement of the file). The unauthorized code is written into the source, and the fileis recompiled. The cracker then examines the size of the file. Perhaps it is toolarge or too small. The process then begins again, until the attacker has compileda file that is as close to the original size as possible. This is a time-consumingprocess. If the binary is a fairly large one, it could take several days.<BLOCKQUOTE> <P><HR><FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>When an original operating-system distributed file is the target, the attacker may or may not have to go through this process. If the file has not yet been distributed to anyone, the attacker need not concern himself or herself with this problem. This is because no one has yet seen the file or its size. Perhaps only the original author of the file would know that something was amiss. If that original author is not security conscious, he or she might not even know. If you are a programmer, think now about the very last binary you compiled. How big was it? What was its file size? I bet you don't remember. <HR></BLOCKQUOTE><P>When the file has been altered, it is placed where others can obtain it. In thecase of operating-system distributions, this is generally a central site for download(such as <TT>sunsite.unc.edu</TT>, which houses one of the largest collection ofUNIX software on the planet). From there, the file finds its way into workstationsacross the void.<BLOCKQUOTE> <P><HR><FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B><TT>sunsite.unc.edu</TT> is the Sun Microsystems-sponsored site at UNC Chapel Hill. This site houses the greater body of free software on the Internet. Thousands of individuals--including me--rely on the high-quality UNIX software available at this location. Not enough good can be said about this site. It is a tremendous public service. <HR></BLOCKQUOTE>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?