crabguard 1.0.0__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.
Files changed (34) hide show
  1. crabguard-1.0.0/LICENSE +21 -0
  2. crabguard-1.0.0/PKG-INFO +206 -0
  3. crabguard-1.0.0/README.md +141 -0
  4. crabguard-1.0.0/crabguard/__init__.py +38 -0
  5. crabguard-1.0.0/crabguard/cli.py +137 -0
  6. crabguard-1.0.0/crabguard/config.py +39 -0
  7. crabguard-1.0.0/crabguard/licensing.py +123 -0
  8. crabguard-1.0.0/crabguard/models.py +189 -0
  9. crabguard-1.0.0/crabguard/reporters/__init__.py +2 -0
  10. crabguard-1.0.0/crabguard/reporters/html_reporter.py +280 -0
  11. crabguard-1.0.0/crabguard/reporters/pdf_reporter.py +83 -0
  12. crabguard-1.0.0/crabguard/scanner.py +193 -0
  13. crabguard-1.0.0/crabguard/scanners/__init__.py +2 -0
  14. crabguard-1.0.0/crabguard/scanners/active/__init__.py +2 -0
  15. crabguard-1.0.0/crabguard/scanners/active/discovery.py +167 -0
  16. crabguard-1.0.0/crabguard/scanners/active/injection.py +164 -0
  17. crabguard-1.0.0/crabguard/scanners/active/redirect.py +137 -0
  18. crabguard-1.0.0/crabguard/scanners/passive/__init__.py +2 -0
  19. crabguard-1.0.0/crabguard/scanners/passive/content.py +244 -0
  20. crabguard-1.0.0/crabguard/scanners/passive/cookies.py +133 -0
  21. crabguard-1.0.0/crabguard/scanners/passive/disclosure.py +141 -0
  22. crabguard-1.0.0/crabguard/scanners/passive/headers.py +139 -0
  23. crabguard-1.0.0/crabguard/scanners/passive/tls.py +182 -0
  24. crabguard-1.0.0/crabguard/utils/__init__.py +7 -0
  25. crabguard-1.0.0/crabguard/utils/http_client.py +107 -0
  26. crabguard-1.0.0/crabguard/utils/patterns.py +175 -0
  27. crabguard-1.0.0/crabguard.egg-info/PKG-INFO +206 -0
  28. crabguard-1.0.0/crabguard.egg-info/SOURCES.txt +32 -0
  29. crabguard-1.0.0/crabguard.egg-info/dependency_links.txt +1 -0
  30. crabguard-1.0.0/crabguard.egg-info/entry_points.txt +2 -0
  31. crabguard-1.0.0/crabguard.egg-info/requires.txt +18 -0
  32. crabguard-1.0.0/crabguard.egg-info/top_level.txt +1 -0
  33. crabguard-1.0.0/pyproject.toml +73 -0
  34. crabguard-1.0.0/setup.cfg +4 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CrabGuard Security
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.
@@ -0,0 +1,206 @@
1
+ Metadata-Version: 2.4
2
+ Name: crabguard
3
+ Version: 1.0.0
4
+ Summary: Enterprise web security scanner - Burp Suite + OWASP ZAP alternative with beautiful reports
5
+ License: MIT License
6
+
7
+ Copyright (c) 2026 CrabGuard Security
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+
27
+ Project-URL: Homepage, https://crabguard.io
28
+ Project-URL: Documentation, https://docs.crabguard.io
29
+ Project-URL: Repository, https://github.com/crabguard/crabguard
30
+ Project-URL: Bug Tracker, https://github.com/crabguard/crabguard/issues
31
+ Project-URL: Changelog, https://github.com/crabguard/crabguard/blob/main/CHANGELOG.md
32
+ Keywords: security,web security,penetration testing,vulnerability scanner,owasp,burp suite,zap,sqli,xss,pentest,appsec
33
+ Classifier: Development Status :: 4 - Beta
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: Intended Audience :: Information Technology
36
+ Classifier: Intended Audience :: System Administrators
37
+ Classifier: Topic :: Security
38
+ Classifier: Topic :: Internet :: WWW/HTTP
39
+ Classifier: License :: OSI Approved :: MIT License
40
+ Classifier: Programming Language :: Python :: 3
41
+ Classifier: Programming Language :: Python :: 3.9
42
+ Classifier: Programming Language :: Python :: 3.10
43
+ Classifier: Programming Language :: Python :: 3.11
44
+ Classifier: Programming Language :: Python :: 3.12
45
+ Classifier: Operating System :: OS Independent
46
+ Requires-Python: >=3.9
47
+ Description-Content-Type: text/markdown
48
+ License-File: LICENSE
49
+ Requires-Dist: requests>=2.31.0
50
+ Requires-Dist: beautifulsoup4>=4.12.0
51
+ Requires-Dist: click>=8.1.0
52
+ Requires-Dist: urllib3>=2.0.0
53
+ Provides-Extra: pdf
54
+ Requires-Dist: weasyprint>=60.0; extra == "pdf"
55
+ Provides-Extra: dev
56
+ Requires-Dist: pytest>=7.0; extra == "dev"
57
+ Requires-Dist: pytest-cov; extra == "dev"
58
+ Requires-Dist: build; extra == "dev"
59
+ Requires-Dist: twine; extra == "dev"
60
+ Requires-Dist: black; extra == "dev"
61
+ Requires-Dist: ruff; extra == "dev"
62
+ Provides-Extra: all
63
+ Requires-Dist: crabguard[dev,pdf]; extra == "all"
64
+ Dynamic: license-file
65
+
66
+ # 🦀 CrabGuard
67
+
68
+ **Enterprise web security scanner. Burp Suite + OWASP ZAP — without the $400/year license.**
69
+
70
+ [![PyPI version](https://badge.fury.io/py/crabguard.svg)](https://badge.fury.io/py/crabguard)
71
+ [![Python](https://img.shields.io/pypi/pyversions/crabguard)](https://pypi.org/project/crabguard/)
72
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
73
+ [![Product Hunt](https://img.shields.io/badge/Product%20Hunt-Featured-%23DA552F)](https://producthunt.com)
74
+
75
+ ```bash
76
+ pip install crabguard
77
+ crabguard scan https://your-site.com
78
+ ```
79
+
80
+ > Scans for OWASP Top 10 vulnerabilities and generates a beautiful, branded security report in seconds.
81
+
82
+ ---
83
+
84
+ ## What it checks
85
+
86
+ | Category | Free (Passive) | Pro (Active) |
87
+ |---|:---:|:---:|
88
+ | Security Headers (CSP, HSTS, XFO...) | ✅ | ✅ |
89
+ | Cookie Security (HttpOnly, Secure, SameSite) | ✅ | ✅ |
90
+ | TLS/HTTPS + Certificate Expiry | ✅ | ✅ |
91
+ | Mixed Content | ✅ | ✅ |
92
+ | Subresource Integrity (SRI) | ✅ | ✅ |
93
+ | Vulnerable JS Libraries | ✅ | ✅ |
94
+ | CORS Misconfiguration | ✅ | ✅ |
95
+ | Information Disclosure | ✅ | ✅ |
96
+ | SQL Injection (error + time-based blind) | — | ✅ |
97
+ | Reflected XSS | — | ✅ |
98
+ | Sensitive File Discovery (.env, .git, ...) | — | ✅ |
99
+ | SSRF | — | ✅ |
100
+ | Open Redirect | — | ✅ |
101
+ | Default Credentials | — | ✅ |
102
+ | **PDF Reports** | — | ✅ |
103
+ | **White-label Reports** | — | ✅ |
104
+
105
+ ---
106
+
107
+ ## Quick Start
108
+
109
+ ```bash
110
+ # Install
111
+ pip install crabguard
112
+
113
+ # Passive scan (free, no account needed)
114
+ crabguard scan https://example.com
115
+
116
+ # Full active scan (Pro — requires API key)
117
+ crabguard scan https://example.com --mode full --api-key YOUR_KEY --consent
118
+
119
+ # Save as PDF
120
+ crabguard scan https://example.com --format pdf --api-key YOUR_KEY
121
+
122
+ # Route through Burp Suite / OWASP ZAP
123
+ crabguard scan https://example.com --proxy http://127.0.0.1:8080
124
+
125
+ # JSON output for CI/CD
126
+ crabguard scan https://example.com --format json --quiet
127
+ echo $? # exit 1 if critical/high findings, 0 if clean
128
+ ```
129
+
130
+ ---
131
+
132
+ ## Python API
133
+
134
+ ```python
135
+ from crabguard import CrabGuardScanner, CrabGuardConfig, ScanMode
136
+
137
+ # Free passive scan
138
+ scanner = CrabGuardScanner("https://example.com", verbose=True)
139
+ report = scanner.scan()
140
+ scanner.save_report(report, "report.html")
141
+
142
+ # Pro active scan
143
+ config = CrabGuardConfig(api_key="YOUR_KEY", active_consent=True)
144
+ scanner = CrabGuardScanner("https://example.com", mode=ScanMode.FULL, config=config)
145
+ report = scanner.scan()
146
+ scanner.save_report(report, "report.html")
147
+ scanner.save_report(report, "report.pdf", fmt="pdf")
148
+
149
+ # Access findings programmatically
150
+ for finding in report.all_findings:
151
+ print(f"[{finding.severity.value.upper()}] {finding.title}")
152
+ if finding.remediation:
153
+ print(f" Fix: {finding.remediation}")
154
+ ```
155
+
156
+ ---
157
+
158
+ ## CI/CD Integration (GitHub Actions)
159
+
160
+ ```yaml
161
+ - name: Security scan
162
+ run: |
163
+ pip install crabguard
164
+ crabguard scan ${{ env.STAGING_URL }} --format json --quiet
165
+ # Fails the build automatically if critical/high findings are found
166
+ ```
167
+
168
+ ---
169
+
170
+ ## Report Sample
171
+
172
+ CrabGuard generates a full HTML or PDF report with:
173
+ - Overall security score (0–100)
174
+ - Per-category scores and OWASP Top 10 mapping
175
+ - Detailed findings with remediation steps and code snippets
176
+ - CrabGuard branded watermark (white-label available on Pro)
177
+
178
+ ---
179
+
180
+ ## Pricing
181
+
182
+ | | Free | Pro | Enterprise |
183
+ |---|:---:|:---:|:---:|
184
+ | Passive scan | ✅ | ✅ | ✅ |
185
+ | Active scan (SQLi, XSS, SSRF...) | — | ✅ | ✅ |
186
+ | PDF reports + white-label | — | ✅ | ✅ |
187
+ | Scan history & dashboard | — | — | ✅ |
188
+ | Team seats | — | — | ✅ |
189
+ | SLA + priority support | — | — | ✅ |
190
+ | Price | Free | $49/mo | Contact us |
191
+
192
+ Get your API key at **[crabguard.io](https://crabguard.io)**
193
+
194
+ ---
195
+
196
+ ## ⚠️ Responsible Use
197
+
198
+ Active scanning sends real payloads to the target server. **Only scan systems you own or have explicit written permission to test.** Unauthorized scanning may be illegal under the CFAA and similar laws. Always pass `--consent` to confirm you have permission.
199
+
200
+ ---
201
+
202
+ ## License
203
+
204
+ MIT — free to use, modify, and distribute. See [LICENSE](LICENSE).
205
+
206
+ Built with ❤️ by [CrabGuard Security](https://crabguard.io)
@@ -0,0 +1,141 @@
1
+ # 🦀 CrabGuard
2
+
3
+ **Enterprise web security scanner. Burp Suite + OWASP ZAP — without the $400/year license.**
4
+
5
+ [![PyPI version](https://badge.fury.io/py/crabguard.svg)](https://badge.fury.io/py/crabguard)
6
+ [![Python](https://img.shields.io/pypi/pyversions/crabguard)](https://pypi.org/project/crabguard/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
8
+ [![Product Hunt](https://img.shields.io/badge/Product%20Hunt-Featured-%23DA552F)](https://producthunt.com)
9
+
10
+ ```bash
11
+ pip install crabguard
12
+ crabguard scan https://your-site.com
13
+ ```
14
+
15
+ > Scans for OWASP Top 10 vulnerabilities and generates a beautiful, branded security report in seconds.
16
+
17
+ ---
18
+
19
+ ## What it checks
20
+
21
+ | Category | Free (Passive) | Pro (Active) |
22
+ |---|:---:|:---:|
23
+ | Security Headers (CSP, HSTS, XFO...) | ✅ | ✅ |
24
+ | Cookie Security (HttpOnly, Secure, SameSite) | ✅ | ✅ |
25
+ | TLS/HTTPS + Certificate Expiry | ✅ | ✅ |
26
+ | Mixed Content | ✅ | ✅ |
27
+ | Subresource Integrity (SRI) | ✅ | ✅ |
28
+ | Vulnerable JS Libraries | ✅ | ✅ |
29
+ | CORS Misconfiguration | ✅ | ✅ |
30
+ | Information Disclosure | ✅ | ✅ |
31
+ | SQL Injection (error + time-based blind) | — | ✅ |
32
+ | Reflected XSS | — | ✅ |
33
+ | Sensitive File Discovery (.env, .git, ...) | — | ✅ |
34
+ | SSRF | — | ✅ |
35
+ | Open Redirect | — | ✅ |
36
+ | Default Credentials | — | ✅ |
37
+ | **PDF Reports** | — | ✅ |
38
+ | **White-label Reports** | — | ✅ |
39
+
40
+ ---
41
+
42
+ ## Quick Start
43
+
44
+ ```bash
45
+ # Install
46
+ pip install crabguard
47
+
48
+ # Passive scan (free, no account needed)
49
+ crabguard scan https://example.com
50
+
51
+ # Full active scan (Pro — requires API key)
52
+ crabguard scan https://example.com --mode full --api-key YOUR_KEY --consent
53
+
54
+ # Save as PDF
55
+ crabguard scan https://example.com --format pdf --api-key YOUR_KEY
56
+
57
+ # Route through Burp Suite / OWASP ZAP
58
+ crabguard scan https://example.com --proxy http://127.0.0.1:8080
59
+
60
+ # JSON output for CI/CD
61
+ crabguard scan https://example.com --format json --quiet
62
+ echo $? # exit 1 if critical/high findings, 0 if clean
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Python API
68
+
69
+ ```python
70
+ from crabguard import CrabGuardScanner, CrabGuardConfig, ScanMode
71
+
72
+ # Free passive scan
73
+ scanner = CrabGuardScanner("https://example.com", verbose=True)
74
+ report = scanner.scan()
75
+ scanner.save_report(report, "report.html")
76
+
77
+ # Pro active scan
78
+ config = CrabGuardConfig(api_key="YOUR_KEY", active_consent=True)
79
+ scanner = CrabGuardScanner("https://example.com", mode=ScanMode.FULL, config=config)
80
+ report = scanner.scan()
81
+ scanner.save_report(report, "report.html")
82
+ scanner.save_report(report, "report.pdf", fmt="pdf")
83
+
84
+ # Access findings programmatically
85
+ for finding in report.all_findings:
86
+ print(f"[{finding.severity.value.upper()}] {finding.title}")
87
+ if finding.remediation:
88
+ print(f" Fix: {finding.remediation}")
89
+ ```
90
+
91
+ ---
92
+
93
+ ## CI/CD Integration (GitHub Actions)
94
+
95
+ ```yaml
96
+ - name: Security scan
97
+ run: |
98
+ pip install crabguard
99
+ crabguard scan ${{ env.STAGING_URL }} --format json --quiet
100
+ # Fails the build automatically if critical/high findings are found
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Report Sample
106
+
107
+ CrabGuard generates a full HTML or PDF report with:
108
+ - Overall security score (0–100)
109
+ - Per-category scores and OWASP Top 10 mapping
110
+ - Detailed findings with remediation steps and code snippets
111
+ - CrabGuard branded watermark (white-label available on Pro)
112
+
113
+ ---
114
+
115
+ ## Pricing
116
+
117
+ | | Free | Pro | Enterprise |
118
+ |---|:---:|:---:|:---:|
119
+ | Passive scan | ✅ | ✅ | ✅ |
120
+ | Active scan (SQLi, XSS, SSRF...) | — | ✅ | ✅ |
121
+ | PDF reports + white-label | — | ✅ | ✅ |
122
+ | Scan history & dashboard | — | — | ✅ |
123
+ | Team seats | — | — | ✅ |
124
+ | SLA + priority support | — | — | ✅ |
125
+ | Price | Free | $49/mo | Contact us |
126
+
127
+ Get your API key at **[crabguard.io](https://crabguard.io)**
128
+
129
+ ---
130
+
131
+ ## ⚠️ Responsible Use
132
+
133
+ Active scanning sends real payloads to the target server. **Only scan systems you own or have explicit written permission to test.** Unauthorized scanning may be illegal under the CFAA and similar laws. Always pass `--consent` to confirm you have permission.
134
+
135
+ ---
136
+
137
+ ## License
138
+
139
+ MIT — free to use, modify, and distribute. See [LICENSE](LICENSE).
140
+
141
+ Built with ❤️ by [CrabGuard Security](https://crabguard.io)
@@ -0,0 +1,38 @@
1
+ """
2
+ CrabGuard — Enterprise Web Security Scanner
3
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4
+ A Burp Suite + OWASP ZAP alternative that does passive AND active scanning
5
+ and generates beautiful branded reports.
6
+
7
+ Quick start:
8
+ from crabguard import CrabGuardScanner, CrabGuardConfig, ScanMode
9
+
10
+ scanner = CrabGuardScanner("https://example.com", verbose=True)
11
+ report = scanner.scan()
12
+ scanner.save_report(report, "report.html")
13
+
14
+ Active scanning (you must own / have permission to scan the target):
15
+ config = CrabGuardConfig(active_consent=True)
16
+ scanner = CrabGuardScanner("https://example.com", mode=ScanMode.FULL, config=config)
17
+ report = scanner.scan()
18
+ scanner.save_report(report, "report.html", fmt="html")
19
+ scanner.save_report(report, "report.pdf", fmt="pdf")
20
+ scanner.save_report(report, "report.json", fmt="json")
21
+ """
22
+
23
+ from .scanner import CrabGuardScanner
24
+ from .config import CrabGuardConfig
25
+ from .models import ScanMode, ScanReport, Finding, Severity, CategoryResult
26
+
27
+ __version__ = "1.0.0"
28
+ __author__ = "CrabGuard Security"
29
+
30
+ __all__ = [
31
+ "CrabGuardScanner",
32
+ "CrabGuardConfig",
33
+ "ScanMode",
34
+ "ScanReport",
35
+ "Finding",
36
+ "Severity",
37
+ "CategoryResult",
38
+ ]
@@ -0,0 +1,137 @@
1
+ """
2
+ CrabGuard - CLI Entry Point
3
+ Usage: crabguard scan https://example.com [OPTIONS]
4
+ """
5
+ from __future__ import annotations
6
+ import sys
7
+ from datetime import datetime
8
+ from pathlib import Path
9
+
10
+ try:
11
+ import click
12
+ except ImportError:
13
+ print("Install click: pip install click", file=sys.stderr)
14
+ sys.exit(1)
15
+
16
+ from .config import CrabGuardConfig
17
+ from .models import ScanMode
18
+ from .scanner import CrabGuardScanner
19
+
20
+ BANNER = """
21
+ CrabGuard - Enterprise Web Security Scanner v1.0.0
22
+ https://crabguard.io
23
+ ----------------------------------------------------------
24
+ """
25
+
26
+
27
+ @click.group()
28
+ def cli():
29
+ """CrabGuard - Enterprise Web Security Scanner"""
30
+ pass
31
+
32
+
33
+ @cli.command()
34
+ @click.argument("target")
35
+ @click.option("--mode", "-m", default="passive",
36
+ type=click.Choice(["passive", "active", "full"]),
37
+ help="Scan mode. 'active'/'full' probe the target (requires --consent).")
38
+ @click.option("--output", "-o", default=None,
39
+ help="Output file path (auto-named if omitted).")
40
+ @click.option("--format", "-f", default="html",
41
+ type=click.Choice(["html", "pdf", "json"]),
42
+ help="Report format.")
43
+ @click.option("--consent", is_flag=True, default=False,
44
+ help="Confirm you have permission to actively scan this target.")
45
+ @click.option("--api-key", "-k", default=None, envvar="CRABGUARD_API_KEY",
46
+ help="CrabGuard Pro API key. Or set env var CRABGUARD_API_KEY.")
47
+ @click.option("--proxy", default=None,
48
+ help="HTTP proxy (e.g. http://127.0.0.1:8080 for Burp Suite).")
49
+ @click.option("--timeout", default=10, type=int, help="Request timeout in seconds.")
50
+ @click.option("--author", default="", help="Company/author name for the report.")
51
+ @click.option("--quiet", "-q", is_flag=True, default=False, help="Suppress progress output.")
52
+ def scan(target, mode, output, format, consent, api_key, proxy, timeout, author, quiet):
53
+ """
54
+ Scan a target URL for security vulnerabilities.
55
+
56
+ \b
57
+ Examples:
58
+ crabguard scan https://example.com
59
+ crabguard scan https://example.com --mode full --consent --api-key cg_live_...
60
+ crabguard scan https://example.com --format json --quiet
61
+ crabguard scan https://example.com --proxy http://127.0.0.1:8080
62
+ """
63
+ if not quiet:
64
+ click.echo(BANNER)
65
+
66
+ if mode in ("active", "full") and not consent:
67
+ click.echo(click.style(
68
+ " Warning: Active scan requires --consent flag.\n"
69
+ " Only scan targets you own or have written permission to test.\n"
70
+ " Add --consent to proceed.",
71
+ fg="yellow"
72
+ ))
73
+ sys.exit(1)
74
+
75
+ config = CrabGuardConfig(
76
+ api_key=api_key,
77
+ active_consent=consent,
78
+ proxy=proxy,
79
+ timeout=timeout,
80
+ report_author=author,
81
+ )
82
+
83
+ scanner = CrabGuardScanner(
84
+ target=target,
85
+ mode=ScanMode(mode),
86
+ config=config,
87
+ verbose=not quiet,
88
+ )
89
+
90
+ if not quiet:
91
+ click.echo(f" Target : {target}")
92
+ click.echo(f" Mode : {mode}")
93
+ click.echo(f" Format : {format}")
94
+ click.echo()
95
+
96
+ report = scanner.scan()
97
+
98
+ if not output:
99
+ from urllib.parse import urlparse
100
+ hostname = urlparse(target).hostname or "scan"
101
+ ts = datetime.utcnow().strftime("%Y%m%d-%H%M%S")
102
+ ext = {"html": ".html", "pdf": ".pdf", "json": ".json"}[format]
103
+ output = f"crabguard-{hostname}-{ts}{ext}"
104
+
105
+ saved = scanner.save_report(report, output, fmt=format)
106
+
107
+ if not quiet:
108
+ score = report.overall_score
109
+ color = "green" if score >= 75 else "yellow" if score >= 50 else "red"
110
+ click.echo()
111
+ click.echo(f" Score : " + click.style(f"{score}/100 {report.score_label}", fg=color))
112
+ click.echo(f" Critical : {report.critical_count} High : {report.high_count} "
113
+ f"Medium : {report.medium_count} Low : {report.low_count}")
114
+ click.echo(f" Report : {Path(saved).name}")
115
+ click.echo()
116
+
117
+ sys.exit(0 if report.critical_count == 0 and report.high_count == 0 else 1)
118
+
119
+
120
+ @cli.command()
121
+ @click.argument("target")
122
+ @click.option("--output", "-o", default="crabguard-report.html")
123
+ @click.option("--author", default="")
124
+ def quick(target, output, author):
125
+ """Quick passive scan - no active probing, fastest option."""
126
+ ctx = click.get_current_context()
127
+ ctx.invoke(scan, target=target, mode="passive", output=output,
128
+ format="html", consent=False, api_key=None,
129
+ proxy=None, timeout=10, author=author, quiet=False)
130
+
131
+
132
+ def main():
133
+ cli()
134
+
135
+
136
+ if __name__ == "__main__":
137
+ main()
@@ -0,0 +1,39 @@
1
+ """
2
+ CrabGuard - Configuration
3
+ """
4
+ from __future__ import annotations
5
+ import os
6
+ from dataclasses import dataclass, field
7
+ from typing import Optional
8
+
9
+
10
+ @dataclass
11
+ class CrabGuardConfig:
12
+ api_key: Optional[str] = None
13
+ timeout: int = 10
14
+ max_redirects: int = 5
15
+ user_agent: str = "CrabGuard/1.0 Security Scanner (https://crabguard.io)"
16
+ verify_ssl: bool = True
17
+ requests_per_second: float = 5.0
18
+ max_concurrent: int = 3
19
+ active_consent: bool = False
20
+ sqli_depth: int = 2
21
+ xss_depth: int = 2
22
+ discovery_wordlist: str = "default"
23
+ brand_name: str = "CrabGuard"
24
+ brand_tagline: str = "Enterprise Web Security Scanner"
25
+ report_author: str = ""
26
+ proxy: Optional[str] = None
27
+ exclude_paths: list = field(default_factory=list)
28
+ exclude_params: list = field(default_factory=list)
29
+
30
+ def __post_init__(self):
31
+ if self.api_key is None:
32
+ self.api_key = os.environ.get("CRABGUARD_API_KEY")
33
+
34
+ @property
35
+ def is_pro(self) -> bool:
36
+ return bool(self.api_key and self.api_key.startswith("cg_"))
37
+
38
+
39
+ DEFAULT_CONFIG = CrabGuardConfig()