{"id":6314,"date":"2017-06-07T10:02:06","date_gmt":"2017-06-07T15:02:06","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=6314"},"modified":"2017-06-08T11:18:02","modified_gmt":"2017-06-08T16:18:02","slug":"interesting-way-to-get-domain-associated-with-amazon-ip","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2017\/06\/07\/interesting-way-to-get-domain-associated-with-amazon-ip\/","title":{"rendered":"Interesting way to get domain associated with Amazon IP"},"content":{"rendered":"<p>While looking for timeouts in splunk for an unrelated reason\u2026<\/p>\n<p><img alt='' class='alignnone size-full wp-image-6320 ' src='http:\/\/appcrawler.com\/wordpress\/wp-content\/uploads\/2017\/06\/img_5938154bae3cb.png' \/><\/p>\n<p>I noticed the Amazon IP\u2019s above.  We normally don\u2019t know the service they represent.  I connected to the IP in my browser on port 443, and noticed that of course the certificate fails, but exposes the domain name\u2026<\/p>\n<p><img alt='' class='alignnone size-full wp-image-6317 ' src='http:\/\/appcrawler.com\/wordpress\/wp-content\/uploads\/2017\/06\/img_59381498af087.png' \/><\/p>\n<p>Since I wanted to automate this, I found you can programmatically get this with the following python snippet.  The libraries other than splunklib are part of the stock install, and easily obtainable in any case.<\/p>\n<p>There may be a splunk plugin for this, as well, but my guess is not.<\/p>\n<pre>\r\nimport splunklib.client as client\r\nimport splunklib.results as results\r\nimport sys, socket, ssl\r\n\r\nservice = client.connect(host=\"mysplunk.com\",port=\"8089\",username=\"ad_username\",password=\"************\")\r\n\r\njob = \"\"\"\r\nsearch sourcetype=cisco:asa \\\"SYN Timeout\\\" \\\"outside:52.\\\" \r\n              | eval tmp=split(_raw,\\\"outside:\\\") \r\n              | eval tmp2=mvindex(tmp,1) \r\n              | eval tmp3=split(tmp2,\\\"\/\\\") \r\n              | eval tmp4=mvindex(tmp3,0) \r\n              | dedup tmp4\r\n\"\"\"\r\n\r\nrr = results.ResultsReader(service.jobs.oneshot(job,**{\"earliest_time\":\"2017-05-20T00:00:00.000-05:00\",\r\n                                                       \"latest_time\":\"2017-05-27T00:00:00.000-05:00\",\r\n                                                       \"count\": 0}))\r\nfor result in rr:\r\n  try:\r\n    hostname = result['tmp4']\r\n    ctx = ssl.create_default_context()\r\n    s = ctx.wrap_socket(socket.socket(), server_hostname=hostname)\r\n    try:\r\n      s.connect((hostname, 443))\r\n    except:\r\n      print hostname,sys.exc_info()[1]\r\n  except:\r\n    print sys.exc_info()[1]\r\n<\/pre>\n<p>This results in the following\u2026<\/p>\n<pre>\r\nc:\\>python.exe getcert.py\r\n52.72.186.111 hostname '52.72.186.111' doesn't match either of '*.adobecqms.net', 'adobecqms.net'\r\n52.203.237.77 hostname '52.203.237.77' doesn't match either of 'apiv2.shoprunner.com', 'www.apiv2.shoprunner.com'\r\n52.206.185.128 hostname '52.206.185.128' doesn't match either of '*.cylance.com', 'cylance.com'\r\n52.207.41.45 hostname '52.207.41.45' doesn't match either of '*.sd-ngp.net', 'sd-ngp.net'\r\n52.6.51.155 hostname '52.6.51.155' doesn't match either of '*.adobecqms.net', 'adobecqms.net'\r\n52.201.105.81 hostname '52.201.105.81' doesn't match either of '*.express.com', 'express.com'\r\n52.44.140.162 hostname '52.44.140.162' doesn't match '*.awana.org'\r\n52.203.43.217 [Errno 10061] No connection could be made because the target machine actively refused it\r\n52.45.138.103 hostname '52.45.138.103' doesn't match '*.test.ultradns.net'\r\n\r\nc:\\>\r\n<\/pre>\n<p>Of course, this only works on SSL, but since most services are on SSL, this should work most of the time.<\/p>\n<p>Another caveat is that if the IP is not a fixed Elastic IP address, the domain associated with it very well could have changed.  The sooner you run what is above after the IP address has been identified, the more likely it is to be discernible.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While looking for timeouts in splunk for an unrelated reason\u2026 I noticed the Amazon IP\u2019s above. We normally don\u2019t know the service they represent. I connected to the IP in my browser on port 443, and noticed that of course&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2017\/06\/07\/interesting-way-to-get-domain-associated-with-amazon-ip\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[26,81],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/6314"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=6314"}],"version-history":[{"count":5,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/6314\/revisions"}],"predecessor-version":[{"id":6323,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/6314\/revisions\/6323"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=6314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=6314"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=6314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}