koi-handler 0.12.6__tar.gz → 0.12.7__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.
Files changed (70) hide show
  1. {koi_handler-0.12.6/src/koi_handler.egg-info → koi_handler-0.12.7}/PKG-INFO +1 -1
  2. {koi_handler-0.12.6 → koi_handler-0.12.7}/pyproject.toml +1 -1
  3. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/main.py +34 -7
  4. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/logger.py +43 -29
  5. {koi_handler-0.12.6 → koi_handler-0.12.7/src/koi_handler.egg-info}/PKG-INFO +1 -1
  6. {koi_handler-0.12.6 → koi_handler-0.12.7}/LICENSE +0 -0
  7. {koi_handler-0.12.6 → koi_handler-0.12.7}/setup.cfg +0 -0
  8. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/listener.py +0 -0
  9. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/mcp/__init__.py +0 -0
  10. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/mcp/schema.py +0 -0
  11. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/mcp/server.py +0 -0
  12. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/blueprint.py +0 -0
  13. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/download.py +0 -0
  14. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/duplicate.py +0 -0
  15. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/get_processes.py +0 -0
  16. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/get_users.py +0 -0
  17. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/ligolo.py +0 -0
  18. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/loader.py +0 -0
  19. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/network_enum.py +0 -0
  20. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/peas.py +0 -0
  21. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/populate_win.py +0 -0
  22. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/secrets_dump.py +0 -0
  23. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/sharphound.py +0 -0
  24. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/ssh_persist.py +0 -0
  25. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/sysinfo.py +0 -0
  26. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/upload.py +0 -0
  27. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/upload64.py +0 -0
  28. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/wifi_enum.py +0 -0
  29. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/modules/winscalate.py +0 -0
  30. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/session.py +0 -0
  31. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/tunnel/__init__.py +0 -0
  32. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/tunnel/agent_payload.py +0 -0
  33. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/tunnel/engine/__init__.py +0 -0
  34. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/tunnel/engine/__main__.py +0 -0
  35. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/tunnel/engine/agent.py +0 -0
  36. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/tunnel/engine/packet.py +0 -0
  37. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/tunnel/engine/proxy.py +0 -0
  38. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/tunnel/engine/stack.py +0 -0
  39. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/tunnel/engine/tcp.py +0 -0
  40. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/tunnel/engine/transport.py +0 -0
  41. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/tunnel/engine/tun.py +0 -0
  42. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/tunnel/manager.py +0 -0
  43. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/__init__.py +0 -0
  44. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/bash_obfuscate.py +0 -0
  45. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/cache.py +0 -0
  46. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/cli.py +0 -0
  47. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/config.py +0 -0
  48. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/config_ui.py +0 -0
  49. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/connect/__init__.py +0 -0
  50. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/connect/base.py +0 -0
  51. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/connect/ntlm.py +0 -0
  52. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/connect/ssh.py +0 -0
  53. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/connect/winrm.py +0 -0
  54. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/connect/wsman.py +0 -0
  55. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/constants.py +0 -0
  56. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/detect.py +0 -0
  57. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/interact.py +0 -0
  58. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/models.py +0 -0
  59. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/obfuscate_ui.py +0 -0
  60. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/payloads.py +0 -0
  61. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/powerupgrade.py +0 -0
  62. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/ps_obfuscate.py +0 -0
  63. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/tcp.py +0 -0
  64. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/terminal.py +0 -0
  65. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/tls.py +0 -0
  66. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi/utils/ui.py +0 -0
  67. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi_handler.egg-info/SOURCES.txt +0 -0
  68. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi_handler.egg-info/dependency_links.txt +0 -0
  69. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi_handler.egg-info/entry_points.txt +0 -0
  70. {koi_handler-0.12.6 → koi_handler-0.12.7}/src/koi_handler.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: koi-handler
3
- Version: 0.12.6
3
+ Version: 0.12.7
4
4
  Summary: Reverse shell listener
5
5
  Requires-Python: >=3.10
