-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from ackatz/v0.3.0
Cleanup and config helper script
- Loading branch information
Showing
12 changed files
with
94 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
[abuseipdb] | ||
# Where API key is optional, requests to that service will still work without a key | ||
# However, requests may be rate-limited or otherwise limited in scope | ||
|
||
[greynoise] # API key optional | ||
api_key = | ||
|
||
[emailrep] | ||
[shodan] # API key optional | ||
api_key = | ||
|
||
[threatfox] # API key optional | ||
api_key = | ||
|
||
[greynoise] | ||
[abuseipdb] | ||
api_key = | ||
|
||
[shodan] | ||
[emailrep] | ||
api_key = | ||
|
||
[virustotal] | ||
api_key = | ||
|
||
[threatfox] | ||
api_key = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import configparser | ||
from seclook.find_config import find_config | ||
import textwrap | ||
import sys | ||
|
||
|
||
def load_config(service_name, key_required=True): | ||
try: | ||
config_path = find_config() | ||
config = configparser.ConfigParser() | ||
config.read(config_path) | ||
except configparser.ParsingError: | ||
print( | ||
textwrap.dedent( | ||
f""" | ||
ParsingError: Ensure the following lines are present in config.ini: | ||
[{service_name}] | ||
api_key = <Note: A key is{' required' if key_required | ||
else ' optional'} to use this API> | ||
""" | ||
) | ||
) | ||
sys.exit() | ||
|
||
if key_required: | ||
try: | ||
api_key = config[service_name]["api_key"] | ||
except KeyError: | ||
print( | ||
textwrap.dedent( | ||
f""" | ||
KeyError: Ensure the following lines are present in config.ini: | ||
[{service_name}] | ||
api_key = <Note: A key is required to use this API> | ||
""" | ||
) | ||
) | ||
sys.exit() | ||
else: | ||
api_key = config[service_name].get("api_key", "") | ||
|
||
return config, api_key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
import requests | ||
import configparser | ||
from seclook.find_config import find_config | ||
|
||
config_path = find_config() | ||
config = configparser.ConfigParser() | ||
config.read(config_path) | ||
from seclook.config_helper import load_config | ||
|
||
base_url = "https://emailrep.io/{}" | ||
|
||
|
||
def search(value): | ||
emailrep_api_key = config["emailrep"]["api_key"] | ||
config, emailrep_api_key = load_config("emailrep") | ||
headers = {"Key": emailrep_api_key} | ||
response = requests.get(base_url.format(value), headers=headers) | ||
return response.json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
import requests | ||
import configparser | ||
from seclook.find_config import find_config | ||
|
||
config_path = find_config() | ||
config = configparser.ConfigParser() | ||
config.read(config_path) | ||
from seclook.config_helper import load_config | ||
|
||
base_url = "https://api.greynoise.io/v3/community/{}" | ||
|
||
|
||
def search(value): | ||
greynoise_api_key = config["greynoise"]["api_key"] | ||
config, greynoise_api_key = load_config("greynoise", key_required=False) | ||
headers = {"Accept": "application/json", "key": greynoise_api_key} | ||
response = requests.get(base_url.format(value), headers=headers) | ||
return response.json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters