Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

false positive when "netstat -tan |grep LISTEN |grep -v 127.0.0.1 | sort" because of Recv-Q #495

Open
nethubonline opened this issue Jan 13, 2015 · 3 comments

Comments

@nethubonline
Copy link

I asked in Google forum here: https://groups.google.com/forum/#!topic/ossec-list/2kcJlXDlSh0

I received alert for port change, however, there is no change, but only change on "Recv-Q"

OSSEC version: 2.8.1

OSSEC HIDS Notification.
2015 Jan 06 11:21:11

Received From: www->netstat -tan |grep LISTEN |grep -v 127.0.0.1 | sort
Rule: 533 fired (level 7) -> "Listened ports status (netstat) changed (new port opened or closed)."
Portion of the log(s):

ossec: output: 'netstat -tan |grep LISTEN |grep -v 127.0.0.1 | sort':
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp6 0 0 ::1:25 :::* LISTEN
tcp6 0 0 :::21 :::* LISTEN
Previous output:
ossec: output: 'netstat -tan |grep LISTEN |grep -v 127.0.0.1 | sort':
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 3 0 0.0.0.0:443 0.0.0.0:* LISTEN
tcp6 0 0 ::1:25 :::* LISTEN
tcp6 0 0 :::21 :::* LISTEN

Possible solution: netstat -tan | grep LISTEN |grep -v 127.0.0.1 | awk '{ print $1,$4,$5}' | sort

@aquerubin
Copy link
Contributor

As long as we're talking about fixing this. please add the IPv6 loopback address as well to the fix. Ie. the grep should be changed to:

grep -v '(127.0.0.1| ::1)' or egrep -v '(127.0.0.1| ::1)'

The latter looks cleaner. Note the space before the two colons is important to prevent removing entries containing regular IPv6 addresses that end with ::1. The IPv6 branch already has this.

@ddpbsd
Copy link
Member

ddpbsd commented Jan 13, 2015

@aquerubin Does the egrep work on Solaris and AIX out of the box?

@aquerubin
Copy link
Contributor

On Tue, 13 Jan 2015, ddpbsd wrote:

@aquerubin Does the egrep work on Solaris and AIX out of the box?

Having neither system I can't say either way.

Antonio Querubin
e-mail: [email protected]
xmpp: [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants