<?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 ARIN Rest API external lookup in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/ARIN-Rest-API-external-lookup/m-p/336108#M62136</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;This is my first time creating a external lookup, and I think am missing something. The error I am getting is "Error in 'lookup' command: Could not find all of the specified lookup fields in the lookup table."  Can someone please review and let me know what i am missing.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/opt/splunk/etc/apps/soc/local/transforms.conf

[arinrestapi]
 external_cmd = arinRestAPI.py src_ip
 fields_list = abuseemail,company

/opt/splunk/etc/apps/soc/bin/arinRestAPI.py

import csv
import json
import sys
import requests

def abuseEMail(ip):
     try:
         ipUrl = 'https://whois.arin.net/rest/ip/' + ip +'.json'
         r = requests.get(ipUrl)
         org = r.json()
         orgUrl = org['net']['orgRef']['$'] + '/pocs.json'
         r = requests.get(orgUrl)
         poc = r.json()
         abuseUrl = poc['pocs']['pocLinkRef'][2]['$'] + '.json'
         r = requests.get(abuseUrl)
         abuse = r.json()
         return abuse['poc']['emails']['email']['$']
     except:
         return ''

 def company(ip):
     try:
         ipUrl = 'https://whois.arin.net/rest/ip/' + ip +'.json'
         r = requests.get(ipUrl)
         org = r.json()
         orgUrl = org['net']['orgRef']['$'] + '/pocs.json'
         r = requests.get(orgUrl)
         poc = r.json()
         abuseUrl = poc['pocs']['pocLinkRef'][2]['$'] + '.json'
         r = requests.get(abuseUrl)
         abuse = r.json()
         return abuse['poc']['company']['$']
     except:
         return ''


 def main():
     if len(sys.argv) != 2:
         print "Usage: python arinRestAPI.py [ip field]"
         sys.exit(1)

     ipfield = sys.argv[1]

     infile = sys.stdin
     outfile = sys.stdout

     r = csv.DictReader(infile)
     header = r.fieldnames

     w = csv.DictWriter(outfile, fieldnames=r.fieldnames)
     w.writeheader()

     for result in r:
         if result[ipfield]:
         # only ip was provided, add host
             result[abuseEMail] = abuseEMail(result[ipfield])
             result[company] = copmany(result[ipfield])

 main()
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 05 Jun 2017 20:40:16 GMT</pubDate>
    <dc:creator>asucrews</dc:creator>
    <dc:date>2017-06-05T20:40:16Z</dc:date>
    <item>
      <title>ARIN Rest API external lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/ARIN-Rest-API-external-lookup/m-p/336108#M62136</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;This is my first time creating a external lookup, and I think am missing something. The error I am getting is "Error in 'lookup' command: Could not find all of the specified lookup fields in the lookup table."  Can someone please review and let me know what i am missing.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/opt/splunk/etc/apps/soc/local/transforms.conf

[arinrestapi]
 external_cmd = arinRestAPI.py src_ip
 fields_list = abuseemail,company

/opt/splunk/etc/apps/soc/bin/arinRestAPI.py

import csv
import json
import sys
import requests

def abuseEMail(ip):
     try:
         ipUrl = 'https://whois.arin.net/rest/ip/' + ip +'.json'
         r = requests.get(ipUrl)
         org = r.json()
         orgUrl = org['net']['orgRef']['$'] + '/pocs.json'
         r = requests.get(orgUrl)
         poc = r.json()
         abuseUrl = poc['pocs']['pocLinkRef'][2]['$'] + '.json'
         r = requests.get(abuseUrl)
         abuse = r.json()
         return abuse['poc']['emails']['email']['$']
     except:
         return ''

 def company(ip):
     try:
         ipUrl = 'https://whois.arin.net/rest/ip/' + ip +'.json'
         r = requests.get(ipUrl)
         org = r.json()
         orgUrl = org['net']['orgRef']['$'] + '/pocs.json'
         r = requests.get(orgUrl)
         poc = r.json()
         abuseUrl = poc['pocs']['pocLinkRef'][2]['$'] + '.json'
         r = requests.get(abuseUrl)
         abuse = r.json()
         return abuse['poc']['company']['$']
     except:
         return ''


 def main():
     if len(sys.argv) != 2:
         print "Usage: python arinRestAPI.py [ip field]"
         sys.exit(1)

     ipfield = sys.argv[1]

     infile = sys.stdin
     outfile = sys.stdout

     r = csv.DictReader(infile)
     header = r.fieldnames

     w = csv.DictWriter(outfile, fieldnames=r.fieldnames)
     w.writeheader()

     for result in r:
         if result[ipfield]:
         # only ip was provided, add host
             result[abuseEMail] = abuseEMail(result[ipfield])
             result[company] = copmany(result[ipfield])

 main()
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Jun 2017 20:40:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/ARIN-Rest-API-external-lookup/m-p/336108#M62136</guid>
      <dc:creator>asucrews</dc:creator>
      <dc:date>2017-06-05T20:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: ARIN Rest API external lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/ARIN-Rest-API-external-lookup/m-p/336109#M62137</link>
      <description>&lt;P&gt;I am making procgess but no running in this error "Script for lookup table 'arinrestapi' returned error code 1. Results may be incorrect."  I still missing something but I don't understand python enoght or I don't understand what Splunk is doing.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    [arinrestapi]
     allow_caching = 0
     case_sensitive_match = 0
     external_cmd = arinrestapi.py src_ip
     fields_list = src_ip,abuseemail,company

    import csv
     import json
     import sys
     import requests

     def abuseEMail(ip):
         try:
             ipUrl = 'https://whois.arin.net/rest/ip/' + ip +'.json'
             r = requests.get(ipUrl)
             org = r.json()
             orgUrl = org['net']['orgRef']['$'] + '/pocs.json'
             r = requests.get(orgUrl)
             poc = r.json()
             abuseUrl = poc['pocs']['pocLinkRef'][2]['$'] + '.json'
             r = requests.get(abuseUrl)
             abuse = r.json()
             return abuse['poc']['emails']['email']['$']
         except:
             return ''

     def company(ip):
         try:
             ipUrl = 'https://whois.arin.net/rest/ip/' + ip +'.json'
             r = requests.get(ipUrl)
             org = r.json()
             orgUrl = org['net']['orgRef']['$'] + '/pocs.json'
             r = requests.get(orgUrl)
             poc = r.json()
             abuseUrl = poc['pocs']['pocLinkRef'][2]['$'] + '.json'
             r = requests.get(abuseUrl)
             abuse = r.json()
             return abuse['poc']['companyName']['$']
         except:
             return ''

     def main():
         if len(sys.argv) != 2:
             print "Usage: python arinRestAPI.py [ip field]"
             sys.exit(1)

         ipfield = sys.argv[1]

         infile = sys.stdin
         outfile = sys.stdout

         r = csv.DictReader(infile)
         header = r.fieldnames

         w = csv.DictWriter(outfile, fieldnames=r.fieldnames)
         w.writeheader()

         for result in r:
             if result[ipfield]:
                 result[src_ip] = result[ipfield]
                 result[abuseemail] = abuseEMail(ipfield)
                 result[company] = company(ipfield)
                 w.writerow(result)

     main()
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Jun 2017 23:14:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/ARIN-Rest-API-external-lookup/m-p/336109#M62137</guid>
      <dc:creator>asucrews</dc:creator>
      <dc:date>2017-06-05T23:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: ARIN Rest API external lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/ARIN-Rest-API-external-lookup/m-p/336110#M62138</link>
      <description>&lt;P&gt;After playing with script i think my issue is with for result in r loop, but i not really sure.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2017 05:26:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/ARIN-Rest-API-external-lookup/m-p/336110#M62138</guid>
      <dc:creator>asucrews</dc:creator>
      <dc:date>2017-06-06T05:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: ARIN Rest API external lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/ARIN-Rest-API-external-lookup/m-p/336111#M62139</link>
      <description>&lt;P&gt;fix it, well sort of , changed it to one input field to get one output field.  not sure if there way to to one input to many outpu fields.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 23:02:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/ARIN-Rest-API-external-lookup/m-p/336111#M62139</guid>
      <dc:creator>asucrews</dc:creator>
      <dc:date>2017-06-08T23:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: ARIN Rest API external lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/ARIN-Rest-API-external-lookup/m-p/336112#M62140</link>
      <description>&lt;P&gt;Can you share the final working version? I am still getting error.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 15:01:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/ARIN-Rest-API-external-lookup/m-p/336112#M62140</guid>
      <dc:creator>manish20171</dc:creator>
      <dc:date>2018-07-26T15:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: ARIN Rest API external lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/ARIN-Rest-API-external-lookup/m-p/575894#M101790</link>
      <description>&lt;P&gt;could you provide step by step procedure?&amp;nbsp; We need to do same for us.&amp;nbsp; Thanks in advance for you help.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 15:40:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/ARIN-Rest-API-external-lookup/m-p/575894#M101790</guid>
      <dc:creator>youngsuh</dc:creator>
      <dc:date>2021-11-22T15:40:37Z</dc:date>
    </item>
  </channel>
</rss>

