Ads by TechWords

See your link here
Subscribe to our e-mail newsletters
For more info on a specific newsletter, click the title. Details will be displayed in a new window.
Linux
Computerworld Daily News (First Look and Wrap-Up)
Computerworld Blogs Newsletter
The Weekly Top 10
More E-Mail Newsletters 
 

Thwart Trojan horse attacks on Linux systems

July 21, 2004 12:00 PM ET

Computerworld -

This content is excerpted from a chapter from the new book, "A Practical
Guide to Red Hat Linux: Fedora Core & Red Hat Enterprise Linux"
, authored by
Mark Sobell, ISBN 0131470248. It is excerpted with permission from publisher
Prentice Hall PTR, copyright 2005, Mark G. Sobell. To learn more, please
visit the book's page at: http://www.phptr.com/title/0131470248



A Trojan horse is a program that does something destructive or disruptive to your system while appearing to be benign. As an example, you could store the following script in an executable file named mkfs:


while true

   do

   echo 'Good Morning Mr. Jones. How are you? Ha Ha Ha.' > /dev/console

   done


If you are running as Superuser when you run this command, it would continuously write a message to the console. If the programmer were malicious, it could do worse. The only thing missing in this plot is access permissions.


A malicious user could implement this Trojan horse by changing Superuser's PATH variable to include a publicly writable directory at the start of the PATH string. (The catch is that you need to be able to write to /etc/profile - where the PATH variable is set for root-and only root can do that.) Then you would need to put the bogus mkfs program file in that directory. Because the fraudulent version appears in a directory mentioned earlier than the real one in PATH, the shell runs it. The next time Superuser tries to run mkfs, the fraudulent version would run.


Trojan horses that wait for and take advantage of the misspellings that most people make are one of the most insidious types. For example, you might type sl instead of ls. Because you do not regularly execute a utility named sl and you may not remember typing the command sl, it is more difficult to track down this type of Trojan horse than one that takes the name of a utility you are familiar with.


A good way to prevent executing a Trojan horse is to make sure that your PATH variable does not contain a single colon (:) at the beginning or end of the PATH string or a period (.) or double colon (::) anywhere in the PATH string. A common way to check for a Trojan horse is to examine the filesystem periodically for files with setuid (refer to item 5 on page 372). The following command lists these files:


# find / -perm -4000 -exec ls -lh {} \; 2> /dev/null

-rwsr-xr-x 1 root root 54K Apr 5 16:17 /usr/bin/lppasswd

-rwsr-xr-x 1 root root 111K Feb 17 10:26 /usr/bin/crontab

-rwsr-xr-x 1 root root 7.0K Apr 13 08:26 /usr/bin/kpac_dhcp_helper

-rws--x--x 1 root root 18K Mar 23 12:05 /usr/bin/chfn

-rws--x--x 1 root root 6.8K Mar 23 12:05 /usr/bin/newgrp

-rwsr-xr-x 1 root root 39K Apr 15 12:26 /usr/bin/at

-rwsr-xr-x 1 root root 42K Mar 30 13:45 /usr/bin/gpasswd

-r-s--x--x 1 root root 91K Feb 15 10:04 /usr/bin/passwd

-rwsr-xr-x 1 root root 17K Feb 17 09:12 /usr/bin/rlogin

---s--x--x 1 root root 96K Apr 1 08:19 /usr/bin/sudo

-rwsr-xr-x 1 root root 6.8K Apr 13 08:26 /usr/bin/kgrantpty

-rwsr-xr-x 1 root root 18K Feb 17 09:12 /usr/bin/rcp

-rwsrwxr-x 1 root root 364K Mar 16 13:32 /usr/bin/tvtime

-rwsr-xr-x 1 root root 40K Mar 30 13:45 /usr/bin/chage

-rwsr-xr-x 1 root root 9.6K Feb 17 09:12 /usr/bin/rsh

-rws--x--x 1 root root 19K Mar 23 12:05 /usr/bin/chsh

...




This command uses find to locate all the files that have their setuid bits set (mode 4000). The hyphen preceding the mode causes find to report on any file that has this bit set, regardless of how the other bits are set. The output sent to standard error is redirected to /dev/null so that it does not clutter the screen.
You can also set up a program, such as AIDE (Advanced Intrusion Detection Environment), that will take a snapshot of your system and check it periodically as you specify. See www.cs.tut.fi/~rammer/aide.html for more information.



Additional Resources

POLL RESULTS
Accelerate your knowledge of the IT world you inhabit by viewing the results of a series of polls taken by your IT peers. These polls of 100+ IT professionals each are available for full viewing. They cover key topics such as virtualization, processor performance, green IT, cloud computing and many others. Be a part of the buzz.
WHITE PAPER
Technology is complex. Keeping it running productively shouldn't be. To that end, you want to minimize the number of solutions needed in-house to simplify operations, maintenance, and support. Kodak offers a best-practices model. One company provides support for both scanner and software, for fast problem resolution without vendor finger-pointing. Download now!
WHITE PAPER
Utilizing demand intelligence improves the precision of pricing, product assortments, channel/store placement, and promotion, which are all essential for sustainable revenue management performance. Learn more, download this free whitepaper today.

White Papers & Webcasts

Accelerate SSL Encrypted Applications
The amount of SSL traffic is growing in the enterprise. Because it is encrypted, it cannot be properly controlled and accelerated. Blue Coat...  

IDC Webcast: Linux Adoption in a Global Recession
Join Al Gillen from IDC and Michael Applebaum from Novell in this on-demand webcast to see how Linux has emerged as an even...

ESG Lab Field Audit
Many companies have successfully implemented Riverbed WAN optimization solutions within their Cisco networks. This ESG Lab Field Audit document explores the success that...  

Usability Is Everything
Learn what sets Workday's HR and Payroll solutions apart from the competition....

Shape Your Apps Strategy to Reflect New SaaS Licensing and Pricing Trends
Why are smart companies choosing software-as-a-service? Find out in the complimentary Forrester Research report...  

The Value of Real SaaS at Workday
Cost savings, speed to value, and innovation brought to the enterprise by Workday's software-as-a-service solutions for HR and Payroll....

Natural User Interface for Enterprise Applications
Learn how a revolutionary user interface can make a complex enterprise application so intuitive even casual users can jump right in....  

SaaS at Flextronics, Inc.
Dave Smoley, CIO of Flextronics, discusses the real value of software-as-a-service and why he chose Workday for his HR solution....

A Truly Global HCM System
Learn about a system built with advanced object-oriented technology that support multi-national requirements and costs less to implement, maintain and upgrade....  

Why Compliance Pays
This OnDemand webcast explores the relationship that firms with best compliance records have higher revenue, greater customer retention, lower financial losses from data...