diff --git a/username/username_keybase.py b/username/username_keybase.py index 0bdeb47e..56050f47 100644 --- a/username/username_keybase.py +++ b/username/username_keybase.py @@ -9,10 +9,12 @@ # Control whether the module is enabled or not ENABLED = True + class style: BOLD = '\033[1m' END = '\033[0m' + def banner(): # Write a cool banner here print colored(style.BOLD + '\n---> Searching User info @ Keybase\n' + style.END, 'blue') @@ -23,13 +25,14 @@ def main(username): # Use the username variable to do some stuff and return the data url = "https://keybase.io/_/api/1.0/user/lookup.json?usernames=%s" %username req = requests.get(url) - data = json.loads(req.text) - if data['them'][0] is not None: + data = json.loads(req.text) + dict_them = [] + if 'them' in data and data['them'][0] is not None: dict_them = data['them'][0] - return dict_them - else: - dict_them = [] - return dict_them + if data['status']['code'] is 100: + error = str(data['status']['name'] + " - " + data['status']['desc']) + dict_them = {'Error': error} + return dict_them def output(dict_them, username): @@ -58,6 +61,10 @@ def output(dict_them, username): print "[+] Total %s Devices found." % len(dict_them['devices'].keys()) for x in dict_them['devices'].keys(): print " - %s (%s)" % (dict_them['devices'][x]['name'], dict_them['devices'][x]['type']) + if 'Error' in dict_them: + for k, v in dict_them.items(): + print colored(style.BOLD + '[!] ' + k + ': '+ v + style.END, 'red') + del dict_them['Error'] else: print "User not found on Keybase" print "" @@ -68,4 +75,3 @@ def output(dict_them, username): banner() result = main(username) output(result, username) -