Splunk Search

How do I convert Hexadecial to text?

Miguel3393
Path Finder

In an index I have files in hexadecimal and I want to convert it to text in a search.

Is there a way to parse that file into hexadecimal and convert it to text

could you help me?,  greetings

Labels (1)
Tags (3)
0 Karma
1 Solution

yuanliu
SplunkTrust
SplunkTrust

Can you explain "I don't know the value that will come in hexadecimal?"  You have an event in the index.  You retrieve it, then apply urldecode.  If that value comes in a specific field,  just use that field.  You need to illustrate raw data (anonymize as needed) and explain its feature related to this question.

View solution in original post

Miguel3393
Path Finder

Thanks for the answers, I managed to get what I was looking for with the following.

| eval value=('Tipo_Trafico')
| eval ascii=urldecode(ltrim(replace(value,"([a-fA-F0-9]{2})","%\1"),"0x"))

0 Karma

yuanliu
SplunkTrust
SplunkTrust

Do you mean convert to decimal, like tonumber(hex, 16)?

Tags (1)
0 Karma

Miguel3393
Path Finder

no, i want to convert hexadecimal to text.

Example:
(Hexadecimal) 20456C20636F7272656F20656C656374726F6E69636F206465207475206375656E74612073652061637475616C697A6F


(conver to text) El correo electrónico de tu cuenta se actualizo

Regards.

0 Karma

yuanliu
SplunkTrust
SplunkTrust

You can lookup printf() but I am doubtful that SPL comes with an explicit UTF or any other encoding conversion.  

0 Karma

Miguel3393
Path Finder

I was able to get the text from the hexadecimal like this:

Miguel3393_0-1683841610244.png

But I need to do it by evaluating a file from an index, because I don't know the value that will come in hexadecimal, it will always come different.

0 Karma

yuanliu
SplunkTrust
SplunkTrust

Can you explain "I don't know the value that will come in hexadecimal?"  You have an event in the index.  You retrieve it, then apply urldecode.  If that value comes in a specific field,  just use that field.  You need to illustrate raw data (anonymize as needed) and explain its feature related to this question.

Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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