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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...