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!

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

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...