Splunk Search

Proxy log regex: search for attachments

tlmayes
Contributor

We are trying to extract from the field "url" all files transferred as part of a session. The ultimate goal is to keep track of all filenames and extensions, with the ability to sort and report on file activity available within the proxy logs.

I started with the intent to prove that a regex worked that would list all url's that included a file name and pre-identified extensions (or all extensions), and then was going to search against the results to pull out the complete filename for reporting (divide and conquer). I tested my regex using several regex sites (ex. REGEX101.com). All accepted the regex as valid but am unable to get it to run in Splunk.

Running the Splunk cmd without success, continue to receive the error "Missing closing tick mark in macro expression". Unable to find any details on what this is referring to, especially since the test on non-Splunk resources give positive results? Where or what is this referring to? Is there a better way to achieve the results?:

| regex _raw="((?:https?:\/\/|www\.)(?:[\dA-Za-z-]++\.)+[A-Za-z]{2,6}+(?:\/[]\w!"#$%&'()*+,.:;<=>?@[\\{|}~^-]+){0,9}\/[\w.-]+.(?:bat|exe|pdf|js|msi))"`

Am able to successfully run the following, but only after stripping out the capability to only return URL's with files and interesting extensions at the end of the URL:
| regex _raw="((?:https?:\/\/|www.)(?:[\dA-Za-z-]++.)+[A-Za-z]{2,6}+(?:))"

Thanks in advance for any assist

0 Karma

adauria_splunk
Splunk Employee
Splunk Employee

I think you will need to escape your single and double quotes and backticks in the string by preceding them with a backslash. Otherwise Splunk sees them as control characters rather than literal quotes that you are matching.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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