threeblindmice 0.3.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.
- tbm/__init__.py +7 -0
- tbm/__main__.py +4 -0
- tbm/asyncutil.py +51 -0
- tbm/cli.py +780 -0
- tbm/dashboard/__init__.py +5 -0
- tbm/dashboard/app.py +127 -0
- tbm/dashboard/charts.py +59 -0
- tbm/dashboard/templates/base.html.j2 +92 -0
- tbm/dashboard/templates/diff.html.j2 +25 -0
- tbm/dashboard/templates/index.html.j2 +30 -0
- tbm/dashboard/templates/inventory.html.j2 +29 -0
- tbm/dashboard/templates/label.html.j2 +28 -0
- tbm/models.py +202 -0
- tbm/paths.py +34 -0
- tbm/pipeline.py +85 -0
- tbm/progress.py +26 -0
- tbm/schedule.py +132 -0
- tbm/scope.py +184 -0
- tbm/scout/__init__.py +6 -0
- tbm/scout/arp.py +109 -0
- tbm/scout/banner.py +257 -0
- tbm/scout/classify.py +99 -0
- tbm/scout/discovery.py +214 -0
- tbm/scout/engine.py +223 -0
- tbm/scout/ports.py +70 -0
- tbm/scout/portscan.py +98 -0
- tbm/scout/tls.py +141 -0
- tbm/scout/udp.py +142 -0
- tbm/scout/wire.py +239 -0
- tbm/sniffer/__init__.py +6 -0
- tbm/sniffer/backport.py +169 -0
- tbm/sniffer/base.py +85 -0
- tbm/sniffer/context.py +58 -0
- tbm/sniffer/cve.py +289 -0
- tbm/sniffer/engine.py +126 -0
- tbm/sniffer/epss.py +61 -0
- tbm/sniffer/http_checks.py +214 -0
- tbm/sniffer/secrets.py +213 -0
- tbm/sniffer/service_checks.py +267 -0
- tbm/sniffer/smb_checks.py +167 -0
- tbm/sniffer/ssh_checks.py +240 -0
- tbm/sniffer/tls_checks.py +83 -0
- tbm/sniffer/udp_checks.py +64 -0
- tbm/sniffer/upnp_checks.py +218 -0
- tbm/squeak/__init__.py +24 -0
- tbm/squeak/acceptance.py +40 -0
- tbm/squeak/diff.py +106 -0
- tbm/squeak/letter.py +87 -0
- tbm/squeak/notify.py +131 -0
- tbm/squeak/redact.py +25 -0
- tbm/squeak/report.py +45 -0
- tbm/squeak/sarif.py +92 -0
- tbm/squeak/scoring.py +57 -0
- tbm/squeak/store.py +145 -0
- tbm/squeak/templates/report.html.j2 +201 -0
- threeblindmice-0.3.0.dist-info/METADATA +181 -0
- threeblindmice-0.3.0.dist-info/RECORD +59 -0
- threeblindmice-0.3.0.dist-info/WHEEL +4 -0
- threeblindmice-0.3.0.dist-info/entry_points.txt +2 -0
tbm/__init__.py
ADDED
tbm/__main__.py
ADDED
tbm/asyncutil.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Primitivas assíncronas reutilizadas pelos engines."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import time
|
|
7
|
+
from collections import deque
|
|
8
|
+
from collections.abc import Awaitable, Callable, Iterable
|
|
9
|
+
from typing import TypeVar
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
async def gather_limited(factories: Iterable[Callable[[], Awaitable[T]]], limit: int) -> list[T]:
|
|
15
|
+
"""Como asyncio.gather, mas com no máximo `limit` corrotinas vivas por vez.
|
|
16
|
+
|
|
17
|
+
Recebe *fábricas* (callables), não corrotinas, para não criar milhões de
|
|
18
|
+
objetos de corrotina de uma vez ao escanear um /16 com todas as portas.
|
|
19
|
+
Os workers compartilham o mesmo iterador; como `next()` é síncrono, não há
|
|
20
|
+
corrida no event loop.
|
|
21
|
+
"""
|
|
22
|
+
iterator = enumerate(factories)
|
|
23
|
+
results: dict[int, T] = {}
|
|
24
|
+
|
|
25
|
+
async def worker() -> None:
|
|
26
|
+
for idx, factory in iterator:
|
|
27
|
+
results[idx] = await factory()
|
|
28
|
+
|
|
29
|
+
await asyncio.gather(*(worker() for _ in range(max(1, limit))))
|
|
30
|
+
return [results[i] for i in sorted(results)]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class RateLimiter:
|
|
34
|
+
"""Janela deslizante: no máximo `max_calls` a cada `period` segundos."""
|
|
35
|
+
|
|
36
|
+
def __init__(self, max_calls: int, period: float) -> None:
|
|
37
|
+
self.max_calls = max_calls
|
|
38
|
+
self.period = period
|
|
39
|
+
self._calls: deque[float] = deque()
|
|
40
|
+
self._lock = asyncio.Lock()
|
|
41
|
+
|
|
42
|
+
async def acquire(self) -> None:
|
|
43
|
+
async with self._lock:
|
|
44
|
+
while True:
|
|
45
|
+
now = time.monotonic()
|
|
46
|
+
while self._calls and now - self._calls[0] >= self.period:
|
|
47
|
+
self._calls.popleft()
|
|
48
|
+
if len(self._calls) < self.max_calls:
|
|
49
|
+
self._calls.append(now)
|
|
50
|
+
return
|
|
51
|
+
await asyncio.sleep(self.period - (now - self._calls[0]) + 0.05)
|