hRun / SA-haveibeenpwned

Splunk add-on providing a custom search command to query Troy Hunt's haveibeenpwned API (https://haveibeenpwned.com/api/v3/) for known breaches of your domains or mail addresses.
https://splunkbase.splunk.com/app/5050/
Apache License 2.0
6 stars 4 forks source link
hibp hibp-api security splunk-addon

SA-haveibeenpwned

A Splunk® add-on providing a custom search command haveibeenpwned to query Troy Hunt's haveibeenpwned API (https://haveibeenpwned.com/api/v3/) for known breaches of your (company's) domains or your friends'/family's/enemies'/hardly distantly related someone's/employees'/colleagues' mail adresses.

Please respect people's privacy and adhere to the service's acceptable use (https://haveibeenpwned.com/API/v3#AcceptableUse). I tried respecting the limits posed on the API's use in the command's source code, which is why you'll have to have a little patience when querying for large amounts of mail addresses.

I was unsatisfied with the publicly available Splunk add-ons already providing this functionality as they either didn't allow control over what and how is queried for or didn't format the output to my wishes. So I came up with my own Splunk add-on implementing these missing features.

Cross-compatible with Python 2 and 3. Tested on Splunk Enterprise 9.0.2 and 8.2.3 on Windows, Linux and Splunk Cloud.

Licensed under http://www.apache.org/licenses/LICENSE-2.0.

Installation & Updating

Just unpack to _$SPLUNKHOME/etc/apps on your Splunk search head and restart the instance. Use the deployer in a distributed environment.

Important note on updating from version 2.1.0 to 2.2.x:

Due to changes in the HIBP API's rate limiting, a parameter to set the supplied API key's individual rate limit was added on the add-on's configuration page. It controls sleep intervals during search execution to prevent provoking API timeouts. The parameter is set to 10 requests per minute by default (current lowest tier). To make full use of your API plan, set it to the rate limit tied to the entered API key (as visible from https://haveibeenpwned.com/API/Key/Verify).

Important note on updating to add-on version 2.x.x:

When updating from add-on version 1.x.x to 2.x.x, you'll be required to reconfigure used API key and proxies (see Requirements & Setup). Un-privileged users without the list_storage_passwords capability will no longer be able to make use of mode=mail. A custom role can_query_hibp is supplied to empower such users (including all negative implications this capability brings with it until Splunk finally decides to fix it).

For legacy Splunk environments, if you prefer a slimmer implementation or if the stated cpability limitations are not an option, please use add-on version 1.2.2. Overall functionality is exactly the same.

Set python.version=python2 or python.version=python3 in commands.conf if you would like to explicitly specify the Python version to use. Otherwise this will be determined by your instance's global settings. Set python.version=python2 in restmap.conf if you experience issues with the app's configuration page on older Splunk instances.

Requirements & Setup

Your Splunk instance requires acess to the internet (via a proxy) to query https://haveibeenpwned.com/api/v3/*. Configure proxies via the app's configuration page if required.

Unfortunately parts of the HIBP API now require an API key which you can obtain here: https://haveibeenpwned.com/API/Key. Specify your API key via the app's configuration page to be able to use mode=mail. mode=domain will work without an API key.

If you require using a proxy, unfortunately currently only HTTP(S) proxies are supported and only Basic Authentication. Support for SOCKS proxies and NTLM authentication will be added in a later verion of the app.

Usage

Use as a search command like so:

search index=example | table email | haveibeenpwned [mode=<mail|domain>] [threshold=\] [output=<text|json>] [pastes=\<all|dated|none>] \

mode: Control whether to query for breaches regarding one or multiple domains or specific mail addresses. Default: mail.

threshold: Set how many days to look back for breaches. Default: 7 days.

output: Control whether to return the fetched and parsed data as plaintext or json formatted fields. Default: text.

pastes: Control whether to additionally query for account pastes or not or only those with a timestamp when using mode=mail. Default: dated.

\: The fields in your Splunk search results that you want to query against the HIBP API. These fields should contain mail addresses or domain names depending on the chosen mode.

When using mode=mail, search performance is highly dependent on the number of queried mail addresses and your API key's rate limit. Expect 0.12 seconds on the highest tier API key and up to 6 seconds per mail address when using the lowest tier API key. This is to adhere to the API's acceptable use terms. Do not attempt to spam the search as it will only degrade the performance further.

Examples

Check a list of mail addresses from local logs for pwnage in the last year, also check for any related pastes

   search index=ad | table email | haveibeenpwned mode=mail threshold=365 pastes=all email

Check a domain for breaches during the last month and output as json

   | makeresults | eval mydomain="mydomain.com" | haveibeenpwned mode=domain threshold=31 output=json mydomain

History

v2.2.2 - v2.2.7

v2.2.0

v2.1.0

v2.0.5

v2.0.4

v2.0.3

v2.0.2

v2.0.1

v2.0.0

v1.2.2

v1.2.1

v1.2.0

TODO / Known Issues