@reverse-craft/smart-fs 1.0.0
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.
- package/LICENSE +21 -0
- package/README.md +101 -0
- package/dist/server.js +41776 -0
- package/dist/server.js.map +7 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 reverse-craft
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# @reverse-craft/smart-fs
|
|
2
|
+
|
|
3
|
+
MCP server for AI-assisted JavaScript reverse engineering. Beautifies minified/obfuscated code and truncates long strings to prevent LLM context overflow.
|
|
4
|
+
|
|
5
|
+
## Why?
|
|
6
|
+
|
|
7
|
+
When reverse engineering JavaScript (especially JSVMP or heavily obfuscated code), AI assistants face two problems:
|
|
8
|
+
|
|
9
|
+
1. **Minified code is unreadable** - Single-line code with no formatting
|
|
10
|
+
2. **Long strings overflow context** - Base64 blobs, encrypted data, and huge arrays waste precious tokens
|
|
11
|
+
|
|
12
|
+
This MCP server solves both by:
|
|
13
|
+
- Auto-beautifying code with source maps (so you can set breakpoints in Chrome DevTools)
|
|
14
|
+
- Truncating strings over a configurable limit while preserving line numbers
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g @reverse-craft/smart-fs
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## MCP Configuration
|
|
23
|
+
|
|
24
|
+
Add to your MCP config (e.g., `~/.kiro/settings/mcp.json`):
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"mcpServers": {
|
|
29
|
+
"smart-fs": {
|
|
30
|
+
"command": "npx",
|
|
31
|
+
"args": ["@reverse-craft/smart-fs"]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or if installed globally:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"mcpServers": {
|
|
42
|
+
"smart-fs": {
|
|
43
|
+
"command": "smart-fs"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
The server provides one tool: `read_code_smart`
|
|
52
|
+
|
|
53
|
+
### Parameters
|
|
54
|
+
|
|
55
|
+
| Parameter | Type | Required | Default | Description |
|
|
56
|
+
|-----------|------|----------|---------|-------------|
|
|
57
|
+
| `file_path` | string | ✓ | - | Path to JavaScript file |
|
|
58
|
+
| `start_line` | number | ✓ | - | Start line (1-based) |
|
|
59
|
+
| `end_line` | number | ✓ | - | End line (1-based) |
|
|
60
|
+
| `char_limit` | number | | 300 | Max string length before truncation |
|
|
61
|
+
|
|
62
|
+
### Example Output
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
FILE: /path/to/obfuscated.js
|
|
66
|
+
VIEW: Auto-beautified (Lines 1-20 of 5000)
|
|
67
|
+
INFO: [Src L:C] = Location in original minified file (for Chrome Breakpoints)
|
|
68
|
+
-------------------------------------------------------------------------------------
|
|
69
|
+
1 | [Src L1:0 ] | var _0x1234 = function() {
|
|
70
|
+
2 | [Src L1:25 ] | var data = "SGVsbG8gV29ybGQ=...[TRUNCATED 50000 CHARS]...base64==";
|
|
71
|
+
3 | [Src L1:50078 ] | return decode(data);
|
|
72
|
+
4 | [Src L1:50100 ] | };
|
|
73
|
+
...
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The `[Src L:C]` column shows the original position in the minified file - use these coordinates to set breakpoints in Chrome DevTools.
|
|
77
|
+
|
|
78
|
+
## Features
|
|
79
|
+
|
|
80
|
+
- **Auto-beautify**: Formats minified JS using esbuild
|
|
81
|
+
- **Source maps**: Maps beautified lines back to original positions
|
|
82
|
+
- **Smart truncation**: Preserves line count when truncating strings
|
|
83
|
+
- **Caching**: Beautified files are cached based on file modification time
|
|
84
|
+
- **Pagination**: Large files can be read in chunks
|
|
85
|
+
|
|
86
|
+
## How It Works
|
|
87
|
+
|
|
88
|
+
1. **Beautification**: Uses esbuild to format minified code and generate source maps
|
|
89
|
+
2. **Truncation**: Parses AST with meriyah, truncates long string literals while preserving newlines
|
|
90
|
+
3. **Mapping**: Uses source-map-js to map each beautified line back to original coordinates
|
|
91
|
+
|
|
92
|
+
## Use Cases
|
|
93
|
+
|
|
94
|
+
- Reverse engineering JSVMP-protected code
|
|
95
|
+
- Analyzing obfuscated JavaScript
|
|
96
|
+
- Understanding minified third-party libraries
|
|
97
|
+
- Setting breakpoints in beautified code while debugging original
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
MIT
|