hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : Hosting Security and Technology Tutorials : Checklist: "Have I been Hacked?"
Reply

Hosting Security and Technology Tutorials Tutorials related to server security or the like.
Forum Jump

Checklist: "Have I been Hacked?"

Reply Post New Thread In Hosting Security and Technology Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 04-07-2004, 05:38 PM
Doggy Doggy is offline
Disabled
 
Join Date: Oct 2003
Location: Portugal
Posts: 62
Exclamation

Checklist: "Have I been Hacked?"


I often see the question "Have I been Hacked?" come up. I thought it would be good to have a thread with some good checklists. I hope I am not duplicating anything (if so, let me know).

Before the checklist, my advice is:

- Don't wait to be Hacked! Use the various HOW-TOs here to secure your box from day one

- Don't think of security as something you need to do after the fact, security must be your hourly/daily mindset

Now, there's a lot of stuff on this subject, go google and search here. But to start off with, this section from the Red Hat Linux Guide is a good place to start.

The first thing an intruder typically does is install a "rootkit". There are many prepackaged rootkits available on the Internet. The rootkit is essentially a script, or set of scripts, that makes quick work of modifying the system so the intruder is in control, and he is well hidden. He does this by installing modified binaries of common system utilities and tampering with log files. Or by using special kernel modules that achieve similar results. So common commands like ls may be modified so as to not show where he has his files stored. Clever!

A well designed rootkit can be quite effective. Nothing on the system can really be trusted to provide accurate feedback. Nothing! But sometimes the modifications are not as smooth as intended and give hints that something is not right. Some things that might be warning signs:
  • Login acts weird. Maybe no one can login. Or only root can login. Any login weirdness at all should be suspicious. Similarly, any weirdness with adding or changing passwords.
    Wierdness with other system commands (e.g. top or ps) should be cause for concern as well.
  • System utilities are slower, or awkward, or show strange and unexpected results. Common utilities that might be modified are: ls, find, who, w, last, netstat, login, ps, top. This is not a definitive list!
  • Files or directories named "..." or ".. " (dot dot space). A sure bet in this case. Files with haxor looking names like "r00t-something".
  • Unexplained bandwidth usage, or connections. Script kiddies have a fondness for IRC, so such connections should raise a red flag.
  • Logs that are missing completely, or missing large sections. Or a sudden change in syslog behavior.
  • Mysterious open ports, or processes.
  • Files that cannot be deleted or moved. Some rootkits use chattr to make files "immutable", or not changable. This kind of change will not show up with ls, or rpm -V, so the files look normal at first glance. See the man pages for chattr and lsattr on how to reverse this. Then see the next section below on restoring your system as the jig is up at this point. This is becoming a more and more common script kiddie trick. In fact, one quick test to run on a suspected system (as root):

Quote:
/usr/bin/lsattr `echo $PATH | tr ':' ' '` | grep i--

@@@
This will look for any "immutable" files in root's PATH, which is almost surely a sign of trouble since no standard distributions ship files in this state. If the above command turns up anything at all, then plan on completely restoring the system (see below). A quick sanity check:

Quote:
# chattr +i /bin/ps
# /usr/bin/lsattr `echo $PATH | tr ':' ' '` | grep "i--"
---i---------- /bin/ps
# chattr -i /bin/ps

This is just to verify the system is not tampered with to the point that lsattr is completely unreliable. The third line is exactly what you should see.
  • Indications of a "sniffer", such as log messages of an interface entering "promiscuous" mode.
  • Modifications to /etc/inetd.conf, rc.local, rc.sysint or /etc/passwd. Especially, any additions. Try using cat, or tail, to view these files. Additions will most likely be appended to the end. Remember though such changes may not be "visible" to any system tools.

Sometimes the intruder is not so smart and forgets about root's .bash_history, or cleaning up log entries, or even leaves strange, leftover files in /tmp. So these should always be checked too. Just don't necessarily expect them to be accurate. Often such left behind files, or log entries, will have obvious script kiddie sounding names, e.g. "r00t.sh".

Interpreting sniffer output is probably beyond the grasp of the average new user.

As mentioned, a compromised system will undoubtedly have altered system binaries, and the output of system utilities is not to be trusted. Nothing on the system can be relied upon to be telling you the whole truth. Re-installing individual packages may or may not help since it could be system libraries or kernel modules that are doing the dirty work. The point here is that there is no way to know with absolute certainty exactly what components have been altered.

We can use rpm -Va |less to attempt to verify the integrity all packages. But again there is no assurance that rpm itself has not been tampered with, or the system components that RPM relies on.

If you have pstree on your system, try this instead of the standard ps. Sometimes the script kiddies forget about this one. No guarantees though that this is accurate either.

You can also try querying the /proc filesystem, which contains everything the kernel knows about processes that are running:

Quote:
# cat /proc/*/stat | awk '{print $1,$2}'
This will provide a list of all processes and PID numbers (assuming a malicious kernel module is not hiding this).

Another approach is to visit http://www.chkrootkit.org, download their rootkit checker, and see what it says.

Reply With Quote


Sponsored Links
  #2  
Old 04-27-2004, 05:28 AM
LowCostGroup LowCostGroup is offline
Junior Guru Wannabe
 
Join Date: Nov 2003
Location: Reading, UK
Posts: 89
Doggy, thats an excellent little checklist.

Also use tools like Retina to routinely check your server for vurnrabilities. Retina checks with CVE's for exploits that are out at present, and then checks if they would apply on your server. A valueable piece of software.

Reply With Quote
  #3  
Old 06-05-2004, 05:57 PM
linux-tech linux-tech is offline
<?require_once("life")?>
 
Join Date: Sep 2002
Location: inside your network
Posts: 9,548
While most OS'es don't ship files chattr'ed it's a good idea TO chattr certain files in respect to security. Why? Simple , really. The more work that kids have to do to your box, the less possibility you'll have of having it rooted.

Most kids don't do the actual file modifications themselves, they have scripts which they know little about to do it for them. The harder you make it for them to work, the btter your chances are

Reply With Quote
Sponsored Links
  #4  
Old 06-05-2004, 08:49 PM
CybexHost CybexHost is offline
Web Hosting Master
 
Join Date: Aug 2003
Location: USA
Posts: 1,030
Great How-To here Doggy!

Quote:
Originally posted by wolfstream
While most OS'es don't ship files chattr'ed it's a good idea TO chattr certain files in respect to security. Why? Simple , really. The more work that kids have to do to your box, the less possibility you'll have of having it rooted.

Most kids don't do the actual file modifications themselves, they have scripts which they know little about to do it for them. The harder you make it for them to work, the btter your chances are
I most certainly agree with this. Somebody's friend writes a script and then hands it out to a bunch of kids who don't know what they're doing

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Whistleblower Site Cryptome Hacked, Infects PCs with Drive-By Exploits Web Hosting News 2012-02-14 14:48:24
Dutch Security Firm Gemnet and Certificate Authority Division Gemnet CSP Offline Following Hack Web Hosting News 2011-12-09 15:33:53
Bangladeshi Hacker TiGER-M@TE Targets InMotion Hosting Web Hosting News 2011-09-26 15:24:05
South Korean Domain Registrar Gabia, Epson Korea Websites Hacked Web Hosting News 2011-08-24 14:04:01
London Police Arrest Hacker in Connection with PlayStation Network Hack Web Hosting News 2011-06-21 14:15:16


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?