1、ZoomEye
获取ZoomEye的token
import requests
import json
def main():
username = input("username:")
password = input("password:")
url = "https://api.zoomeye.org/user/login"
data = json.dumps({'username': username, 'password': password})
access_key = requests.post(url=url,data=data,verify=False)
print(access_key.text)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("interrupted by user, killing all threads...")
利用zoomeye查询开放6379端口的服务器IP地址
import requests
from bs4 import BeautifulSoup
import json
import re
def main():
# zoomeye token
headers = {
"Authorization": "JWT eyJhbGciOi*****************************************"
}
url = "https://api.zoomeye.org/host/search?query=port:6379&page=1&facet=app,os"
info = requests.get(url=url,headers=headers)
r_decoded = json.loads(info.text)
for line in r_decoded['matches']:
print(line['ip']+': '+str(line['portinfo']['port']))
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("interrupted by user, killing all threads...")
2、shodan
搜索apche服务IP地址和端口
import shodan
# shodan账号API_KEY
SHODAN_API_KEY = '8H******************'
api = shodan.Shodan(SHODAN_API_KEY)
try:
# shodan搜索
results = api.search('apache')
# 显示搜索
print('Results is: %s' % results['total'])
for result in results['matches']:
print(result['ip_str'], result['port'])
except shodan.APIError as e:
print("Error: %s" % e)