honeydb 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- honeydb-2.0.0/.github/workflows/format-lint.yml +34 -0
- honeydb-2.0.0/.gitignore +107 -0
- honeydb-2.0.0/LICENSE +21 -0
- honeydb-2.0.0/Makefile +47 -0
- honeydb-2.0.0/PKG-INFO +252 -0
- honeydb-2.0.0/README.md +220 -0
- honeydb-2.0.0/example.py +60 -0
- honeydb-2.0.0/honeydb/__init__.py +25 -0
- honeydb-2.0.0/honeydb/api/__init__.py +5 -0
- honeydb-2.0.0/honeydb/api/client.py +518 -0
- honeydb-2.0.0/honeydb/cli.py +425 -0
- honeydb-2.0.0/honeydb/exceptions.py +54 -0
- honeydb-2.0.0/honeydb/py.typed +0 -0
- honeydb-2.0.0/pyproject.toml +51 -0
- honeydb-2.0.0/tests/test_cli.py +135 -0
- honeydb-2.0.0/tests/test_client.py +181 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Format, Lint & Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["master"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ["master"]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
matrix:
|
|
17
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
22
|
+
uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: ${{ matrix.python-version }}
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: |
|
|
27
|
+
python -m pip install --upgrade pip
|
|
28
|
+
pip install -e ".[dev]"
|
|
29
|
+
- name: Format check
|
|
30
|
+
run: ruff format --check .
|
|
31
|
+
- name: Lint check
|
|
32
|
+
run: ruff check .
|
|
33
|
+
- name: Test
|
|
34
|
+
run: pytest
|
honeydb-2.0.0/.gitignore
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
env/
|
|
12
|
+
build/
|
|
13
|
+
develop-eggs/
|
|
14
|
+
dist/
|
|
15
|
+
downloads/
|
|
16
|
+
eggs/
|
|
17
|
+
.eggs/
|
|
18
|
+
lib/
|
|
19
|
+
lib64/
|
|
20
|
+
parts/
|
|
21
|
+
sdist/
|
|
22
|
+
var/
|
|
23
|
+
wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
|
|
28
|
+
# PyInstaller
|
|
29
|
+
# Usually these files are written by a python script from a template
|
|
30
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
31
|
+
*.manifest
|
|
32
|
+
*.spec
|
|
33
|
+
|
|
34
|
+
# Installer logs
|
|
35
|
+
pip-log.txt
|
|
36
|
+
pip-delete-this-directory.txt
|
|
37
|
+
|
|
38
|
+
# Unit test / coverage reports
|
|
39
|
+
htmlcov/
|
|
40
|
+
.tox/
|
|
41
|
+
.coverage
|
|
42
|
+
.coverage.*
|
|
43
|
+
.cache
|
|
44
|
+
nosetests.xml
|
|
45
|
+
coverage.xml
|
|
46
|
+
*.cover
|
|
47
|
+
.hypothesis/
|
|
48
|
+
|
|
49
|
+
# Translations
|
|
50
|
+
*.mo
|
|
51
|
+
*.pot
|
|
52
|
+
|
|
53
|
+
# Django stuff:
|
|
54
|
+
*.log
|
|
55
|
+
local_settings.py
|
|
56
|
+
|
|
57
|
+
# Flask stuff:
|
|
58
|
+
instance/
|
|
59
|
+
.webassets-cache
|
|
60
|
+
|
|
61
|
+
# Scrapy stuff:
|
|
62
|
+
.scrapy
|
|
63
|
+
|
|
64
|
+
# Sphinx documentation
|
|
65
|
+
docs/_build/
|
|
66
|
+
|
|
67
|
+
# PyBuilder
|
|
68
|
+
target/
|
|
69
|
+
|
|
70
|
+
# Jupyter Notebook
|
|
71
|
+
.ipynb_checkpoints
|
|
72
|
+
|
|
73
|
+
# pyenv
|
|
74
|
+
.python-version
|
|
75
|
+
|
|
76
|
+
# celery beat schedule file
|
|
77
|
+
celerybeat-schedule
|
|
78
|
+
|
|
79
|
+
# SageMath parsed files
|
|
80
|
+
*.sage.py
|
|
81
|
+
|
|
82
|
+
# dotenv
|
|
83
|
+
.env
|
|
84
|
+
|
|
85
|
+
# virtualenv
|
|
86
|
+
.venv
|
|
87
|
+
venv/
|
|
88
|
+
ENV/
|
|
89
|
+
|
|
90
|
+
# Spyder project settings
|
|
91
|
+
.spyderproject
|
|
92
|
+
.spyproject
|
|
93
|
+
|
|
94
|
+
# Rope project settings
|
|
95
|
+
.ropeproject
|
|
96
|
+
|
|
97
|
+
# mkdocs documentation
|
|
98
|
+
/site
|
|
99
|
+
|
|
100
|
+
# mypy
|
|
101
|
+
.mypy_cache/
|
|
102
|
+
.vscode/settings.json
|
|
103
|
+
|
|
104
|
+
.env3/
|
|
105
|
+
|
|
106
|
+
# Claude Code
|
|
107
|
+
.claude/
|
honeydb-2.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Px Mx
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
honeydb-2.0.0/Makefile
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.PHONY: env format format-check lint lint-fix test build publish local-install update-from-upstream clean
|
|
2
|
+
|
|
3
|
+
PY ?= .env/bin/python
|
|
4
|
+
|
|
5
|
+
env:
|
|
6
|
+
python3 -m venv .env
|
|
7
|
+
$(PY) -m pip install --upgrade pip
|
|
8
|
+
$(PY) -m pip install --upgrade -e ".[dev]"
|
|
9
|
+
|
|
10
|
+
format:
|
|
11
|
+
$(PY) -m ruff format .
|
|
12
|
+
|
|
13
|
+
format-check:
|
|
14
|
+
$(PY) -m ruff format --check .
|
|
15
|
+
|
|
16
|
+
lint:
|
|
17
|
+
$(PY) -m ruff check .
|
|
18
|
+
|
|
19
|
+
lint-fix:
|
|
20
|
+
$(PY) -m ruff check --fix .
|
|
21
|
+
|
|
22
|
+
test:
|
|
23
|
+
$(PY) -m pytest
|
|
24
|
+
|
|
25
|
+
build:
|
|
26
|
+
-rm -rf dist
|
|
27
|
+
$(PY) -m build
|
|
28
|
+
|
|
29
|
+
publish:
|
|
30
|
+
$(PY) -m twine upload --skip-existing dist/*
|
|
31
|
+
|
|
32
|
+
local-install:
|
|
33
|
+
-$(PY) -m pip uninstall -y honeydb
|
|
34
|
+
$(PY) -m pip install dist/*.whl
|
|
35
|
+
|
|
36
|
+
update-from-upstream:
|
|
37
|
+
# update master branch from honeydbio
|
|
38
|
+
# first add upstream with: git remote add upstream https://github.com/honeydbio/honeydb-python.git
|
|
39
|
+
git fetch upstream
|
|
40
|
+
git checkout master
|
|
41
|
+
git merge upstream/master
|
|
42
|
+
git push origin master
|
|
43
|
+
|
|
44
|
+
clean:
|
|
45
|
+
find . -name "*.pyc" -type f -delete
|
|
46
|
+
rm -rf dist build .pytest_cache .ruff_cache
|
|
47
|
+
find . -name "__pycache__" -type d -exec rm -rf {} +
|
honeydb-2.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: honeydb
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: A Python API wrapper and CLI tool for HoneyDB.
|
|
5
|
+
Project-URL: Homepage, https://honeydb.io
|
|
6
|
+
Project-URL: Repository, https://github.com/honeydbio/honeydb-python
|
|
7
|
+
Author: foospidy
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: api,cli,honeydb,library,threat-intelligence,wrapper
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Information Technology
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Security
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: requests>=2.31
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: build; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
28
|
+
Requires-Dist: requests-mock; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
30
|
+
Requires-Dist: twine; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# honeydb-python
|
|
34
|
+
|
|
35
|
+
[](https://github.com/honeydbio/honeydb-python/actions/workflows/format-lint.yml?query=branch%3Amaster)
|
|
36
|
+
[](https://pypi.org/project/honeydb/)
|
|
37
|
+
[](https://pypi.org/project/honeydb/)
|
|
38
|
+
|
|
39
|
+
A Python API wrapper and command-line tool for the [HoneyDB](https://honeydb.io) API.
|
|
40
|
+
|
|
41
|
+
HoneyDB provides real-time threat intelligence collected from a distributed network of
|
|
42
|
+
honeypots — bad hosts, IP reputation, ASN activity, CVE sightings, network info, cloud/datacenter
|
|
43
|
+
IP ranges, and more.
|
|
44
|
+
|
|
45
|
+
- **Full API coverage** — every current HoneyDB endpoint is exposed.
|
|
46
|
+
- **Modern & typed** — Python 3.10+, full type hints, ships a `py.typed` marker.
|
|
47
|
+
- **Robust HTTP** — pooled `requests.Session` with automatic retries and typed exceptions.
|
|
48
|
+
- **Ergonomic CLI** — a git-style subcommand interface: `honeydb ip 8.8.8.8`.
|
|
49
|
+
|
|
50
|
+
## Requirements
|
|
51
|
+
|
|
52
|
+
- Python 3.10+
|
|
53
|
+
- A HoneyDB API ID and API key ([sign in](https://honeydb.io) to get yours).
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install honeydb
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Authentication
|
|
62
|
+
|
|
63
|
+
All requests require an API ID and API key. Provide them via environment variables:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
export HONEYDB_API_ID=<your api id>
|
|
67
|
+
export HONEYDB_API_KEY=<your api key>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The CLI also accepts `--api-id` / `--api-key`, and the library takes them as constructor
|
|
71
|
+
arguments.
|
|
72
|
+
|
|
73
|
+
## CLI usage
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Bad hosts seen in the last 24 hours
|
|
77
|
+
honeydb bad-hosts
|
|
78
|
+
|
|
79
|
+
# Full context for an IP (pretty-printed)
|
|
80
|
+
honeydb ip 8.8.8.8 --pretty
|
|
81
|
+
|
|
82
|
+
# Just the geolocation view of that IP
|
|
83
|
+
honeydb ip 8.8.8.8 --geo
|
|
84
|
+
|
|
85
|
+
# ASN organization + its prefixes
|
|
86
|
+
honeydb asn 15169
|
|
87
|
+
honeydb asn 15169 --prefixes
|
|
88
|
+
|
|
89
|
+
# Check an IP against a specific list
|
|
90
|
+
honeydb ipinfo 185.220.101.1 --source tor
|
|
91
|
+
|
|
92
|
+
# Cloud/datacenter IP ranges (does not count against monthly limits)
|
|
93
|
+
honeydb datacenter aws
|
|
94
|
+
|
|
95
|
+
# Your own sensor data for a date
|
|
96
|
+
honeydb sensor-data --date 2025-04-01
|
|
97
|
+
honeydb sensor-data --date 2025-04-01 --count
|
|
98
|
+
|
|
99
|
+
# Manage monitors
|
|
100
|
+
honeydb monitors list
|
|
101
|
+
honeydb monitors create --json '[{"monitor_type":"asn","monitor_value":"401120","description":"ASN Example"}]'
|
|
102
|
+
honeydb monitors delete --id 122 123
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Run `honeydb --help` or `honeydb <command> --help` for the full command tree. Global flags
|
|
106
|
+
`--pretty/-p` and `--timeout` apply to any command. Output is JSON on stdout; errors go to
|
|
107
|
+
stderr with a non-zero exit code.
|
|
108
|
+
|
|
109
|
+
### Commands
|
|
110
|
+
|
|
111
|
+
| Command | Description |
|
|
112
|
+
| --- | --- |
|
|
113
|
+
| `bad-hosts [--service S] [--mydata]` | Bad hosts (last 24h), optionally by service. |
|
|
114
|
+
| `ip <ip> [--geo\|--netinfo\|--threatinfo\|--scanner\|--history\|--cve]` | IP context, or a single view. |
|
|
115
|
+
| `ip-cidr <cidr>` | All IP addresses within a network range. |
|
|
116
|
+
| `asn <n> [--prefixes]` | ASN organization info or its prefixes. |
|
|
117
|
+
| `asns [--days 1\|7]` | ASNs seen in the last 1 (default) or 7 days. |
|
|
118
|
+
| `cve <cve>` | IP history for a CVE. |
|
|
119
|
+
| `cve-ip <ip>` | CVE history for an IP. |
|
|
120
|
+
| `sensor-data --date D [--from-id ID] [--count] [--all]` | Your sensor event data for a date. |
|
|
121
|
+
| `services` | Emulated services (last 24h). |
|
|
122
|
+
| `stats --year Y --month M` | Summary stats for a year/month. |
|
|
123
|
+
| `monitors {list,logs,notifications,create,delete}` | Manage monitors. |
|
|
124
|
+
| `nodes [--mydata]` | honeydb-agent nodes (last 3 days). |
|
|
125
|
+
| `payload-history {remote-hosts,attributes,...}` | Payload history data. |
|
|
126
|
+
| `internet-scanner <ip> [--info]` | Whether an IP is a known internet scanner. |
|
|
127
|
+
| `ipinfo <ip> [--source SRC]` | Check an IP against known IP lists. |
|
|
128
|
+
| `netinfo {lookup,network-addresses,prefixes,as-name,geolocation} <arg>` | Network info (no monthly limit). |
|
|
129
|
+
| `datacenter <provider>` | Cloud/datacenter IP ranges (no monthly limit). |
|
|
130
|
+
|
|
131
|
+
`ipinfo --source` values: `bogon`, `tor`, `sansip`, `ciarmy`, `et-compromised`,
|
|
132
|
+
`project-honeypot`, `pallebone`, `threatfox`, `blocklist_net_ua`.
|
|
133
|
+
|
|
134
|
+
`datacenter` providers: `aws`, `azure`, `azure/china`, `azure/germany`, `azure/gov`,
|
|
135
|
+
`cloudflare`, `gcp`, `ibm`, `oracle`.
|
|
136
|
+
|
|
137
|
+
## Library usage
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
from honeydb import Client
|
|
141
|
+
|
|
142
|
+
with Client("api_id", "api_key") as honeydb:
|
|
143
|
+
hosts = honeydb.bad_hosts()
|
|
144
|
+
context = honeydb.ip("8.8.8.8")
|
|
145
|
+
is_tor = honeydb.ipinfo_source("tor", "185.220.101.1")
|
|
146
|
+
ranges = honeydb.datacenter("aws")
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The client can also be used without the context manager (call `.close()` when done), and
|
|
150
|
+
you can pass a shared `requests.Session`, a custom `timeout`, or a different `base_url`:
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
client = Client("api_id", "api_key", timeout=10, retries=5)
|
|
154
|
+
try:
|
|
155
|
+
print(client.services())
|
|
156
|
+
finally:
|
|
157
|
+
client.close()
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Error handling
|
|
161
|
+
|
|
162
|
+
Every failed request raises a typed exception, all subclasses of `HoneyDBError`:
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
from honeydb import (
|
|
166
|
+
Client,
|
|
167
|
+
HoneyDBError,
|
|
168
|
+
HoneyDBAuthError,
|
|
169
|
+
HoneyDBNotFoundError,
|
|
170
|
+
HoneyDBRateLimitError,
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
with Client("api_id", "api_key") as honeydb:
|
|
174
|
+
try:
|
|
175
|
+
honeydb.ip("8.8.8.8")
|
|
176
|
+
except HoneyDBAuthError:
|
|
177
|
+
print("Check your API credentials.")
|
|
178
|
+
except HoneyDBRateLimitError as error:
|
|
179
|
+
print(f"Rate limited; retry after {error.retry_after}s")
|
|
180
|
+
except HoneyDBError as error:
|
|
181
|
+
print(f"Request failed with HTTP {error.status_code}: {error}")
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Monitors
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
with Client("api_id", "api_key") as honeydb:
|
|
188
|
+
honeydb.create_monitors([
|
|
189
|
+
{"monitor_type": "ip_address", "ip_address": "196.251.81.54",
|
|
190
|
+
"description": "IP Address Example"},
|
|
191
|
+
{"monitor_type": "asn", "monitor_value": "401120",
|
|
192
|
+
"description": "ASN Example"},
|
|
193
|
+
])
|
|
194
|
+
monitors = honeydb.monitors()
|
|
195
|
+
honeydb.delete_monitors([m["id"] for m in monitors])
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## API reference
|
|
199
|
+
|
|
200
|
+
The `Client` exposes one method per endpoint, grouped below.
|
|
201
|
+
|
|
202
|
+
- **Bad hosts:** `bad_hosts(mydata=False)`, `bad_hosts_by_service(service, mydata=False)`
|
|
203
|
+
- **IP context:** `ip(ip)`, `ip_geo(ip)`, `ip_netinfo(ip)`, `ip_threatinfo(ip)`,
|
|
204
|
+
`ip_internet_scanner(ip)`, `ip_history(ip)`, `ip_cve(ip)`, `ip_cidr(cidr)`
|
|
205
|
+
- **ASN:** `asn(n)`, `asn_prefixes(n)`, `asns()`, `asns_7d()`
|
|
206
|
+
- **CVE:** `cve(cve)`, `cve_ip(ip)`
|
|
207
|
+
- **Sensor data:** `sensor_data(date, from_id=None, mydata=True)`, `sensor_data_count(date, mydata=True)`
|
|
208
|
+
- **Services / stats:** `services()`, `stats(year, month)`
|
|
209
|
+
- **Monitors:** `monitors()`, `create_monitors(list)`, `delete_monitors(ids)`,
|
|
210
|
+
`monitors_logs()`, `monitors_notifications()`
|
|
211
|
+
- **Nodes:** `nodes(mydata=False)`
|
|
212
|
+
- **Payload history:** `payload_history_remote_hosts()`, `payload_history_attributes()`,
|
|
213
|
+
`payload_history_attribute(attr)` (plus API-deprecated helpers)
|
|
214
|
+
- **Internet scanner:** `internet_scanner(ip)`, `internet_scanner_info(ip)`
|
|
215
|
+
- **IP info lists:** `ipinfo(ip)`, `ipinfo_source(source, ip)`
|
|
216
|
+
- **Net info (no monthly limit):** `netinfo_lookup(ip)`, `netinfo_network_addresses(cidr)`,
|
|
217
|
+
`netinfo_prefixes(asn)`, `netinfo_as_name(asn)`, `netinfo_geolocation(ip)`
|
|
218
|
+
- **Datacenter (no monthly limit):** `datacenter(provider)`
|
|
219
|
+
|
|
220
|
+
See the [HoneyDB API documentation](https://honeydb.io/threats) for endpoint details and
|
|
221
|
+
response formats.
|
|
222
|
+
|
|
223
|
+
## Migrating from v1.x
|
|
224
|
+
|
|
225
|
+
v2.0.0 is a ground-up rewrite. Notable changes:
|
|
226
|
+
|
|
227
|
+
- **New import surface.** `from honeydb import Client` (the `from honeydb import api;
|
|
228
|
+
api.Client(...)` form still works).
|
|
229
|
+
- **The CLI is now subcommand-based.** For example, `honeydb --bad-hosts` becomes
|
|
230
|
+
`honeydb bad-hosts`, and `honeydb --netinfo-lookup 1.2.3.4` becomes
|
|
231
|
+
`honeydb netinfo lookup 1.2.3.4`.
|
|
232
|
+
- **Replaced endpoints were dropped** in favor of their modern equivalents:
|
|
233
|
+
the old `ip_history()` / `ip-context` top-level methods are replaced by `ip()` and
|
|
234
|
+
`ip_history()` under the `/ip/<ip>` family, and `stats_asn()` is replaced by `asns()`.
|
|
235
|
+
- **Errors now raise typed exceptions** (`HoneyDBError` and subclasses) instead of returning
|
|
236
|
+
raw response bodies.
|
|
237
|
+
|
|
238
|
+
## Development
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
make env # create .env venv and install with dev extras
|
|
242
|
+
make format # ruff format
|
|
243
|
+
make lint # ruff check
|
|
244
|
+
make test # pytest (uses mocked HTTP, no API keys needed)
|
|
245
|
+
make build # build sdist + wheel
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
This project uses [ruff](https://docs.astral.sh/ruff/) for both formatting and linting.
|
|
249
|
+
|
|
250
|
+
## License
|
|
251
|
+
|
|
252
|
+
MIT — see [LICENSE](LICENSE).
|
honeydb-2.0.0/README.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# honeydb-python
|
|
2
|
+
|
|
3
|
+
[](https://github.com/honeydbio/honeydb-python/actions/workflows/format-lint.yml?query=branch%3Amaster)
|
|
4
|
+
[](https://pypi.org/project/honeydb/)
|
|
5
|
+
[](https://pypi.org/project/honeydb/)
|
|
6
|
+
|
|
7
|
+
A Python API wrapper and command-line tool for the [HoneyDB](https://honeydb.io) API.
|
|
8
|
+
|
|
9
|
+
HoneyDB provides real-time threat intelligence collected from a distributed network of
|
|
10
|
+
honeypots — bad hosts, IP reputation, ASN activity, CVE sightings, network info, cloud/datacenter
|
|
11
|
+
IP ranges, and more.
|
|
12
|
+
|
|
13
|
+
- **Full API coverage** — every current HoneyDB endpoint is exposed.
|
|
14
|
+
- **Modern & typed** — Python 3.10+, full type hints, ships a `py.typed` marker.
|
|
15
|
+
- **Robust HTTP** — pooled `requests.Session` with automatic retries and typed exceptions.
|
|
16
|
+
- **Ergonomic CLI** — a git-style subcommand interface: `honeydb ip 8.8.8.8`.
|
|
17
|
+
|
|
18
|
+
## Requirements
|
|
19
|
+
|
|
20
|
+
- Python 3.10+
|
|
21
|
+
- A HoneyDB API ID and API key ([sign in](https://honeydb.io) to get yours).
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install honeydb
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Authentication
|
|
30
|
+
|
|
31
|
+
All requests require an API ID and API key. Provide them via environment variables:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
export HONEYDB_API_ID=<your api id>
|
|
35
|
+
export HONEYDB_API_KEY=<your api key>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The CLI also accepts `--api-id` / `--api-key`, and the library takes them as constructor
|
|
39
|
+
arguments.
|
|
40
|
+
|
|
41
|
+
## CLI usage
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Bad hosts seen in the last 24 hours
|
|
45
|
+
honeydb bad-hosts
|
|
46
|
+
|
|
47
|
+
# Full context for an IP (pretty-printed)
|
|
48
|
+
honeydb ip 8.8.8.8 --pretty
|
|
49
|
+
|
|
50
|
+
# Just the geolocation view of that IP
|
|
51
|
+
honeydb ip 8.8.8.8 --geo
|
|
52
|
+
|
|
53
|
+
# ASN organization + its prefixes
|
|
54
|
+
honeydb asn 15169
|
|
55
|
+
honeydb asn 15169 --prefixes
|
|
56
|
+
|
|
57
|
+
# Check an IP against a specific list
|
|
58
|
+
honeydb ipinfo 185.220.101.1 --source tor
|
|
59
|
+
|
|
60
|
+
# Cloud/datacenter IP ranges (does not count against monthly limits)
|
|
61
|
+
honeydb datacenter aws
|
|
62
|
+
|
|
63
|
+
# Your own sensor data for a date
|
|
64
|
+
honeydb sensor-data --date 2025-04-01
|
|
65
|
+
honeydb sensor-data --date 2025-04-01 --count
|
|
66
|
+
|
|
67
|
+
# Manage monitors
|
|
68
|
+
honeydb monitors list
|
|
69
|
+
honeydb monitors create --json '[{"monitor_type":"asn","monitor_value":"401120","description":"ASN Example"}]'
|
|
70
|
+
honeydb monitors delete --id 122 123
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Run `honeydb --help` or `honeydb <command> --help` for the full command tree. Global flags
|
|
74
|
+
`--pretty/-p` and `--timeout` apply to any command. Output is JSON on stdout; errors go to
|
|
75
|
+
stderr with a non-zero exit code.
|
|
76
|
+
|
|
77
|
+
### Commands
|
|
78
|
+
|
|
79
|
+
| Command | Description |
|
|
80
|
+
| --- | --- |
|
|
81
|
+
| `bad-hosts [--service S] [--mydata]` | Bad hosts (last 24h), optionally by service. |
|
|
82
|
+
| `ip <ip> [--geo\|--netinfo\|--threatinfo\|--scanner\|--history\|--cve]` | IP context, or a single view. |
|
|
83
|
+
| `ip-cidr <cidr>` | All IP addresses within a network range. |
|
|
84
|
+
| `asn <n> [--prefixes]` | ASN organization info or its prefixes. |
|
|
85
|
+
| `asns [--days 1\|7]` | ASNs seen in the last 1 (default) or 7 days. |
|
|
86
|
+
| `cve <cve>` | IP history for a CVE. |
|
|
87
|
+
| `cve-ip <ip>` | CVE history for an IP. |
|
|
88
|
+
| `sensor-data --date D [--from-id ID] [--count] [--all]` | Your sensor event data for a date. |
|
|
89
|
+
| `services` | Emulated services (last 24h). |
|
|
90
|
+
| `stats --year Y --month M` | Summary stats for a year/month. |
|
|
91
|
+
| `monitors {list,logs,notifications,create,delete}` | Manage monitors. |
|
|
92
|
+
| `nodes [--mydata]` | honeydb-agent nodes (last 3 days). |
|
|
93
|
+
| `payload-history {remote-hosts,attributes,...}` | Payload history data. |
|
|
94
|
+
| `internet-scanner <ip> [--info]` | Whether an IP is a known internet scanner. |
|
|
95
|
+
| `ipinfo <ip> [--source SRC]` | Check an IP against known IP lists. |
|
|
96
|
+
| `netinfo {lookup,network-addresses,prefixes,as-name,geolocation} <arg>` | Network info (no monthly limit). |
|
|
97
|
+
| `datacenter <provider>` | Cloud/datacenter IP ranges (no monthly limit). |
|
|
98
|
+
|
|
99
|
+
`ipinfo --source` values: `bogon`, `tor`, `sansip`, `ciarmy`, `et-compromised`,
|
|
100
|
+
`project-honeypot`, `pallebone`, `threatfox`, `blocklist_net_ua`.
|
|
101
|
+
|
|
102
|
+
`datacenter` providers: `aws`, `azure`, `azure/china`, `azure/germany`, `azure/gov`,
|
|
103
|
+
`cloudflare`, `gcp`, `ibm`, `oracle`.
|
|
104
|
+
|
|
105
|
+
## Library usage
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from honeydb import Client
|
|
109
|
+
|
|
110
|
+
with Client("api_id", "api_key") as honeydb:
|
|
111
|
+
hosts = honeydb.bad_hosts()
|
|
112
|
+
context = honeydb.ip("8.8.8.8")
|
|
113
|
+
is_tor = honeydb.ipinfo_source("tor", "185.220.101.1")
|
|
114
|
+
ranges = honeydb.datacenter("aws")
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The client can also be used without the context manager (call `.close()` when done), and
|
|
118
|
+
you can pass a shared `requests.Session`, a custom `timeout`, or a different `base_url`:
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
client = Client("api_id", "api_key", timeout=10, retries=5)
|
|
122
|
+
try:
|
|
123
|
+
print(client.services())
|
|
124
|
+
finally:
|
|
125
|
+
client.close()
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Error handling
|
|
129
|
+
|
|
130
|
+
Every failed request raises a typed exception, all subclasses of `HoneyDBError`:
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from honeydb import (
|
|
134
|
+
Client,
|
|
135
|
+
HoneyDBError,
|
|
136
|
+
HoneyDBAuthError,
|
|
137
|
+
HoneyDBNotFoundError,
|
|
138
|
+
HoneyDBRateLimitError,
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
with Client("api_id", "api_key") as honeydb:
|
|
142
|
+
try:
|
|
143
|
+
honeydb.ip("8.8.8.8")
|
|
144
|
+
except HoneyDBAuthError:
|
|
145
|
+
print("Check your API credentials.")
|
|
146
|
+
except HoneyDBRateLimitError as error:
|
|
147
|
+
print(f"Rate limited; retry after {error.retry_after}s")
|
|
148
|
+
except HoneyDBError as error:
|
|
149
|
+
print(f"Request failed with HTTP {error.status_code}: {error}")
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Monitors
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
with Client("api_id", "api_key") as honeydb:
|
|
156
|
+
honeydb.create_monitors([
|
|
157
|
+
{"monitor_type": "ip_address", "ip_address": "196.251.81.54",
|
|
158
|
+
"description": "IP Address Example"},
|
|
159
|
+
{"monitor_type": "asn", "monitor_value": "401120",
|
|
160
|
+
"description": "ASN Example"},
|
|
161
|
+
])
|
|
162
|
+
monitors = honeydb.monitors()
|
|
163
|
+
honeydb.delete_monitors([m["id"] for m in monitors])
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## API reference
|
|
167
|
+
|
|
168
|
+
The `Client` exposes one method per endpoint, grouped below.
|
|
169
|
+
|
|
170
|
+
- **Bad hosts:** `bad_hosts(mydata=False)`, `bad_hosts_by_service(service, mydata=False)`
|
|
171
|
+
- **IP context:** `ip(ip)`, `ip_geo(ip)`, `ip_netinfo(ip)`, `ip_threatinfo(ip)`,
|
|
172
|
+
`ip_internet_scanner(ip)`, `ip_history(ip)`, `ip_cve(ip)`, `ip_cidr(cidr)`
|
|
173
|
+
- **ASN:** `asn(n)`, `asn_prefixes(n)`, `asns()`, `asns_7d()`
|
|
174
|
+
- **CVE:** `cve(cve)`, `cve_ip(ip)`
|
|
175
|
+
- **Sensor data:** `sensor_data(date, from_id=None, mydata=True)`, `sensor_data_count(date, mydata=True)`
|
|
176
|
+
- **Services / stats:** `services()`, `stats(year, month)`
|
|
177
|
+
- **Monitors:** `monitors()`, `create_monitors(list)`, `delete_monitors(ids)`,
|
|
178
|
+
`monitors_logs()`, `monitors_notifications()`
|
|
179
|
+
- **Nodes:** `nodes(mydata=False)`
|
|
180
|
+
- **Payload history:** `payload_history_remote_hosts()`, `payload_history_attributes()`,
|
|
181
|
+
`payload_history_attribute(attr)` (plus API-deprecated helpers)
|
|
182
|
+
- **Internet scanner:** `internet_scanner(ip)`, `internet_scanner_info(ip)`
|
|
183
|
+
- **IP info lists:** `ipinfo(ip)`, `ipinfo_source(source, ip)`
|
|
184
|
+
- **Net info (no monthly limit):** `netinfo_lookup(ip)`, `netinfo_network_addresses(cidr)`,
|
|
185
|
+
`netinfo_prefixes(asn)`, `netinfo_as_name(asn)`, `netinfo_geolocation(ip)`
|
|
186
|
+
- **Datacenter (no monthly limit):** `datacenter(provider)`
|
|
187
|
+
|
|
188
|
+
See the [HoneyDB API documentation](https://honeydb.io/threats) for endpoint details and
|
|
189
|
+
response formats.
|
|
190
|
+
|
|
191
|
+
## Migrating from v1.x
|
|
192
|
+
|
|
193
|
+
v2.0.0 is a ground-up rewrite. Notable changes:
|
|
194
|
+
|
|
195
|
+
- **New import surface.** `from honeydb import Client` (the `from honeydb import api;
|
|
196
|
+
api.Client(...)` form still works).
|
|
197
|
+
- **The CLI is now subcommand-based.** For example, `honeydb --bad-hosts` becomes
|
|
198
|
+
`honeydb bad-hosts`, and `honeydb --netinfo-lookup 1.2.3.4` becomes
|
|
199
|
+
`honeydb netinfo lookup 1.2.3.4`.
|
|
200
|
+
- **Replaced endpoints were dropped** in favor of their modern equivalents:
|
|
201
|
+
the old `ip_history()` / `ip-context` top-level methods are replaced by `ip()` and
|
|
202
|
+
`ip_history()` under the `/ip/<ip>` family, and `stats_asn()` is replaced by `asns()`.
|
|
203
|
+
- **Errors now raise typed exceptions** (`HoneyDBError` and subclasses) instead of returning
|
|
204
|
+
raw response bodies.
|
|
205
|
+
|
|
206
|
+
## Development
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
make env # create .env venv and install with dev extras
|
|
210
|
+
make format # ruff format
|
|
211
|
+
make lint # ruff check
|
|
212
|
+
make test # pytest (uses mocked HTTP, no API keys needed)
|
|
213
|
+
make build # build sdist + wheel
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
This project uses [ruff](https://docs.astral.sh/ruff/) for both formatting and linting.
|
|
217
|
+
|
|
218
|
+
## License
|
|
219
|
+
|
|
220
|
+
MIT — see [LICENSE](LICENSE).
|