<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: convert string to binary in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/convert-string-to-binary/m-p/341893#M5268</link>
    <description>&lt;P&gt;Try this macro:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[IP32BitToDottedQuad(2)]
args = 32BitIP, newFieldName
definition = `comment("This creates a new field (the last arg) by converting \
a 32-bit packed IP address (the first arg) to Dotted-Quad format")` \
| rex field=$32BitIP$ "(?i)(?&amp;lt;JuNkT3Mp_1&amp;gt;[0-9A-F]{2})(?&amp;lt;JuNkT3Mp_2&amp;gt;[0-9A-F]{2})(?&amp;lt;JuNkT3Mp_3&amp;gt;[0-9A-F]{2})(?&amp;lt;JuNkT3Mp_4&amp;gt;[0-9A-F]{2})" \
| eval $newFieldName$ \
= tostring(tonumber(JuNkT3Mp_1,16)) + "." \
+ tostring(tonumber(JuNkT3Mp_2,16)) + "." \
+ tostring(tonumber(JuNkT3Mp_3,16)) + "." \
+ tostring(tonumber(JuNkT3Mp_4,16)) \
| eval $newFieldName$ = \
if((NOT match($newFieldName$, "Null")), $newFieldName$, "unconvertable") \
| fields - JuNkT3Mp_*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 13 Jun 2017 12:49:54 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-06-13T12:49:54Z</dc:date>
    <item>
      <title>convert string to binary</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/convert-string-to-binary/m-p/341888#M5263</link>
      <description>&lt;P&gt;hi &lt;BR /&gt;
how can i convert string to the form of ip add.when i search the ip add it shows ip add in the form of string instead of ip add format.&lt;/P&gt;

&lt;P&gt;is there any solution to convert string to binary format of ip add?&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2017 12:11:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/convert-string-to-binary/m-p/341888#M5263</guid>
      <dc:creator>khanlarloo</dc:creator>
      <dc:date>2017-06-10T12:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: convert string to binary</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/convert-string-to-binary/m-p/341889#M5264</link>
      <description>&lt;P&gt;do you have any example data you can share?  And/Or could you elaborate a bit?  What is the difference between the string representation and the IP address form?&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2017 12:28:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/convert-string-to-binary/m-p/341889#M5264</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2017-06-10T12:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: convert string to binary</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/convert-string-to-binary/m-p/341890#M5265</link>
      <description>&lt;P&gt;you can find a sample log file below &lt;/P&gt;

&lt;P&gt;"May 13 17:55:05 192.168.10.16 May 13 17:55:05 wsm-2 attack: risk=Low, event=""Backend error"", proxy=""both://gsh:443"", proxy_id=31, log_id=3545324, source=""81.91.144.51"", violation=""General request violation"", path=""/content/assets/css/byekan.woff"", method=""GET"", node=""wsm-2.rb.snig.armandata.net"", action=""Allow"", time=""May 13 17:54:58 2017""","2017-05-13T17:55:05.000+0430",Allow,"81.91.144.51",17,13,55,may,5,saturday,2017,local,"Backend error",,,"192.168.10.16",main,1,3545324,GET,"wsm-2.rb.snig.armandata.net",,"/content/assets/css/byekan.woff",,attack,,"both://gsh:443",31,"&lt;STRONG&gt;::_...&lt;/STRONG&gt;&lt;EM&gt;::&lt;/EM&gt;-&lt;EM&gt;:&lt;/EM&gt;=,&lt;EM&gt;=""&lt;/EM&gt;"",&lt;EM&gt;=""://..:"",&lt;/EM&gt;=,&lt;EM&gt;=,&lt;/EM&gt;=""...""",Low,"udp:514",syslog,SIEM,,,,"May 13 17:54:58 2017",15,0,,"General request violation"&lt;/P&gt;

&lt;P&gt;as you see the  source field contains IP address that i want  extract it.&lt;BR /&gt;
and use it in Choropleth Map&lt;BR /&gt;
how can i do that.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:25:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/convert-string-to-binary/m-p/341890#M5265</guid>
      <dc:creator>khanlarloo</dc:creator>
      <dc:date>2020-09-29T14:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: convert string to binary</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/convert-string-to-binary/m-p/341891#M5266</link>
      <description>&lt;P&gt;I think it means to convert a quad format string representation of the numeric IP address into a binary representation of the numeric value.  For example, the numeric value of 255.0.0.1 is 255*2^24 + 0*2^16 + 0*2^8 + 1*2 = (dec)4278190081 = (bin)11111111000000000000000000000001.  Sometimes it is useful to use decimal string or hexadecimal string of the address value, but I really don't see what benefit could it be to use a binary string representation.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:25:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/convert-string-to-binary/m-p/341891#M5266</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2020-09-29T14:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: convert string to binary</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/convert-string-to-binary/m-p/341892#M5267</link>
      <description>&lt;P&gt;I'll just convert the quad string representation to the numeric address.  After this, you can decide which representation to use for this value.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| regex field=ip "(?&amp;lt;quad4&amp;gt;\d+)\.(?&amp;lt;quad3&amp;gt;\d+)\.(?&amp;lt;quad2&amp;gt;\d+)\.(?&amp;lt;quad1&amp;gt;\d+)"
| eval NumericIP=quad4*pow(2,24) + quad3*pow(2,16) + quad2*pow(2,8) + quad1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There is no printf conversion to convert this numeric value into a binary representation, so you'll have to write your own using / and %.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2017 17:30:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/convert-string-to-binary/m-p/341892#M5267</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2017-06-10T17:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: convert string to binary</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/convert-string-to-binary/m-p/341893#M5268</link>
      <description>&lt;P&gt;Try this macro:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[IP32BitToDottedQuad(2)]
args = 32BitIP, newFieldName
definition = `comment("This creates a new field (the last arg) by converting \
a 32-bit packed IP address (the first arg) to Dotted-Quad format")` \
| rex field=$32BitIP$ "(?i)(?&amp;lt;JuNkT3Mp_1&amp;gt;[0-9A-F]{2})(?&amp;lt;JuNkT3Mp_2&amp;gt;[0-9A-F]{2})(?&amp;lt;JuNkT3Mp_3&amp;gt;[0-9A-F]{2})(?&amp;lt;JuNkT3Mp_4&amp;gt;[0-9A-F]{2})" \
| eval $newFieldName$ \
= tostring(tonumber(JuNkT3Mp_1,16)) + "." \
+ tostring(tonumber(JuNkT3Mp_2,16)) + "." \
+ tostring(tonumber(JuNkT3Mp_3,16)) + "." \
+ tostring(tonumber(JuNkT3Mp_4,16)) \
| eval $newFieldName$ = \
if((NOT match($newFieldName$, "Null")), $newFieldName$, "unconvertable") \
| fields - JuNkT3Mp_*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Jun 2017 12:49:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/convert-string-to-binary/m-p/341893#M5268</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-13T12:49:54Z</dc:date>
    </item>
  </channel>
</rss>