6
6
  License-File: LICENSE
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "koi-handler"
7
- version = "0.12.6"
7
+ version = "0.12.7"
8
8
  description = "Reverse shell listener"
9
9
  requires-python = ">=3.10"
10
10
  dependencies = []
@@ -88,23 +88,50 @@ class _ArtHelpAction(argparse.Action):
88
88
  parser.exit()
89
89
 
90
90
 
91
- def _print_version() -> None:
92
- from koi.utils.ui import accent, bold, dim
93
- print(f"koi {bold(__version__)}")
91
+ def _latest_apt() -> str | None:
92
+ import subprocess
93
+ try:
94
+ out = subprocess.check_output(
95
+ ["apt-cache", "policy", "koi"],
96
+ stderr=subprocess.DEVNULL, timeout=5, text=True,
97
+ )
98
+ for line in out.splitlines():
99
+ if "Candidate:" in line:
100
+ raw = line.split("Candidate:", 1)[1].strip()
101
+ return raw.split("-")[0]
102
+ except Exception:
103
+ pass
104
+ return None
105
+
106
+
107
+ def _latest_github() -> str | None:
108
+ from urllib.request import urlopen, Request
109
+ import json
94
110
  try:
95
- from urllib.request import urlopen, Request
96
- import json
97
111
  req = Request(
98
112
  "https://api.github.com/repos/b3rt1ng/Koi/releases/latest",
99
113
  headers={"User-Agent": "koi/update-check", "Accept": "application/json"},
100
114
  )
101
115
  with urlopen(req, timeout=3) as resp:
102
- latest = json.loads(resp.read())["tag_name"].lstrip("vV")
116
+ return json.loads(resp.read())["tag_name"].lstrip("vV")
117
+ except Exception:
118
+ return None
119
+
120
+
121
+ def _print_version() -> None:
122
+ from koi.utils.ui import accent, bold, dim
123
+ print(f"koi {bold(__version__)}")
124
+ try:
125
+ is_apt = _PKG_NAME == "koi"
126
+ latest = _latest_apt() if is_apt else _latest_github()
127
+ if latest is None:
128
+ print(dim(" could not check for updates"))
129
+ return
103
130
  local = __version__.lstrip("vV")
104
131
  if latest == local:
105
132
  print(dim("up to date"))
106
133
  else:
107
- if _PKG_NAME == "koi":
134
+ if is_apt:
108
135
  hint = dim("sudo apt update && sudo apt upgrade koi")
109
136
  else:
110
137
  hint = dim("pipx upgrade koi-handler")
@@ -23,6 +23,7 @@ if TYPE_CHECKING:
23
23
  _LOG_DIR = Path.home() / ".koi" / "logs"
24
24
  _CTRL = re.compile(r"[\x00-\x08\x0b-\x0c\x0e-\x1f\x7f]")
25
25
  _PROMPT_SUFFIXES = ("$", "#", "❯", "% ")
26
+ _PROMPT_FRAGMENTS = ("└─$", "└─#", "┌──(", "PS C:\\", "PS>")
26
27
  _MAX_LOG_BYTES = 50 * 1024 * 1024
27
28
 
28
29
 
@@ -46,7 +47,10 @@ def _printable(text: str) -> bool:
46
47
 
47
48
 
48
49
  def _is_prompt(line: str) -> bool:
49
- return any(line.strip().endswith(sfx) for sfx in _PROMPT_SUFFIXES)
50
+ s = line.strip()
51
+ if any(s.endswith(sfx) for sfx in _PROMPT_SUFFIXES):
52
+ return True
53
+ return any(frag in s for frag in _PROMPT_FRAGMENTS)
50
54
 
51
55
 
52
56
  def _dim_ts(entry: dict) -> str:
@@ -226,14 +230,30 @@ def review(name: str) -> None:
226
230
  notify("error", f"Log not found: {name}")
227
231
  sys.exit(1)
228
232
 
