redgun-security 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.
@@ -0,0 +1,21 @@
1
+ name: Security
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ pull_request:
6
+
7
+ permissions:
8
+ contents: write
9
+ pull-requests: write
10
+ security-events: write
11
+
12
+ jobs:
13
+ redgun:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: actions/setup-node@v4
18
+ with:
19
+ node-version: '20'
20
+ - run: npm ci
21
+ - run: node bin/redgun.js audit . --ci --min-score 70
package/.redgunignore ADDED
@@ -0,0 +1,11 @@
1
+ # Ignore translation files
2
+ **/i18n/**
3
+ **/locales/**
4
+
5
+ # Ignore test fixtures
6
+ **/fixtures/**
7
+ **/test-data/**
8
+
9
+ # Ignore by pattern
10
+ *.locale.*
11
+ *.min.js
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 aloc999
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,281 @@
1
+ <p align="center">
2
+ <pre align="center">
3
+ ██████╗ ███████╗██████╗ ██████╗ ██╗ ██╗███╗ ██╗
4
+ ██╔══██╗██╔════╝██╔══██╗██╔════╝ ██║ ██║████╗ ██║
5
+ ██████╔╝█████╗ ██║ ██║██║ ███╗██║ ██║██╔██╗ ██║
6
+ ██╔══██╗██╔══╝ ██║ ██║██║ ██║██║ ██║██║╚██╗██║
7
+ ██║ ██║███████╗██████╔╝╚██████╔╝╚██████╔╝██║ ╚████║
8
+ ╚═╝ ╚═╝╚══════╝╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝
9
+ </pre>
10
+ </p>
11
+
12
+ <p align="center">
13
+ <strong>Black-box & white-box security auditor for web applications — HackTricks Enhanced.</strong>
14
+ </p>
15
+
16
+ <p align="center">
17
+ <a href="https://github.com/aloc999/redgun/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="License"></a>
18
+ <img src="https://img.shields.io/badge/node-%3E%3D18-green" alt="Node">
19
+ <img src="https://img.shields.io/badge/modules-39-ff4444" alt="Modules">
20
+ <img src="https://img.shields.io/badge/HackTricks-Enhanced-critical" alt="HackTricks">
21
+ </p>
22
+
23
+ <br>
24
+
25
+ ## What is RedGun?
26
+
27
+ RedGun is a security auditing CLI tool that finds vulnerabilities in your web applications. It includes **39 security modules** covering techniques from [HackTricks](https://book.hacktricks.wiki). Two modes:
28
+
29
+ **Remote scan** (black-box): Give it a URL. It tests your site from the outside — XSS, SQLi, SSRF, CORS, CRLF injection, cache poisoning, host header injection, HTTP request smuggling, GraphQL introspection, path traversal, NoSQL injection, and more.
30
+
31
+ **Local audit** (white-box): Point it at your project directory. It reads your source code checking for secrets, SSTI, insecure deserialization, prototype pollution, JWT vulnerabilities, command injection, weak crypto, path traversal, and more.
32
+
33
+ <br>
34
+
35
+ ## Quick start
36
+
37
+ ```bash
38
+ # Install globally
39
+ npm install -g redgun-security
40
+
41
+ # Interactive mode
42
+ redgun
43
+
44
+ # Or run directly
45
+ redgun scan https://target.com # Remote scan (black-box)
46
+ redgun audit . # Local audit (white-box)
47
+ redgun audit . --ci # CI mode (exit code 0 or 1)
48
+ redgun history # View saved reports
49
+ redgun modules # List all modules
50
+ ```
51
+
52
+ <br>
53
+
54
+ ## Remote Scan Modules (25 — Black-box)
55
+
56
+ | Module | What it tests | Source |
57
+ |---|---|---|
58
+ | **HTTP Headers** | Missing CSP, HSTS, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, COOP, CORP, COEP | OWASP |
59
+ | **Exposed Files** | `.env`, `.git/config`, `package.json`, `.DS_Store`, source maps, actuator, swagger, phpinfo, Docker files, backups | HackTricks |
60
+ | **Secrets Detection** | API keys (AWS, Stripe, Firebase, Supabase, OpenAI, Anthropic), tokens, passwords in page source | HackTricks |
61
+ | **XSS Reflected** | 6 payloads × 14 parameters, DOM-based indicators | HackTricks |
62
+ | **SQL Injection** | Error-based, UNION-based, time-based blind across common parameters | HackTricks |
63
+ | **CORS Misconfiguration** | Wildcard + credentials, reflected origin, null origin | HackTricks |
64
+ | **Open Redirect** | 12 redirect parameters tested with external URL | HackTricks |
65
+ | **SSRF** | AWS metadata, internal IPs, localhost, IPv6, decimal IP, file:// protocol | HackTricks |
66
+ | **Host Header Injection** | Reflected host, X-Forwarded-Host poisoning | HackTricks |
67
+ | **HTTP Request Smuggling** | CL.TE probe detection | HackTricks |
68
+ | **CRLF Injection** | Header injection via URL encoding variants | HackTricks |
69
+ | **GraphQL Introspection** | Schema exposure via introspection query at 5 endpoints | HackTricks |
70
+ | **Clickjacking** | Missing X-Frame-Options and frame-ancestors CSP | OWASP |
71
+ | **Cookie Security** | Missing HttpOnly, Secure, SameSite flags | OWASP |
72
+ | **HTTP Methods** | TRACE, PUT, DELETE enabled | HackTricks |
73
+ | **Subdomain Enumeration** | 40+ common subdomains, dangerous subdomain detection | HackTricks |
74
+ | **DNS & Email** | SPF, DKIM, DMARC analysis | HackTricks |
75
+ | **Technology Fingerprint** | 40+ frameworks, servers, and services detected | — |
76
+ | **API Discovery** | Common API paths, auth testing | HackTricks |
77
+ | **SSL/TLS Analysis** | HTTP vs HTTPS detection | OWASP |
78
+ | **Path Traversal / LFI** | Double-encoding, unicode bypass, null byte | HackTricks |
79
+ | **NoSQL Injection** | MongoDB operator injection auth bypass | HackTricks |
80
+ | **WebSocket Security** | Origin validation, authentication checks | HackTricks |
81
+ | **Cache Poisoning** | Unkeyed headers (X-Forwarded-Host, X-Forwarded-Scheme, X-Original-URL) | HackTricks |
82
+ | **Race Conditions** | Detection guidance for concurrent request attacks | HackTricks |
83
+
84
+ <br>
85
+
86
+ ## Local Audit Modules (14 — White-box)
87
+
88
+ | Module | What it checks | Source |
89
+ |---|---|---|
90
+ | **Code Secrets** | 25+ secret patterns (AWS, GitHub, Stripe, OpenAI, Anthropic, Discord, Telegram, npm, etc.) with line numbers | HackTricks |
91
+ | **Environment Files** | `.env` in `.gitignore`, real secrets in `.env.example`, sensitive config exposure | OWASP |
92
+ | **Dependencies** | `npm audit` for CVEs, supply-chain attack package detection | OWASP |
93
+ | **Code Vulnerabilities** | SQL injection (template literals), XSS (`v-html`, `dangerouslySetInnerHTML`, `innerHTML`), eval(), ReDoS | HackTricks |
94
+ | **Auth & Middleware** | Rate limiting, CORS wildcards, CSRF protection, session config, JWT expiration, hardcoded passwords | HackTricks |
95
+ | **Headers Config** | CSP/HSTS in Nuxt, Next.js, Vercel, Netlify, Express configs | OWASP |
96
+ | **SSRF Detection** | User-controlled URLs in fetch/axios/request/http.get/urllib | HackTricks |
97
+ | **SSTI Detection** | Jinja2, Twig, Nunjucks, Pug, EJS, Handlebars, Velocity, Freemarker, Thymeleaf | HackTricks |
98
+ | **Insecure Deserialization** | pickle, yaml.load, unserialize, ObjectInputStream, Marshal, BinaryFormatter | HackTricks |
99
+ | **Prototype Pollution** | Object.assign, spread operator, deepmerge, lodash.merge, __proto__ access | HackTricks |
100
+ | **JWT Vulnerabilities** | Algorithm "none", verify disabled, weak secrets, expiration bypass, decode without verify | HackTricks |
101
+ | **Path Traversal / LFI** | User input in file paths, readFile, sendFile, include/require | HackTricks |
102
+ | **Command Injection** | exec, spawn, child_process, system, subprocess with user input, shell interpolation | HackTricks |
103
+ | **Weak Cryptography** | MD5, SHA1, DES, RC4, ECB mode, Math.random, hardcoded keys/IVs | HackTricks |
104
+
105
+ <br>
106
+
107
+ ## GitHub Action
108
+
109
+ Add `.github/workflows/security.yml` to your repo:
110
+
111
+ ```yaml
112
+ name: Security
113
+ on:
114
+ push:
115
+ branches: [main]
116
+ pull_request:
117
+
118
+ permissions:
119
+ contents: write
120
+ pull-requests: write
121
+ security-events: write
122
+
123
+ jobs:
124
+ redgun:
125
+ runs-on: ubuntu-latest
126
+ steps:
127
+ - uses: actions/checkout@v4
128
+ - uses: aloc999/redgun@v1
129
+ ```
130
+
131
+ ### Inputs
132
+
133
+ | Input | Description | Default |
134
+ |---|---|---|
135
+ | `path` | Project path to audit | `.` |
136
+ | `min-score` | Minimum score required to pass (0-100) | `70` |
137
+ | `fail-on-score` | Fail the workflow if score is below min-score | `true` |
138
+ | `comment-pr` | Post a comment on pull requests | `true` |
139
+ | `update-badge` | Update the security badge file on push | `true` |
140
+ | `upload-sarif` | Upload SARIF findings to GitHub Code Scanning | `true` |
141
+
142
+ ### Outputs
143
+
144
+ | Output | Description |
145
+ |---|---|
146
+ | `score` | Security score from 0 to 100 |
147
+ | `grade` | Grade from A to F |
148
+ | `total-findings` | Total number of findings |
149
+ | `critical-findings` | Number of critical findings |
150
+ | `high-findings` | Number of high severity findings |
151
+
152
+ <br>
153
+
154
+ ## Scoring
155
+
156
+ Every scan produces a security score from 0 to 100, graded A through F.
157
+
158
+ | Severity | Score impact | Meaning |
159
+ |---|---|---|
160
+ | **Critical** | -15 | Exploitable vulnerability, immediate action required |
161
+ | **High** | -8 | Serious risk, fix soon |
162
+ | **Medium** | -3 | Moderate risk, fix when possible |
163
+ | **Low** | -1 | Minor risk |
164
+ | **Info** | 0 | Informational, no action needed |
165
+
166
+ <br>
167
+
168
+ ## Configuration
169
+
170
+ ### CLI options
171
+
172
+ ```bash
173
+ redgun scan # Interactive remote scan
174
+ redgun scan https://target.com # Direct URL scan
175
+ redgun audit . # Audit current directory
176
+ redgun audit /path/to/project # Audit specific project
177
+ redgun audit . --ci # CI mode, exit 1 if score < 70
178
+ redgun audit . --ci --min-score 80 # Custom threshold
179
+ redgun audit . --modules secrets,jwt # Run specific modules only
180
+ redgun audit . --sarif # Generate SARIF output
181
+ redgun history # Browse saved reports
182
+ redgun modules # List all modules
183
+ ```
184
+
185
+ ### Config file (optional)
186
+
187
+ Create `redgun.config.js` in your project root:
188
+
189
+ ```js
190
+ export default {
191
+ url: 'https://your-site.com',
192
+ ignore: ['Firebase API Key'],
193
+ ci: {
194
+ minScore: 70,
195
+ failOnCritical: true,
196
+ },
197
+ }
198
+ ```
199
+
200
+ ### `.redgunignore` (optional)
201
+
202
+ Create a `.redgunignore` file to exclude files from local audit:
203
+
204
+ ```
205
+ **/i18n/**
206
+ **/locales/**
207
+ *.locale.*
208
+ ```
209
+
210
+ <br>
211
+
212
+ ## HackTricks Techniques Included
213
+
214
+ RedGun integrates techniques documented in [HackTricks](https://book.hacktricks.wiki):
215
+
216
+ - **SSRF** — AWS/GCP metadata, internal IP bypass, DNS rebinding indicators
217
+ - **SSTI** — Template engine detection and exploitation patterns
218
+ - **Insecure Deserialization** — Language-specific gadget chain detection
219
+ - **Prototype Pollution** — Object merge sinks and __proto__ injection
220
+ - **JWT Attacks** — Algorithm confusion, none bypass, key brute-force indicators
221
+ - **HTTP Request Smuggling** — CL.TE/TE.CL probe methodology
222
+ - **Cache Poisoning** — Unkeyed header detection and Web Cache Deception
223
+ - **CRLF Injection** — Header injection via encoding variants
224
+ - **GraphQL** — Introspection, batching, query depth abuse
225
+ - **NoSQL Injection** — MongoDB operator injection ($ne, $gt, $regex)
226
+ - **Host Header Injection** — Password reset poisoning, cache poisoning via Host
227
+ - **Path Traversal** — Double encoding, unicode bypass, null byte truncation
228
+ - **Command Injection** — Shell metacharacter injection patterns
229
+ - **Race Conditions** — Single-packet HTTP/2 attack detection guidance
230
+ - **Open Redirect** — OAuth token theft chain detection
231
+ - **Subdomain Takeover** — Dangling CNAME detection
232
+ - **Weak Cryptography** — Deprecated algorithms and hardcoded key detection
233
+
234
+ <br>
235
+
236
+ ## Project Structure
237
+
238
+ ```
239
+ redgun/
240
+ ├── bin/
241
+ │ └── redgun.js # CLI entry point
242
+ ├── src/
243
+ │ ├── core/
244
+ │ │ ├── findings.js # Shared findings store
245
+ │ │ ├── score.js # A-F score calculator
246
+ │ │ └── reporter/
247
+ │ │ ├── console.js # Terminal output
248
+ │ │ ├── json.js # JSON + SARIF export
249
+ │ │ └── html.js # HTML report
250
+ │ ├── local/ # White-box modules (14)
251
+ │ │ ├── index.js # Module orchestrator
252
+ │ │ ├── secrets.js # Source code secrets
253
+ │ │ ├── env.js # .env audit
254
+ │ │ ├── dependencies.js # npm audit + supply chain
255
+ │ │ ├── code-vulnerabilities.js # SQLi, XSS, eval, ReDoS
256
+ │ │ ├── auth.js # Auth & middleware
257
+ │ │ ├── headers-config.js # CSP/HSTS config
258
+ │ │ ├── ssrf.js # SSRF detection
259
+ │ │ ├── ssti.js # SSTI detection
260
+ │ │ ├── deserialization.js # Insecure deserialization
261
+ │ │ ├── prototype-pollution.js # Prototype pollution
262
+ │ │ ├── jwt.js # JWT vulnerabilities
263
+ │ │ ├── path-traversal.js # LFI/path traversal
264
+ │ │ ├── command-injection.js # OS command injection
265
+ │ │ └── crypto.js # Weak cryptography
266
+ │ └── utils/
267
+ │ ├── fetch.js # HTTP with timeout
268
+ │ └── patterns.js # Shared regex patterns
269
+ ├── scan.js # Remote scan engine (25 modules)
270
+ ├── action.yml # GitHub Action definition
271
+ ├── .github/workflows/security.yml
272
+ └── package.json
273
+ ```
274
+
275
+ <br>
276
+
277
+ ## License
278
+
279
+ MIT. See [LICENSE](LICENSE).
280
+
281
+ This tool is intended for authorized security testing only. You are solely responsible for how you use it.
package/action.yml ADDED
@@ -0,0 +1,67 @@
1
+ name: 'RedGun Security Audit'
2
+ description: 'Black-box & white-box security auditor with HackTricks techniques'
3
+ author: 'aloc999'
4
+ branding:
5
+ icon: 'shield'
6
+ color: 'red'
7
+
8
+ inputs:
9
+ path:
10
+ description: 'Project path to audit'
11
+ default: '.'
12
+ min-score:
13
+ description: 'Minimum score required to pass (0-100)'
14
+ default: '70'
15
+ fail-on-score:
16
+ description: 'Fail the workflow if score is below min-score'
17
+ default: 'true'
18
+ comment-pr:
19
+ description: 'Post a comment on pull requests'
20
+ default: 'true'
21
+ update-badge:
22
+ description: 'Update the security badge file on push'
23
+ default: 'true'
24
+ upload-sarif:
25
+ description: 'Upload SARIF findings to GitHub Code Scanning'
26
+ default: 'true'
27
+ badge-path:
28
+ description: 'Path to the badge JSON file'
29
+ default: '.github/redgun-badge.json'
30
+ github-token:
31
+ description: 'Token used to post comments and commit the badge'
32
+ default: ${{ github.token }}
33
+
34
+ outputs:
35
+ score:
36
+ description: 'Security score from 0 to 100'
37
+ grade:
38
+ description: 'Grade from A to F'
39
+ total-findings:
40
+ description: 'Total number of findings'
41
+ critical-findings:
42
+ description: 'Number of critical findings'
43
+ high-findings:
44
+ description: 'Number of high severity findings'
45
+ report-path:
46
+ description: 'Absolute path to the JSON report file'
47
+
48
+ runs:
49
+ using: 'composite'
50
+ steps:
51
+ - name: Setup Node.js
52
+ uses: actions/setup-node@v4
53
+ with:
54
+ node-version: '20'
55
+
56
+ - name: Install RedGun
57
+ shell: bash
58
+ run: |
59
+ cd ${{ github.action_path }}
60
+ npm ci --production 2>/dev/null || npm install --production
61
+
62
+ - name: Run Audit
63
+ id: audit
64
+ shell: bash
65
+ run: |
66
+ cd ${{ github.workspace }}
67
+ node ${{ github.action_path }}/bin/redgun.js audit ${{ inputs.path }} --ci --min-score ${{ inputs.min-score }} --sarif || true
package/bin/redgun.js ADDED
@@ -0,0 +1,195 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from 'commander';
4
+ import inquirer from 'inquirer';
5
+ import ora from 'ora';
6
+ import chalk from 'chalk';
7
+ import { resolve } from 'path';
8
+ import { existsSync } from 'fs';
9
+
10
+ import { clearFindings } from '../src/core/findings.js';
11
+ import { calculateScore, getGrade } from '../src/core/score.js';
12
+ import { printBanner, printResults } from '../src/core/reporter/console.js';
13
+ import { exportJson, exportSarif } from '../src/core/reporter/json.js';
14
+ import { exportHtml } from '../src/core/reporter/html.js';
15
+ import { runLocalAudit, LOCAL_MODULES } from '../src/local/index.js';
16
+ import { runRemoteScan } from '../scan.js';
17
+
18
+ const program = new Command();
19
+
20
+ program
21
+ .name('redgun')
22
+ .description('Black-box & white-box security auditor for web applications (HackTricks Enhanced)')
23
+ .version('1.0.0');
24
+
25
+ program
26
+ .command('scan')
27
+ .description('Remote scan (black-box) - give it a URL')
28
+ .argument('[url]', 'Target URL to scan')
29
+ .option('--modules <modules>', 'Comma-separated list of modules to run')
30
+ .action(async (url, options) => {
31
+ printBanner();
32
+ showDisclaimer();
33
+
34
+ if (!url) {
35
+ const answers = await inquirer.prompt([{
36
+ type: 'input',
37
+ name: 'url',
38
+ message: 'Target URL:',
39
+ validate: (v) => v.startsWith('http') ? true : 'Must start with http:// or https://',
40
+ }]);
41
+ url = answers.url;
42
+ }
43
+
44
+ if (!url.startsWith('http')) url = `https://${url}`;
45
+
46
+ clearFindings();
47
+ const spinner = ora('Starting remote scan...').start();
48
+
49
+ try {
50
+ const modules = options.modules ? options.modules.split(',') : null;
51
+ await runRemoteScan(url, spinner, modules);
52
+ spinner.succeed('Remote scan complete');
53
+ } catch (err) {
54
+ spinner.fail(`Scan error: ${err.message}`);
55
+ }
56
+
57
+ const { score, grade } = printResults();
58
+ const jsonPath = exportJson();
59
+ const htmlPath = exportHtml();
60
+ console.log(chalk.gray(` Reports saved: ${jsonPath}`));
61
+ console.log(chalk.gray(` HTML report: ${htmlPath}\n`));
62
+ });
63
+
64
+ program
65
+ .command('audit')
66
+ .description('Local audit (white-box) - point it at your project')
67
+ .argument('[path]', 'Project path to audit', '.')
68
+ .option('--ci', 'CI mode - exit 1 if score below threshold')
69
+ .option('--min-score <score>', 'Minimum score (default: 70)', '70')
70
+ .option('--modules <modules>', 'Comma-separated list of modules to run')
71
+ .option('--json', 'Output JSON report')
72
+ .option('--html', 'Output HTML report')
73
+ .option('--sarif', 'Output SARIF report')
74
+ .action(async (projectPath, options) => {
75
+ printBanner();
76
+
77
+ const absPath = resolve(projectPath);
78
+ if (!existsSync(absPath)) {
79
+ console.error(chalk.red(`Error: Path does not exist: ${absPath}`));
80
+ process.exit(1);
81
+ }
82
+
83
+ clearFindings();
84
+ const spinner = ora('Starting local audit...').start();
85
+
86
+ try {
87
+ const modules = options.modules ? options.modules.split(',') : null;
88
+ await runLocalAudit(absPath, spinner, modules);
89
+ spinner.succeed('Local audit complete');
90
+ } catch (err) {
91
+ spinner.fail(`Audit error: ${err.message}`);
92
+ }
93
+
94
+ const { score, grade } = printResults();
95
+
96
+ const jsonPath = exportJson();
97
+ console.log(chalk.gray(` JSON report: ${jsonPath}`));
98
+
99
+ if (options.html || !options.ci) {
100
+ const htmlPath = exportHtml();
101
+ console.log(chalk.gray(` HTML report: ${htmlPath}`));
102
+ }
103
+
104
+ if (options.sarif) {
105
+ const sarifPath = exportSarif();
106
+ console.log(chalk.gray(` SARIF report: ${sarifPath}`));
107
+ }
108
+
109
+ console.log('');
110
+
111
+ if (options.ci) {
112
+ const minScore = parseInt(options.minScore, 10);
113
+ if (score < minScore) {
114
+ console.error(chalk.red(` FAILED: Score ${score} is below minimum ${minScore}`));
115
+ process.exit(1);
116
+ } else {
117
+ console.log(chalk.green(` PASSED: Score ${score} meets minimum ${minScore}`));
118
+ }
119
+ }
120
+ });
121
+
122
+ program
123
+ .command('history')
124
+ .description('View saved scan reports')
125
+ .action(async () => {
126
+ const { readdirSync } = await import('fs');
127
+ const { join } = await import('path');
128
+ const scansDir = './scans';
129
+
130
+ if (!existsSync(scansDir)) {
131
+ console.log(chalk.yellow('No scan history found.'));
132
+ return;
133
+ }
134
+
135
+ const files = readdirSync(scansDir).filter((f) => f.endsWith('.json')).sort().reverse();
136
+ if (files.length === 0) {
137
+ console.log(chalk.yellow('No scan history found.'));
138
+ return;
139
+ }
140
+
141
+ console.log(chalk.bold('\n Scan History:\n'));
142
+ for (const file of files.slice(0, 20)) {
143
+ console.log(` ${chalk.gray('•')} ${file}`);
144
+ }
145
+ console.log('');
146
+ });
147
+
148
+ program
149
+ .command('modules')
150
+ .description('List available scan modules')
151
+ .action(() => {
152
+ printBanner();
153
+ console.log(chalk.bold('\n Local Audit Modules (White-box):\n'));
154
+ for (const mod of LOCAL_MODULES) {
155
+ console.log(` ${chalk.green('•')} ${mod.name} ${chalk.gray(`[${mod.value}]`)}`);
156
+ }
157
+ console.log(chalk.bold('\n Remote Scan Modules (Black-box):\n'));
158
+ const remoteModules = [
159
+ 'headers', 'files', 'secrets', 'xss', 'sqli', 'cors', 'redirect',
160
+ 'ssrf', 'hostheader', 'smuggling', 'crlf', 'graphql', 'clickjack',
161
+ 'cookies', 'methods', 'subdomains', 'dns', 'tech', 'api', 'ssl',
162
+ 'lfi', 'nosqli', 'websocket', 'cache', 'race',
163
+ ];
164
+ for (const mod of remoteModules) {
165
+ console.log(` ${chalk.red('•')} ${mod}`);
166
+ }
167
+ console.log('');
168
+ });
169
+
170
+ if (process.argv.length <= 2) {
171
+ printBanner();
172
+ inquirer.prompt([{
173
+ type: 'list',
174
+ name: 'mode',
175
+ message: 'What would you like to do?',
176
+ choices: [
177
+ { name: 'Remote scan (black-box) - scan a URL', value: 'scan' },
178
+ { name: 'Local audit (white-box) - audit source code', value: 'audit' },
179
+ { name: 'View scan history', value: 'history' },
180
+ { name: 'List modules', value: 'modules' },
181
+ ],
182
+ }]).then((answers) => {
183
+ const args = ['node', 'redgun', answers.mode];
184
+ if (answers.mode === 'audit') args.push('.');
185
+ program.parse(args);
186
+ });
187
+ } else {
188
+ program.parse();
189
+ }
190
+
191
+ function showDisclaimer() {
192
+ console.log(chalk.yellow.bold(' ⚠ DISCLAIMER'));
193
+ console.log(chalk.yellow(' This tool is for authorized security testing only.'));
194
+ console.log(chalk.yellow(' You are responsible for how you use it.\n'));
195
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "redgun-security",
3
+ "version": "1.0.0",
4
+ "description": "Black-box & white-box security auditor for web applications with HackTricks techniques",
5
+ "type": "module",
6
+ "main": "scan.js",
7
+ "bin": {
8
+ "redgun": "./bin/redgun.js"
9
+ },
10
+ "scripts": {
11
+ "start": "node bin/redgun.js",
12
+ "scan": "node bin/redgun.js scan",
13
+ "audit": "node bin/redgun.js audit .",
14
+ "test": "node --test"
15
+ },
16
+ "keywords": [
17
+ "security",
18
+ "scanner",
19
+ "pentest",
20
+ "vulnerability",
21
+ "audit",
22
+ "hacktricks",
23
+ "xss",
24
+ "sqli",
25
+ "ssrf",
26
+ "ssti",
27
+ "web-security"
28
+ ],
29
+ "author": "aloc999",
30
+ "license": "MIT",
31
+ "dependencies": {
32
+ "chalk": "^5.3.0",
33
+ "commander": "^12.1.0",
34
+ "inquirer": "^9.2.23",
35
+ "ora": "^8.0.1",
36
+ "puppeteer": "^22.12.0",
37
+ "node-fetch": "^3.3.2",
38
+ "glob": "^10.4.2",
39
+ "table": "^6.8.2"
40
+ },
41
+ "engines": {
42
+ "node": ">=18"
43
+ },
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "https://github.com/aloc999/redgun"
47
+ }
48
+ }