<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>What’s the “best way to do it” is dependent on your system.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>That said, I can offer two non-audit suggestions.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>One I call the “Old Shell Game”. Stick this bash code in in the appropriate system wide bash file:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>function log<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>{<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> typeset x<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> x=$(history 1 | cut -f 5-)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> logger -p daemon.notice -t "$LOGNAME" $PWD "${x#        }"<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>}<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>trap log DEBUG<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>And you get things like this in your syslog:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>Apr  8 13:50:51 dr-who root: /root    18  ls -ls /etc/pam.d/*su*<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>Apr  8 13:51:17 dr-who root: /root    19  ps -ef | grep audit | grep -v grep<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>Apr  8 13:51:53 dr-who root: /root    20  ps -ef | grep -v root | wc –l <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>Apr  8 13:52:31 dr-who root: /root    21  ps -ef | grep -v root | sort | more<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Is this easy to defeat? Yup. But it will let you get experiment with command logging and see if it’s really of any benefit to you.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Another is use the program called “snoopy” available at <a href="http://sourceforge.net/projects/snoopylogger/">http://sourceforge.net/projects/snoopylogger/</a><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>It uses a little known feature of the Linux loader, namely, LD_PRELOAD. <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Once you’ve got it in place you get output like this:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";color:black'>Apr 13 16:55:19 dr-who snoopy[2029]: [uid:0 sid:1890 tty:/dev/pts/1 cwd:/root filename:/bin/uname]: uname </span><span style='color:black'>–</span><span style='font-family:"Courier New";color:black'>a</span><span style='font-family:"Arial","sans-serif";color:black'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";color:black'>Apr 13 16:56:18 dr-who snoopy[2031]: [uid:0 sid:1890 tty:/dev/pts/1 cwd:/root filename:/bin/ps]: ps </span><span style='color:black'>–</span><span style='font-family:"Courier New";color:black'>ef</span><span style='font-family:"Arial","sans-serif";color:black'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";color:black'>Apr 13 16:57:50 dr-who snoopy[2035]: [uid:0 sid:1890 tty:/dev/pts/1 cwd:/root filename:/bin/ps]: ps -ef </span><span style='font-family:"Arial","sans-serif";color:black'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";color:black'>Apr 13 16:57:50 dr-who snoopy[2036]: [uid:0 sid:1890 tty: cwd:/root filename:/bin/grep]: grep audit </span><span style='font-family:"Arial","sans-serif";color:black'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";color:black'>Apr 13 16:57:50 dr-who snoopy[2037]: [uid:0 sid:1890 tty: cwd:/root filename:/bin/grep]: grep -v grep <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-family:"Calibri","sans-serif";color:black'>It’s not as easy to circumvent as the above bash code. As a suggestion based on experience, don’t put snoopy into affect until after the system is up. You really don’t want to log all the commands root does in the process of starting up a system.<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-family:"Calibri","sans-serif";color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-family:"Calibri","sans-serif";color:black'>I hope this helps.<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-family:"Calibri","sans-serif";color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-family:"Calibri","sans-serif";color:black'>Best regards,<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-family:"Calibri","sans-serif";color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-family:"Calibri","sans-serif";color:black'>Gary Smith<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-family:"Calibri","sans-serif";color:black'>Information System Security Officer<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-family:"Calibri","sans-serif";color:black'>Pacific Northwest National Laboratory</span><span style='font-family:"Calibri","sans-serif";color:black'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> linux-audit-bounces@redhat.com [mailto:linux-audit-bounces@redhat.com] <b>On Behalf Of </b>zhu xiuming<br><b>Sent:</b> Wednesday, October 09, 2013 3:11 PM<br><b>To:</b> Steve Grubb<br><b>Cc:</b> Richard Guy Briggs; Linux-audit@redhat.com<br><b>Subject:</b> Re: how to use auditd to record all user command history<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><div><div><div><p class=MsoNormal>Thanks. <o:p></o:p></p></div><p class=MsoNormal style='margin-bottom:12.0pt'>I know the kernel do the most work. So, I can't use pam_tty_audit for our hosts. <o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'>However, I still hope to record user command history. I just wonder what is the best way to do it. <br><br><o:p></o:p></p></div></div></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p> </o:p></p><div><p class=MsoNormal>On Wed, Oct 9, 2013 at 2:57 PM, Steve Grubb <<a href="mailto:sgrubb@redhat.com" target="_blank">sgrubb@redhat.com</a>> wrote:<o:p></o:p></p><div><p class=MsoNormal style='margin-bottom:12.0pt'>On Wednesday, October 09, 2013 02:51:39 PM zhu xiuming wrote:<br>> So, if I can't update all kernels (the cost will be very high), is there<br>> any other way to resolve this issue?<o:p></o:p></p></div><p class=MsoNormal>The kernel is what does all the heavy work in the audit system. Auditd only<br>records to disk, pam_tty_audit and auditctl tell the kernel what they are<br>interested in. But all the action is in the kernel, not user space.<br><span style='color:#888888'><br><span class=hoenzb>-Steve</span></span><o:p></o:p></p><div><div><p class=MsoNormal style='margin-bottom:12.0pt'><br>> On Tue, Oct 8, 2013 at 2:33 PM, Richard Guy Briggs <<a href="mailto:rgb@redhat.com">rgb@redhat.com</a>> wrote:<br>> > On Tue, Oct 08, 2013 at 02:05:48PM -0700, zhu xiuming wrote:<br>> > > Thanks for your reply.<br>> > > Currently, our Linux kernel versions are mostly Redhat 2.6.18-xxx.el5. I<br>> > > wonder whether it supports this feature.<br>> ><br>> > The log_passwd feature has not been backported to RHEL5 because the<br>> > pam_tty_audit feature wasn't backported to RHEL5, so I would have to say<br>> > it is not supported in your system.<br>> ><br>> > An upgrade is necessary.<br>> ><br>> > > On Mon, Oct 7, 2013 at 8:13 PM, Richard Guy Briggs <<a href="mailto:rgb@redhat.com">rgb@redhat.com</a>><br>> ><br>> > wrote:<br>> > > > On Mon, Oct 07, 2013 at 10:30:24AM -0700, zhu xiuming wrote:<br>> > > > > This is correct. The problem is,  this records every keystrokes and<br>> ><br>> > even<br>> ><br>> > > > > the password of the users. While I only care about the user command<br>> > > > > history, I surely do not want to know their passwords.<br>> > > ><br>> > > > There is now support in the upstream kernel (3.10-rc1) and in pam<br>> > > > (1.1.8+) to not record passwords by default.  If you want the old<br>> > > > behaviour, add the optional argument to pam_tty_audit: "log_passwd"<br>> > > ><br>> > > > > On Sun, Oct 6, 2013 at 2:40 PM, Trevor Vaughan <<br>> ><br>> > <a href="mailto:tvaughan@onyxpoint.com">tvaughan@onyxpoint.com</a><br>> ><br>> > > > >wrote:<br>> > > > > > Does pam_tty_audit with enable=* not do what you want?<br>> > > > > ><br>> > > > > > Trevor<br>> > > > > ><br>> > > > > > On Sun, Oct 6, 2013 at 5:26 PM, zhu xiuming <<a href="mailto:xiumingzhu@gmail.com">xiumingzhu@gmail.com</a>><br>> > > ><br>> > > > wrote:<br>> > > > > >> HI<br>> > > > > >> I know this seems an old topic. But unfortunately, I can't find a<br>> > > > > >> solution for this. I have googled long time. I tried following<br>> > > ><br>> > > > options:<br>> > > > > >> 1. audit execv syscall,<br>> > > > > >><br>> > > > > >>     this does record every command typed any tty. However, it<br>> > > ><br>> > > > generates<br>> > > ><br>> > > > > >> lots of noise.  Sometimes, the execv syscall is so frequently<br>> ><br>> > called<br>> ><br>> > > > that<br>> > > ><br>> > > > > >> the system can't afford to log every call of it and it crashes<br>> > > > > >> !!!<br>> > > > > >><br>> > > > > >> 2. use *pam_tty_audit.so<br>> > > > > >> *<br>> > > > > >> this makes it possible to record one or two users, not all users.<br>> ><br>> > *<br>> ><br>> > > > > >> *<br>> > > > > >> So, may I ask, is this problem solvable by auditd or do I need<br>> ><br>> > other<br>> ><br>> > > > > >> tools ?*<br>> > > > > >><br>> > > > > >> *<br>> > > > > >> *Thanks a lot<br>> > > > > ><br>> > > > > > Trevor Vaughan<br>> > > ><br>> > > > - RGB<br>> ><br>> > - RGB<br>> ><br>> > --<br>> > Richard Guy Briggs <<a href="mailto:rbriggs@redhat.com">rbriggs@redhat.com</a>><br>> > Senior Software Engineer<br>> > Kernel Security<br>> > AMER ENG Base Operating Systems<br>> > Remote, Ottawa, Canada<br>> > Voice: <a href="tel:%2B1.647.777.2635">+1.647.777.2635</a><br>> > Internal: (81) 32635<br>> > Alt: <a href="tel:%2B1.613.693.0684x3545">+1.613.693.0684x3545</a><o:p></o:p></p></div></div></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>