LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 04-20-2006, 04:09 AM   #1
jnguy
LQ Newbie
 
Registered: Nov 2003
Posts: 9

Rep: Reputation: 0
Determining whether or not a machine has been penetrated


Hello all,

Although I do not believe my machine has been penetrated, I was curious as to what steps can be taken to, although obviously not with 100% certainty, determine whether or not a machine has been compromised. I've done the obvious of running chkrootkit and ocassionally nmaping and running nessus against my own machines. Just wondering what everyone else is doing. Are there any clear signs and indications of a hacked machine? Checking last, and checking if any new users have been added to your passwd, etc. Netstat for checking for listening connections. Just happen to be pondering upon this item tonight.

Jack
 
Old 04-20-2006, 05:45 AM   #2
okmyx
Member
 
Registered: May 2004
Location: Cornwall, UK
Distribution: Ubuntu 8.04
Posts: 464

Rep: Reputation: 31
You could look at Tripwire. It monitors and informs you of any modified system files on your computer.
 
Old 04-20-2006, 10:40 PM   #3
ZST
LQ Newbie
 
Registered: Apr 2006
Posts: 21

Rep: Reputation: 15
Well, my stance is that nessus is just a vuln scanner. It does not check to see if something is infected.

Nmaping once a day or so w/ a cron job is good. And have it e-mail you differances from day to day.

On a machine for work, i was looking at netstat-nap to see what was causing the irc connections outbound, and couldn't see anything at all. So what i did was nmap from the outside and compare it to a netstat -nap, i found that port 4932 was listening, but filtered. This did not show up on my netstat -nap, so i loged into the box, did a telnet localhost 4932 and found a backdoor running. Granted this was a RH6.1 box, that didn't do anything but it alarmed me and taught me a new way to look at vuln's on a system.

May or may not help.

Regards,
ZST
 
Old 04-21-2006, 08:42 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,417
Blog Entries: 55

Rep: Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627
I was curious as to what steps can be taken to, although obviously not with 100% certainty, determine whether or not a machine has been compromised.
I'd like to preface this by talking about something else first. We all know a Linux box is powerful because it is versatile, reliable, performs well and has excellent networking capabilities. But do we realise the data it contains, the services it provides, and the time invested in configuring, running and maintaining a Linux box represent a value? Things of value should be protected (hardened and regularly audited) and be treated with care. What I mean is that taking into account the value it represents, the automatic reaction to any sign (clear or vague) of compromise should be to treat a box as infected (threatening and urgent condition) which means it should be dealt with defensively, immediately.

Moving on, although there are basic steps for checking any box after a (perceived) breach of security, it helps to first know (read "make certain", not "guess") the purpose of the box and where it's placed in the network: knowing its purpose should lead to a list of services it provides. Knowing the place in the network shows its exposure (who has access), any devices to check in front and (where necessary) a list of (adjacent/"trusted") machines to check (it communicates with). In a professional environment you'll also have to know about network and security policies which should include a list of people to contact (like helpdesk, network admin, S.O.). Somewhere in between this all we've got to wedge in knowledge of the level of hardening of the box and network. Having remote access to network device logs, (remote) syslogs and (N)IDS logs can provide pieces of the puzzle. What I mean is that thinking should come before acting. More on reasons later on.

Now, if there are clear signs an intrusion is in progress or the box was compromised the first steps should be to isolate the box from the network (fire up a "known good" spare server to take over services if necessary) and responsable people and users should be warned. If there are no clear signs please realise that, whatever you do, you will need to make certain, not "guess" things are really OK.


I've done the obvious of running chkrootkit
That's a good thing though you'll have to take into account that output of tools like Chkrootkit, Rootkit Hunter or OSSEC Rootcheck (ossec.net) can be circumvented not only at the kernel level but also due to use of hardcoded stuff[0] like searchpaths. That's why having a file integrity checker[1] is important and not relying on the report of one single tool.


and ocassionally nmaping and running nessus against my own machines.
Portscanning a host (from another box) can show the status of a port, however it doesn't show ports that are not open (proto/port/bit-knock-alike mechanism), it uses a static port-to-service mapping (use version scanning) but most importantly if a cracker is watching a scan will tip her off. Nice.


Just wondering what everyone else is doing.
Leaving out things already mentioned and checks performed by Chkrootkit, Rootkit Hunter, Rootcheck here's some things in no particular order:
- logs. Always check the logs,
- (config) files that should not be touched that have their MAC times changed,
- any files that have their checksums changed,
- processes with unusual characteristics (name[2], deleted file usage, work directory),
- network connections (for instance to an IRCd),
- (any libpcap) processes using device promiscuous mode,
- new or changed setuid root binaries (in publicly accessable directories).

Output of listing modules, processes and network connections can be changed, so I prefer to use additional tools for example "unhide" (security-projects.com) for both process and network checks, "ip" for promiscuous mode checks, "kern_check" (la-samhna.de), an IDT checker (see Phrack, can be subverted too). If I'm unsure and I need more info there's nothing left but to drop to runlevel 1 or reboot with KNOPPIX-STD, PSK, FIRE or any other CDROM-based toolkit in case there's enough leads something weird is going on.


Are there any clear signs and indications of a hacked machine?
I'd say anything that is not "normal" behaviour is worth looking at like hight of or spikes in load or network usage, fill rate or full disks or logs. Basically anything that doesn't work "as expected".


Just happen to be pondering upon this item tonight.
Which means you're on a road that leads to hightened awareness, which is a Good Thing. The next thing to do would be to recheck the box (and network) for any holes wrt hardening and auditing capabilities (see the LQ FAQ: Security references). After that comes practicing. Practice builds familiarity and knowledge wrt tools to use and confidence and efficiency wrt execution.


[0] It's rather easy to for instance make Adore-ng invisible to Chkrootkit's "chkproc".

[1] Chkrootkit also has the nasty habit of relying on the "ifconfig" binary instead of "ip" which can, under certain circumstances, skew results of promiscuous mode checks. Choosing which file integrity checker to deploy should depend on the expected threat level (exposure) of the host and if it's using MAC (SELinux) or RBAC (GRSecurity). Samhain is an active one (includes an LKM) which should be a good choice for hosts that have less restrictions due to the services they provide. Aide (a "better" tripwire replacement) is a passive one meaning it needs to be run periodically. (Also see "Saint Jude LKM" where no MAC or RBAC can be used).

[2] Do not assume just because the process name reads "httpd" it *is* the webserver:
Code:
#!perl
$cmd = "httpd";
$system = '/bin/sh';
$0 = $cmd;
sleep
 
Old 05-05-2006, 04:05 AM   #5
jnguy
LQ Newbie
 
Registered: Nov 2003
Posts: 9

Original Poster
Rep: Reputation: 0
unSpawn, Thanks so much for the elaborate response. I will definately look into these things consider all of them as I continue to use linux regularly.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
determining shell abk4523 Linux - Newbie 2 06-09-2005 08:28 AM
Not determining IP addy? PlentifulBalls Fedora 16 09-28-2004 08:27 PM
determining fs type FirebirdV0273 Linux - General 3 10-09-2003 06:25 PM
determining hardware Abe_the_Man Linux - Newbie 2 09-08-2003 09:46 PM
Determining IP bluethundr Linux - Newbie 1 08-11-2003 11:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 06:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration