Splunk Search

Need help forming search string to show when users create new users

jcorkey
Explorer

I have a linux box with a universal forwarder sending linux data to my Splunk enterprise. I am trying to detect when a user creates another user by running useradd User2
Below is my search string:

index=main host=myhost useradd

This gives me the logs I want but how do I know the username of the user that created the new user?

For example. User1 creates User2....The logs show that User2 was created but it only shows the uid of User1 who did the creating and it does not tell me the actual username which should be User1.

How do I get the username of the user who creates new users??

0 Karma

woodcock
Esteemed Legend

Use a cron like this:

01 23 * * * * /bin/cat /etc/passwd | /bin/awk -F: 'BEGIN {OFS=","; print "UID,login,FullName"} {print $3,$1,$5}' > /tmp/eraseme.csv && /bin/cat /tmp/splunk_user_lookup.csv /tmp/eraseme.csv | sort -ru > /tmp/eraseme2.csv && /bin/mv -f /tmp/eraseme2.csv /tmp/splunk_user_lookup.csv && /bin/scp Your scp stuff here to copy this to your Search Head or Deployer or Deployment Server and run reload deploy-server or whatever too if you need to
0 Karma

s2_splunk
Splunk Employee
Splunk Employee

If you don't already have the mapping somewhere in Splunk, you could create a scripted input that executes cat /etc/passwd at a reasonable frequency and index those results with proper field extractions. You can then either create a lookup table from that with a scheduled search (run once a day to update?) or use a subsearch.

0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...