GainAccess 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.
- gainaccess-0.1.0/LICENSE +21 -0
- gainaccess-0.1.0/PKG-INFO +96 -0
- gainaccess-0.1.0/README.md +83 -0
- gainaccess-0.1.0/pyproject.toml +31 -0
- gainaccess-0.1.0/setup.cfg +4 -0
- gainaccess-0.1.0/src/GainAccess/__init__.py +7 -0
- gainaccess-0.1.0/src/GainAccess/core/analyzer.py +121 -0
- gainaccess-0.1.0/src/GainAccess/core/colors.py +7 -0
- gainaccess-0.1.0/src/GainAccess/core/planner.py +73 -0
- gainaccess-0.1.0/src/GainAccess/core/reporter.py +9 -0
- gainaccess-0.1.0/src/GainAccess/core/requester.py +35 -0
- gainaccess-0.1.0/src/GainAccess/core/scanner.py +159 -0
- gainaccess-0.1.0/src/GainAccess/core/tasks.py +47 -0
- gainaccess-0.1.0/src/GainAccess/core/utils.py +73 -0
- gainaccess-0.1.0/src/GainAccess/db/payloads/api.yaml +17 -0
- gainaccess-0.1.0/src/GainAccess/db/payloads/forwarded_header.yaml +23 -0
- gainaccess-0.1.0/src/GainAccess/db/payloads/params.yaml +86 -0
- gainaccess-0.1.0/src/GainAccess/db/payloads/path_manipulation.yaml +45 -0
- gainaccess-0.1.0/src/GainAccess/db/payloads/url_override.yaml +14 -0
- gainaccess-0.1.0/src/GainAccess/main.py +101 -0
- gainaccess-0.1.0/src/GainAccess/techniques/api_testing.py +40 -0
- gainaccess-0.1.0/src/GainAccess/techniques/header_manipulation.py +54 -0
- gainaccess-0.1.0/src/GainAccess/techniques/method_fuzzing.py +15 -0
- gainaccess-0.1.0/src/GainAccess/techniques/param_testing.py +45 -0
- gainaccess-0.1.0/src/GainAccess/techniques/path_manipulation.py +28 -0
- gainaccess-0.1.0/src/GainAccess.egg-info/PKG-INFO +96 -0
- gainaccess-0.1.0/src/GainAccess.egg-info/SOURCES.txt +29 -0
- gainaccess-0.1.0/src/GainAccess.egg-info/dependency_links.txt +1 -0
- gainaccess-0.1.0/src/GainAccess.egg-info/entry_points.txt +2 -0
- gainaccess-0.1.0/src/GainAccess.egg-info/requires.txt +2 -0
- gainaccess-0.1.0/src/GainAccess.egg-info/top_level.txt +1 -0
gainaccess-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
SOFTWARE.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: GainAccess
|
|
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
|
+
Requires-Dist: PyYAML
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# GainAccess
|
|
15
|
+
|
|
16
|
+
> ⚠️ **Warning:** This tool is currently not functional. The repository is public, but the tool is not ready for use.
|
|
17
|
+
>
|
|
18
|
+
> GainAccess is an open-source project currently under development.
|
|
19
|
+
|
|
20
|
+
GainAccess is an open-source security testing tool for identifying access control vulnerabilities in web applications. It tests HTTP 403 bypass techniques, authorization weaknesses, and resource access through request and identifier manipulation.
|
|
21
|
+
|
|
22
|
+
## Key Techniques
|
|
23
|
+
|
|
24
|
+
GainAccess focuses on testing access control vulnerabilities, including:
|
|
25
|
+
|
|
26
|
+
- **403 Bypass:** Test alternative HTTP methods, header manipulation, path variations, and other request modification techniques to evaluate whether access restrictions can be bypassed.
|
|
27
|
+
- **IDOR (Insecure Direct Object Reference):** Identify insecure direct object references that may allow unauthorized access to other users' resources.
|
|
28
|
+
- **Authorization Bypass:** Identify weaknesses in authorization enforcement that may allow users to access resources or perform actions beyond their assigned permissions.
|
|
29
|
+
|
|
30
|
+
More techniques may be added in future releases.
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
### Using pipx
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Install
|
|
38
|
+
pipx install GainAccess
|
|
39
|
+
|
|
40
|
+
# Upgrade
|
|
41
|
+
pipx upgrade GainAccess
|
|
42
|
+
|
|
43
|
+
# Uninstall
|
|
44
|
+
pipx uninstall GainAccess
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Using pip
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Install
|
|
51
|
+
pip install GainAccess
|
|
52
|
+
|
|
53
|
+
# Upgrade
|
|
54
|
+
pip install --upgrade GainAccess
|
|
55
|
+
|
|
56
|
+
# Uninstall
|
|
57
|
+
pip uninstall GainAccess
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Docker
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Build
|
|
64
|
+
docker build -t gainaccess .
|
|
65
|
+
|
|
66
|
+
# Run
|
|
67
|
+
docker run --rm gainaccess --help
|
|
68
|
+
|
|
69
|
+
# Run a scan
|
|
70
|
+
docker run --rm gainaccess -u "https://target.com"
|
|
71
|
+
|
|
72
|
+
# Remove image
|
|
73
|
+
docker rmi gainaccess
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
> **Note:** Using `pipx` is recommended because it automatically manages an isolated virtual environment for GainAccess, avoiding dependency conflicts with other Python packages.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
## Legal Disclaimer
|
|
81
|
+
|
|
82
|
+
GainAccess is developed strictly for educational purposes and authorized security testing.
|
|
83
|
+
|
|
84
|
+
Users are responsible for ensuring that they have explicit permission to test any target systems or applications.
|
|
85
|
+
|
|
86
|
+
The author is not responsible for any misuse, damage, data loss, or legal consequences resulting from the use of this tool.
|
|
87
|
+
|
|
88
|
+
**Do not use GainAccess against systems you do not own or have explicit authorization to test.**
|
|
89
|
+
|
|
90
|
+
By using this tool, you agree to take full responsibility for your actions and comply with all applicable laws and regulations.
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
95
|
+
|
|
96
|
+
You are free to use, modify, and distribute this software in accordance with the terms of the license.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# GainAccess
|
|
2
|
+
|
|
3
|
+
> ⚠️ **Warning:** This tool is currently not functional. The repository is public, but the tool is not ready for use.
|
|
4
|
+
>
|
|
5
|
+
> GainAccess is an open-source project currently under development.
|
|
6
|
+
|
|
7
|
+
GainAccess is an open-source security testing tool for identifying access control vulnerabilities in web applications. It tests HTTP 403 bypass techniques, authorization weaknesses, and resource access through request and identifier manipulation.
|
|
8
|
+
|
|
9
|
+
## Key Techniques
|
|
10
|
+
|
|
11
|
+
GainAccess focuses on testing access control vulnerabilities, including:
|
|
12
|
+
|
|
13
|
+
- **403 Bypass:** Test alternative HTTP methods, header manipulation, path variations, and other request modification techniques to evaluate whether access restrictions can be bypassed.
|
|
14
|
+
- **IDOR (Insecure Direct Object Reference):** Identify insecure direct object references that may allow unauthorized access to other users' resources.
|
|
15
|
+
- **Authorization Bypass:** Identify weaknesses in authorization enforcement that may allow users to access resources or perform actions beyond their assigned permissions.
|
|
16
|
+
|
|
17
|
+
More techniques may be added in future releases.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
### Using pipx
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Install
|
|
25
|
+
pipx install GainAccess
|
|
26
|
+
|
|
27
|
+
# Upgrade
|
|
28
|
+
pipx upgrade GainAccess
|
|
29
|
+
|
|
30
|
+
# Uninstall
|
|
31
|
+
pipx uninstall GainAccess
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Using pip
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Install
|
|
38
|
+
pip install GainAccess
|
|
39
|
+
|
|
40
|
+
# Upgrade
|
|
41
|
+
pip install --upgrade GainAccess
|
|
42
|
+
|
|
43
|
+
# Uninstall
|
|
44
|
+
pip uninstall GainAccess
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Docker
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Build
|
|
51
|
+
docker build -t gainaccess .
|
|
52
|
+
|
|
53
|
+
# Run
|
|
54
|
+
docker run --rm gainaccess --help
|
|
55
|
+
|
|
56
|
+
# Run a scan
|
|
57
|
+
docker run --rm gainaccess -u "https://target.com"
|
|
58
|
+
|
|
59
|
+
# Remove image
|
|
60
|
+
docker rmi gainaccess
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
> **Note:** Using `pipx` is recommended because it automatically manages an isolated virtual environment for GainAccess, avoiding dependency conflicts with other Python packages.
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
## Legal Disclaimer
|
|
68
|
+
|
|
69
|
+
GainAccess is developed strictly for educational purposes and authorized security testing.
|
|
70
|
+
|
|
71
|
+
Users are responsible for ensuring that they have explicit permission to test any target systems or applications.
|
|
72
|
+
|
|
73
|
+
The author is not responsible for any misuse, damage, data loss, or legal consequences resulting from the use of this tool.
|
|
74
|
+
|
|
75
|
+
**Do not use GainAccess against systems you do not own or have explicit authorization to test.**
|
|
76
|
+
|
|
77
|
+
By using this tool, you agree to take full responsibility for your actions and comply with all applicable laws and regulations.
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
82
|
+
|
|
83
|
+
You are free to use, modify, and distribute this software in accordance with the terms of the license.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "GainAccess"
|
|
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
|
+
"PyYAML"
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
gainaccess = "GainAccess.main:main"
|
|
22
|
+
|
|
23
|
+
[tool.setuptools]
|
|
24
|
+
package-dir = {"" = "src"}
|
|
25
|
+
|
|
26
|
+
[tool.setuptools.packages.find]
|
|
27
|
+
where = ["src"]
|
|
28
|
+
include = ["GainAccess*"]
|
|
29
|
+
|
|
30
|
+
[tool.setuptools.package-data]
|
|
31
|
+
GainAccess = ["db/payloads/*.yaml", "db/payloads/**/*.yaml"]
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import hashlib
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
SENSITIVE_KEYS_FILE = Path(__file__).resolve().parent.parent / "db" / "sensitive_keys.txt"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def load_sensitive_keys():
|
|
10
|
+
with open(SENSITIVE_KEYS_FILE, "r", encoding="utf-8") as file:
|
|
11
|
+
return {line.strip().lower() for line in file if line.strip()}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def get_response_info(response):
|
|
15
|
+
body = response.content
|
|
16
|
+
content_type = response.headers.get("Content-Type", "").lower()
|
|
17
|
+
|
|
18
|
+
info = {
|
|
19
|
+
"status_code": response.status_code,
|
|
20
|
+
"content_length": len(body),
|
|
21
|
+
"body": response.text,
|
|
22
|
+
"hash": None,
|
|
23
|
+
"json": None,
|
|
24
|
+
"is_json": False,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try:
|
|
28
|
+
if "json" in content_type:
|
|
29
|
+
info["json"] = response.json()
|
|
30
|
+
info["is_json"] = True
|
|
31
|
+
else:
|
|
32
|
+
info["hash"] = hashlib.sha256(body).hexdigest()
|
|
33
|
+
|
|
34
|
+
except (ValueError, json.JSONDecodeError):
|
|
35
|
+
info["hash"] = hashlib.sha256(body).hexdigest()
|
|
36
|
+
|
|
37
|
+
return info
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def extract_sensitive_fields(data, sensitive_keys, result=None):
|
|
41
|
+
if result is None:
|
|
42
|
+
result = {}
|
|
43
|
+
|
|
44
|
+
if isinstance(data, dict):
|
|
45
|
+
for key, value in data.items():
|
|
46
|
+
if key.lower() in sensitive_keys:
|
|
47
|
+
result.setdefault(key.lower(), []).append(value)
|
|
48
|
+
|
|
49
|
+
extract_sensitive_fields(value, sensitive_keys, result)
|
|
50
|
+
|
|
51
|
+
elif isinstance(data, list):
|
|
52
|
+
for item in data:
|
|
53
|
+
extract_sensitive_fields(item, sensitive_keys, result)
|
|
54
|
+
|
|
55
|
+
return result
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def analyze_response(context, task, response):
|
|
59
|
+
baseline = context["baseline"]
|
|
60
|
+
baseline_param = context["baseline_param"]
|
|
61
|
+
|
|
62
|
+
reference = baseline_param if task["technique"] == "Param Testing" else baseline
|
|
63
|
+
|
|
64
|
+
baseline_info = get_response_info(reference)
|
|
65
|
+
response_info = get_response_info(response)
|
|
66
|
+
|
|
67
|
+
findings = []
|
|
68
|
+
|
|
69
|
+
# Status code comparison
|
|
70
|
+
if baseline_info["status_code"] != response_info["status_code"]:
|
|
71
|
+
findings.append({
|
|
72
|
+
"type": "status_code_changed",
|
|
73
|
+
"baseline": baseline_info["status_code"],
|
|
74
|
+
"response": response_info["status_code"],
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
# JSON comparison
|
|
78
|
+
if baseline_info["is_json"] and response_info["is_json"]:
|
|
79
|
+
sensitive_keys = load_sensitive_keys()
|
|
80
|
+
|
|
81
|
+
baseline_fields = extract_sensitive_fields(
|
|
82
|
+
baseline_info["json"], sensitive_keys
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
response_fields = extract_sensitive_fields(
|
|
86
|
+
response_info["json"], sensitive_keys
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
for key, values in response_fields.items():
|
|
90
|
+
if key not in baseline_fields:
|
|
91
|
+
findings.append({
|
|
92
|
+
"type": "sensitive_field_added",
|
|
93
|
+
"key": key,
|
|
94
|
+
"value": values,
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
elif baseline_fields[key] != values:
|
|
98
|
+
findings.append({
|
|
99
|
+
"type": "sensitive_field_changed",
|
|
100
|
+
"key": key,
|
|
101
|
+
"baseline": baseline_fields[key],
|
|
102
|
+
"response": values,
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
# Non-JSON comparison
|
|
106
|
+
elif not baseline_info["is_json"] and not response_info["is_json"]:
|
|
107
|
+
if baseline_info["hash"] != response_info["hash"]:
|
|
108
|
+
findings.append({
|
|
109
|
+
"type": "body_changed",
|
|
110
|
+
"baseline_hash": baseline_info["hash"],
|
|
111
|
+
"response_hash": response_info["hash"],
|
|
112
|
+
"baseline_length": baseline_info["content_length"],
|
|
113
|
+
"response_length": response_info["content_length"],
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
"technique": task["technique"],
|
|
118
|
+
"baseline": baseline_info,
|
|
119
|
+
"response": response_info,
|
|
120
|
+
"findings": findings,
|
|
121
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from urllib.parse import urlparse, urlunparse, urlencode
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
from GainAccess.core.utils import resolve_request, url_probe, normalize_path
|
|
6
|
+
from GainAccess.techniques.path_manipulation import build_paths
|
|
7
|
+
from GainAccess.techniques.param_testing import build_params
|
|
8
|
+
from GainAccess.techniques.method_fuzzing import build_methods
|
|
9
|
+
from GainAccess.techniques.header_manipulation import build_overrides, build_forwarded
|
|
10
|
+
from GainAccess.techniques.api_testing import build_apis
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def create_tasks(payload_data):
|
|
14
|
+
tasks = []
|
|
15
|
+
|
|
16
|
+
for task in payload_data:
|
|
17
|
+
request, target_id = resolve_request(task["request"])
|
|
18
|
+
|
|
19
|
+
url = request["url"]
|
|
20
|
+
payload = request.get("payload")
|
|
21
|
+
technique = task["technique"]
|
|
22
|
+
|
|
23
|
+
if technique == "Path Manipulation":
|
|
24
|
+
if target_id and payload:
|
|
25
|
+
match = re.search(r"/" + re.escape(target_id) + r"(?=/|$)", url)
|
|
26
|
+
|
|
27
|
+
if match:
|
|
28
|
+
tail = url[match.end():]
|
|
29
|
+
if tail == "/":
|
|
30
|
+
tail = ""
|
|
31
|
+
url = url[:match.start()] + payload + tail
|
|
32
|
+
|
|
33
|
+
elif technique == "URL Override":
|
|
34
|
+
parsed = urlparse(url)
|
|
35
|
+
url = f"{parsed.scheme}://{parsed.netloc}/"
|
|
36
|
+
|
|
37
|
+
elif technique == "API Testing":
|
|
38
|
+
pattern = r"/api(?=/|$)"
|
|
39
|
+
match = re.search(pattern, url, re.IGNORECASE)
|
|
40
|
+
|
|
41
|
+
if match:
|
|
42
|
+
version = payload.strip("/")
|
|
43
|
+
insert_pos = match.end()
|
|
44
|
+
url = url[:insert_pos] + f"/{version}" + url[insert_pos:]
|
|
45
|
+
|
|
46
|
+
elif technique == "Param Testing":
|
|
47
|
+
if isinstance(payload, dict):
|
|
48
|
+
query = urlencode(payload)
|
|
49
|
+
separator = "&" if "?" in url else "?"
|
|
50
|
+
url = f"{url}{separator}{query}"
|
|
51
|
+
|
|
52
|
+
request["url"] = url
|
|
53
|
+
request["payload"] = payload
|
|
54
|
+
task["request"] = request
|
|
55
|
+
|
|
56
|
+
tasks.append(task)
|
|
57
|
+
|
|
58
|
+
return tasks
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def create_plan(base_request):
|
|
62
|
+
task_groups = [
|
|
63
|
+
build_forwarded(base_request),
|
|
64
|
+
build_overrides(base_request),
|
|
65
|
+
build_params(base_request),
|
|
66
|
+
build_methods(base_request),
|
|
67
|
+
build_paths(base_request),
|
|
68
|
+
build_apis(base_request),
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
payload_data = [task for group in task_groups for task in group]
|
|
72
|
+
|
|
73
|
+
return create_tasks(payload_data)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import requests
|
|
3
|
+
|
|
4
|
+
from GainAccess.core.colors import colors
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def send_request(request, config):
|
|
8
|
+
try:
|
|
9
|
+
delay = float(config.get("delay", 0))
|
|
10
|
+
if delay > 0:
|
|
11
|
+
time.sleep(delay)
|
|
12
|
+
|
|
13
|
+
return requests.request(
|
|
14
|
+
method=request["method"],
|
|
15
|
+
url=request["url"],
|
|
16
|
+
headers=request.get("headers"),
|
|
17
|
+
cookies=request.get("cookies"),
|
|
18
|
+
params=request.get("params"),
|
|
19
|
+
data=request.get("data"),
|
|
20
|
+
json=request.get("json"),
|
|
21
|
+
timeout=config.get("timeout", 10),
|
|
22
|
+
allow_redirects=config.get("allow_redirects", True),
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
except requests.RequestException as error:
|
|
26
|
+
print(f"{colors['red']}[ERROR] {error}{colors['reset']}")
|
|
27
|
+
return None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def executor(request, config):
|
|
31
|
+
return send_request(request, config)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def call_requester(data):
|
|
35
|
+
return executor(data["request"], data["config"])
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# import concurrent.futures
|
|
2
|
+
from urllib.parse import urlencode
|
|
3
|
+
|
|
4
|
+
from GainAccess.core.requester import call_requester
|
|
5
|
+
from GainAccess.core.colors import colors
|
|
6
|
+
from GainAccess.core.planner import create_plan
|
|
7
|
+
from GainAccess.core.utils import url_probe
|
|
8
|
+
from GainAccess.core.analyzer import analyze_response
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def send_baseline(context):
|
|
12
|
+
base_request = context["base_request"]
|
|
13
|
+
|
|
14
|
+
baseline_request = {
|
|
15
|
+
"url": base_request["url"],
|
|
16
|
+
"method": base_request["method"],
|
|
17
|
+
"headers": base_request["headers"],
|
|
18
|
+
"cookies": base_request["cookies"],
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
baseline_param_request = baseline_request.copy()
|
|
22
|
+
separator = "&" if "?" in baseline_param_request["url"] else "?"
|
|
23
|
+
baseline_param_request["url"] += separator + urlencode({
|
|
24
|
+
"random_abcdefg": "random_abcdef"
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
baseline_response = call_requester({
|
|
28
|
+
"request": baseline_request,
|
|
29
|
+
"config": context["config"],
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
baseline_param_response = call_requester({
|
|
33
|
+
"request": baseline_param_request,
|
|
34
|
+
"config": context["config"],
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
"baseline": baseline_response,
|
|
39
|
+
"baseline_param": baseline_param_response,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def print_baseline_status(label, response):
|
|
44
|
+
if response is not None:
|
|
45
|
+
print(f"{colors['blue']}[+] {label} (Status Code: {response.status_code}){colors['reset']}")
|
|
46
|
+
else:
|
|
47
|
+
print(f"{colors['yellow']}[!] {label} failed{colors['reset']}")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def print_verbose_payload(task):
|
|
51
|
+
technique = task["technique"]
|
|
52
|
+
request = task["request"]
|
|
53
|
+
payload = task.get("payload")
|
|
54
|
+
|
|
55
|
+
if technique in {"Forwarded Headers", "URL Override"}:
|
|
56
|
+
if isinstance(payload, dict):
|
|
57
|
+
for key in payload:
|
|
58
|
+
value = request.get("headers", {}).get(key)
|
|
59
|
+
if value is not None:
|
|
60
|
+
print(f"{key}: {value}")
|
|
61
|
+
|
|
62
|
+
elif technique in {"Param Testing", "Path Manipulation", "API Testing"}:
|
|
63
|
+
print(request["url"])
|
|
64
|
+
|
|
65
|
+
elif technique in {"HTTP Method", "Method Fuzzing"}:
|
|
66
|
+
print(request["method"])
|
|
67
|
+
|
|
68
|
+
elif payload is not None:
|
|
69
|
+
print(payload)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def print_finding(task, analysis):
|
|
73
|
+
findings = analysis.get("findings")
|
|
74
|
+
|
|
75
|
+
if not findings:
|
|
76
|
+
return
|
|
77
|
+
|
|
78
|
+
request = task["request"]
|
|
79
|
+
url = request["url"]
|
|
80
|
+
|
|
81
|
+
print(f"{colors['red']}[!] {url}{colors['reset']}")
|
|
82
|
+
|
|
83
|
+
if task["technique"] == "Method Fuzzing":
|
|
84
|
+
print(f"{colors['red']}Method: {request['method']}{colors['reset']}")
|
|
85
|
+
|
|
86
|
+
if task["technique"] in {"URL Override", "Forwarded Headers"}:
|
|
87
|
+
payload = task.get("payload", {})
|
|
88
|
+
for key in payload:
|
|
89
|
+
value = request.get("headers", {}).get(key)
|
|
90
|
+
if value is not None:
|
|
91
|
+
print(f"{colors['red']}{key}: {value}{colors['reset']}")
|
|
92
|
+
|
|
93
|
+
status_code = analysis.get("response", {}).get("status_code")
|
|
94
|
+
|
|
95
|
+
if status_code is not None:
|
|
96
|
+
print(f"{colors['red']}Status code: {status_code}{colors['reset']}")
|
|
97
|
+
|
|
98
|
+
if isinstance(findings, dict):
|
|
99
|
+
for key, value in findings.items():
|
|
100
|
+
if value:
|
|
101
|
+
print(f"{colors['red']}{key}: {value}{colors['reset']}")
|
|
102
|
+
elif isinstance(findings, list):
|
|
103
|
+
for finding in findings:
|
|
104
|
+
print(f"{colors['red']}{finding}{colors['reset']}")
|
|
105
|
+
else:
|
|
106
|
+
print(f"{colors['red']}{findings}{colors['reset']}")
|
|
107
|
+
|
|
108
|
+
print()
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def start_scan(context, is_verbosed):
|
|
112
|
+
base_request = context["base_request"]
|
|
113
|
+
|
|
114
|
+
print(f"{colors['blue']}[+] Scan: {url_probe(base_request['url'])}{colors['reset']}")
|
|
115
|
+
|
|
116
|
+
tasks = create_plan(base_request)
|
|
117
|
+
total_requests = len(tasks) + 2
|
|
118
|
+
|
|
119
|
+
print(f"{colors['blue']}[+] Total requests: {total_requests}{colors['reset']}")
|
|
120
|
+
|
|
121
|
+
# Baseline
|
|
122
|
+
baseline_responses = send_baseline(context)
|
|
123
|
+
|
|
124
|
+
context["baseline"] = baseline_responses["baseline"]
|
|
125
|
+
context["baseline_param"] = baseline_responses["baseline_param"]
|
|
126
|
+
|
|
127
|
+
print_baseline_status("Baseline request sent", context["baseline"])
|
|
128
|
+
print_baseline_status("Parameter baseline sent", context["baseline_param"])
|
|
129
|
+
|
|
130
|
+
if context["baseline"] is None:
|
|
131
|
+
print(f"{colors['red']}[!] Baseline request failed. Aborting scan.{colors['reset']}")
|
|
132
|
+
return
|
|
133
|
+
|
|
134
|
+
# Fuzzing
|
|
135
|
+
current_technique = None
|
|
136
|
+
|
|
137
|
+
for task in tasks:
|
|
138
|
+
technique = task["technique"]
|
|
139
|
+
request = task["request"]
|
|
140
|
+
|
|
141
|
+
if technique != current_technique:
|
|
142
|
+
current_technique = technique
|
|
143
|
+
print(f"\n{colors['blue']}[+] Testing {technique}...{colors['reset']}")
|
|
144
|
+
|
|
145
|
+
if is_verbosed:
|
|
146
|
+
print_verbose_payload(task)
|
|
147
|
+
|
|
148
|
+
response = call_requester({
|
|
149
|
+
"request": request,
|
|
150
|
+
"config": context["config"],
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
if response is None:
|
|
154
|
+
continue
|
|
155
|
+
|
|
156
|
+
analysis = analyze_response(context, task, response)
|
|
157
|
+
|
|
158
|
+
if analysis.get("findings"):
|
|
159
|
+
print_finding(task, analysis)
|