jame 1.0.dev0__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.
- jame-1.0.dev0/LICENSE +21 -0
- jame-1.0.dev0/PKG-INFO +169 -0
- jame-1.0.dev0/README.md +145 -0
- jame-1.0.dev0/jame/__init__.py +109 -0
- jame-1.0.dev0/jame/__main__.py +6 -0
- jame-1.0.dev0/jame/cli/__init__.py +1 -0
- jame-1.0.dev0/jame/cli/jame_cli.py +151 -0
- jame-1.0.dev0/jame/core/__init__.py +5 -0
- jame-1.0.dev0/jame/core/filetype.py +69 -0
- jame-1.0.dev0/jame/core/jame.py +372 -0
- jame-1.0.dev0/jame/core/patterns.py +72 -0
- jame-1.0.dev0/jame/core/utils.py +74 -0
- jame-1.0.dev0/jame/modules/__init__.py +53 -0
- jame-1.0.dev0/jame/modules/archive.py +63 -0
- jame-1.0.dev0/jame/modules/binary.py +60 -0
- jame-1.0.dev0/jame/modules/crypto.py +169 -0
- jame-1.0.dev0/jame/modules/forensics.py +69 -0
- jame-1.0.dev0/jame/modules/stego.py +65 -0
- jame-1.0.dev0/jame/results/__init__.py +18 -0
- jame-1.0.dev0/jame/results/binary_result.py +51 -0
- jame-1.0.dev0/jame/results/crypto_result.py +26 -0
- jame-1.0.dev0/jame/results/forensics_result.py +26 -0
- jame-1.0.dev0/jame/results/scan_result.py +26 -0
- jame-1.0.dev0/jame/results/solve_result.py +26 -0
- jame-1.0.dev0/jame/results/stego_result.py +26 -0
- jame-1.0.dev0/jame.egg-info/PKG-INFO +169 -0
- jame-1.0.dev0/jame.egg-info/SOURCES.txt +33 -0
- jame-1.0.dev0/jame.egg-info/dependency_links.txt +1 -0
- jame-1.0.dev0/jame.egg-info/entry_points.txt +2 -0
- jame-1.0.dev0/jame.egg-info/requires.txt +1 -0
- jame-1.0.dev0/jame.egg-info/top_level.txt +1 -0
- jame-1.0.dev0/pyproject.toml +79 -0
- jame-1.0.dev0/setup.cfg +4 -0
- jame-1.0.dev0/tests/test_api.py +206 -0
- jame-1.0.dev0/tests/test_cli.py +57 -0
jame-1.0.dev0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 JAMe Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
jame-1.0.dev0/PKG-INFO
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jame
|
|
3
|
+
Version: 1.0.dev0
|
|
4
|
+
Summary: Just Another Method of Exploitation
|
|
5
|
+
Author: JAMe Contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://example.com/jame
|
|
8
|
+
Project-URL: Documentation, https://example.com/jame/docs
|
|
9
|
+
Project-URL: Source, https://example.com/jame
|
|
10
|
+
Project-URL: Issues, https://example.com/jame/issues
|
|
11
|
+
Keywords: forensics,triage,security,steganography,crypto,extraction,jame
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Development Status :: 4 - Beta
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: PyYAML>=6.0
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# JAMe
|
|
26
|
+
|
|
27
|
+
Just Another Method of Exploitation.
|
|
28
|
+
|
|
29
|
+
JAMe is a lightweight forensic and triage toolkit for scanning files, extracting archives, identifying likely crypto patterns, checking for stegano indicators, and surfacing candidate flags in challenge files.
|
|
30
|
+
|
|
31
|
+
## Overview
|
|
32
|
+
|
|
33
|
+
- File type detection
|
|
34
|
+
- Flag hunting with custom wildcard patterns
|
|
35
|
+
- Crypto heuristics (base64/base32/base58, XOR, Caesar, Vigenere hints, hash detection)
|
|
36
|
+
- Binary triage with strings, readelf, and objdump-style output
|
|
37
|
+
- Steganography checks for LSB, appended ZIP, EXIF anomalies, and archive-style traces
|
|
38
|
+
- Forensics triage for PDF, PCAP, and carved content
|
|
39
|
+
- Archive extraction with recursive support and depth limits
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
JAMe requires Python 3.10 or newer. From the repository root, this one-line
|
|
44
|
+
installer creates the virtual environment, installs JAMe, links the command
|
|
45
|
+
into the absolute path `$HOME/.local/bin`, and adds that directory to the
|
|
46
|
+
current shell and future Bash login/interactive shells:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
python3 -m venv .venv && .venv/bin/pip install jame && mkdir -p "$HOME/.local/bin" && if [[ -e "$HOME/.local/bin/jame" && ! "$HOME/.local/bin/jame" -ef "$(pwd -P)/.venv/bin/jame" ]]; then printf '%s\n' 'Refusing to replace existing command at ~/.local/bin/jame' >&2; exit 1; fi && ln -sfn "$(pwd -P)/.venv/bin/jame" "$HOME/.local/bin/jame" && for rc in "$HOME/.profile" "$HOME/.bashrc"; do grep -qxF 'export PATH="$HOME/.local/bin:$PATH"' "$rc" 2>/dev/null || printf '%s\n' 'export PATH="$HOME/.local/bin:$PATH"' >> "$rc"; done && export PATH="$HOME/.local/bin:$PATH" && jame --help
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## CLI
|
|
53
|
+
|
|
54
|
+
From a checkout, the Bash launcher can also be run directly; it uses the active
|
|
55
|
+
virtual environment, the checkout's `.venv`, or `python3.10`, in that order:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
./jame.sh --help
|
|
59
|
+
./jame.sh tests/files/solution.txt
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The default command finds a flag and extracts supported archives. The original
|
|
63
|
+
path-only form remains supported:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
./jame.sh tests/files/solution.txt
|
|
67
|
+
./jame.sh solve tests/files/solution.txt --format 'flag{*}'
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Use `*` for any-length text and `*N` for exactly `N` characters. Repeating
|
|
71
|
+
unqualified asterisks does not set an exact length; for example, use `hcr{*5}`
|
|
72
|
+
to require five characters, not `hcr{*****}`.
|
|
73
|
+
|
|
74
|
+
Other available methods:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
./jame.sh find-flag tests/files/challenge.txt --format 'hcr{*4}'
|
|
78
|
+
./jame.sh scan tests/files/scan.txt
|
|
79
|
+
./jame.sh crypto tests/files/strings.txt --verbose
|
|
80
|
+
./jame.sh binary tests/files/strings.txt
|
|
81
|
+
./jame.sh stego tests/files/strings.txt
|
|
82
|
+
./jame.sh forensics tests/files/strings.txt
|
|
83
|
+
./jame.sh archive path/to/archive.zip --max-depth 2
|
|
84
|
+
./jame.sh file-type tests/files/strings.txt
|
|
85
|
+
./jame.sh strings tests/files/strings.txt
|
|
86
|
+
./jame.sh binwalk path/to/file.bin
|
|
87
|
+
./jame.sh caesar 'Khoor' --shift 3
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`--verbose` prints the structured result, including analyzer details and raw
|
|
91
|
+
output where available. `binwalk` requires the external `binwalk` utility.
|
|
92
|
+
|
|
93
|
+
## Quickstart
|
|
94
|
+
|
|
95
|
+
### Instance API
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
import jame
|
|
99
|
+
|
|
100
|
+
engine = jame.Jame()
|
|
101
|
+
result = engine.scanFile('example.bin')
|
|
102
|
+
print(result.summary)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Module-level API
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
import jame
|
|
109
|
+
|
|
110
|
+
result = jame.scanFile('example.bin')
|
|
111
|
+
print(result.summary)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Module-level functions use a shared singleton engine. Configuration set through
|
|
115
|
+
functions such as `jame.setFlagPatterns()` persists across subsequent module-level calls.
|
|
116
|
+
|
|
117
|
+
## API Reference
|
|
118
|
+
|
|
119
|
+
The camelCase API is available on `Jame` instances and as module-level functions.
|
|
120
|
+
Use the instance API for independent configurations, or the module-level API to
|
|
121
|
+
share one engine configuration.
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
import jame
|
|
125
|
+
|
|
126
|
+
jame.scanFile('path/to/file')
|
|
127
|
+
jame.findFlag('path/to/file', 'hcr{*4}')
|
|
128
|
+
jame.autoSolve('path/to/file', format='flag{*}')
|
|
129
|
+
jame.cryptoAnalyze('path/to/file')
|
|
130
|
+
jame.binaryAnalyze('path/to/file')
|
|
131
|
+
jame.stegoAnalyze('path/to/file')
|
|
132
|
+
jame.forensicsAnalyze('path/to/file')
|
|
133
|
+
jame.archiveExtract('path/to/archive.zip')
|
|
134
|
+
jame.decodeCaesar('uryyb', 'brute')
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Examples
|
|
138
|
+
|
|
139
|
+
### Find a flag-like value
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
import jame
|
|
143
|
+
|
|
144
|
+
flag = jame.findFlag('notes.txt', 'hcr{*4}')
|
|
145
|
+
print(flag)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Run a full scan
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
import jame
|
|
152
|
+
|
|
153
|
+
scan = jame.Jame().scanFile('challenge.bin')
|
|
154
|
+
print(scan.summary)
|
|
155
|
+
print(scan.confidence)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Decode Caesar candidates
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
import jame
|
|
162
|
+
|
|
163
|
+
result = jame.decodeCaesar('QEBJQ', 'brute') # brute is default
|
|
164
|
+
print(result)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
This project is licensed under the MIT License.
|
jame-1.0.dev0/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# JAMe
|
|
2
|
+
|
|
3
|
+
Just Another Method of Exploitation.
|
|
4
|
+
|
|
5
|
+
JAMe is a lightweight forensic and triage toolkit for scanning files, extracting archives, identifying likely crypto patterns, checking for stegano indicators, and surfacing candidate flags in challenge files.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
- File type detection
|
|
10
|
+
- Flag hunting with custom wildcard patterns
|
|
11
|
+
- Crypto heuristics (base64/base32/base58, XOR, Caesar, Vigenere hints, hash detection)
|
|
12
|
+
- Binary triage with strings, readelf, and objdump-style output
|
|
13
|
+
- Steganography checks for LSB, appended ZIP, EXIF anomalies, and archive-style traces
|
|
14
|
+
- Forensics triage for PDF, PCAP, and carved content
|
|
15
|
+
- Archive extraction with recursive support and depth limits
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
JAMe requires Python 3.10 or newer. From the repository root, this one-line
|
|
20
|
+
installer creates the virtual environment, installs JAMe, links the command
|
|
21
|
+
into the absolute path `$HOME/.local/bin`, and adds that directory to the
|
|
22
|
+
current shell and future Bash login/interactive shells:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
python3 -m venv .venv && .venv/bin/pip install jame && mkdir -p "$HOME/.local/bin" && if [[ -e "$HOME/.local/bin/jame" && ! "$HOME/.local/bin/jame" -ef "$(pwd -P)/.venv/bin/jame" ]]; then printf '%s\n' 'Refusing to replace existing command at ~/.local/bin/jame' >&2; exit 1; fi && ln -sfn "$(pwd -P)/.venv/bin/jame" "$HOME/.local/bin/jame" && for rc in "$HOME/.profile" "$HOME/.bashrc"; do grep -qxF 'export PATH="$HOME/.local/bin:$PATH"' "$rc" 2>/dev/null || printf '%s\n' 'export PATH="$HOME/.local/bin:$PATH"' >> "$rc"; done && export PATH="$HOME/.local/bin:$PATH" && jame --help
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## CLI
|
|
29
|
+
|
|
30
|
+
From a checkout, the Bash launcher can also be run directly; it uses the active
|
|
31
|
+
virtual environment, the checkout's `.venv`, or `python3.10`, in that order:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
./jame.sh --help
|
|
35
|
+
./jame.sh tests/files/solution.txt
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The default command finds a flag and extracts supported archives. The original
|
|
39
|
+
path-only form remains supported:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
./jame.sh tests/files/solution.txt
|
|
43
|
+
./jame.sh solve tests/files/solution.txt --format 'flag{*}'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Use `*` for any-length text and `*N` for exactly `N` characters. Repeating
|
|
47
|
+
unqualified asterisks does not set an exact length; for example, use `hcr{*5}`
|
|
48
|
+
to require five characters, not `hcr{*****}`.
|
|
49
|
+
|
|
50
|
+
Other available methods:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
./jame.sh find-flag tests/files/challenge.txt --format 'hcr{*4}'
|
|
54
|
+
./jame.sh scan tests/files/scan.txt
|
|
55
|
+
./jame.sh crypto tests/files/strings.txt --verbose
|
|
56
|
+
./jame.sh binary tests/files/strings.txt
|
|
57
|
+
./jame.sh stego tests/files/strings.txt
|
|
58
|
+
./jame.sh forensics tests/files/strings.txt
|
|
59
|
+
./jame.sh archive path/to/archive.zip --max-depth 2
|
|
60
|
+
./jame.sh file-type tests/files/strings.txt
|
|
61
|
+
./jame.sh strings tests/files/strings.txt
|
|
62
|
+
./jame.sh binwalk path/to/file.bin
|
|
63
|
+
./jame.sh caesar 'Khoor' --shift 3
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`--verbose` prints the structured result, including analyzer details and raw
|
|
67
|
+
output where available. `binwalk` requires the external `binwalk` utility.
|
|
68
|
+
|
|
69
|
+
## Quickstart
|
|
70
|
+
|
|
71
|
+
### Instance API
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
import jame
|
|
75
|
+
|
|
76
|
+
engine = jame.Jame()
|
|
77
|
+
result = engine.scanFile('example.bin')
|
|
78
|
+
print(result.summary)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Module-level API
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
import jame
|
|
85
|
+
|
|
86
|
+
result = jame.scanFile('example.bin')
|
|
87
|
+
print(result.summary)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Module-level functions use a shared singleton engine. Configuration set through
|
|
91
|
+
functions such as `jame.setFlagPatterns()` persists across subsequent module-level calls.
|
|
92
|
+
|
|
93
|
+
## API Reference
|
|
94
|
+
|
|
95
|
+
The camelCase API is available on `Jame` instances and as module-level functions.
|
|
96
|
+
Use the instance API for independent configurations, or the module-level API to
|
|
97
|
+
share one engine configuration.
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
import jame
|
|
101
|
+
|
|
102
|
+
jame.scanFile('path/to/file')
|
|
103
|
+
jame.findFlag('path/to/file', 'hcr{*4}')
|
|
104
|
+
jame.autoSolve('path/to/file', format='flag{*}')
|
|
105
|
+
jame.cryptoAnalyze('path/to/file')
|
|
106
|
+
jame.binaryAnalyze('path/to/file')
|
|
107
|
+
jame.stegoAnalyze('path/to/file')
|
|
108
|
+
jame.forensicsAnalyze('path/to/file')
|
|
109
|
+
jame.archiveExtract('path/to/archive.zip')
|
|
110
|
+
jame.decodeCaesar('uryyb', 'brute')
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Examples
|
|
114
|
+
|
|
115
|
+
### Find a flag-like value
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
import jame
|
|
119
|
+
|
|
120
|
+
flag = jame.findFlag('notes.txt', 'hcr{*4}')
|
|
121
|
+
print(flag)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Run a full scan
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
import jame
|
|
128
|
+
|
|
129
|
+
scan = jame.Jame().scanFile('challenge.bin')
|
|
130
|
+
print(scan.summary)
|
|
131
|
+
print(scan.confidence)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Decode Caesar candidates
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
import jame
|
|
138
|
+
|
|
139
|
+
result = jame.decodeCaesar('QEBJQ', 'brute') # brute is default
|
|
140
|
+
print(result)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
This project is licensed under the MIT License.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'''JAMe package.'''
|
|
2
|
+
|
|
3
|
+
from jame.core.jame import Jame, create_jame
|
|
4
|
+
from jame.results.binary_result import BinaryResult, BinwalkResult
|
|
5
|
+
from jame.results.crypto_result import CryptoResult
|
|
6
|
+
from jame.results.forensics_result import ForensicsResult
|
|
7
|
+
from jame.results.scan_result import ScanResult
|
|
8
|
+
from jame.results.solve_result import SolveResult
|
|
9
|
+
from jame.results.stego_result import StegoResult
|
|
10
|
+
|
|
11
|
+
__version__ = '0.1.0'
|
|
12
|
+
_engine = Jame()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def scanFile(path: str) -> ScanResult:
|
|
16
|
+
'''Scan a file using the shared JAMe engine.'''
|
|
17
|
+
return _engine.scanFile(path)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def findFlag(path: str, format: str) -> str | None:
|
|
21
|
+
'''Find a matching flag using the shared JAMe engine.'''
|
|
22
|
+
return _engine.findFlag(path, format)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def autoSolve(path: str, **ctx: object) -> SolveResult:
|
|
26
|
+
'''Run the solve workflow using the shared JAMe engine.'''
|
|
27
|
+
return _engine.autoSolve(path, **ctx)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def cryptoAnalyze(path: str) -> CryptoResult:
|
|
31
|
+
'''Analyze file crypto indicators using the shared JAMe engine.'''
|
|
32
|
+
return _engine.cryptoAnalyze(path)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def binaryAnalyze(path: str) -> BinaryResult:
|
|
36
|
+
'''Analyze binary indicators using the shared JAMe engine.'''
|
|
37
|
+
return _engine.binaryAnalyze(path)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def stegoAnalyze(path: str) -> StegoResult:
|
|
41
|
+
'''Analyze steganography indicators using the shared JAMe engine.'''
|
|
42
|
+
return _engine.stegoAnalyze(path)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def forensicsAnalyze(path: str) -> ForensicsResult:
|
|
46
|
+
'''Analyze forensic indicators using the shared JAMe engine.'''
|
|
47
|
+
return _engine.forensicsAnalyze(path)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def archiveExtract(path: str) -> list[str]:
|
|
51
|
+
'''Extract supported archives using the shared JAMe engine.'''
|
|
52
|
+
return _engine.archiveExtract(path)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def getFileType(path: str) -> str:
|
|
56
|
+
'''Return the file type using the shared JAMe engine.'''
|
|
57
|
+
return _engine.getFileType(path)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def decodeCaesar(text: str, shift: int | str = 'brute') -> dict:
|
|
61
|
+
'''Decode Caesar text using the shared JAMe engine.'''
|
|
62
|
+
return _engine.decodeCaesar(text, shift)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def setFlagPatterns(patterns: list[str]) -> None:
|
|
66
|
+
'''Set flag patterns on the shared JAMe engine.'''
|
|
67
|
+
_engine.setFlagPatterns(patterns)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def setMaxDepth(depth: int) -> None:
|
|
71
|
+
'''Set archive extraction depth on the shared JAMe engine.'''
|
|
72
|
+
_engine.setMaxDepth(depth)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def setVerbose(enabled: bool) -> None:
|
|
76
|
+
'''Set verbose mode on the shared JAMe engine.'''
|
|
77
|
+
_engine.setVerbose(enabled)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def runStrings(path: str) -> list[str]:
|
|
81
|
+
'''Extract printable strings using the shared JAMe engine.'''
|
|
82
|
+
return _engine.runStrings(path)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def runBinwalk(path: str) -> BinwalkResult:
|
|
86
|
+
'''Run binwalk using the shared JAMe engine.'''
|
|
87
|
+
return _engine.runBinwalk(path)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
__all__ = [
|
|
91
|
+
'Jame',
|
|
92
|
+
'__version__',
|
|
93
|
+
'archiveExtract',
|
|
94
|
+
'autoSolve',
|
|
95
|
+
'binaryAnalyze',
|
|
96
|
+
'create_jame',
|
|
97
|
+
'cryptoAnalyze',
|
|
98
|
+
'decodeCaesar',
|
|
99
|
+
'findFlag',
|
|
100
|
+
'forensicsAnalyze',
|
|
101
|
+
'getFileType',
|
|
102
|
+
'runBinwalk',
|
|
103
|
+
'runStrings',
|
|
104
|
+
'scanFile',
|
|
105
|
+
'setFlagPatterns',
|
|
106
|
+
'setMaxDepth',
|
|
107
|
+
'setVerbose',
|
|
108
|
+
'stegoAnalyze',
|
|
109
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'''Command-line entry points for JAMe.'''
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
'''Command-line entry point for JAMe.'''
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
from jame import Jame
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
_COMMANDS = {
|
|
11
|
+
'archive',
|
|
12
|
+
'binary',
|
|
13
|
+
'binwalk',
|
|
14
|
+
'caesar',
|
|
15
|
+
'crypto',
|
|
16
|
+
'file-type',
|
|
17
|
+
'find-flag',
|
|
18
|
+
'forensics',
|
|
19
|
+
'scan',
|
|
20
|
+
'solve',
|
|
21
|
+
'stego',
|
|
22
|
+
'strings',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _add_path_arguments(command: argparse.ArgumentParser) -> None:
|
|
27
|
+
command.add_argument('path', help='Path to the file to analyze')
|
|
28
|
+
command.add_argument('--verbose', action='store_true', help='Print structured result details')
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _build_parser() -> argparse.ArgumentParser:
|
|
32
|
+
parser = argparse.ArgumentParser(
|
|
33
|
+
prog='jame',
|
|
34
|
+
description='Just Another Method of Exploitation',
|
|
35
|
+
)
|
|
36
|
+
subparsers = parser.add_subparsers(dest='command', required=True)
|
|
37
|
+
|
|
38
|
+
solve = subparsers.add_parser('solve', help='Find a flag and extract supported archives')
|
|
39
|
+
_add_path_arguments(solve)
|
|
40
|
+
solve.add_argument(
|
|
41
|
+
'--format',
|
|
42
|
+
default='flag{*}',
|
|
43
|
+
help="Flag pattern; '*' matches any length and '*N' matches exactly N characters",
|
|
44
|
+
)
|
|
45
|
+
solve.add_argument('--max-depth', type=int, default=3, help='Archive extraction depth')
|
|
46
|
+
|
|
47
|
+
find_flag = subparsers.add_parser('find-flag', help='Find a flag matching a pattern')
|
|
48
|
+
_add_path_arguments(find_flag)
|
|
49
|
+
find_flag.add_argument(
|
|
50
|
+
'--format',
|
|
51
|
+
default='flag{*}',
|
|
52
|
+
help="Flag pattern; '*' matches any length and '*N' matches exactly N characters",
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
for name, description in (
|
|
56
|
+
('scan', 'Run all available analyzers'),
|
|
57
|
+
('crypto', 'Analyze crypto indicators'),
|
|
58
|
+
('binary', 'Analyze binary indicators'),
|
|
59
|
+
('stego', 'Check for steganography indicators'),
|
|
60
|
+
('forensics', 'Run forensic checks'),
|
|
61
|
+
('file-type', 'Detect the file type'),
|
|
62
|
+
('strings', 'Extract printable strings'),
|
|
63
|
+
('binwalk', 'Run binwalk when installed'),
|
|
64
|
+
):
|
|
65
|
+
command = subparsers.add_parser(name, help=description)
|
|
66
|
+
_add_path_arguments(command)
|
|
67
|
+
|
|
68
|
+
archive = subparsers.add_parser('archive', help='Extract supported archives')
|
|
69
|
+
_add_path_arguments(archive)
|
|
70
|
+
archive.add_argument('--max-depth', type=int, default=3, help='Archive extraction depth')
|
|
71
|
+
|
|
72
|
+
caesar = subparsers.add_parser('caesar', help='Decode Caesar-shifted text')
|
|
73
|
+
caesar.add_argument('text', help='Text to decode')
|
|
74
|
+
caesar.add_argument('--shift', default='brute', help="Integer shift or 'brute'")
|
|
75
|
+
caesar.add_argument('--verbose', action='store_true', help='Print structured result details')
|
|
76
|
+
|
|
77
|
+
return parser
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _print_result(result: object, verbose: bool) -> None:
|
|
81
|
+
if verbose:
|
|
82
|
+
to_dict = getattr(result, 'to_dict', None)
|
|
83
|
+
output = to_dict() if callable(to_dict) else result
|
|
84
|
+
print(json.dumps(output, indent=2, default=str))
|
|
85
|
+
elif hasattr(result, 'summary'):
|
|
86
|
+
print(result.summary)
|
|
87
|
+
elif result is None:
|
|
88
|
+
print('No flag found.')
|
|
89
|
+
elif isinstance(result, list):
|
|
90
|
+
print('\n'.join(str(item) for item in result) if result else 'No results.')
|
|
91
|
+
elif isinstance(result, (dict, tuple)):
|
|
92
|
+
print(json.dumps(result, indent=2, default=str))
|
|
93
|
+
else:
|
|
94
|
+
print(result)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def main() -> None:
|
|
98
|
+
'''Parse command-line options and run the requested JAMe method.'''
|
|
99
|
+
argv = sys.argv[1:]
|
|
100
|
+
if argv and argv[0] not in _COMMANDS and argv[0] not in {'-h', '--help'}:
|
|
101
|
+
argv.insert(0, 'solve')
|
|
102
|
+
|
|
103
|
+
parser = _build_parser()
|
|
104
|
+
args = parser.parse_args(argv)
|
|
105
|
+
max_depth = getattr(args, 'max_depth', 3)
|
|
106
|
+
engine = Jame(
|
|
107
|
+
flag_patterns=[getattr(args, 'format', 'flag{*}')],
|
|
108
|
+
max_depth=max_depth,
|
|
109
|
+
verbose=args.verbose,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
if args.command == 'solve':
|
|
113
|
+
result = engine.autoSolve(
|
|
114
|
+
args.path,
|
|
115
|
+
format=args.format,
|
|
116
|
+
maxDepth=args.max_depth,
|
|
117
|
+
verbose=args.verbose,
|
|
118
|
+
)
|
|
119
|
+
elif args.command == 'find-flag':
|
|
120
|
+
result = engine.findFlag(args.path, args.format)
|
|
121
|
+
elif args.command == 'scan':
|
|
122
|
+
result = engine.scanFile(args.path)
|
|
123
|
+
elif args.command == 'crypto':
|
|
124
|
+
result = engine.cryptoAnalyze(args.path)
|
|
125
|
+
elif args.command == 'binary':
|
|
126
|
+
result = engine.binaryAnalyze(args.path)
|
|
127
|
+
elif args.command == 'stego':
|
|
128
|
+
result = engine.stegoAnalyze(args.path)
|
|
129
|
+
elif args.command == 'forensics':
|
|
130
|
+
result = engine.forensicsAnalyze(args.path)
|
|
131
|
+
elif args.command == 'archive':
|
|
132
|
+
engine.setMaxDepth(args.max_depth)
|
|
133
|
+
result = engine.archiveExtract(args.path)
|
|
134
|
+
elif args.command == 'file-type':
|
|
135
|
+
result = engine.getFileType(args.path)
|
|
136
|
+
elif args.command == 'strings':
|
|
137
|
+
result = engine.runStrings(args.path)
|
|
138
|
+
elif args.command == 'binwalk':
|
|
139
|
+
result = engine.runBinwalk(args.path)
|
|
140
|
+
else:
|
|
141
|
+
try:
|
|
142
|
+
shift = 'brute' if args.shift == 'brute' else int(args.shift)
|
|
143
|
+
except ValueError:
|
|
144
|
+
parser.error("--shift must be an integer or 'brute'")
|
|
145
|
+
result = engine.decodeCaesar(args.text, shift)
|
|
146
|
+
|
|
147
|
+
_print_result(result, args.verbose)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
if __name__ == '__main__':
|
|
151
|
+
main()
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'''File type helpers for JAMe.'''
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def detect_file_type_from_bytes(data: bytes) -> str:
|
|
7
|
+
'''Return a best-effort file type label from the file header.'''
|
|
8
|
+
if len(data) >= 4 and data[:4] == b'\x7fELF':
|
|
9
|
+
return 'ELF binary'
|
|
10
|
+
if data.startswith(b'PK'):
|
|
11
|
+
return 'ZIP archive'
|
|
12
|
+
if data.startswith(b'\x1f\x8b'):
|
|
13
|
+
return 'GZIP compressed data'
|
|
14
|
+
if data.startswith(b'%PDF'):
|
|
15
|
+
return 'PDF document'
|
|
16
|
+
if data.startswith(b'\x89PNG'):
|
|
17
|
+
return 'PNG image'
|
|
18
|
+
if data.startswith(b'GIF8'):
|
|
19
|
+
return 'GIF image'
|
|
20
|
+
if data.startswith(b'RIFF') and data[8:12] == b'WAVE':
|
|
21
|
+
return 'WAV audio'
|
|
22
|
+
if data.startswith(b'\xff\xd8\xff'):
|
|
23
|
+
return 'JPEG image'
|
|
24
|
+
if data.startswith(b'#!'):
|
|
25
|
+
return 'script'
|
|
26
|
+
return 'unknown binary'
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_file_type(path: str) -> str:
|
|
30
|
+
'''Return a string label for a file based on extension and file header.'''
|
|
31
|
+
if not os.path.exists(path):
|
|
32
|
+
return 'missing'
|
|
33
|
+
|
|
34
|
+
_, ext = os.path.splitext(path)
|
|
35
|
+
ext = ext.lower()
|
|
36
|
+
lookup = {
|
|
37
|
+
'.zip': 'ZIP archive',
|
|
38
|
+
'.jar': 'JAR archive',
|
|
39
|
+
'.tar': 'TAR archive',
|
|
40
|
+
'.gz': 'GZIP archive',
|
|
41
|
+
'.bz2': 'BZIP2 archive',
|
|
42
|
+
'.xz': 'XZ archive',
|
|
43
|
+
'.pdf': 'PDF document',
|
|
44
|
+
'.png': 'PNG image',
|
|
45
|
+
'.jpg': 'JPEG image',
|
|
46
|
+
'.jpeg': 'JPEG image',
|
|
47
|
+
'.gif': 'GIF image',
|
|
48
|
+
'.pcap': 'PCAP capture',
|
|
49
|
+
'.pcapng': 'PCAPNG capture',
|
|
50
|
+
'.exe': 'PE binary',
|
|
51
|
+
'.dll': 'DLL binary',
|
|
52
|
+
'.so': 'shared object',
|
|
53
|
+
'.bin': 'binary blob',
|
|
54
|
+
'.txt': 'text file',
|
|
55
|
+
'.csv': 'CSV file',
|
|
56
|
+
'.py': 'Python source',
|
|
57
|
+
'.html': 'HTML document',
|
|
58
|
+
'.json': 'JSON document',
|
|
59
|
+
'.xml': 'XML document',
|
|
60
|
+
}
|
|
61
|
+
if ext in lookup:
|
|
62
|
+
return lookup[ext]
|
|
63
|
+
|
|
64
|
+
try:
|
|
65
|
+
with open(path, 'rb') as handle:
|
|
66
|
+
data = handle.read(256)
|
|
67
|
+
except OSError:
|
|
68
|
+
return 'unknown'
|
|
69
|
+
return detect_file_type_from_bytes(data)
|