public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
From: Lev Stipakov <lstipakov@gmail.com>
To: linux-audit@redhat.com
Subject: Auditing network traffic
Date: Wed, 20 Jan 2016 16:26:34 +0200	[thread overview]
Message-ID: <n7o5eq$4qj$1@ger.gmane.org> (raw)

Hello,

I work on an audisp plugin which audits network traffic – what process 
has send/received data to/from what remote address. So far I see 2 ways 
of accomplishing that:

Hook syscalls. First, hook socket call with af_inet/inet6 to get pid and 
fd, then read/write/sendto/recvfrom filtered by pid and fd. I see few 
issues with this appoach:

1) Fd can be closed or duped, so I should probably hook close/dup2 calls 
too. Not sure, though, if socket could be closed by kernel without any 
syscall. As a workaroud, one can just hook read/write and check if fd is 
socket (S_ISSOCK) and also somehow filter out af_unix.

2) Getting saddr/daddr. Seems that dest addr could be obtained from 
connect call. However I am not sure what is the right way to get that - 
I got two records, first SYSCALL and then SOCKADDR. First one has an 
argument which points to memory location where sockaddr structure lays, 
and second one has ”saddr” field.  Latter looks good, but does SOCKADDR 
event type always follows SYSCALL for connect call? Same for sendto call.

Another way of getting network stats is the AUDIT target for netfilter. 
Looks good, no need to worry about fds/addrs. However there is no pid. 
What would be the ”best” way to get pid for those records? Anything else 
besides looking into /proc/net/tcp?

-Lev

--
Linux-audit mailing list
Linux-audit@redhat.com
https://www.redhat.com/mailman/listinfo/linux-audit

             reply	other threads:[~2016-01-20 14:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-20 14:26 Lev Stipakov [this message]
2016-01-20 15:18 ` Auditing network traffic Steve Grubb
2016-01-20 15:29   ` Steve Grubb
2016-01-20 18:05     ` F Rafi
2016-01-20 18:30       ` Steve Grubb
2016-01-21  9:49     ` Lev Stipakov
2016-01-21 16:50       ` Steve Grubb
2016-01-21 20:49         ` Lev Stipakov
2016-01-21 22:09           ` Steve Grubb
2016-01-20 21:40 ` Paul Moore
2016-01-21  5:19 ` Peter Moody

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='n7o5eq$4qj$1@ger.gmane.org' \
    --to=lstipakov@gmail.com \
    --cc=linux-audit@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox