Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SSH Key & Fingerprint output to host command #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions shodan/cli/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ def host_print_pretty(host, history=False):
if 'fingerprint' in banner['ssl']['dhparams']:
click.echo('\t\t{:15s}{}'.format('Fingerprint:', banner['ssl']['dhparams']['fingerprint']))

# Show optional ssh info
if 'ssh' in banner:
if 'key' in banner['ssh'] and banner['ssh']['key']:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this could be simplified like the following: if banner.get('ssh') and banner['ssh'].get('key')

Given that `bannher['ssh']['key'] returns a string, the second part of your nested if statement is not needed. I think the same could be said for your check for banner['ssh']['fingerprint']

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please feel free to adjust, the idea was more to provide a solution to the request at the same time as the request itself, if there's a better or preferred way to do it, I'm all for that. I think at the time I was just trying to make these changes as close to the original code as possible.

click.echo('\t|-- SSH Key: {}'.format(banner['ssh']['key'].replace('\n','').strip()))
if 'fingerprint' in banner['ssh'] and banner['ssh']['fingerprint']:
click.echo('\t|-- SSH Fingerprint: {}'.format(banner['ssh']['fingerprint']))


def host_print_tsv(host, history=False):
"""Show the host information in a succinct, grep-friendly manner."""
Expand Down