Splunk Search
Highlighted

## Converting an encoded IP address to dotted decimal

Communicator

I've got a log that includes an obfuscated IP address. The source takes dotted decimal, reverses the order of the octets, converts them to binary, concatenates them, and then converts to decimal.

For example:
10.9.8.7 is turned around:
7 8 9 10
Then the octets are changed to binary:
00000111 00001000 00001001 00001010
Then all smashed together:
00000111000010000000100100001010
Then converted to a decimal number:
117967114
And that's what I get in the log. Are there any fun tools in Splunk that would help? If the set were limited, I could just use a lookup table.

Tags (4)
Highlighted

## Re: Converting an encoded IP address to dotted decimal

Super Champion

You could write a script to evaluate the obfuscated data - here is something similar from a Splunk blog post:

http://blogs.splunk.com/2011/07/19/the-naughty-bits-how-to-splunk-binary-logfiles/

Highlighted

## Re: Converting an encoded IP address to dotted decimal

Communicator

OK - This is what worked:

`| eval ip=if(encip<1,encip+2147483648,enc_ip) | eval aaa=floor(ip/16777216) | eval     bbb=floor((ip-aaa*16777216)/65536) | eval ccc=floor((ip-(aaa*16777216+bbb*65536))/256)| eval ddd=ip-(aaa*16777216+bbb*65536+ccc*256) | eval ipv4=tostring(ddd)+"."+tostring(ccc)+"."+tostring(bbb)+"."+tostring(aaa)`

Highlighted

Super Champion

Very clever.

Highlighted

## Re: Converting an encoded IP address to dotted decimal

Builder

One question, which is the source field, i mean, the field with the decimal IP? enc_ip?

Highlighted

## Re: Converting an encoded IP address to dotted decimal

Explorer

What if you want to match the ip against another CSV file to see if it falls in the range?
looks like this
(( 3743019008, -----> this is actually 223.25.240.0 if converted to IP format
3743020031, -----> range end 223.25.243.255
'http://thegigabit.com/'),