hook-sec 0.1.0__py3-none-any.whl

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.
hook_sec/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from .middleware import HookSecurityMiddleware
hook_sec/middleware.py ADDED
@@ -0,0 +1,52 @@
1
+ import httpx
2
+ from starlette.middleware.base import BaseHTTPMiddleware
3
+ from starlette.requests import Request
4
+ from starlette.responses import JSONResponse
5
+
6
+ class HookSecurityMiddleware(BaseHTTPMiddleware):
7
+ def __init__(
8
+ self,
9
+ app,
10
+ api_key: str,
11
+ # Указываем боевой эндпоинт твоего облака HOOK на Railway
12
+ hook_cloud_endpoint: str = "https://hook-production-502a79b4.up.railway.app/v1/hook/trap",
13
+ timeout: float = 0.8
14
+ ):
15
+ super().__init__(app)
16
+ self.api_key = api_key
17
+ self.hook_cloud_endpoint = hook_cloud_endpoint
18
+ self.timeout = timeout
19
+
20
+ # Сигнатуры автономных ИИ-агентов и сканеров
21
+ self.ai_signatures = ["gpt-agent", "langchain", "autogen", "python-requests", "curl", "nmap", "ai-scanner"]
22
+
23
+ async def dispatch(self, request: Request, call_next):
24
+ user_agent = request.headers.get("user-agent", "").lower()
25
+ path = request.url.path
26
+ client_ip = request.client.host if request.client else "127.0.0.1"
27
+
28
+ is_ai_bot = any(sig in user_agent for sig in self.ai_signatures)
29
+ is_trap_path = path in ["/.env", "/config.json", "/admin/db_dump.sql", "/api/v1/debug", "/api/v2/internal/exec"]
30
+
31
+ if is_ai_bot or is_trap_path:
32
+ headers = {
33
+ "Authorization": f"Bearer {self.api_key}",
34
+ "Content-Type": "application/json"
35
+ }
36
+ payload = {
37
+ "attacker_ip": client_ip,
38
+ "user_agent": user_agent,
39
+ "request_path": path
40
+ }
41
+
42
+ try:
43
+ async with httpx.AsyncClient(timeout=self.timeout) as client:
44
+ resp = await client.post(self.hook_cloud_endpoint, json=payload, headers=headers)
45
+ if resp.status_code == 200:
46
+ return JSONResponse(status_code=200, content=resp.json())
47
+ except Exception:
48
+ pass
49
+
50
+ return JSONResponse(status_code=404, content={"error": "Not Found"})
51
+
52
+ return await call_next(request)
@@ -0,0 +1,46 @@
1
+ Metadata-Version: 2.4
2
+ Name: hook-sec
3
+ Version: 0.1.0
4
+ Summary: Autonomous AI Deception & Sandbox SDK for FastAPI
5
+ Author-email: "nihad.aghazada" <agazadenihad707@gmail.com>
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Classifier: Topic :: Security
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: fastapi>=0.68.0
13
+ Requires-Dist: httpx>=0.20.0
14
+ Requires-Dist: starlette>=0.14.0
15
+
16
+ # HOOK SDK (`hook-sec`)
17
+
18
+ Official Python SDK for [HOOK Cloud](https://hooksec.cloud) — Autonomous AI Deception & Sandbox Security for FastAPI.
19
+
20
+ ## Quickstart
21
+
22
+ ```bash
23
+ pip install hook-sec
24
+
25
+
26
+
27
+
28
+
29
+
30
+ Add the middleware to your FastAPI app:
31
+
32
+ from fastapi import FastAPI
33
+ from hook_sec import HookSecurityMiddleware
34
+
35
+ app = FastAPI()
36
+
37
+ app.add_middleware(
38
+ HookSecurityMiddleware,
39
+ api_key="hook_your_project_key_here"
40
+ )
41
+
42
+
43
+
44
+
45
+
46
+
@@ -0,0 +1,6 @@
1
+ hook_sec/__init__.py,sha256=AumvpWoa2FcLb4W0gi-oHfjVLeZiA4jPp7p5en-yur8,46
2
+ hook_sec/middleware.py,sha256=oqGoJA9WHaCrOG4W8UmHlrrq6aZEGSvTlqCk_0wt1dg,2223
3
+ hook_sec-0.1.0.dist-info/METADATA,sha256=NayYc2IwiwFsP8NJZ7tx-eejZfcfDXxsCyd1Svs5hRo,946
4
+ hook_sec-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
5
+ hook_sec-0.1.0.dist-info/top_level.txt,sha256=cs4AavBQX_hqk0Jjlm6M8O1im9RcDb0SDvqLWibayro,9
6
+ hook_sec-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ hook_sec