229
- encoding = "utf-8"
230
- input_buf = b""
231
- recent_cmds: set[str] = set()
233
+ encoding = "utf-8"
234
+ input_buf = b""
235
+ output_buf = ""
236
+ accepting_output = False
237
+ last_cmd = ""
238
+
239
+ def _flush_output(ts_str: str) -> None:
240
+ nonlocal output_buf
241
+ for line in output_buf.splitlines():
242
+ stripped = _CTRL.sub("", line).strip()
243
+ if (not stripped or not _printable(stripped)
244
+ or stripped.lower() == last_cmd.lower()
245
+ or _is_prompt(stripped)
246
+ or "__KOI_" in stripped):
247
+ continue
248
+ _render_output_line(ts_str, stripped)
249
+ output_buf = ""
232
250
 
233
- def flush_state() -> None:
234
- nonlocal input_buf
251
+ def _flush_all(ts_str: str) -> None:
252
+ nonlocal input_buf, accepting_output, last_cmd
253
+ _flush_output(ts_str)
235
254
  input_buf = b""
236
- recent_cmds.clear()
255
+ accepting_output = False
256
+ last_cmd = ""
237
257
 
238
258
  print()
239
259
  with open(path, encoding="utf-8") as f:
@@ -246,7 +266,7 @@ def review(name: str) -> None:
246
266
  except json.JSONDecodeError:
247
267
  continue
248
268
 
249
- kind = entry.get("type")
269
+ kind = entry.get("type")
250
270
  ts_str = _dim_ts(entry)
251
271
 
252
272
  if kind == "meta":
@@ -254,33 +274,27 @@ def review(name: str) -> None:
254
274
  _render_meta(entry)
255
275
 
256
276
  elif kind == "input":
257
- input_buf += base64.b64decode(entry["data"])
258
- while b"\n" in input_buf or b"\r" in input_buf:
259
- positions = [(input_buf.find(s), s) for s in (b"\r\n", b"\n", b"\r")]
260
- _, sep = min(
261
- ((i, s) for i, s in positions if i != -1),
262
- key=lambda t: (t[0], -len(t[1])),
263
- )
264
- cmd_bytes, input_buf = input_buf.split(sep, 1)
265
- cmd = _CTRL.sub("", _clean(cmd_bytes, encoding)).strip()
277
+ chunk = base64.b64decode(entry["data"])
278
+ if chunk in (b"\r", b"\n", b"\r\n"):
279
+ _flush_output(ts_str)
280
+ cmd = _CTRL.sub("", _clean(input_buf, encoding)).strip()
266
281
  if cmd and _printable(cmd):
267
282
  _render_cmd(ts_str, cmd)
268
- recent_cmds.add(cmd.lower())
283
+ last_cmd = cmd
284
+ input_buf = b""
285
+ accepting_output = True
286
+ else:
287
+ input_buf += chunk
269
288
 
270
289
  elif kind == "output":
271
- text = _clean(base64.b64decode(entry["data"]), encoding)
272
- for line in text.splitlines():
273
- stripped = _CTRL.sub("", line).strip()
274
- if (not stripped or not _printable(stripped)
275
- or stripped.lower() in recent_cmds
276
- or _is_prompt(stripped)
277
- or "__KOI_" in stripped):
278
- continue
279
- _render_output_line(ts_str, stripped)
280
- recent_cmds.clear()
290
+ if not accepting_output:
291
+ continue
292
+ output_buf += _clean(base64.b64decode(entry["data"]), encoding)
281
293
 
282
294
  elif kind == "event":
283
- flush_state()
295
+ _flush_all(ts_str)
296
+ accepting_output = True
284
297
  _render_event(entry)
285
298
 
299
+ _flush_output(_dim_ts({"ts": time.time()}))
286
300
  print()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: koi-handler
3
- Version: 0.12.6
3
+ Version: 0.12.7
4
4
  Summary: Reverse shell listener
5
5
  Requires-Python: >=3.10
6
6
  License-File: LICENSE
File without changes
File without changes