Skip to content
Mateusz Piotrowski edited this page Jul 4, 2016 · 9 revisions

2016-05-30

Print audit logs onto stdout

  1. Make sure your kernel has options AUDIT.
  2. Run praudit /dev/auditpipe.

Resources:

  • auditpipe(4)

Token types definitions

The token type indentifiers are defined in /sys/bsd/bsm/audit_record.h.

Parsing audit logs

It is recommended to use libbsm(3).

2016-06-01

Let's try to learn how the audit_events file is generated and how to add new events.

  1. audit_events can be found in contrib/openbsm/etc.

  2. According to the comments inside audit_events I should modify audit_event, audit_kevents.h and audit_uevents.h and recompile the kernel.

The paths are:

    contrib/openbsm/etc/audit_events
    contrib/openbsm/bsm/audit_uevents.h
    contrib/openbsm/bsm/audit_kevents.h
  1. contrib/openbsm/etc/ has sample configuration files. Nothing special. (Source: contrib/openbsm/README)

  2. FreeBSD seems to ignore the audit_uevents.h file since I cannot find it in the sys/bsm directory. Actually, it doesn't seem to be an important file to FreeBSD anyway.

2016-06-02

A BSM audit record is made of tokens. The record starts with a header token and ends with a trailer token.

The Linux Audit audit fields can be stored in the arbitrary data token.

Cracking the mapping of Linux Audit to BSM

(Source)

Let's try to break down the audit trail of the cat /etc/ssh/sshd_config command.

The trail of that command might look like this:

type=SYSCALL msg=audit(1364481363.243:24287): arch=c000003e syscall=2 success=no exit=-13 a0=7fffd19c5592 a1=0 a2=7fffd19c4b50 a3=a items=1 ppid=2686 pid=3538 auid=500 uid=500 gid=500 euid=500 suid=500 fsuid=500 egid=500 sgid=500 fsgid=500 tty=pts0 ses=1 comm="cat" exe="/bin/cat" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key="sshd_config"
type=CWD msg=audit(1364481363.243:24287):  cwd="/home/shadowman"
type=PATH msg=audit(1364481363.243:24287): item=0 name="/etc/ssh/sshd_config" inode=409248 dev=fd:00 mode=0100600 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:etc_t:s0

type=SYSCALL

Linux Audit field mapped to notes
type=SYSCALL Every type should be mapped to a token.
msg=audit(1364481363.243:24287) The ID might be mapped to the seq token and the time stamp can stored in the header token.
arch=c000003e Create a new event to save this information.
syscall=2 Consult the Linux Syscall Table.
success=no
exit=-13
a0=7fffd19c5592
a1=0
a2=7fffd19c4b50
a3=a
items=1
ppid=2686
pid=3538
auid=500
uid=500
gid=500
euid=500
suid=500
fsuid=500
egid=500
sgid=500
fsgid=500
tty=pts0
ses=1
comm="cat"
exe="/bin/cat"
subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
key="sshd_config"

type=CWD

Linux Audit field mapped to notes
type=CWD
msg=audit(1364481363.243:24287)
cwd="/home/shadowman"

type=PATH

Linux Audit field mapped to notes
type=PATH
msg=audit(1364481363.243:24287)
item=0
name="/etc/ssh/sshd_config"
inode=409248
dev=fd:00
mode=0100600
ouid=0
ogid=0
rdev=00:00
obj=system_u:object_r:etc_t:s0

Understanding audit events

The format of the events in the /etc/security/audit_event is number:name:description:flags.

2016-06-05

Linux Audit

An audit file is made of audit events. An audit event is made of records. A record starts with the type= keyword. The records of an event share the same time stamp and serial number.

BSM

An audit file is made of records. A record is made of tokens.

2016-06-25

TAILQ