muaddib-scanner 1.0.7 → 1.0.9
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/CONTRIBUTING.md +98 -0
- package/README.fr.md +310 -0
- package/README.md +118 -93
- package/bin/muaddib.js +33 -26
- package/data/iocs.json +28 -0
- package/package.json +1 -1
- package/src/index.js +73 -15
- package/src/ioc/scraper.js +91 -50
- package/src/rules/index.js +40 -1
- package/vscode-extension/extension.js +12 -5
- package/vscode-extension/package.json +8 -3
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Contributing to MUAD'DIB
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in improving MUAD'DIB!
|
|
4
|
+
|
|
5
|
+
## Ways to contribute
|
|
6
|
+
|
|
7
|
+
### 1. Add new IOCs (Indicators of Compromise)
|
|
8
|
+
|
|
9
|
+
Edit `iocs/packages.yaml` and add:
|
|
10
|
+
```yaml
|
|
11
|
+
- id: MALWARE-XXX-001
|
|
12
|
+
name: "malicious-package-name"
|
|
13
|
+
version: "*"
|
|
14
|
+
severity: critical
|
|
15
|
+
confidence: high
|
|
16
|
+
source: your-name
|
|
17
|
+
description: "Short description of the threat"
|
|
18
|
+
references:
|
|
19
|
+
- https://link-to-blog-or-advisory
|
|
20
|
+
mitre: T1195.002
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Severity levels:** critical, high, medium, low
|
|
24
|
+
|
|
25
|
+
**MITRE techniques:**
|
|
26
|
+
- T1195.002 — Supply chain compromise
|
|
27
|
+
- T1552.001 — Credentials in files
|
|
28
|
+
- T1059 — Command execution
|
|
29
|
+
- T1027 — Obfuscation
|
|
30
|
+
- T1041 — Exfiltration
|
|
31
|
+
|
|
32
|
+
### 2. Add detection rules
|
|
33
|
+
|
|
34
|
+
Edit `src/rules/index.js` and add a new rule:
|
|
35
|
+
```javascript
|
|
36
|
+
my_new_rule: {
|
|
37
|
+
id: 'MUADDIB-XXX-001',
|
|
38
|
+
name: 'My New Detection',
|
|
39
|
+
severity: 'HIGH',
|
|
40
|
+
confidence: 'high',
|
|
41
|
+
description: 'What this rule detects',
|
|
42
|
+
references: ['https://...'],
|
|
43
|
+
mitre: 'T1195.002'
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 3. Add response playbooks
|
|
48
|
+
|
|
49
|
+
Edit `src/response/playbooks.js` and add:
|
|
50
|
+
```javascript
|
|
51
|
+
case 'my_new_rule':
|
|
52
|
+
return 'Step-by-step response instructions';
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 4. Report false positives
|
|
56
|
+
|
|
57
|
+
Open an issue with:
|
|
58
|
+
- Package name
|
|
59
|
+
- Detection rule triggered
|
|
60
|
+
- Why it's a false positive
|
|
61
|
+
|
|
62
|
+
### 5. Report missed detections
|
|
63
|
+
|
|
64
|
+
Open an issue with:
|
|
65
|
+
- Malicious package name
|
|
66
|
+
- What it does
|
|
67
|
+
- Links to advisories
|
|
68
|
+
|
|
69
|
+
## Development
|
|
70
|
+
```bash
|
|
71
|
+
git clone https://github.com/DNSZLSK/muad-dib.git
|
|
72
|
+
cd muad-dib
|
|
73
|
+
npm install
|
|
74
|
+
npm test
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Testing your changes
|
|
78
|
+
```bash
|
|
79
|
+
node bin/muaddib.js scan tests/samples --explain
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Pull request process
|
|
83
|
+
|
|
84
|
+
1. Fork the repo
|
|
85
|
+
2. Create a branch (`git checkout -b feature/my-feature`)
|
|
86
|
+
3. Make your changes
|
|
87
|
+
4. Run tests (`npm test`)
|
|
88
|
+
5. Commit (`git commit -m "Add my feature"`)
|
|
89
|
+
6. Push (`git push origin feature/my-feature`)
|
|
90
|
+
7. Open a Pull Request
|
|
91
|
+
|
|
92
|
+
## Code of conduct
|
|
93
|
+
|
|
94
|
+
Be respectful. We're all here to make npm safer.
|
|
95
|
+
|
|
96
|
+
## Questions?
|
|
97
|
+
|
|
98
|
+
Open an issue or join our Discord: https://discord.gg/y8zxSmue
|
package/README.fr.md
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="MUADDIBLOGO.png" alt="MUAD'DIB Logo" width="200">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">MUAD'DIB</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Supply-chain threat detection & response for npm</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<img src="https://img.shields.io/npm/v/muaddib-scanner" alt="npm version">
|
|
13
|
+
<img src="https://img.shields.io/badge/license-MIT-green" alt="License">
|
|
14
|
+
<img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen" alt="Node">
|
|
15
|
+
<img src="https://img.shields.io/badge/IOCs-180%2B-red" alt="IOCs">
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
<p align="center">
|
|
19
|
+
<a href="#installation">Installation</a> |
|
|
20
|
+
<a href="#utilisation">Utilisation</a> |
|
|
21
|
+
<a href="#features">Features</a> |
|
|
22
|
+
<a href="#vs-code">VS Code</a> |
|
|
23
|
+
<a href="#discord">Discord</a>
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Pourquoi MUAD'DIB ?
|
|
29
|
+
|
|
30
|
+
Les attaques supply chain npm explosent. Shai-Hulud a compromis 25K+ repos en 2025. Les outils existants detectent, mais n'aident pas a repondre.
|
|
31
|
+
|
|
32
|
+
MUAD'DIB detecte ET guide la reponse.
|
|
33
|
+
|
|
34
|
+
| Feature | MUAD'DIB | Socket | Snyk |
|
|
35
|
+
|---------|----------|--------|------|
|
|
36
|
+
| Detection IOCs | Oui | Oui | Oui |
|
|
37
|
+
| Analyse AST | Oui | Oui | Non |
|
|
38
|
+
| Analyse Dataflow | Oui | Non | Non |
|
|
39
|
+
| Detection Typosquatting | Oui | Oui | Non |
|
|
40
|
+
| Playbooks reponse | Oui | Non | Non |
|
|
41
|
+
| Score de risque | Oui | Oui | Oui |
|
|
42
|
+
| SARIF / GitHub Security | Oui | Oui | Oui |
|
|
43
|
+
| MITRE ATT&CK mapping | Oui | Non | Non |
|
|
44
|
+
| Webhook Discord/Slack | Oui | Non | Non |
|
|
45
|
+
| Extension VS Code | Oui | Oui | Oui |
|
|
46
|
+
| Mode daemon | Oui | Non | Non |
|
|
47
|
+
| 100% Open Source | Oui | Non | Non |
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
### npm (recommande)
|
|
54
|
+
```bash
|
|
55
|
+
npm install -g muaddib-scanner
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Depuis les sources
|
|
59
|
+
```bash
|
|
60
|
+
git clone https://github.com/DNSZLSK/muad-dib.git
|
|
61
|
+
cd muad-dib
|
|
62
|
+
npm install
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Utilisation
|
|
68
|
+
|
|
69
|
+
### Scan basique
|
|
70
|
+
```bash
|
|
71
|
+
muaddib scan .
|
|
72
|
+
muaddib scan /chemin/vers/projet
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Score de risque
|
|
76
|
+
|
|
77
|
+
Chaque scan affiche un score de risque 0-100 :
|
|
78
|
+
```
|
|
79
|
+
[SCORE] 58/100 [███████████░░░░░░░░░] HIGH
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Mode explain (details complets)
|
|
83
|
+
```bash
|
|
84
|
+
muaddib scan . --explain
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Affiche pour chaque detection :
|
|
88
|
+
- Rule ID
|
|
89
|
+
- MITRE ATT&CK technique
|
|
90
|
+
- References (articles, CVEs)
|
|
91
|
+
- Playbook de reponse
|
|
92
|
+
|
|
93
|
+
### Export
|
|
94
|
+
```bash
|
|
95
|
+
muaddib scan . --json > results.json # JSON
|
|
96
|
+
muaddib scan . --html rapport.html # HTML
|
|
97
|
+
muaddib scan . --sarif results.sarif # SARIF (GitHub Security)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Seuil de severite
|
|
101
|
+
```bash
|
|
102
|
+
muaddib scan . --fail-on critical # Fail seulement sur CRITICAL
|
|
103
|
+
muaddib scan . --fail-on high # Fail sur HIGH et CRITICAL (defaut)
|
|
104
|
+
muaddib scan . --fail-on medium # Fail sur MEDIUM, HIGH, CRITICAL
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Webhook Discord/Slack
|
|
108
|
+
```bash
|
|
109
|
+
muaddib scan . --webhook "https://discord.com/api/webhooks/..."
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Envoie une alerte avec le score et les menaces sur Discord ou Slack.
|
|
113
|
+
|
|
114
|
+
### Surveillance temps reel
|
|
115
|
+
```bash
|
|
116
|
+
muaddib watch .
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Mode daemon
|
|
120
|
+
```bash
|
|
121
|
+
muaddib daemon
|
|
122
|
+
muaddib daemon --webhook "https://discord.com/api/webhooks/..."
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Surveille automatiquement tous les `npm install` et scanne les nouveaux packages.
|
|
126
|
+
|
|
127
|
+
### Mise a jour des IOCs
|
|
128
|
+
```bash
|
|
129
|
+
muaddib update
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Features
|
|
135
|
+
|
|
136
|
+
### Detection typosquatting
|
|
137
|
+
|
|
138
|
+
MUAD'DIB detecte les packages dont le nom ressemble a un package populaire :
|
|
139
|
+
```
|
|
140
|
+
[HIGH] Package "lodahs" ressemble a "lodash" (swapped_chars). Possible typosquatting.
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Analyse dataflow
|
|
144
|
+
|
|
145
|
+
Detecte quand du code lit des credentials ET les envoie sur le reseau :
|
|
146
|
+
```
|
|
147
|
+
[CRITICAL] Flux suspect: lecture credentials (readFileSync, GITHUB_TOKEN) + envoi reseau (fetch)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Attaques detectees
|
|
151
|
+
|
|
152
|
+
| Campagne | Packages | Status |
|
|
153
|
+
|----------|----------|--------|
|
|
154
|
+
| Shai-Hulud v1 | @ctrl/tinycolor, ng2-file-upload | Detecte |
|
|
155
|
+
| Shai-Hulud v2 | @asyncapi/specs, posthog-node, kill-port | Detecte |
|
|
156
|
+
| Shai-Hulud v3 | @vietmoney/react-big-calendar | Detecte |
|
|
157
|
+
| event-stream (2018) | flatmap-stream, event-stream | Detecte |
|
|
158
|
+
| eslint-scope (2018) | eslint-scope | Detecte |
|
|
159
|
+
| Protestware | node-ipc, colors, faker | Detecte |
|
|
160
|
+
| Typosquats | crossenv, mongose, babelcli | Detecte |
|
|
161
|
+
|
|
162
|
+
### Techniques detectees
|
|
163
|
+
|
|
164
|
+
| Technique | MITRE | Detection |
|
|
165
|
+
|-----------|-------|-----------|
|
|
166
|
+
| Vol credentials (.npmrc, .ssh) | T1552.001 | AST |
|
|
167
|
+
| Exfiltration env vars | T1552.001 | AST |
|
|
168
|
+
| Execution code distant | T1105 | Pattern |
|
|
169
|
+
| Reverse shell | T1059.004 | Pattern |
|
|
170
|
+
| Dead man's switch | T1485 | Pattern |
|
|
171
|
+
| Code obfusque | T1027 | Heuristiques |
|
|
172
|
+
| Typosquatting | T1195.002 | Levenshtein |
|
|
173
|
+
| Supply chain compromise | T1195.002 | IOC matching |
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## VS Code
|
|
178
|
+
|
|
179
|
+
L'extension VS Code scanne automatiquement vos projets npm.
|
|
180
|
+
|
|
181
|
+
### Installation
|
|
182
|
+
|
|
183
|
+
Le dossier `vscode-extension/` contient l'extension. Pour tester :
|
|
184
|
+
|
|
185
|
+
1. Ouvrir le dossier `vscode-extension` dans VS Code
|
|
186
|
+
2. Appuyer sur F5
|
|
187
|
+
3. Dans la nouvelle fenetre, ouvrir un projet npm
|
|
188
|
+
|
|
189
|
+
### Commandes
|
|
190
|
+
|
|
191
|
+
- `MUAD'DIB: Scan Project` - Scanner tout le projet
|
|
192
|
+
- `MUAD'DIB: Scan Current File` - Scanner le fichier actuel
|
|
193
|
+
|
|
194
|
+
### Configuration
|
|
195
|
+
|
|
196
|
+
- `muaddib.autoScan` - Scanner automatiquement a l'ouverture (defaut: true)
|
|
197
|
+
- `muaddib.webhookUrl` - URL webhook Discord/Slack
|
|
198
|
+
- `muaddib.failLevel` - Niveau d'alerte (critical/high/medium/low)
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Integration CI/CD
|
|
203
|
+
|
|
204
|
+
### GitHub Actions
|
|
205
|
+
```yaml
|
|
206
|
+
name: Security Scan
|
|
207
|
+
|
|
208
|
+
on: [push, pull_request]
|
|
209
|
+
|
|
210
|
+
jobs:
|
|
211
|
+
scan:
|
|
212
|
+
runs-on: ubuntu-latest
|
|
213
|
+
permissions:
|
|
214
|
+
security-events: write
|
|
215
|
+
contents: read
|
|
216
|
+
steps:
|
|
217
|
+
- uses: actions/checkout@v4
|
|
218
|
+
- uses: actions/setup-node@v4
|
|
219
|
+
with:
|
|
220
|
+
node-version: '20'
|
|
221
|
+
- run: npm install -g muaddib-scanner
|
|
222
|
+
- run: muaddib scan . --sarif results.sarif
|
|
223
|
+
- uses: github/codeql-action/upload-sarif@v3
|
|
224
|
+
with:
|
|
225
|
+
sarif_file: results.sarif
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Les alertes apparaissent dans Security > Code scanning alerts.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Discord
|
|
233
|
+
|
|
234
|
+
Rejoignez le serveur Discord pour :
|
|
235
|
+
- Recevoir les alertes de scan
|
|
236
|
+
- Partager des IOCs
|
|
237
|
+
- Contribuer au projet
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Architecture
|
|
242
|
+
```
|
|
243
|
+
MUAD'DIB Scanner
|
|
244
|
+
|
|
|
245
|
+
+-- IOC Match (YAML DB)
|
|
246
|
+
+-- AST Parse (acorn)
|
|
247
|
+
+-- Pattern Matching (shell, scripts)
|
|
248
|
+
+-- Typosquat Detection (Levenshtein)
|
|
249
|
+
|
|
|
250
|
+
v
|
|
251
|
+
Dataflow Analysis (credential read -> network send)
|
|
252
|
+
|
|
|
253
|
+
v
|
|
254
|
+
Threat Enrichment (rules, MITRE ATT&CK, playbooks)
|
|
255
|
+
|
|
|
256
|
+
v
|
|
257
|
+
Output (CLI, JSON, HTML, SARIF, Webhook)
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Contribuer
|
|
263
|
+
|
|
264
|
+
### Ajouter des IOCs
|
|
265
|
+
|
|
266
|
+
Editez les fichiers YAML dans `iocs/` :
|
|
267
|
+
```yaml
|
|
268
|
+
- id: NEW-MALWARE-001
|
|
269
|
+
name: "malicious-package"
|
|
270
|
+
version: "*"
|
|
271
|
+
severity: critical
|
|
272
|
+
confidence: high
|
|
273
|
+
source: community
|
|
274
|
+
description: "Description de la menace"
|
|
275
|
+
references:
|
|
276
|
+
- https://example.com/article
|
|
277
|
+
mitre: T1195.002
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Developper
|
|
281
|
+
```bash
|
|
282
|
+
git clone https://github.com/DNSZLSK/muad-dib.git
|
|
283
|
+
cd muad-dib
|
|
284
|
+
npm install
|
|
285
|
+
npm test
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Communaute
|
|
289
|
+
|
|
290
|
+
- Discord: https://discord.gg/y8zxSmue
|
|
291
|
+
- Issues: https://github.com/DNSZLSK/muad-dib/issues
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Documentation
|
|
296
|
+
|
|
297
|
+
- [Threat Model](docs/threat-model.md) - Ce que MUAD'DIB detecte et ne detecte pas
|
|
298
|
+
- [IOCs YAML](iocs/) - Base de donnees des menaces
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Licence
|
|
303
|
+
|
|
304
|
+
MIT
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
<p align="center">
|
|
309
|
+
<strong>The spice must flow. The worms must die.</strong>
|
|
310
|
+
</p>
|