Prives 0.1.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.
- prives-0.1.0/LICENSE +25 -0
- prives-0.1.0/PKG-INFO +94 -0
- prives-0.1.0/README.md +82 -0
- prives-0.1.0/pyproject.toml +30 -0
- prives-0.1.0/setup.cfg +4 -0
- prives-0.1.0/src/Prives.egg-info/PKG-INFO +94 -0
- prives-0.1.0/src/Prives.egg-info/SOURCES.txt +28 -0
- prives-0.1.0/src/Prives.egg-info/dependency_links.txt +1 -0
- prives-0.1.0/src/Prives.egg-info/entry_points.txt +2 -0
- prives-0.1.0/src/Prives.egg-info/requires.txt +1 -0
- prives-0.1.0/src/Prives.egg-info/top_level.txt +1 -0
- prives-0.1.0/src/prives/__init__.py +6 -0
- prives-0.1.0/src/prives/core/analyzer.py +129 -0
- prives-0.1.0/src/prives/core/colors.py +7 -0
- prives-0.1.0/src/prives/core/reporter.py +15 -0
- prives-0.1.0/src/prives/core/requester.py +17 -0
- prives-0.1.0/src/prives/core/scanner.py +97 -0
- prives-0.1.0/src/prives/core/tasks.py +79 -0
- prives-0.1.0/src/prives/db/sensitive_keys.txt +556 -0
- prives-0.1.0/src/prives/generators/api_version.py +29 -0
- prives-0.1.0/src/prives/generators/forwarded.py +15 -0
- prives-0.1.0/src/prives/generators/idor.py +60 -0
- prives-0.1.0/src/prives/generators/override.py +16 -0
- prives-0.1.0/src/prives/generators/params.py +35 -0
- prives-0.1.0/src/prives/generators/paths.py +50 -0
- prives-0.1.0/src/prives/generators/user_agents.py +30 -0
- prives-0.1.0/src/prives/main.py +141 -0
- prives-0.1.0/src/prives/tests/call_analyzer.py +17 -0
- prives-0.1.0/src/prives/tests/get_payloads.py +67 -0
- prives-0.1.0/src/prives/tests/server.py +45 -0
prives-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hunter
|
|
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
|
+
<<<<<<< HEAD
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
=======
|
|
24
|
+
SOFTWARE.
|
|
25
|
+
>>>>>>> cf84cef (Initial commit)
|
prives-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Prives
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A tool for testing access control vulnerabilities and authorization bypasses.
|
|
5
|
+
Author: 0nely
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: requests
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# Prives
|
|
14
|
+
|
|
15
|
+
Prives is a security testing tool designed to identify potential Broken Access Control (BAC) vulnerabilities in web applications and APIs.
|
|
16
|
+
|
|
17
|
+
It automates various request manipulation techniques to help security researchers discover access control weaknesses and assess authorization behavior.
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
## Key Techniques
|
|
22
|
+
|
|
23
|
+
- **IDOR** – Tests for insecure direct object references and unauthorized object access.
|
|
24
|
+
- **Authorization Bypass** – Tests alternative request formats, headers, and path manipulation techniques to identify potential authorization bypasses, particularly on endpoints returning HTTP 401 or 403.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
### pipx
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Install
|
|
32
|
+
pipx install prives
|
|
33
|
+
|
|
34
|
+
# Upgrade
|
|
35
|
+
pipx upgrade prives
|
|
36
|
+
|
|
37
|
+
# Uninstall
|
|
38
|
+
pipx uninstall prives
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### pip
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Install
|
|
45
|
+
pip install prives
|
|
46
|
+
|
|
47
|
+
# Upgrade
|
|
48
|
+
pip install --upgrade prives
|
|
49
|
+
|
|
50
|
+
# Uninstall
|
|
51
|
+
pip uninstall prives
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
### Basic Scan
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
prives -u https://target.com
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Specify Target ID
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
prives -u https://target.com/api/user/{prives-user123}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Enable IDOR Testing
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
prives -u https://target.com/api/user/{prives-user123} -sI "admin"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
For more options and available techniques:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
prives --help
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Bug Reports & Feedback
|
|
81
|
+
|
|
82
|
+
Bug reports, suggestions, and feedback are always welcome. Feel free to open an issue or share your thoughts. I'd be happy to hear from you!
|
|
83
|
+
|
|
84
|
+
## Legal Disclaimer
|
|
85
|
+
|
|
86
|
+
Prives is intended for authorized security testing, educational purposes, and security research only.
|
|
87
|
+
|
|
88
|
+
Users are responsible for ensuring they have proper authorization before testing any application or system.
|
|
89
|
+
|
|
90
|
+
The developers assume no responsibility for misuse, unauthorized access, or any damage resulting from the use of this tool.
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
prives-0.1.0/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Prives
|
|
2
|
+
|
|
3
|
+
Prives is a security testing tool designed to identify potential Broken Access Control (BAC) vulnerabilities in web applications and APIs.
|
|
4
|
+
|
|
5
|
+
It automates various request manipulation techniques to help security researchers discover access control weaknesses and assess authorization behavior.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## Key Techniques
|
|
10
|
+
|
|
11
|
+
- **IDOR** – Tests for insecure direct object references and unauthorized object access.
|
|
12
|
+
- **Authorization Bypass** – Tests alternative request formats, headers, and path manipulation techniques to identify potential authorization bypasses, particularly on endpoints returning HTTP 401 or 403.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
### pipx
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Install
|
|
20
|
+
pipx install prives
|
|
21
|
+
|
|
22
|
+
# Upgrade
|
|
23
|
+
pipx upgrade prives
|
|
24
|
+
|
|
25
|
+
# Uninstall
|
|
26
|
+
pipx uninstall prives
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### pip
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Install
|
|
33
|
+
pip install prives
|
|
34
|
+
|
|
35
|
+
# Upgrade
|
|
36
|
+
pip install --upgrade prives
|
|
37
|
+
|
|
38
|
+
# Uninstall
|
|
39
|
+
pip uninstall prives
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
### Basic Scan
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
prives -u https://target.com
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Specify Target ID
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
prives -u https://target.com/api/user/{prives-user123}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Enable IDOR Testing
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
prives -u https://target.com/api/user/{prives-user123} -sI "admin"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
For more options and available techniques:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
prives --help
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Bug Reports & Feedback
|
|
69
|
+
|
|
70
|
+
Bug reports, suggestions, and feedback are always welcome. Feel free to open an issue or share your thoughts. I'd be happy to hear from you!
|
|
71
|
+
|
|
72
|
+
## Legal Disclaimer
|
|
73
|
+
|
|
74
|
+
Prives is intended for authorized security testing, educational purposes, and security research only.
|
|
75
|
+
|
|
76
|
+
Users are responsible for ensuring they have proper authorization before testing any application or system.
|
|
77
|
+
|
|
78
|
+
The developers assume no responsibility for misuse, unauthorized access, or any damage resulting from the use of this tool.
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "Prives"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A tool for testing access control vulnerabilities and authorization bypasses."
|
|
9
|
+
authors = [
|
|
10
|
+
{ name = "0nely" }
|
|
11
|
+
]
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
license = { text = "MIT" }
|
|
14
|
+
requires-python = ">=3.10"
|
|
15
|
+
dependencies = [
|
|
16
|
+
"requests",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.scripts]
|
|
20
|
+
prives = "prives.main:main"
|
|
21
|
+
|
|
22
|
+
[tool.setuptools]
|
|
23
|
+
package-dir = {"" = "src"}
|
|
24
|
+
|
|
25
|
+
[tool.setuptools.packages.find]
|
|
26
|
+
where = ["src"]
|
|
27
|
+
include = ["prives*"]
|
|
28
|
+
|
|
29
|
+
[tool.setuptools.package-data]
|
|
30
|
+
"prives.db" = ["sensitive_keys.txt"]
|
prives-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Prives
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A tool for testing access control vulnerabilities and authorization bypasses.
|
|
5
|
+
Author: 0nely
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: requests
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# Prives
|
|
14
|
+
|
|
15
|
+
Prives is a security testing tool designed to identify potential Broken Access Control (BAC) vulnerabilities in web applications and APIs.
|
|
16
|
+
|
|
17
|
+
It automates various request manipulation techniques to help security researchers discover access control weaknesses and assess authorization behavior.
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
## Key Techniques
|
|
22
|
+
|
|
23
|
+
- **IDOR** – Tests for insecure direct object references and unauthorized object access.
|
|
24
|
+
- **Authorization Bypass** – Tests alternative request formats, headers, and path manipulation techniques to identify potential authorization bypasses, particularly on endpoints returning HTTP 401 or 403.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
### pipx
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Install
|
|
32
|
+
pipx install prives
|
|
33
|
+
|
|
34
|
+
# Upgrade
|
|
35
|
+
pipx upgrade prives
|
|
36
|
+
|
|
37
|
+
# Uninstall
|
|
38
|
+
pipx uninstall prives
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### pip
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Install
|
|
45
|
+
pip install prives
|
|
46
|
+
|
|
47
|
+
# Upgrade
|
|
48
|
+
pip install --upgrade prives
|
|
49
|
+
|
|
50
|
+
# Uninstall
|
|
51
|
+
pip uninstall prives
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
### Basic Scan
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
prives -u https://target.com
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Specify Target ID
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
prives -u https://target.com/api/user/{prives-user123}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Enable IDOR Testing
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
prives -u https://target.com/api/user/{prives-user123} -sI "admin"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
For more options and available techniques:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
prives --help
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Bug Reports & Feedback
|
|
81
|
+
|
|
82
|
+
Bug reports, suggestions, and feedback are always welcome. Feel free to open an issue or share your thoughts. I'd be happy to hear from you!
|
|
83
|
+
|
|
84
|
+
## Legal Disclaimer
|
|
85
|
+
|
|
86
|
+
Prives is intended for authorized security testing, educational purposes, and security research only.
|
|
87
|
+
|
|
88
|
+
Users are responsible for ensuring they have proper authorization before testing any application or system.
|
|
89
|
+
|
|
90
|
+
The developers assume no responsibility for misuse, unauthorized access, or any damage resulting from the use of this tool.
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/Prives.egg-info/PKG-INFO
|
|
5
|
+
src/Prives.egg-info/SOURCES.txt
|
|
6
|
+
src/Prives.egg-info/dependency_links.txt
|
|
7
|
+
src/Prives.egg-info/entry_points.txt
|
|
8
|
+
src/Prives.egg-info/requires.txt
|
|
9
|
+
src/Prives.egg-info/top_level.txt
|
|
10
|
+
src/prives/__init__.py
|
|
11
|
+
src/prives/main.py
|
|
12
|
+
src/prives/core/analyzer.py
|
|
13
|
+
src/prives/core/colors.py
|
|
14
|
+
src/prives/core/reporter.py
|
|
15
|
+
src/prives/core/requester.py
|
|
16
|
+
src/prives/core/scanner.py
|
|
17
|
+
src/prives/core/tasks.py
|
|
18
|
+
src/prives/db/sensitive_keys.txt
|
|
19
|
+
src/prives/generators/api_version.py
|
|
20
|
+
src/prives/generators/forwarded.py
|
|
21
|
+
src/prives/generators/idor.py
|
|
22
|
+
src/prives/generators/override.py
|
|
23
|
+
src/prives/generators/params.py
|
|
24
|
+
src/prives/generators/paths.py
|
|
25
|
+
src/prives/generators/user_agents.py
|
|
26
|
+
src/prives/tests/call_analyzer.py
|
|
27
|
+
src/prives/tests/get_payloads.py
|
|
28
|
+
src/prives/tests/server.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
prives
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import hashlib
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
from importlib.resources import files
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def load_sensitive_keys():
|
|
8
|
+
path = files("prives.db").joinpath("sensitive_keys.txt")
|
|
9
|
+
return {
|
|
10
|
+
key.strip()
|
|
11
|
+
for key in path.read_text(encoding="utf-8").splitlines()
|
|
12
|
+
if key.strip()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
SENSITIVE_KEYS = load_sensitive_keys()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_content_type(response):
|
|
20
|
+
return response.headers.get("Content-Type", "").lower()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def get_body(response):
|
|
24
|
+
return response.content or b""
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def get_hash(body):
|
|
28
|
+
return hashlib.sha256(body).hexdigest()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def parse_json(response):
|
|
32
|
+
try:
|
|
33
|
+
return True, response.json()
|
|
34
|
+
except ValueError:
|
|
35
|
+
return False, None
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def extract_sensitive_keys(data, path="$"):
|
|
39
|
+
found = {}
|
|
40
|
+
|
|
41
|
+
if isinstance(data, dict):
|
|
42
|
+
for key, value in data.items():
|
|
43
|
+
current_path = f"{path}.{key}"
|
|
44
|
+
|
|
45
|
+
if key in SENSITIVE_KEYS:
|
|
46
|
+
found[current_path] = value
|
|
47
|
+
|
|
48
|
+
found.update(extract_sensitive_keys(value, current_path))
|
|
49
|
+
|
|
50
|
+
elif isinstance(data, list):
|
|
51
|
+
for index, value in enumerate(data):
|
|
52
|
+
found.update(extract_sensitive_keys(value, f"{path}[{index}]"))
|
|
53
|
+
|
|
54
|
+
return found
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def analyze_sensitive_keys(baseline_data, response_data):
|
|
58
|
+
baseline_keys = extract_sensitive_keys(baseline_data)
|
|
59
|
+
response_keys = extract_sensitive_keys(response_data)
|
|
60
|
+
|
|
61
|
+
newly_exposed = {}
|
|
62
|
+
changed = {}
|
|
63
|
+
missing = {}
|
|
64
|
+
|
|
65
|
+
for path, value in response_keys.items():
|
|
66
|
+
if path not in baseline_keys:
|
|
67
|
+
newly_exposed[path] = True
|
|
68
|
+
elif baseline_keys[path] != value:
|
|
69
|
+
changed[path] = True
|
|
70
|
+
|
|
71
|
+
for path in baseline_keys:
|
|
72
|
+
if path not in response_keys:
|
|
73
|
+
missing[path] = True
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
"baseline_count": len(baseline_keys),
|
|
77
|
+
"response_count": len(response_keys),
|
|
78
|
+
"newly_exposed": newly_exposed,
|
|
79
|
+
"changed": changed,
|
|
80
|
+
"missing": missing,
|
|
81
|
+
"match": not (newly_exposed or changed or missing)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def analyze_response(baseline, response):
|
|
86
|
+
baseline_body = get_body(baseline)
|
|
87
|
+
response_body = get_body(response)
|
|
88
|
+
|
|
89
|
+
baseline_type = get_content_type(baseline)
|
|
90
|
+
response_type = get_content_type(response)
|
|
91
|
+
|
|
92
|
+
baseline_json, baseline_data = parse_json(baseline)
|
|
93
|
+
response_json, response_data = parse_json(response)
|
|
94
|
+
|
|
95
|
+
result = {
|
|
96
|
+
"status_code": {
|
|
97
|
+
"baseline": baseline.status_code,
|
|
98
|
+
"response": response.status_code,
|
|
99
|
+
"match": baseline.status_code == response.status_code
|
|
100
|
+
},
|
|
101
|
+
"content_length": {
|
|
102
|
+
"baseline": len(baseline_body),
|
|
103
|
+
"response": len(response_body),
|
|
104
|
+
"match": len(baseline_body) == len(response_body)
|
|
105
|
+
},
|
|
106
|
+
"content_type": {
|
|
107
|
+
"baseline": baseline_type,
|
|
108
|
+
"response": response_type,
|
|
109
|
+
"match": baseline_type == response_type
|
|
110
|
+
},
|
|
111
|
+
"body": {
|
|
112
|
+
"type": "json" if baseline_json and response_json else "text",
|
|
113
|
+
"match": None
|
|
114
|
+
},
|
|
115
|
+
"sensitive_keys": None
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if baseline_json and response_json:
|
|
119
|
+
result["body"]["match"] = baseline_data == response_data
|
|
120
|
+
result["sensitive_keys"] = analyze_sensitive_keys(
|
|
121
|
+
baseline_data,
|
|
122
|
+
response_data
|
|
123
|
+
)
|
|
124
|
+
else:
|
|
125
|
+
result["body"]["match"] = (
|
|
126
|
+
get_hash(baseline_body) == get_hash(response_body)
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
return result
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def export_json(findings):
|
|
5
|
+
return json.dumps(findings, indent=4, ensure_ascii=False)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def report(findings, output=None):
|
|
9
|
+
content = export_json(findings)
|
|
10
|
+
|
|
11
|
+
if output:
|
|
12
|
+
with open(output, "w", encoding="utf-8") as file:
|
|
13
|
+
file.write(content)
|
|
14
|
+
else:
|
|
15
|
+
print(content)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def send_request(task):
|
|
5
|
+
try:
|
|
6
|
+
return requests.request(
|
|
7
|
+
method=task["method"],
|
|
8
|
+
url=task["url"],
|
|
9
|
+
headers=task.get("headers"),
|
|
10
|
+
cookies=task.get("cookies"),
|
|
11
|
+
timeout=task.get("timeout", 10),
|
|
12
|
+
allow_redirects=False
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
except requests.RequestException as err:
|
|
16
|
+
print(f"[!] Request error: {err}")
|
|
17
|
+
return None
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
from urllib.parse import urlsplit
|
|
2
|
+
|
|
3
|
+
from prives.core.colors import colors
|
|
4
|
+
from prives.core.tasks import GENERATORS
|
|
5
|
+
from prives.core.requester import send_request
|
|
6
|
+
from prives.core.analyzer import analyze_response
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def print_stage(message):
|
|
10
|
+
print(f"{colors['yellow']}[+] {message}{colors['reset']}")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def print_finding(url, result):
|
|
14
|
+
print(f"{colors['red']}[!] Anomaly: {url}{colors['reset']}")
|
|
15
|
+
for key, value in result.items():
|
|
16
|
+
if isinstance(value, dict) and value.get("match") is False:
|
|
17
|
+
print(f" {key}: {value}")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def is_local_url(url):
|
|
21
|
+
hostname = (urlsplit(url).hostname or "").lower()
|
|
22
|
+
return hostname in {"localhost", "127.0.0.1", "::1"}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def start_scanner(base_request, tasks):
|
|
26
|
+
findings = []
|
|
27
|
+
|
|
28
|
+
print_stage("Sending baseline request")
|
|
29
|
+
baseline = send_request(base_request)
|
|
30
|
+
|
|
31
|
+
if baseline is None:
|
|
32
|
+
print_stage("Baseline request failed")
|
|
33
|
+
return findings
|
|
34
|
+
|
|
35
|
+
print(f"[+] Status: {baseline.status_code} | Length: {len(baseline.content)}")
|
|
36
|
+
|
|
37
|
+
grouped = {}
|
|
38
|
+
for task in tasks:
|
|
39
|
+
grouped.setdefault(task["techniques"], []).append(task)
|
|
40
|
+
|
|
41
|
+
for technique in GENERATORS:
|
|
42
|
+
technique_tasks = grouped.get(technique, [])
|
|
43
|
+
|
|
44
|
+
if not technique_tasks:
|
|
45
|
+
print_stage(f"Skipping {technique}")
|
|
46
|
+
continue
|
|
47
|
+
|
|
48
|
+
print_stage(f"Test {technique}")
|
|
49
|
+
|
|
50
|
+
for task in technique_tasks:
|
|
51
|
+
added_headers = {
|
|
52
|
+
key: value
|
|
53
|
+
for key, value in task.get("headers", {}).items()
|
|
54
|
+
if base_request["headers"].get(key) != value
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if added_headers:
|
|
58
|
+
payload = ", ".join(f"{key}: {value}" for key, value in added_headers.items())
|
|
59
|
+
label = f"{task['url']} > {payload}"
|
|
60
|
+
else:
|
|
61
|
+
label = task["url"]
|
|
62
|
+
|
|
63
|
+
response = send_request(task)
|
|
64
|
+
|
|
65
|
+
if response is None:
|
|
66
|
+
print(label)
|
|
67
|
+
continue
|
|
68
|
+
|
|
69
|
+
result = analyze_response(baseline, response)
|
|
70
|
+
|
|
71
|
+
finding = {
|
|
72
|
+
"technique": technique,
|
|
73
|
+
"url": task["url"],
|
|
74
|
+
"headers": task.get("headers", {}),
|
|
75
|
+
"status_code": response.status_code,
|
|
76
|
+
"analysis": result
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
findings.append(finding)
|
|
80
|
+
|
|
81
|
+
anomalous = any(
|
|
82
|
+
isinstance(value, dict) and value.get("match") is False
|
|
83
|
+
for value in result.values()
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
if anomalous:
|
|
87
|
+
print(f"\n{colors['red']}[!] {label} - Anomaly Detection{colors['reset']}")
|
|
88
|
+
|
|
89
|
+
for key, value in result.items():
|
|
90
|
+
if isinstance(value, dict) and value.get("match") is False:
|
|
91
|
+
print(f" {key}: {value}")
|
|
92
|
+
|
|
93
|
+
print()
|
|
94
|
+
else:
|
|
95
|
+
print(label)
|
|
96
|
+
|
|
97
|
+
return findings
|