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!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...