diff --git a/CHANGELOG b/CHANGELOG index 6fce983..57066c4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v1.2] - 2021-8-2 +### Added +- optimizedthe problem of outputting an empty table when no data is returned +- optimized the problem that no data is returned when the number of parameters in the page is exceeded +- update Use mmh3 encoding when querying iconhash +- add Output the current icon query statement +- update User credentials are saved as hidden files ## [v1.1] - 2021-7-13 ### Added diff --git a/README.md b/README.md index b0b3f50..4bd7566 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ Linux: Windows: cd kunyu python3 console.py + +P.S. Windows also supports python3 setup.py install ``` # 0x02 Configuration instructions @@ -194,8 +196,7 @@ Kunyu's auto-completion supports upper and lower case, command logging, etc., us # 0x06 Contributions -[风起@knownsec 404](https://github.com/wikiZ) - +[风起@knownsec 404](https://github.com/wikiZ) [wh0am1i@knownsec 404](https://github.com/wh0am1i) [fenix@knownsec 404](https://github.com/13ph03nix) [0x7F@knownsec 404](https://github.com/0x7Fancy) diff --git a/doc/README_CN.md b/doc/README_CN.md index c0468b3..b1edae3 100644 --- a/doc/README_CN.md +++ b/doc/README_CN.md @@ -41,6 +41,8 @@ Linux: Windows: cd kunyu python3 console.py + +P.S. Windows同样支持python3 setup.py install ``` # 0x02 配置说明 diff --git a/kunyu/config/__version__.py b/kunyu/config/__version__.py index 3f1933b..f0e299c 100644 --- a/kunyu/config/__version__.py +++ b/kunyu/config/__version__.py @@ -15,7 +15,7 @@ __python_version__ = sys.version.split()[0] __platform__ = platform.platform() __url__ = "https://github.com/knownsec/Kunyu" -__version__ = '1.1' +__version__ = '1.2' __author__ = '风起' __Team__ = 'KnownSec 404 Team' __author_email__ = 'onlyzaliks@gmail.com' diff --git a/kunyu/core/__init__.py b/kunyu/core/__init__.py index 6f7875d..eb4f962 100644 --- a/kunyu/core/__init__.py +++ b/kunyu/core/__init__.py @@ -45,7 +45,7 @@ path = os.path.expanduser("~/") conf = configparser.ConfigParser() -__path = os.path.join(path, "kunyu.ini") +__path = os.path.join(path, ".kunyu.ini") # Read config.user.ini conf.read(__path) diff --git a/kunyu/core/zoomeye.py b/kunyu/core/zoomeye.py index 241c6eb..b884508 100644 --- a/kunyu/core/zoomeye.py +++ b/kunyu/core/zoomeye.py @@ -10,6 +10,7 @@ import json import random import sys +import re import requests from rich.table import Table @@ -55,9 +56,14 @@ def wrapper(*args, **kwargs): nonlocal func req_list = [] login_url = func(self, *args, **kwargs) - for num in range(int(self.page)): - params['query'], params['page'] = self.search, (num + 1) - req_list.append(self.__request(login_url, data=params, headers=self.headers)) + try: + for num in range(int(self.page)): + params['query'], params['page'] = self.search, (num + 1) + req_list.append(self.__request(login_url, data=params, headers=self.headers)) + except requests.HTTPError as err: + logger.warning(err) + except requests.exceptions.ConnectionError: + logger.error("Network timeout") return req_list return wrapper @@ -69,31 +75,24 @@ def __request(self, login_url, data=None, headers=None): which is displayed on the terminal after processing by the presentation layer. """ # The API is not available for tourist users - - try: - if self.method == "GET": - resp = requests.get( - login_url, - data=data, - headers=headers, - timeout=5 - ) - else: - resp = requests.post( - login_url, - data=data, - headers=headers, - timeout=5 - ) - self.check_status(resp) - self.check_error(resp.json()) - - return json.loads(resp.text) - - except requests.HTTPError as err: - return logger.warning(err) - except requests.exceptions.ConnectionError: - return logger.error("Network timeout") + if self.method == "GET": + resp = requests.get( + login_url, + data=data, + headers=headers, + timeout=5 + ) + else: + resp = requests.post( + login_url, + data=data, + headers=headers, + timeout=5 + ) + self.check_status(resp) + self.check_error(resp.json()) + # return query data + return json.loads(resp.text) # Check return http status code def check_status(self, resp): @@ -137,8 +136,6 @@ def _dork_search(self, url, search, page): except ArithmeticError: return logger.warning("Please enter the correct number of queries!") - except requests.exceptions.ConnectionError: - return logger.error("Network timeout") except Exception: return logger.warning("Search for parameter exceptions!") @@ -174,7 +171,7 @@ class ZoomEye: exit Exit KunYu & """ # ZoomEye Command List - Command_Info = ["help", "info", "set", "Seebug", "SearchWeb", "SearchHost", "SearchIcon", "SearchBatch", "SearchCert", "SearchDomain", "ExportPath","show", "clear", "exit"] + Command_Info = ["help", "info", "set", "Seebug", "SearchWeb", "SearchHost", "SearchIcon", "SearchBatch", "SearchCert", "SearchDomain", "ExportPath", "show", "clear", "exit"] def __init__(self): self.fields_tables = None @@ -206,10 +203,6 @@ def __command_search(self, search, types="host"): # Get data information for result in _dork_search(api_url, search, self.page): - # Check return data Whether it is empty - if not result: - return logger.error("No data returned") - try: total = result['total'] webapp_name, server_name, db_name, system_os, language = "", "", "", "", "" @@ -270,13 +263,15 @@ def __command_search(self, search, types="host"): if export_list: export_xls(export_list, FIELDS) - except Exception as e: - print(e) + except Exception: continue - console.log("search result amount:", total, style="green") - console.print(table) - logger.info("Search information retrieval is completed\n") + if total > 0: + console.log("search result amount:", total, style="green") + console.print(table) + logger.info("Search information retrieval is completed\n") + else: + logger.error("The query result is empty\n") return console @classmethod @@ -327,8 +322,10 @@ def command_searchcert(cls, hostname): @classmethod # ZoomEye Icon Image Search def command_searchicon(cls, filename): - if encode.encode_md5(filename) is not None: - return cls.__command_search(cls, "iconhash:" + str(encode.encode_md5(filename))) + icon_hash = str(encode.encode_mmh3(filename)) + if icon_hash != "": + logger.info("iconhash:"+icon_hash) + return cls.command_searchhost("iconhash:" + icon_hash) @classmethod # Get SeeBug vulnerability information @@ -343,3 +340,4 @@ def command_seebug(cls, search): logger.info("Seebug Search retrieval is completed\n") +