MCPcopy Create free account
hub / github.com/achillean/shodan-python / get_api_key

Function get_api_key

shodan/cli/helpers.py:20–35  ·  view source on GitHub ↗

Returns the API key of the current logged-in user.

()

Source from the content-addressed store, hash-verified

18
19
20def get_api_key():
21 '''Returns the API key of the current logged-in user.'''
22 shodan_dir = os.path.expanduser(SHODAN_CONFIG_DIR)
23 keyfile = shodan_dir + '/api_key'
24
25 # If the file doesn't yet exist let the user know that they need to
26 # initialize the shodan cli
27 if not os.path.exists(keyfile):
28 raise click.ClickException('Please run "shodan init <api key>" before using this command')
29
30 # Make sure it is a read-only file
31 if not oct(os.stat(keyfile).st_mode).endswith("600"):
32 os.chmod(keyfile, 0o600)
33
34 with open(keyfile, 'r') as fin:
35 return fin.read().strip()
36
37
38def escape_data(args):

Callers 15

domain_infoFunction · 0.90
countFunction · 0.90
downloadFunction · 0.90
hostFunction · 0.90
infoFunction · 0.90
myipFunction · 0.90
searchFunction · 0.90
statsFunction · 0.90
streamFunction · 0.90
honeyscoreFunction · 0.90
radarFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected