dotspot 0.0.1__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.
- dotspot-0.0.1/.gitignore +34 -0
- dotspot-0.0.1/LICENSE +21 -0
- dotspot-0.0.1/PKG-INFO +83 -0
- dotspot-0.0.1/README.md +52 -0
- dotspot-0.0.1/__init__.py +0 -0
- dotspot-0.0.1/checks/__init__.py +17 -0
- dotspot-0.0.1/checks/ai_overview.py +155 -0
- dotspot-0.0.1/checks/base64_decode.py +172 -0
- dotspot-0.0.1/checks/comments.py +107 -0
- dotspot-0.0.1/checks/cookies.py +47 -0
- dotspot-0.0.1/checks/exposed_paths.py +142 -0
- dotspot-0.0.1/checks/js_analysis.py +327 -0
- dotspot-0.0.1/checks/sqli.py +541 -0
- dotspot-0.0.1/checks/ssti.py +311 -0
- dotspot-0.0.1/core/__init__.py +0 -0
- dotspot-0.0.1/core/crawler.py +184 -0
- dotspot-0.0.1/core/reporter.py +235 -0
- dotspot-0.0.1/core/scanner.py +504 -0
- dotspot-0.0.1/data/__init__.py +0 -0
- dotspot-0.0.1/data/paths.txt +123 -0
- dotspot-0.0.1/data/payloads.json +140 -0
- dotspot-0.0.1/data/prompt.txt +18 -0
- dotspot-0.0.1/dotspot.egg-info/PKG-INFO +83 -0
- dotspot-0.0.1/dotspot.egg-info/SOURCES.txt +38 -0
- dotspot-0.0.1/dotspot.egg-info/dependency_links.txt +1 -0
- dotspot-0.0.1/dotspot.egg-info/entry_points.txt +2 -0
- dotspot-0.0.1/dotspot.egg-info/requires.txt +4 -0
- dotspot-0.0.1/dotspot.egg-info/top_level.txt +6 -0
- dotspot-0.0.1/dotspot.py +43 -0
- dotspot-0.0.1/pyproject.toml +53 -0
- dotspot-0.0.1/run.sh +9 -0
- dotspot-0.0.1/setup.cfg +4 -0
- dotspot-0.0.1/ui/__init__.py +0 -0
- dotspot-0.0.1/ui/banner.py +39 -0
- dotspot-0.0.1/ui/console.py +3 -0
- dotspot-0.0.1/ui/prompts.py +123 -0
- dotspot-0.0.1/utils/__init__.py +18 -0
- dotspot-0.0.1/utils/diff.py +78 -0
- dotspot-0.0.1/utils/http.py +121 -0
- dotspot-0.0.1/utils/patterns.py +117 -0
dotspot-0.0.1/.gitignore
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Python bytecode
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Virtual environment
|
|
7
|
+
venv/
|
|
8
|
+
.env/
|
|
9
|
+
.env
|
|
10
|
+
|
|
11
|
+
# Environment variables
|
|
12
|
+
.env.*
|
|
13
|
+
!.env.example
|
|
14
|
+
|
|
15
|
+
# OS files
|
|
16
|
+
.DS_Store
|
|
17
|
+
Thumbs.db
|
|
18
|
+
|
|
19
|
+
.vscode/
|
|
20
|
+
.idea/
|
|
21
|
+
|
|
22
|
+
# Logs
|
|
23
|
+
*.log
|
|
24
|
+
|
|
25
|
+
# Reports
|
|
26
|
+
reports/
|
|
27
|
+
|
|
28
|
+
# Cache
|
|
29
|
+
*.cache
|
|
30
|
+
|
|
31
|
+
# Build artifacts
|
|
32
|
+
dist/
|
|
33
|
+
build/
|
|
34
|
+
*.egg-info/
|
dotspot-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sagnik Mukherjee
|
|
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.
|
dotspot-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dotspot
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A powerful web vulnerability scanner with SQL injection, SSTI, exposed path detection, and AI-powered analysis.
|
|
5
|
+
Author: Sagnik Mukherjee
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/itssagnikmukherjee/dotSpot
|
|
8
|
+
Project-URL: Repository, https://github.com/itssagnikmukherjee/dotSpot
|
|
9
|
+
Project-URL: Issues, https://github.com/itssagnikmukherjee/dotSpot/issues
|
|
10
|
+
Keywords: security,scanner,vulnerability,pentesting,web-security
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Information Technology
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Security
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: requests>=2.28
|
|
27
|
+
Requires-Dist: rich>=13.0
|
|
28
|
+
Requires-Dist: urllib3>=2.0
|
|
29
|
+
Requires-Dist: groq>=0.4
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# dotSpot
|
|
33
|
+
|
|
34
|
+
A powerful web vulnerability scanner built in Python.
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- **SQL Injection (SQLi)** detection with comprehensive payload testing
|
|
39
|
+
- **Server-Side Template Injection (SSTI)** scanning
|
|
40
|
+
- **Exposed Path Discovery** for sensitive files and directories
|
|
41
|
+
- **Cookie Security** analysis
|
|
42
|
+
- **HTML Comment** extraction for information leakage
|
|
43
|
+
- **JavaScript Analysis** for secrets and sensitive data
|
|
44
|
+
- **Base64 Decoding** of embedded data
|
|
45
|
+
- **AI-Powered Analysis** via Groq for intelligent scan report summaries
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install dotspot
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
### Scan a target URL
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
dotspot scan <target-url>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
You'll be prompted to choose between vulnerability scanning or flag hunting mode.
|
|
62
|
+
|
|
63
|
+
### Analyze scan results with AI
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
dotspot analyze <scan-report.json>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Optionally pass `--api-key YOUR_KEY` or set the `GROQ_API_KEY` environment variable.
|
|
70
|
+
|
|
71
|
+
### Show help
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
dotspot help
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Requirements
|
|
78
|
+
|
|
79
|
+
- Python 3.9+
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
|
|
83
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
dotspot-0.0.1/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# dotSpot
|
|
2
|
+
|
|
3
|
+
A powerful web vulnerability scanner built in Python.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **SQL Injection (SQLi)** detection with comprehensive payload testing
|
|
8
|
+
- **Server-Side Template Injection (SSTI)** scanning
|
|
9
|
+
- **Exposed Path Discovery** for sensitive files and directories
|
|
10
|
+
- **Cookie Security** analysis
|
|
11
|
+
- **HTML Comment** extraction for information leakage
|
|
12
|
+
- **JavaScript Analysis** for secrets and sensitive data
|
|
13
|
+
- **Base64 Decoding** of embedded data
|
|
14
|
+
- **AI-Powered Analysis** via Groq for intelligent scan report summaries
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install dotspot
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Scan a target URL
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
dotspot scan <target-url>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
You'll be prompted to choose between vulnerability scanning or flag hunting mode.
|
|
31
|
+
|
|
32
|
+
### Analyze scan results with AI
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
dotspot analyze <scan-report.json>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Optionally pass `--api-key YOUR_KEY` or set the `GROQ_API_KEY` environment variable.
|
|
39
|
+
|
|
40
|
+
### Show help
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
dotspot help
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Requirements
|
|
47
|
+
|
|
48
|
+
- Python 3.9+
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from checks import exposed_paths
|
|
2
|
+
from checks import cookies
|
|
3
|
+
from checks import comments
|
|
4
|
+
from checks import sqli
|
|
5
|
+
from checks import ssti
|
|
6
|
+
from checks import js_analysis
|
|
7
|
+
from checks import base64_decode
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
'exposed_paths',
|
|
11
|
+
'cookies',
|
|
12
|
+
'comments',
|
|
13
|
+
'sqli',
|
|
14
|
+
'ssti',
|
|
15
|
+
'js_analysis',
|
|
16
|
+
'base64_decode',
|
|
17
|
+
]
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
import re
|
|
4
|
+
from typing import Dict, Optional
|
|
5
|
+
from rich.console import Console
|
|
6
|
+
from rich.panel import Panel
|
|
7
|
+
from rich.table import Table
|
|
8
|
+
from rich.markdown import Markdown
|
|
9
|
+
|
|
10
|
+
console = Console()
|
|
11
|
+
|
|
12
|
+
GROQ_API_URL = os.environ.get("GROQ_API_URL")
|
|
13
|
+
DEFAULT_MODEL = os.environ.get("DEFAULT_MODEL")
|
|
14
|
+
|
|
15
|
+
TABLE_WIDTH = 100
|
|
16
|
+
|
|
17
|
+
def get_groq_api_key() -> Optional[str]:
|
|
18
|
+
return os.environ.get("GROQ_API_KEY")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def analyze_with_groq(scan_data: Dict, api_key: str) -> str:
|
|
22
|
+
try:
|
|
23
|
+
from groq import Groq, APIError
|
|
24
|
+
except ImportError:
|
|
25
|
+
console.print("Groq SDK not installed")
|
|
26
|
+
return ""
|
|
27
|
+
|
|
28
|
+
client = Groq(api_key=api_key)
|
|
29
|
+
|
|
30
|
+
findings_text = json.dumps(scan_data.get("findings", []), indent=2)
|
|
31
|
+
|
|
32
|
+
prompt_path = os.path.join(os.path.dirname(__file__), '..', 'data', 'prompt.txt')
|
|
33
|
+
prompt = open(prompt_path, "r").read()
|
|
34
|
+
|
|
35
|
+
try:
|
|
36
|
+
chat_completion = client.chat.completions.create(
|
|
37
|
+
messages=[
|
|
38
|
+
{"role": "system", "content": prompt},
|
|
39
|
+
{"role": "user", "content": findings_text}
|
|
40
|
+
],
|
|
41
|
+
model=DEFAULT_MODEL,
|
|
42
|
+
temperature=0.3,
|
|
43
|
+
max_tokens=2000
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
return chat_completion.choices[0].message.content
|
|
47
|
+
|
|
48
|
+
except APIError as e:
|
|
49
|
+
console.print("Groq API Error")
|
|
50
|
+
console.print(f"Type: {type(e).__name__}")
|
|
51
|
+
console.print(f"Message: {str(e)}")
|
|
52
|
+
if "model" in str(e).lower():
|
|
53
|
+
console.print(f"Hint: The model '{DEFAULT_MODEL}' might be invalid or deprecated.")
|
|
54
|
+
return ""
|
|
55
|
+
except Exception as e:
|
|
56
|
+
console.print(f"Unexpected error during AI analysis: {e}")
|
|
57
|
+
return ""
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def analyze_scan_report(json_path: str, api_key: Optional[str] = None) -> None:
|
|
61
|
+
key = api_key or get_groq_api_key()
|
|
62
|
+
if not key:
|
|
63
|
+
console.print("API KEY NOT FOUND")
|
|
64
|
+
return
|
|
65
|
+
|
|
66
|
+
try:
|
|
67
|
+
with open(json_path, 'r') as f:
|
|
68
|
+
scan_data = json.load(f)
|
|
69
|
+
except FileNotFoundError:
|
|
70
|
+
console.print(f"File not found: {json_path}")
|
|
71
|
+
return
|
|
72
|
+
except json.JSONDecodeError:
|
|
73
|
+
console.print(f"Invalid JSON file: {json_path}")
|
|
74
|
+
return
|
|
75
|
+
|
|
76
|
+
console.print(Panel.fit(
|
|
77
|
+
f"[bold cyan]Analyzing:[/] {json_path}\n"
|
|
78
|
+
f"[bold cyan]Model:[/] {DEFAULT_MODEL}",
|
|
79
|
+
title="[bold green]🤖 AI Analysis[/]",
|
|
80
|
+
border_style="green"
|
|
81
|
+
))
|
|
82
|
+
|
|
83
|
+
with console.status("[bold cyan]Analyzing with Groq AI...[/]", spinner="dots"):
|
|
84
|
+
analysis = analyze_with_groq(scan_data, key)
|
|
85
|
+
|
|
86
|
+
if analysis:
|
|
87
|
+
console.print()
|
|
88
|
+
console.print(Panel(
|
|
89
|
+
Markdown(analysis),
|
|
90
|
+
title="[bold green]🔍 Security Analysis[/]",
|
|
91
|
+
border_style="cyan",
|
|
92
|
+
padding=(1, 2)
|
|
93
|
+
))
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _parse_ai_table(analysis: str) -> list:
|
|
97
|
+
rows = []
|
|
98
|
+
for line in analysis.strip().splitlines():
|
|
99
|
+
line = line.strip()
|
|
100
|
+
if not line or line.startswith('#') or line.startswith('---'):
|
|
101
|
+
continue
|
|
102
|
+
if 'vulnerability' in line.lower() and 'info' in line.lower() and 'fix' in line.lower():
|
|
103
|
+
continue
|
|
104
|
+
parts = [p.strip() for p in line.split('|')]
|
|
105
|
+
parts = [p for p in parts if p]
|
|
106
|
+
if len(parts) >= 3:
|
|
107
|
+
rows.append((parts[0], parts[1], parts[2]))
|
|
108
|
+
elif len(parts) == 2:
|
|
109
|
+
rows.append((parts[0], parts[1], "—"))
|
|
110
|
+
elif len(parts) == 1 and line.startswith('-'):
|
|
111
|
+
cleaned = line.lstrip('- ').strip()
|
|
112
|
+
if ':' in cleaned:
|
|
113
|
+
vuln, info = cleaned.split(':', 1)
|
|
114
|
+
rows.append((vuln.strip(), info.strip(), "—"))
|
|
115
|
+
return rows
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def run(ctx):
|
|
119
|
+
key = get_groq_api_key()
|
|
120
|
+
if not key:
|
|
121
|
+
return
|
|
122
|
+
|
|
123
|
+
scan_data = {
|
|
124
|
+
"target_url": ctx.base_url,
|
|
125
|
+
"findings": [{"description": f} for f in ctx.findings],
|
|
126
|
+
"summary": {"total": len(ctx.findings)}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
with console.status("[bold cyan]Getting AI insights...[/]", spinner="dots"):
|
|
130
|
+
analysis = analyze_with_groq(scan_data, key)
|
|
131
|
+
|
|
132
|
+
if analysis:
|
|
133
|
+
rows = _parse_ai_table(analysis)
|
|
134
|
+
if rows:
|
|
135
|
+
ai_table = Table(
|
|
136
|
+
title="[bold green]🤖 AI Insights[/]",
|
|
137
|
+
show_header=True,
|
|
138
|
+
header_style="bold cyan",
|
|
139
|
+
border_style="cyan",
|
|
140
|
+
show_lines=True,
|
|
141
|
+
width=TABLE_WIDTH,
|
|
142
|
+
)
|
|
143
|
+
ai_table.add_column("Vulnerability", style="red", ratio=1, no_wrap=False, overflow="fold")
|
|
144
|
+
ai_table.add_column("Info", style="white", ratio=2, no_wrap=False, overflow="fold")
|
|
145
|
+
ai_table.add_column("Potential Fix", style="green", ratio=2, no_wrap=False, overflow="fold")
|
|
146
|
+
|
|
147
|
+
for vuln, info, fix in rows:
|
|
148
|
+
ai_table.add_row(vuln, info, fix)
|
|
149
|
+
console.print(ai_table)
|
|
150
|
+
else:
|
|
151
|
+
console.print(Panel(
|
|
152
|
+
Markdown(analysis),
|
|
153
|
+
title="[bold green]🤖 AI Insights[/]",
|
|
154
|
+
border_style="cyan"
|
|
155
|
+
))
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
|
|
2
|
+
import re
|
|
3
|
+
import base64
|
|
4
|
+
from typing import List, Tuple, Optional
|
|
5
|
+
from rich.console import Console
|
|
6
|
+
|
|
7
|
+
from utils.http import safe_get
|
|
8
|
+
|
|
9
|
+
console = Console()
|
|
10
|
+
|
|
11
|
+
MIN_BASE64_LENGTH = 20
|
|
12
|
+
MAX_FINDINGS = 10
|
|
13
|
+
|
|
14
|
+
FALSE_POSITIVES = [
|
|
15
|
+
'data:image',
|
|
16
|
+
'data:audio',
|
|
17
|
+
'data:video',
|
|
18
|
+
'data:font',
|
|
19
|
+
'data:application',
|
|
20
|
+
'googleapis.com',
|
|
21
|
+
'gstatic.com',
|
|
22
|
+
'jquery',
|
|
23
|
+
'bootstrap',
|
|
24
|
+
'sourceMappingURL'
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def is_valid_base64(s: str) -> bool:
|
|
29
|
+
if len(s) < MIN_BASE64_LENGTH:
|
|
30
|
+
return False
|
|
31
|
+
|
|
32
|
+
if not re.match(r'^[A-Za-z0-9+/=]+$', s):
|
|
33
|
+
return False
|
|
34
|
+
|
|
35
|
+
if len(s) % 4 not in [0, 2, 3]:
|
|
36
|
+
padded = s + '=' * (4 - len(s) % 4) if len(s) % 4 != 0 else s
|
|
37
|
+
if len(padded) % 4 != 0:
|
|
38
|
+
return False
|
|
39
|
+
|
|
40
|
+
return True
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def decode_base64(s: str) -> Optional[str]:
|
|
44
|
+
try:
|
|
45
|
+
padded = s + '=' * (4 - len(s) % 4) if len(s) % 4 != 0 else s
|
|
46
|
+
decoded_bytes = base64.b64decode(padded)
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
decoded = decoded_bytes.decode('utf-8')
|
|
50
|
+
if all(c.isprintable() or c in '\n\r\t' for c in decoded):
|
|
51
|
+
return decoded
|
|
52
|
+
except UnicodeDecodeError:
|
|
53
|
+
try:
|
|
54
|
+
decoded = decoded_bytes.decode('latin-1')
|
|
55
|
+
if all(c.isprintable() or c in '\n\r\t' for c in decoded):
|
|
56
|
+
return decoded
|
|
57
|
+
except:
|
|
58
|
+
pass
|
|
59
|
+
except Exception:
|
|
60
|
+
pass
|
|
61
|
+
|
|
62
|
+
return None
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def categorize_decoded(decoded: str) -> Tuple[str, str]:
|
|
66
|
+
decoded_lower = decoded.lower()
|
|
67
|
+
|
|
68
|
+
if any(p in decoded_lower for p in ['password', 'passwd', 'secret', 'api_key', 'apikey', 'token', 'auth']):
|
|
69
|
+
return 'credential', 'critical'
|
|
70
|
+
|
|
71
|
+
if re.search(r'flag\{|ctf\{|picoCTF\{', decoded, re.IGNORECASE):
|
|
72
|
+
return 'flag', 'critical'
|
|
73
|
+
|
|
74
|
+
if decoded.strip().startswith('{') and decoded.strip().endswith('}'):
|
|
75
|
+
return 'json', 'high'
|
|
76
|
+
|
|
77
|
+
if 'http://' in decoded or 'https://' in decoded:
|
|
78
|
+
return 'url', 'medium'
|
|
79
|
+
|
|
80
|
+
if re.search(r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}', decoded):
|
|
81
|
+
return 'email', 'medium'
|
|
82
|
+
|
|
83
|
+
if re.search(r'^(/|[A-Za-z]:\\)', decoded) or '/' in decoded:
|
|
84
|
+
return 'path', 'low'
|
|
85
|
+
|
|
86
|
+
return 'text', 'info'
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def is_interesting(decoded: str) -> bool:
|
|
90
|
+
if len(decoded) < 5:
|
|
91
|
+
return False
|
|
92
|
+
|
|
93
|
+
if '\x00' in decoded:
|
|
94
|
+
return False
|
|
95
|
+
|
|
96
|
+
decoded_lower = decoded.lower()
|
|
97
|
+
skip_patterns = [
|
|
98
|
+
'lorem ipsum',
|
|
99
|
+
'copyright',
|
|
100
|
+
'license',
|
|
101
|
+
'all rights reserved'
|
|
102
|
+
]
|
|
103
|
+
if any(p in decoded_lower for p in skip_patterns):
|
|
104
|
+
return False
|
|
105
|
+
|
|
106
|
+
alpha_ratio = sum(c.isalpha() for c in decoded) / len(decoded)
|
|
107
|
+
if alpha_ratio < 0.3:
|
|
108
|
+
return False
|
|
109
|
+
|
|
110
|
+
return True
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def find_base64_strings(html: str) -> List[Tuple[str, str, str, str]]:
|
|
114
|
+
findings = []
|
|
115
|
+
|
|
116
|
+
pattern = r'[A-Za-z0-9+/]{20,}={0,2}'
|
|
117
|
+
matches = re.findall(pattern, html)
|
|
118
|
+
|
|
119
|
+
for match in matches:
|
|
120
|
+
if any(fp in match for fp in FALSE_POSITIVES):
|
|
121
|
+
continue
|
|
122
|
+
|
|
123
|
+
context_start = html.find(match)
|
|
124
|
+
if context_start > 0:
|
|
125
|
+
context = html[max(0, context_start - 50):context_start]
|
|
126
|
+
if any(fp in context for fp in FALSE_POSITIVES):
|
|
127
|
+
continue
|
|
128
|
+
|
|
129
|
+
if is_valid_base64(match):
|
|
130
|
+
decoded = decode_base64(match)
|
|
131
|
+
if decoded and is_interesting(decoded):
|
|
132
|
+
category, severity = categorize_decoded(decoded)
|
|
133
|
+
findings.append((match, decoded, category, severity))
|
|
134
|
+
|
|
135
|
+
seen = set()
|
|
136
|
+
unique_findings = []
|
|
137
|
+
for f in findings:
|
|
138
|
+
if f[1] not in seen:
|
|
139
|
+
seen.add(f[1])
|
|
140
|
+
unique_findings.append(f)
|
|
141
|
+
|
|
142
|
+
return unique_findings[:MAX_FINDINGS]
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def run(ctx):
|
|
146
|
+
urls_to_scan = list(ctx.urls) if hasattr(ctx, 'urls') and ctx.urls else [ctx.base_url]
|
|
147
|
+
|
|
148
|
+
all_findings = []
|
|
149
|
+
|
|
150
|
+
for url in urls_to_scan:
|
|
151
|
+
response, error = safe_get(url)
|
|
152
|
+
if error or not response:
|
|
153
|
+
continue
|
|
154
|
+
|
|
155
|
+
page_findings = find_base64_strings(response.text)
|
|
156
|
+
|
|
157
|
+
for original, decoded, category, severity in page_findings:
|
|
158
|
+
if not any(decoded == f[1] for f in all_findings):
|
|
159
|
+
all_findings.append((original, decoded, category, severity, url))
|
|
160
|
+
|
|
161
|
+
if not all_findings:
|
|
162
|
+
return
|
|
163
|
+
|
|
164
|
+
for original, decoded, category, severity, source_url in all_findings[:MAX_FINDINGS]:
|
|
165
|
+
page_name = source_url.split('/')[-1] or 'index'
|
|
166
|
+
display_encoded = original if len(original) <= 50 else original[:50] + "..."
|
|
167
|
+
finding = f"Base64 found in {page_name} ({category}): \"{display_encoded}\" → Decoded: \"{decoded}\""
|
|
168
|
+
ctx.findings.append(finding)
|
|
169
|
+
|
|
170
|
+
if len(all_findings) > MAX_FINDINGS:
|
|
171
|
+
remaining = len(all_findings) - MAX_FINDINGS
|
|
172
|
+
ctx.findings.append(f"Base64: {remaining} additional encoded strings not shown")
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from typing import List, Tuple
|
|
3
|
+
from rich.console import Console
|
|
4
|
+
|
|
5
|
+
from utils.http import safe_get
|
|
6
|
+
|
|
7
|
+
console = Console()
|
|
8
|
+
|
|
9
|
+
MAX_COMMENT_LENGTH = 200
|
|
10
|
+
MAX_COMMENTS_TO_REPORT = 10
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def clean_comment(comment: str) -> str:
|
|
14
|
+
cleaned = re.sub(r'\s+', ' ', comment.strip())
|
|
15
|
+
if len(cleaned) > MAX_COMMENT_LENGTH:
|
|
16
|
+
cleaned = cleaned[:MAX_COMMENT_LENGTH] + "..."
|
|
17
|
+
return cleaned
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def find_comment_position(html: str, raw_comment: str) -> Tuple[int, int]:
|
|
21
|
+
marker = f"<!--{raw_comment}-->"
|
|
22
|
+
pos = html.find(marker)
|
|
23
|
+
|
|
24
|
+
if pos == -1:
|
|
25
|
+
pos = html.find(f"<!--{raw_comment}")
|
|
26
|
+
|
|
27
|
+
if pos >= 0:
|
|
28
|
+
before = html[:pos]
|
|
29
|
+
line_number = before.count('\n') + 1
|
|
30
|
+
last_newline = before.rfind('\n')
|
|
31
|
+
column = (pos + 1) if last_newline == -1 else (pos - last_newline)
|
|
32
|
+
return line_number, column
|
|
33
|
+
|
|
34
|
+
return 0, 0
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def categorize_comment(comment: str) -> Tuple[str, str]:
|
|
38
|
+
comment_lower = comment.lower()
|
|
39
|
+
|
|
40
|
+
if any(p in comment_lower for p in ['password', 'passwd', 'pwd', 'secret', 'api_key', 'apikey', 'token']):
|
|
41
|
+
return 'credential', 'high'
|
|
42
|
+
|
|
43
|
+
if any(p in comment_lower for p in ['todo', 'fixme', 'hack', 'xxx', 'bug']):
|
|
44
|
+
return 'todo', 'medium'
|
|
45
|
+
|
|
46
|
+
if any(p in comment_lower for p in ['debug', 'test', 'dev', 'staging']):
|
|
47
|
+
return 'debug', 'medium'
|
|
48
|
+
|
|
49
|
+
if any(p in comment_lower for p in ['version', 'v1', 'v2', 'build']):
|
|
50
|
+
return 'version', 'low'
|
|
51
|
+
|
|
52
|
+
if any(p in comment_lower for p in ['author', 'created', 'modified', 'copyright']):
|
|
53
|
+
return 'metadata', 'info'
|
|
54
|
+
|
|
55
|
+
if re.search(r'\b(?:localhost|127\.0\.0\.1|192\.168\.|10\.)', comment_lower):
|
|
56
|
+
return 'internal_url', 'medium'
|
|
57
|
+
|
|
58
|
+
if re.search(r'function|var |let |const |class |def |import ', comment):
|
|
59
|
+
return 'code', 'low'
|
|
60
|
+
|
|
61
|
+
return 'general', 'info'
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def run(ctx):
|
|
65
|
+
urls_to_scan = list(ctx.urls) if hasattr(ctx, 'urls') and ctx.urls else [ctx.base_url]
|
|
66
|
+
|
|
67
|
+
if not hasattr(ctx, 'comment_results'):
|
|
68
|
+
ctx.comment_results = []
|
|
69
|
+
|
|
70
|
+
all_comments = []
|
|
71
|
+
|
|
72
|
+
for url in urls_to_scan:
|
|
73
|
+
response, error = safe_get(url)
|
|
74
|
+
if error or not response:
|
|
75
|
+
continue
|
|
76
|
+
|
|
77
|
+
page_name = url.split('/')[-1] or 'index.html'
|
|
78
|
+
html_content = response.text
|
|
79
|
+
|
|
80
|
+
comments = re.findall(r"<!--(.*?)-->", html_content, re.DOTALL)
|
|
81
|
+
|
|
82
|
+
for comment in comments:
|
|
83
|
+
cleaned = clean_comment(comment)
|
|
84
|
+
if len(cleaned) > 5 and not cleaned.startswith('[if '):
|
|
85
|
+
if not any(cleaned == c[0] for c in all_comments):
|
|
86
|
+
line, col = find_comment_position(html_content, comment)
|
|
87
|
+
all_comments.append((cleaned, page_name, line, col))
|
|
88
|
+
|
|
89
|
+
if not all_comments:
|
|
90
|
+
return
|
|
91
|
+
|
|
92
|
+
for comment, page, line, col in all_comments[:MAX_COMMENTS_TO_REPORT]:
|
|
93
|
+
category, severity = categorize_comment(comment)
|
|
94
|
+
|
|
95
|
+
location = f"{line},{col}" if line > 0 else "0,0"
|
|
96
|
+
finding = f"HTML comment in {page} ({location}): \"{comment}\""
|
|
97
|
+
ctx.findings.append(finding)
|
|
98
|
+
|
|
99
|
+
ctx.comment_results.append({
|
|
100
|
+
"comment": comment,
|
|
101
|
+
"file": page,
|
|
102
|
+
"line": line if line > 0 else "—",
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
if len(all_comments) > MAX_COMMENTS_TO_REPORT:
|
|
106
|
+
remaining = len(all_comments) - MAX_COMMENTS_TO_REPORT
|
|
107
|
+
ctx.findings.append(f"HTML comments: {remaining} additional comments not shown")
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from rich.console import Console
|
|
3
|
+
from rich.table import Table
|
|
4
|
+
|
|
5
|
+
console = Console()
|
|
6
|
+
|
|
7
|
+
TABLE_WIDTH = 100
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def run(ctx):
|
|
11
|
+
if not hasattr(ctx, 'cookie_results'):
|
|
12
|
+
ctx.cookie_results = []
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
r = requests.get(ctx.base_url, timeout=5, verify=False)
|
|
16
|
+
except Exception:
|
|
17
|
+
return
|
|
18
|
+
|
|
19
|
+
if not r.cookies:
|
|
20
|
+
return
|
|
21
|
+
|
|
22
|
+
for c in r.cookies:
|
|
23
|
+
httponly = "Yes" if c.has_nonstandard_attr("HttpOnly") else "No"
|
|
24
|
+
secure = "Yes" if c.secure else "No"
|
|
25
|
+
domain = c.domain or "—"
|
|
26
|
+
path = c.path or "/"
|
|
27
|
+
expires = c.expires or "—"
|
|
28
|
+
|
|
29
|
+
ctx.cookie_results.append({
|
|
30
|
+
"name": c.name,
|
|
31
|
+
"value": c.value or "",
|
|
32
|
+
"domain": domain,
|
|
33
|
+
"path": path,
|
|
34
|
+
"httponly": httponly,
|
|
35
|
+
"secure": secure,
|
|
36
|
+
"expires": expires,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
issues = []
|
|
40
|
+
if httponly == "No":
|
|
41
|
+
issues.append("missing HttpOnly")
|
|
42
|
+
if secure == "No":
|
|
43
|
+
issues.append("missing Secure")
|
|
44
|
+
if expires == "—":
|
|
45
|
+
issues.append("no expiration date")
|
|
46
|
+
if issues:
|
|
47
|
+
ctx.findings.append(f"Cookie issue ({c.name}): {', '.join(issues)}")
|