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.
Files changed (59) hide show
  1. tbm/__init__.py +7 -0
  2. tbm/__main__.py +4 -0
  3. tbm/asyncutil.py +51 -0
  4. tbm/cli.py +780 -0
  5. tbm/dashboard/__init__.py +5 -0
  6. tbm/dashboard/app.py +127 -0
  7. tbm/dashboard/charts.py +59 -0
  8. tbm/dashboard/templates/base.html.j2 +92 -0
  9. tbm/dashboard/templates/diff.html.j2 +25 -0
  10. tbm/dashboard/templates/index.html.j2 +30 -0
  11. tbm/dashboard/templates/inventory.html.j2 +29 -0
  12. tbm/dashboard/templates/label.html.j2 +28 -0
  13. tbm/models.py +202 -0
  14. tbm/paths.py +34 -0
  15. tbm/pipeline.py +85 -0
  16. tbm/progress.py +26 -0
  17. tbm/schedule.py +132 -0
  18. tbm/scope.py +184 -0
  19. tbm/scout/__init__.py +6 -0
  20. tbm/scout/arp.py +109 -0
  21. tbm/scout/banner.py +257 -0
  22. tbm/scout/classify.py +99 -0
  23. tbm/scout/discovery.py +214 -0
  24. tbm/scout/engine.py +223 -0
  25. tbm/scout/ports.py +70 -0
  26. tbm/scout/portscan.py +98 -0
  27. tbm/scout/tls.py +141 -0
  28. tbm/scout/udp.py +142 -0
  29. tbm/scout/wire.py +239 -0
  30. tbm/sniffer/__init__.py +6 -0
  31. tbm/sniffer/backport.py +169 -0
  32. tbm/sniffer/base.py +85 -0
  33. tbm/sniffer/context.py +58 -0
  34. tbm/sniffer/cve.py +289 -0
  35. tbm/sniffer/engine.py +126 -0
  36. tbm/sniffer/epss.py +61 -0
  37. tbm/sniffer/http_checks.py +214 -0
  38. tbm/sniffer/secrets.py +213 -0
  39. tbm/sniffer/service_checks.py +267 -0
  40. tbm/sniffer/smb_checks.py +167 -0
  41. tbm/sniffer/ssh_checks.py +240 -0
  42. tbm/sniffer/tls_checks.py +83 -0
  43. tbm/sniffer/udp_checks.py +64 -0
  44. tbm/sniffer/upnp_checks.py +218 -0
  45. tbm/squeak/__init__.py +24 -0
  46. tbm/squeak/acceptance.py +40 -0
  47. tbm/squeak/diff.py +106 -0
  48. tbm/squeak/letter.py +87 -0
  49. tbm/squeak/notify.py +131 -0
  50. tbm/squeak/redact.py +25 -0
  51. tbm/squeak/report.py +45 -0
  52. tbm/squeak/sarif.py +92 -0
  53. tbm/squeak/scoring.py +57 -0
  54. tbm/squeak/store.py +145 -0
  55. tbm/squeak/templates/report.html.j2 +201 -0
  56. threeblindmice-0.3.0.dist-info/METADATA +181 -0
  57. threeblindmice-0.3.0.dist-info/RECORD +59 -0
  58. threeblindmice-0.3.0.dist-info/WHEEL +4 -0
  59. threeblindmice-0.3.0.dist-info/entry_points.txt +2 -0
tbm/__init__.py ADDED
@@ -0,0 +1,7 @@
1
+ """threeblindmice: Scout, Sniffer e Squeak.
2
+
3
+ Toolkit defensivo para avaliar a segurança de redes e serviços que você controla.
4
+ """
5
+
6
+ __version__ = "0.3.0"
7
+ USER_AGENT = f"threeblindmice/{__version__} (+defensive-scanner)"
tbm/__main__.py ADDED
@@ -0,0 +1,4 @@
1
+ from tbm.cli import app
2
+
3
+ if __name__ == "__main__":
4
+ app()
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)