Last active
May 29, 2019 18:52
-
-
Save jimywork/489102340e3046c3e43da59abee81191 to your computer and use it in GitHub Desktop.
Returns a list with ip address and port using shodan
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
import shodan | |
def search (api=None, dork=None, limit=None, offset=None) : | |
urls = [] | |
try: | |
api = shodan.Shodan(api) | |
res = api.search(dork, limit=limit, offset=offset) | |
matches = res['matches'] | |
for match in matches: | |
ipaddress = match['ip_str'] | |
port = match['port'] | |
# Skip hosts with SSL | |
if port == 443 : | |
continue | |
urls.append('http://{}:{}'.format(ipaddress, port)) | |
except shodan.APIError as error: | |
print(error) | |
return urls |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment