Splunk Search

File Deletion search query

mailmetoramu
Explorer

Hi All,

Actually in one of my server, some files has been deleted from the file path C\Windows\Systems32\drivers\etc\hosts.

Under the hosts, the file has been completely deleted by someone, need to investigate on that.

Can anyone tell me exact query i need to type in search head to fetch the logs from splunk from this particular directory.

Thanks,

Ramu.R

Tags (1)
0 Karma

iamarkaprabha
Contributor

If your windows AD data is coming into splunk indexes, then you can identify who has deleted it most probably

adonio
Ultra Champion

i think it will be good to double check, without proper auditing rules enabled on the directory or file prior to deletion, imho widows will not log the file deletion.

0 Karma

mailmetoramu
Explorer

All proper rules has been enabled perfectly. Just mention only the required query instead of posting links for articles, i have already gone through 100s of link like these, then only i came here for answer.

0 Karma

adonio
Ultra Champion

in that case, look for ... EventCode=4656 ... <file name> ...

0 Karma

mailmetoramu
Explorer

Hi Adonio,

Can you paste the complete query here

0 Karma

mailmetoramu
Explorer

Hi All,

Lets make my question as below :

Hostname : abc123

File Path : C\Windows\System32\drivers\etc\hosts

Under the hosts, the file has been completely deleted by someone. Can anyone tell me exact query for this scenario.

Thanks,

Ramu.R

0 Karma

iamarkaprabha
Contributor

I think it will log those info. The event code for file deletion is 4656 .
Please refer to the below links for more information.

https://www.netwrix.com/how_to_detect_who_deleted_file.html
https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/event.aspx?eventid=4656

0 Karma

ddrillic
Ultra Champion

Can you please try? index=* source="C:\\Windows\\Systems32\\drivers\\etc\\hosts.*"

0 Karma

adonio
Ultra Champion

are you pulling that data into splunk?
to find deletions or file modifications, you will have to enable auditing on that particular directory / file
this is being done on the windows (OS) side. also, you will have to pull and bring windows security event logs to splunk

0 Karma

mailmetoramu
Explorer

Hi ddrillic,

Its not working actually, moreover i did not see the host name mentioned in your query.

Thanks,

Ramu.R

0 Karma
Get Updates on the Splunk Community!

Observability Unlocked: Kubernetes Monitoring with Splunk Observability Cloud

 Ready to master Kubernetes and cloud monitoring like the pros? Join Splunk’s Growth Engineering team for an ...

Update Your SOAR Apps for Python 3.13: What Community Developers Need to Know

To Community SOAR App Developers - we're reaching out with an important update regarding Python 3.9's ...

October Community Champions: A Shoutout to Our Contributors!

As October comes to a close, we want to take a moment to celebrate the people who make the Splunk Community ...