unk-scanner 0.1.0__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.
- unk_scanner-0.1.0/LICENSE +25 -0
- unk_scanner-0.1.0/MANIFEST.in +1 -0
- unk_scanner-0.1.0/PKG-INFO +58 -0
- unk_scanner-0.1.0/README.md +39 -0
- unk_scanner-0.1.0/pyproject.toml +37 -0
- unk_scanner-0.1.0/setup.cfg +4 -0
- unk_scanner-0.1.0/src/unk_scanner/__init__.py +65 -0
- unk_scanner-0.1.0/src/unk_scanner/__main__.py +3 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/LICENSE +25 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/bin/unk-scanner.mjs +6 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/node_modules/acorn/CHANGELOG.md +986 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/node_modules/acorn/LICENSE +21 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/node_modules/acorn/README.md +304 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/node_modules/acorn/bin/acorn +4 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/node_modules/acorn/dist/acorn.d.mts +889 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/node_modules/acorn/dist/acorn.d.ts +889 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/node_modules/acorn/dist/acorn.js +6333 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/node_modules/acorn/dist/acorn.mjs +6304 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/node_modules/acorn/dist/bin.js +90 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/node_modules/acorn/package.json +50 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/package.json +36 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/src/artifacts.mjs +24 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/src/bounded.mjs +33 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/src/cli.mjs +57 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/src/inspect.mjs +101 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/src/loaders.mjs +68 -0
- unk_scanner-0.1.0/src/unk_scanner/_engine/src/worker.mjs +8 -0
- unk_scanner-0.1.0/src/unk_scanner.egg-info/PKG-INFO +58 -0
- unk_scanner-0.1.0/src/unk_scanner.egg-info/SOURCES.txt +31 -0
- unk_scanner-0.1.0/src/unk_scanner.egg-info/dependency_links.txt +1 -0
- unk_scanner-0.1.0/src/unk_scanner.egg-info/entry_points.txt +2 -0
- unk_scanner-0.1.0/src/unk_scanner.egg-info/top_level.txt +1 -0
- unk_scanner-0.1.0/tests/test_wrapper.py +59 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 UNK_DeadDrop research contributors
|
|
4
|
+
|
|
5
|
+
This license applies only to original code, tests, configuration and detection
|
|
6
|
+
rules in this companion repository. It does not cover research prose or any
|
|
7
|
+
third-party evidence.
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include src/unk_scanner/_engine *
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: unk-scanner
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python CLI and API for static UNK_DeadDrop JavaScript triage (requires Node.js 22+)
|
|
5
|
+
Author: Ilja Krasnjanski
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://krasforge.github.io/UNK_DeadDrop/
|
|
8
|
+
Project-URL: Repository, https://github.com/KrasForge/unk-deaddrop-companion
|
|
9
|
+
Project-URL: Research, https://doi.org/10.5281/zenodo.23652298
|
|
10
|
+
Keywords: security,static-analysis,javascript,unk-deaddrop
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Topic :: Security
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# unk-scanner for Python
|
|
21
|
+
|
|
22
|
+
Python CLI and API for the static JavaScript scanner from the [UNK_DeadDrop investigation](https://krasforge.github.io/UNK_DeadDrop/).
|
|
23
|
+
|
|
24
|
+
Requires Python 3.10+ and **Node.js 22+ on PATH**. The wheel bundles the same JavaScript engine as the npm distribution, plus Acorn 8.17.0. It does not require npm, execute submitted JavaScript, or download code during analysis.
|
|
25
|
+
|
|
26
|
+
## Installation and usage
|
|
27
|
+
|
|
28
|
+
Once published:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
pip install unk-scanner
|
|
32
|
+
python -m unk_scanner suspect.js > findings.json
|
|
33
|
+
python -m unk_scanner --gzip captured-response.js > findings.json
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The distribution also installs an `unk-scanner` command. Prefer `python -m unk_scanner` if both npm and Python versions are installed, to make the selected installation explicit.
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from unk_scanner import scan, ScannerError
|
|
40
|
+
|
|
41
|
+
try:
|
|
42
|
+
report = scan("suspect.js")
|
|
43
|
+
print(report["findings"])
|
|
44
|
+
except ScannerError as error:
|
|
45
|
+
print(error)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Scope
|
|
49
|
+
|
|
50
|
+
Reports contain original SHA-256 hashes, byte counts, source locations, findings, limitations, and separate artifact identity records. With `--gzip`, `decoded` records the decompressed hash and size. `artifactMatches` can identify ordinary login code or a shared polyfill; these are context, not malware alerts.
|
|
51
|
+
|
|
52
|
+
The scanner recognizes literal and selected identifier markers, clipboard writes, and one linked AES-GCM loader pattern. It does not decrypt payloads, resolve general aliases or obfuscated string tables, prove execution, or determine whether a file is safe. Exact identity matches cover only the listed bytes.
|
|
53
|
+
|
|
54
|
+
Input and decompressed sizes are limited to 8 MiB. Parsing uses a worker with a 10-second deadline and V8 heap limits; reports are capped at 10,000 findings. The Python wrapper applies an additional process timeout. Limit failures return an error rather than a partial report. These controls are not an OS security sandbox. Output can contain input strings and should be handled accordingly.
|
|
55
|
+
|
|
56
|
+
The CLI returns 0 for completed analysis, including findings, and 2 for errors. The Python API raises `ScannerError` when analysis fails.
|
|
57
|
+
|
|
58
|
+
Original code is MIT licensed. Bundled Acorn includes its MIT license. No malware samples or active credentials are distributed. See the [companion repository](https://github.com/KrasForge/unk-deaddrop-companion) and [preprint](https://doi.org/10.5281/zenodo.23652298).
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# unk-scanner for Python
|
|
2
|
+
|
|
3
|
+
Python CLI and API for the static JavaScript scanner from the [UNK_DeadDrop investigation](https://krasforge.github.io/UNK_DeadDrop/).
|
|
4
|
+
|
|
5
|
+
Requires Python 3.10+ and **Node.js 22+ on PATH**. The wheel bundles the same JavaScript engine as the npm distribution, plus Acorn 8.17.0. It does not require npm, execute submitted JavaScript, or download code during analysis.
|
|
6
|
+
|
|
7
|
+
## Installation and usage
|
|
8
|
+
|
|
9
|
+
Once published:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pip install unk-scanner
|
|
13
|
+
python -m unk_scanner suspect.js > findings.json
|
|
14
|
+
python -m unk_scanner --gzip captured-response.js > findings.json
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The distribution also installs an `unk-scanner` command. Prefer `python -m unk_scanner` if both npm and Python versions are installed, to make the selected installation explicit.
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from unk_scanner import scan, ScannerError
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
report = scan("suspect.js")
|
|
24
|
+
print(report["findings"])
|
|
25
|
+
except ScannerError as error:
|
|
26
|
+
print(error)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Scope
|
|
30
|
+
|
|
31
|
+
Reports contain original SHA-256 hashes, byte counts, source locations, findings, limitations, and separate artifact identity records. With `--gzip`, `decoded` records the decompressed hash and size. `artifactMatches` can identify ordinary login code or a shared polyfill; these are context, not malware alerts.
|
|
32
|
+
|
|
33
|
+
The scanner recognizes literal and selected identifier markers, clipboard writes, and one linked AES-GCM loader pattern. It does not decrypt payloads, resolve general aliases or obfuscated string tables, prove execution, or determine whether a file is safe. Exact identity matches cover only the listed bytes.
|
|
34
|
+
|
|
35
|
+
Input and decompressed sizes are limited to 8 MiB. Parsing uses a worker with a 10-second deadline and V8 heap limits; reports are capped at 10,000 findings. The Python wrapper applies an additional process timeout. Limit failures return an error rather than a partial report. These controls are not an OS security sandbox. Output can contain input strings and should be handled accordingly.
|
|
36
|
+
|
|
37
|
+
The CLI returns 0 for completed analysis, including findings, and 2 for errors. The Python API raises `ScannerError` when analysis fails.
|
|
38
|
+
|
|
39
|
+
Original code is MIT licensed. Bundled Acorn includes its MIT license. No malware samples or active credentials are distributed. See the [companion repository](https://github.com/KrasForge/unk-deaddrop-companion) and [preprint](https://doi.org/10.5281/zenodo.23652298).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "unk-scanner"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python CLI and API for static UNK_DeadDrop JavaScript triage (requires Node.js 22+)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{name = "Ilja Krasnjanski"}]
|
|
14
|
+
keywords = ["security", "static-analysis", "javascript", "unk-deaddrop"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Topic :: Security",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Homepage = "https://krasforge.github.io/UNK_DeadDrop/"
|
|
24
|
+
Repository = "https://github.com/KrasForge/unk-deaddrop-companion"
|
|
25
|
+
Research = "https://doi.org/10.5281/zenodo.23652298"
|
|
26
|
+
|
|
27
|
+
[project.scripts]
|
|
28
|
+
unk-scanner = "unk_scanner:main"
|
|
29
|
+
|
|
30
|
+
[tool.setuptools.packages.find]
|
|
31
|
+
where = ["src"]
|
|
32
|
+
|
|
33
|
+
[tool.setuptools]
|
|
34
|
+
include-package-data = true
|
|
35
|
+
|
|
36
|
+
[tool.setuptools.package-data]
|
|
37
|
+
unk_scanner = ["_engine/**/*"]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Python interface to the bundled static JavaScript scanner.
|
|
2
|
+
|
|
3
|
+
Requires Node.js >=22. Submitted source is parsed, never executed.
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
import re
|
|
10
|
+
import shutil
|
|
11
|
+
import subprocess
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
__version__ = "0.1.0"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ScannerError(RuntimeError):
|
|
18
|
+
"""The scanner could not produce a complete analysis."""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _command() -> list[str]:
|
|
22
|
+
node = shutil.which("node")
|
|
23
|
+
if node is None:
|
|
24
|
+
raise ScannerError("Node.js 22 or later is required; install Node.js and put node on PATH")
|
|
25
|
+
try:
|
|
26
|
+
version = subprocess.run(
|
|
27
|
+
[node, "--version"], capture_output=True, text=True, timeout=5, check=True
|
|
28
|
+
).stdout.strip()
|
|
29
|
+
except (OSError, subprocess.SubprocessError) as error:
|
|
30
|
+
raise ScannerError("Could not check the installed Node.js version") from error
|
|
31
|
+
match = re.fullmatch(r"v(\d+)\.\d+\.\d+(?:[-+].*)?", version)
|
|
32
|
+
if not match or int(match[1]) < 22:
|
|
33
|
+
raise ScannerError(f"Node.js 22 or later is required; found {version!r}")
|
|
34
|
+
return [node, str(Path(__file__).parent / "_engine" / "bin" / "unk-scanner.mjs")]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def scan(path: str | Path, *, gzip: bool = False, timeout: float = 30) -> dict:
|
|
38
|
+
"""Return the scanner's JSON result for one file.
|
|
39
|
+
|
|
40
|
+
gzip explicitly enables bounded gzip decoding. Findings are review leads;
|
|
41
|
+
artifactMatches are separate identity records, not malware verdicts.
|
|
42
|
+
"""
|
|
43
|
+
if timeout <= 0:
|
|
44
|
+
raise ValueError("timeout must be positive")
|
|
45
|
+
args = _command() + (["--gzip"] if gzip else []) + ["--", str(path)]
|
|
46
|
+
try:
|
|
47
|
+
result = subprocess.run(args, capture_output=True, text=True, encoding="utf-8", timeout=timeout)
|
|
48
|
+
except (OSError, subprocess.SubprocessError) as error:
|
|
49
|
+
raise ScannerError(f"Scanner process failed: {error}") from error
|
|
50
|
+
if result.returncode:
|
|
51
|
+
raise ScannerError(result.stderr.strip() or f"Scanner exited with code {result.returncode}")
|
|
52
|
+
try:
|
|
53
|
+
return json.loads(result.stdout)
|
|
54
|
+
except json.JSONDecodeError as error:
|
|
55
|
+
raise ScannerError("Scanner returned invalid JSON") from error
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def main() -> int:
|
|
59
|
+
try:
|
|
60
|
+
return subprocess.run(_command() + sys.argv[1:], timeout=30).returncode
|
|
61
|
+
except (ScannerError, OSError, subprocess.SubprocessError) as error:
|
|
62
|
+
print(f"unk-scanner: {error}", file=sys.stderr)
|
|
63
|
+
return 2
|
|
64
|
+
except KeyboardInterrupt:
|
|
65
|
+
return 130
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 UNK_DeadDrop research contributors
|
|
4
|
+
|
|
5
|
+
This license applies only to original code, tests, configuration and detection
|
|
6
|
+
rules in this companion repository. It does not cover research prose or any
|
|
7
|
+
third-party evidence.
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|