[sf-lug] interlopers continued

Michael Paoli Michael.Paoli at cal.berkeley.edu
Sat Jul 21 08:05:52 PDT 2007

[snipped: lots of stuff about "interesting" looking apparent IRC
connections, e.g.:
et. seq.]

If the host is *not* root compromised, one may want to investigate
the connections a bit more, to determine if they're legitimate,
or case of authorized user exceeding their authority / violating policy
(but short of root compromise) ... or maybe some (quasi-?)legitimate
software with perhaps some undesired behavior(s).

E.g. with fuser or lsof (and possibly other tools too),
one should be able to isolate those TCP connections to the specific PIDs
that have them open.  From there, one can use ps and the /proc filesystem
to find out a lot more about those PIDs (e.g. what binary are they running,
what command line arguments/options, and what UID (user/login) is using
them, when did they start, from what directory, what's the PPID, TTY, etc.

Sometimes stuff that looks funky/suspicious ends up having a fairly easy
(but sometimes surprising) explanation.  It's often observed that when
folks set up firewalls (and monitoring/logging thereof) and/or look at
their various network activity in sufficient detail, especially if they're
not rather to quite well acquainted with such traffic, they'll think lots
of stuff they see is an "attack" or security problem or the like, when
it isn't really.  Of course there may also be illegitimate traffic,
problems, "attacks" or such in there too (speaking of which, I just blocked
another ssh "dictionary" attack as I'm typing this).

So, ... while it's good to at least keep in the back of your head that
stuff one sees may be indicative of a problem - or perhaps the system has
already been root compromised, ... it's often useful to first look for
more legitimate explanations ... and follow through on either or both
hypotheses until one can have a suitably high degree of confidence in
precisely one of those hypotheses.

Miscellaneous bits of related technical information.
UNIX/LINUX manual pages, typically noted in form, e.g.:
which would refer to the manual page on man, in section 1 of the UNIX/LINUX
This manual page can be examined via the man command, e.g. for fuser(1)
man 1 fuser
The section information can be omitted if the command is first found
in man page ordering in the desired section or the command only exists
in that one section.  Precise syntax for specifying man sections varies
among UNIX/LINUX/BSD flavors.
*nix (or *NIX) if often used as a shorthand for UNIX-like families of
operating systems (most notably LINUX, UNIX, and BSD, although there are
some others too).
E.g. using fuser and friends to investigate a connection:
$ netstat -an | fgrep
tcp        0      0        ESTABLISHED
$ fuser -n tcp 36594
36594/tcp:           23160
$ ps lwwwww 23160
0  1003 23160 23116   9   0  5124  392 select S+   pts/12     0:01 ssh -ax
$ ps uwwwww 23160
michael  23160  0.0  0.0  5124  392 pts/12   S+   Jun20   0:01 ssh -ax
PID - Process ID
PPID - Parent Process ID
UID - User ID
GID - Group ID
{E,R}{U,G}ID - {Effective,Real}{User,Group}ID
I/O - Input/Output
{a,b} - syntax often used (like C-shell) to show alternatives - either a or b
[foo] - man page like syntax also used to show optional portions
[abc] - Bourne/Bash/POSIX etc. syntax often used to show match to any one
        of the characters within the square brackets (see shell man pages
        for some of the more specific details/exceptions)
context matters, e.g. what is meant by [abe] will depend on context

If a system is root compromised, one cannot rely upon what it claims to
be the case - e.g. the output, behavior and actions of all commands are
suspect and may not be telling the truth at all.

If the host showing IRC connections was in fact root compromised, it's fairly
likely that netstat would be replaced, and that the illegitimate replacement
netstat command would likely not show the illegitimate connections.
Of course root compromises vary in their thoroughness of hiding the
compromise.  Perhaps some funky utility or such makes use of those IRC

Also, tools such as tcpdump may be useful to see what's being done with
those apparent IRC connections.  If the host is in fact root compromised,
that data could still be examined elsewhere on the network by a host
that hadn't been compromised (e.g. a LINUX based router with
tcpdump available on it).

Watching for unusual patters - e.g. in network traffic and/or disk I/O - is
often useful in detecting or noticing evidence of compromise, unauthorized
traffic/connections, or other problems (program gone nuts).  E.g. is one's
network activity LED showing heavy continuous activity when one would
expect it to have little to no activity?

And thus far still the case: how are most root/Administrator compromises
"detected"?  Not by folks that are (or should be) administering those
compromised systems, but by systems/network administrators of other systems
who complain that: "Hey, *your* box is beating away trying to
attack / break into *my* box/network!"

More information about the sf-lug mailing list