Splunk Search

How to prepend a value to a field at search-time to sanitize malicious URLs?

JSkier
Communicator

I'd like to sanitize host names during search time in Splunk (IDS alerts), so users don't receive a hyperlink to the bad sites and the alerts don't get snagged by the mail filter. I'd like to keep the inline table results of the alerts for mobile users and general convenience.

For example, www.badsite.com is automatically hyperlinked in e-mail clients, so I'd like to prepend hxxp:// to the field so the sent alert message doesn't get hyperlink or dropped. By specifying a bogus protocol both fat mail client and mail scanner will pass the inline table without issue.

I found something about appending in the community, but that just shows a blank field during search for me (even when I assign httphostname without a period).

eval http.hostname=http.hostname."hxxp://" |

In theory, I'd like this to prepend and actually work:

eval http.hostname="hxxp://".http.hostname |

I'm using Splunk 6.3.2 in a clustered Linux environment, any help is appreciated.

0 Karma
1 Solution

woodcock
Esteemed Legend

Assuming that you have a field called http.hostname then like this:

... | eval "http.hostname" = "hxxp://" . $http.hostname$

Or possibly this:

... | rex field="http.hostname" mode=sed "s/^http:/hxxp:/"

View solution in original post

woodcock
Esteemed Legend

Assuming that you have a field called http.hostname then like this:

... | eval "http.hostname" = "hxxp://" . $http.hostname$

Or possibly this:

... | rex field="http.hostname" mode=sed "s/^http:/hxxp:/"

JSkier
Communicator

This worked perfectly, thanks!
... | eval "http.hostname" = "hxxp://" . $http.hostname$

0 Karma

sundareshr
Legend

Try putting your field name with single quotes. Like this

| eval http.hostname="hxxp://".`http.hostname`
0 Karma

JSkier
Communicator
Error in 'SearchParser': The name 'http.hostname' is invalid. Macro and argument names may only include alphanumerics, '_' and '-'. 
0 Karma
Get Updates on the Splunk Community!

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...

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 ...