Skip to content

Commit

Permalink
Fixes issues with greynoise
Browse files Browse the repository at this point in the history
  • Loading branch information
Te-k committed Nov 9, 2020
1 parent bba11b9 commit 2a37d0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions harpoon/commands/gn.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#! /usr/bin/env python3
import json
import sys
import logging

from greynoise import GreyNoise
from harpoon.commands.base import Command
Expand Down Expand Up @@ -50,6 +51,7 @@ def run(self, conf, args, plugins):
if conf["GreyNoise"]["key"] == "":
print("You need to set your API key with GreyNoise")
sys.exit()
logging.getLogger("greynoise").setLevel(logging.CRITICAL)
gn = GreyNoise(api_key=conf["GreyNoise"]["key"])
if args.ip:
res = gn.ip(args.ip)
Expand Down
12 changes: 8 additions & 4 deletions harpoon/commands/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import tarfile
import urllib
import urllib.request
import logging

import geoip2.database
import pyasn
Expand Down Expand Up @@ -511,7 +512,8 @@ def run(self, conf, args, plugins):
gn_e = plugins["greynoise"].test_config(conf)
greynoise = []
if gn_e:
gn = GreyNoise(cfg)
logging.getLogger("greynoise").setLevel(logging.CRITICAL)
gn = GreyNoise(conf['GreyNoise']['key'])
greynoise = gn.ip(unbracket(args.IP))

tg_e = plugins["threatgrid"].test_config(conf)
Expand Down Expand Up @@ -590,9 +592,11 @@ def run(self, conf, args, plugins):
)
)
if len(greynoise) > 0:
print("GreyNoise: IP identified as")
for key, value in greynoise.items():
print(key, "->", value)
if "seen" in greynoise:
if greynoise['seen']:
print("GreyNoise: IP identified as")
for key, value in greynoise.items():
print(key, "->", value)
else:
print("GreyNoise: Not found")
if pt_e:
Expand Down

0 comments on commit 2a37d0c

Please sign in to comment.