Skip to content

Commit

Permalink
Merge pull request #3 from wikiZ/main
Browse files Browse the repository at this point in the history
Update version Kunyu v1.2
  • Loading branch information
0x7Fancy authored Aug 3, 2021
2 parents 8afc4ae + de45628 commit 04bd864
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 46 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Linux:
Windows:
cd kunyu
python3 console.py
P.S. Windows also supports python3 setup.py install
```

# 0x02 Configuration instructions
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions doc/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Linux:
Windows:
cd kunyu
python3 console.py
P.S. Windows同样支持python3 setup.py install
```

# 0x02 配置说明
Expand Down
2 changes: 1 addition & 1 deletion kunyu/config/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = '[email protected]'
Expand Down
2 changes: 1 addition & 1 deletion kunyu/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
82 changes: 40 additions & 42 deletions kunyu/core/zoomeye.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import json
import random
import sys
import re

import requests
from rich.table import Table
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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!")

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = "", "", "", "", ""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -343,3 +340,4 @@ def command_seebug(cls, search):
logger.info("Seebug Search retrieval is completed\n")



0 comments on commit 04bd864

Please sign in to comment.