DefendKing
A defensive-only Python security toolkit (~60 functions) covering:
- Passwords & authentication
- Phishing & URL/email safety
- Brute-force / abuse protection
- File / malware hygiene
- Web application security (XSS, CSRF, SQLi heuristics, headers)
- Network-level defense (TLS, firewall rules, ARP/DNS checks)
- Cryptography & secrets management
- Monitoring, risk scoring & reporting
Every function protects, detects, or reports — none of them attack, exploit, or access systems you don't own/manage.
Author: Barman License: MIT
Structure
defendking/
├── pyproject.toml
├── README.md
├── tests/
│ └── test_defendking.py
└── defendking/ ← the actual package
├── __init__.py ← re-exports everything from handler.py
└── handler.py ← all ~60 functions live here
Install
pip install -e . # core package, no third-party deps required
pip install -e ".[full]" # adds requests / cryptography / pyjwt for the
# functions that call external APIs or do AES/JWT
pip install -e ".[dev]" # adds pytest for running the test suite
import defendking
defendking.check_password_strength("...")
# or
from defendking import check_password_strength
Run the tests
python -m pytest tests/ -v
Known limitations
- Heuristic detection isn't a real classifier.
detect_xss_patterns,validate_input_against_sql_injection, andcheck_suspicious_urlare regex-based signals, not a guarantee of safety. Always pair them with the real defenses: parameterized queries/ORM for SQL, contextual output encoding + a strict CSP for XSS, and a reputation/block-list service for URLs. - The local common-password list is a small sample, not a real breach
corpus.
check_password_breachedqueries the Have I Been Pwned API by default — the local list is only an offline fallback. detect_anomalous_login_locationgives an accurate result only when you pass realprevious_coords/new_coords(it then uses haversine distance viadistance_km_between). Without coordinates it falls back to a conservative fixed-distance estimate, which is a rough approximation.
Versioning
Following semantic-ish convention: first digit = structural changes, second = new features, third = bug fixes.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
defendking-1.0.0.tar.gz
(26.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file defendking-1.0.0.tar.gz.
File metadata
- Download URL: defendking-1.0.0.tar.gz
- Upload date:
- Size: 26.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
694a4308b9eeb46a4d5158b054db44c9ac425f5fe5e2904d83b051a8187f1881
|
|
| MD5 |
c3fb27eaedda2bea944191a35eb68ee9
|
|
| BLAKE2b-256 |
840fc51199806f6b8909f2e2039e8d4059fd41fdef574ed2cd37a53dbfd0d7c9
|
File details
Details for the file defendking-1.0.0-py3-none-any.whl.
File metadata
- Download URL: defendking-1.0.0-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5a14684e1526ad902d4c7f74419bc6324f4b476bdb0dc83a7d07df7ab95cd28
|
|
| MD5 |
f8839c652e5d969285e859e92b861690
|
|
| BLAKE2b-256 |
e320448f8c54ccd214819eef20cb0b3a9b6b7b62effacca50a8cf0d75814b864
|