GainAccess 0.1.0__py3-none-any.whl

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/__init__.py ADDED
@@ -0,0 +1,7 @@
1
+ from importlib.metadata import version
2
+
3
+
4
+ try:
5
+ __version__ = version("GainAccess")
6
+ except PackageNotFoundError:
7
+ __version__ = "0.0.0 - ERROR"
@@ -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,7 @@
1
+ colors = {
2
+ "red": "\033[91m",
3
+ "green": "\033[92m",
4
+ "yellow": "\033[93m",
5
+ "blue": "\033[94m",
6
+ "reset": "\033[0m"
7
+ }
@@ -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,9 @@
1
+ import json
2
+
3
+
4
+ def export_txt():
5
+ pass
6
+
7
+
8
+ def export_json():
9
+ pass
@@ -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)
@@ -0,0 +1,47 @@
1
+ """
2
+ tasks.py
3
+
4
+ Builds the scan context and individual test tasks.
5
+
6
+ - `build_context()`: Creates the shared context for a scan.
7
+ - `clone_request()`: Creates a copy of a request with optional overrides.
8
+ - `build_task()`: Packages a request with its technique and label.
9
+
10
+ Uses plain dictionaries without additional parsing or validation.
11
+
12
+ Used by `scanner.py` and modules in `techniques/`.
13
+ """
14
+
15
+
16
+ def build_context(args):
17
+ """Build the scan context from preprocessed CLI arguments."""
18
+ return {
19
+ "base_request": {
20
+ "url": args["url"],
21
+ "method": args["method"],
22
+ "headers": args["headers"],
23
+ "cookies": args["cookies"],
24
+ },
25
+ "config": {
26
+ "threads": args["threads"],
27
+ "delay": args["delay"],
28
+ "timeout": args["timeout"],
29
+ },
30
+ }
31
+
32
+
33
+ def clone_request(base_request, **overrides):
34
+ """Create a copy of the base request with the specified overrides."""
35
+ new_request = dict(base_request)
36
+ for key, value in overrides.items():
37
+ new_request[key] = value
38
+ return new_request
39
+
40
+
41
+ def build_task(technique, payload, request):
42
+ """Package a request with its technique and description."""
43
+ return {
44
+ "technique": technique,
45
+ "payload": payload,
46
+ "request": request,
47
+ }
@@ -0,0 +1,73 @@
1
+ import re
2
+ from urllib.parse import urlparse, urlunparse
3
+
4
+
5
+ def parse_id(value):
6
+ if not isinstance(value, str):
7
+ return None
8
+
9
+ match = re.search(r"\{GAINACCESS-([^}]*)\}", value)
10
+ return match.group(1) if match else None
11
+
12
+
13
+ def parse_payload(payload, target_id):
14
+ if not target_id:
15
+ return payload
16
+
17
+ if isinstance(payload, str):
18
+ payload = re.sub(r"\{GAINACCESS-[^}]*\}", target_id, payload)
19
+ return payload.replace("{GAINACCESS-ID}", target_id)
20
+
21
+ if isinstance(payload, dict):
22
+ return {key: parse_payload(value, target_id) for key, value in payload.items()}
23
+
24
+ if isinstance(payload, list):
25
+ return [parse_payload(value, target_id) for value in payload]
26
+
27
+ return payload
28
+
29
+
30
+ def url_probe(base_url):
31
+ if base_url.endswith("/"):
32
+ base_url = base_url.rstrip("/")
33
+
34
+ if not base_url.startswith(("http://", "https://")):
35
+ raise ValueError("GainAccess only supports 'http' and 'https' schemes")
36
+
37
+ return re.sub(r"\{GAINACCESS-", "", base_url).replace("}", "")
38
+
39
+
40
+ def resolve_request(request):
41
+ target_id = None
42
+
43
+ def find_id(value):
44
+ nonlocal target_id
45
+
46
+ if target_id:
47
+ return
48
+
49
+ if isinstance(value, str):
50
+ target_id = parse_id(value)
51
+
52
+ elif isinstance(value, dict):
53
+ for item in value.values():
54
+ find_id(item)
55
+
56
+ elif isinstance(value, list):
57
+ for item in value:
58
+ find_id(item)
59
+
60
+ find_id(request)
61
+
62
+ if target_id:
63
+ request = parse_payload(request, target_id)
64
+
65
+ return request, target_id
66
+
67
+
68
+ def normalize_path(url):
69
+ """Collapse consecutive '/' characters and remove trailing '/' characters from the URL path."""
70
+ parsed = urlparse(url)
71
+ path = re.sub(r"/{2,}", "/", parsed.path)
72
+ path = path.rstrip("/")
73
+ return urlunparse((parsed.scheme, parsed.netloc, path, parsed.params, parsed.query, parsed.fragment))
@@ -0,0 +1,17 @@
1
+ name: "API Version Manipulation"
2
+ description: >
3
+ Tests alternative API version identifiers and versioning patterns to identify
4
+ potential access-control inconsistencies across API versions.
5
+
6
+ payloads:
7
+ versions:
8
+ - "v0"
9
+ - "v1"
10
+ - "v2"
11
+ - "v3"
12
+ - "v1.0"
13
+ - "v1.1"
14
+ - "v1.2"
15
+ - "v2.0"
16
+ - "beta"
17
+ - "preview"
@@ -0,0 +1,23 @@
1
+ name: "Forwarded Header"
2
+ description: >
3
+ Tests forwarded HTTP headers that may influence client IP identification,
4
+ host resolution, or request routing to identify potential access-control
5
+ weaknesses and unintended access.
6
+
7
+ payloads:
8
+ keys:
9
+ - "X-Forwarded-For"
10
+ - "X-Forwarded"
11
+ - "X-Real-IP"
12
+ - "X-Client-IP"
13
+ - "X-Original-Forwarded-For"
14
+ - "Forwarded"
15
+
16
+ values:
17
+ - "127.0.0.1"
18
+ - "127.0.0.2"
19
+ - "localhost"
20
+ - "10.0.0.1"
21
+ - "192.168.1.1"
22
+ - "172.16.0.1"
23
+ - "172.17.0.1"
@@ -0,0 +1,86 @@
1
+ name: "Parameter Testing"
2
+ description: >
3
+ Tests common parameter names and values to identify potential weaknesses
4
+ in parameter-based access control.
5
+
6
+ payloads:
7
+ keys:
8
+ boolean:
9
+ - "admin"
10
+ - "is_admin"
11
+ - "verified"
12
+ - "is_verified"
13
+ - "active"
14
+ - "is_active"
15
+
16
+ id:
17
+ - "id"
18
+ - "uid"
19
+ - "user_id"
20
+ - "account_id"
21
+ - "profile_id"
22
+
23
+ role:
24
+ - "role"
25
+ - "user_role"
26
+ - "permission"
27
+ - "group"
28
+
29
+ baseline:
30
+ - "random_abcdefg"
31
+
32
+ # Maybe this will be added in a future update
33
+ # redirect:
34
+ # - "url"
35
+ # - "redirect"
36
+ # - "next"
37
+
38
+ values:
39
+ boolean:
40
+ - "true"
41
+ - "false"
42
+ - "1"
43
+ - "0"
44
+ - "yes"
45
+ - "no"
46
+
47
+ id:
48
+ - "1"
49
+ - "0"
50
+ - "01"
51
+ - "123"
52
+ - "12345678"
53
+ - "1234567890"
54
+ - "12345678-1234-1234-1234-123456789012"
55
+
56
+ role:
57
+ - "admin"
58
+ - "administrator"
59
+ - "superadmin"
60
+ - "user"
61
+ - "mod"
62
+ - "moderator"
63
+ - "manager"
64
+ - "superuser"
65
+
66
+ baseline:
67
+ - "random_abcdef"
68
+
69
+ # Maybe this will be added in a future update
70
+ # techniques:
71
+ # param_testing:
72
+ # - "boolean"
73
+ # - "id"
74
+ # - "role"
75
+
76
+ # mass_assignment:
77
+ # - "boolean"
78
+ # - "role"
79
+
80
+ # idor:
81
+ # - "id"
82
+
83
+ # authorization_testing:
84
+ # - "boolean"
85
+ # - "id"
86
+ # - "role"
@@ -0,0 +1,45 @@
1
+ name: "Path Manipulation"
2
+ description: >
3
+ Tests alternative URL path representations and path normalization behaviors
4
+ to identify potential access-control weaknesses or unintended access to
5
+ restricted resources.
6
+
7
+ payloads:
8
+ slash-and-dot-tricks:
9
+ - "/{id}/"
10
+ - "//{id}//"
11
+ - "/./{id}"
12
+ - "///{id}"
13
+ - "/{id}/."
14
+ - "/../{id}"
15
+ - "/anything/../{id}"
16
+ - "/{id}/..;/"
17
+
18
+ path-params:
19
+ - "/{id};"
20
+ - "/{id}/;"
21
+ - "/{id};foo=bar"
22
+ - "/..;/{id}"
23
+ - "/;/{id}"
24
+
25
+ encoding-and-special-chars:
26
+ # 'encoded_id' is a fully encoded id or a partially encoded id
27
+ # 2 attempts
28
+ - "/%2e/{id}"
29
+ - "/{id}%20"
30
+ - "/{id}%09"
31
+ - "/{id}%00anything"
32
+ - "/{id}?"
33
+ - "/{id}??"
34
+ - "/{id}#"
35
+ - "/{id}~"
36
+ - "/{id}.txt"
37
+ - "/{id}.php"
38
+ - "/{id}.html"
39
+
40
+ backslash:
41
+ - "/{id}\\"
42
+ - "/{id}%5c"
43
+ - "/..\\{id}"
44
+ - "/..%5c{id}"
45
+ - "/anything/..%5c{id}"
@@ -0,0 +1,14 @@
1
+ name: "URL Override"
2
+ description: >
3
+ Tests HTTP headers that may influence URL routing or path resolution to
4
+ identify potential access-control weaknesses and unintended access to
5
+ restricted endpoints.
6
+
7
+ payloads:
8
+ keys:
9
+ - "X-Original-URL"
10
+ - "X-Rewrite-URL"
11
+ - "X-Original-URI"
12
+ - "X-Rewrite-URI"
13
+ - "X-Forwarded-Uri"
14
+ - "X-Forwarded-Path"
GainAccess/main.py ADDED
@@ -0,0 +1,101 @@
1
+ import argparse
2
+ import sys
3
+
4
+ from GainAccess.core.colors import colors
5
+ from GainAccess.core.tasks import build_task
6
+ from GainAccess import __version__
7
+ from GainAccess.core.scanner import start_scan
8
+
9
+
10
+ def banner():
11
+ return fr"""{colors["green"]}
12
+ ________ .__ _____
13
+ / _____/_____ |__| ____ / _ \ ____ ____ ____ ______ ______
14
+ / \ ___\__ \ | |/ \ / /_\ \_/ ___\/ ___\/ __ \ / ___// ___/
15
+ \ \_\ \/ __ \| | | \/ | \ \__\ \__\ ___/ \___ \ \___ \
16
+ \______ (____ /__|___| /\____|__ /\___ >___ >___ >____ >____ >
17
+ \/ \/ \/ \/ \/ \/ \/ \/ \/ v{__version__}
18
+ {colors["reset"]}
19
+ > Bug reports & feedback ・ https://github.com/0nely/GainAccess
20
+ > A tool that helps you gain access to resources you shouldn't have access to, made with ❤️ by 0nely
21
+ """
22
+
23
+
24
+ def build_parser():
25
+ parser = argparse.ArgumentParser(
26
+ prog="gainaccess",
27
+ add_help=False,
28
+ epilog="To avoid conflicts, use `--help` instead of `-h` to display the help message.",
29
+ description="""
30
+ Optional: Use '{GAINACCESS-ID}' as a placeholder for the target user's identity so GainAccess can identify it.
31
+ Example: `gainaccess -u 'https://example.com/user/{GAINACCESS-user123}'`
32
+ As you know, this tool doesn't just bypass 403 responses; it also tests for access control vulnerabilities.""",
33
+ formatter_class=lambda prog: argparse.RawDescriptionHelpFormatter(prog, max_help_position=30, width=120,),
34
+ )
35
+
36
+ input_group = parser.add_argument_group(f"{colors['yellow']}Input{colors['reset']}")
37
+ input_group.add_argument("-u", "--url", metavar="", type=str, required=True, help="Target URL to test")
38
+ input_group.add_argument("-H", "--header", metavar="", action="append", help="Custom HTTP header (e.g. -H 'User-Agent: GainAccess'). Can be specified multiple times")
39
+ input_group.add_argument("-C", "--cookie", metavar="", action="append", help="Custom cookie (e.g. -C 'session=abc123'). Can be specified multiple times")
40
+ input_group.add_argument("-X", "--method", metavar="", type=str, default="GET", help="HTTP request method")
41
+ # input_group.add_argument("-D", "--data", metavar="", type=str, help="HTTP request body")
42
+ # input_group.add_argument("-p", "--param", metavar="", type=str, help="Specify a parameter to fuzz. GainAccess will also test a limited number of alternative parameters")
43
+ # input_group.add_argument("-sI", "--swap-identifier", metavar="", type=str, help="Second identifier to test (recommended: a fake victim identifier)")
44
+
45
+ performance_group = parser.add_argument_group(f"{colors['yellow']}Performance{colors['reset']}")
46
+ performance_group.add_argument("-d", "--delay", metavar="", type=float, default=0, help="Delay between requests in seconds (default: 0)")
47
+ # performance_group.add_argument("-t", "--threads", metavar="", type=int, default=5, help="Number of concurrent threads (default: 5)")
48
+ performance_group.add_argument("--timeout", metavar="", type=float, default=10, help="Request timeout in seconds (default: 10)")
49
+
50
+ output_group = parser.add_argument_group(f"{colors['yellow']}Output{colors['reset']}")
51
+ output_group.add_argument("-o", "--output", metavar="", type=str, help="Output file path")
52
+ output_group.add_argument("-f", "--format", metavar="", choices=["txt", "json"], default="txt", help="Output format: txt or json (default: txt)")
53
+
54
+ misc_group = parser.add_argument_group(f"{colors['yellow']}Misc{colors['reset']}")
55
+ misc_group.add_argument("--help", action="help", help="Show this help options")
56
+ misc_group.add_argument("--verbose", action="store_true", help="Show detailed scan progress")
57
+
58
+ if len(sys.argv) == 1:
59
+ parser.print_help()
60
+ sys.exit(0)
61
+
62
+ args = vars(parser.parse_args())
63
+ return args
64
+
65
+
66
+ def parse_headers(values):
67
+ return dict(value.split(":", 1) for value in values) if values else {}
68
+
69
+
70
+ def parse_cookies(values):
71
+ return dict(value.split("=", 1) for value in values) if values else {}
72
+
73
+
74
+ def main():
75
+ try:
76
+ print(banner())
77
+ args = build_parser()
78
+
79
+ context = {
80
+ "base_request": {
81
+ "url": args["url"],
82
+ "method": args["method"],
83
+ "headers": parse_headers(args["header"]),
84
+ "cookies": parse_cookies(args["cookie"]),
85
+ "params": {},
86
+ },
87
+ "config": {
88
+ "threads": 5,
89
+ "delay": args["delay"],
90
+ "timeout": args["timeout"],
91
+ },
92
+ }
93
+
94
+ start_scan(context, args["verbose"])
95
+
96
+ except KeyboardInterrupt:
97
+ print(f"\n{colors['yellow']}[!] Scan interrupted by user.{colors['reset']}")
98
+
99
+
100
+ if __name__ == "__main__":
101
+ main()
@@ -0,0 +1,40 @@
1
+ import re
2
+ import yaml
3
+ from pathlib import Path
4
+ from urllib.parse import urlparse
5
+
6
+ from GainAccess.core.tasks import build_task, clone_request
7
+
8
+
9
+ api_file = Path(__file__).resolve().parent.parent / "db" / "payloads" / "api.yaml"
10
+
11
+
12
+ def _has_api_segment(url):
13
+ """
14
+ Check whether the URL path contains "api" as a full, standalone segment
15
+ (e.g. "/api/user" or "/api"), not as part of a longer word like
16
+ "/fakeapi/" or "/myapi/". Only the path is checked, never the netloc,
17
+ so a subdomain like "api.example.com" is never treated as a match.
18
+ """
19
+ path = urlparse(url).path
20
+ return re.search(r"/api(?=/|$)", path, re.IGNORECASE) is not None
21
+
22
+
23
+ def build_apis(base_request):
24
+ # Skip entirely if the target has no "/api" path segment at all.
25
+ # Without this guard, every version payload below would still be
26
+ # turned into a task, fire a request, and silently do nothing -
27
+ # pure noise on a target that was never "API-style" to begin with.
28
+ if not _has_api_segment(base_request["url"]):
29
+ return []
30
+
31
+ with open(api_file, "r", encoding="utf-8") as file:
32
+ data = yaml.safe_load(file)
33
+
34
+ payloads = []
35
+
36
+ for payload in data["payloads"]["versions"]:
37
+ request = clone_request(base_request, payload=payload)
38
+ payloads.append(build_task(technique="API Testing", payload=payload, request=request))
39
+
40
+ return payloads
@@ -0,0 +1,54 @@
1
+ import yaml
2
+ from pathlib import Path
3
+ from urllib.parse import urlsplit, urlunsplit
4
+
5
+ from GainAccess.core.tasks import build_task, clone_request
6
+
7
+
8
+ override_file = Path(__file__).resolve().parent.parent / "db" / "payloads" / "url_override.yaml"
9
+ forwarded_file = Path(__file__).resolve().parent.parent / "db" / "payloads" / "forwarded_header.yaml"
10
+
11
+
12
+ def build_forwarded(base_request):
13
+ """Build payloads for X-Forwarded headers."""
14
+
15
+ with open(forwarded_file, "r", encoding="utf-8") as file:
16
+ data = yaml.safe_load(file)
17
+
18
+ keys = data["payloads"]["keys"]
19
+ values = data["payloads"]["values"]
20
+
21
+ payloads = []
22
+
23
+ for header in keys:
24
+ for value in values:
25
+ payload = {header: value}
26
+ headers = {**base_request["headers"], **payload}
27
+
28
+ request = clone_request(base_request, headers=headers)
29
+
30
+ payloads.append(build_task(technique="Forwarded Headers", payload=payload, request=request))
31
+
32
+ return payloads
33
+
34
+
35
+ def build_overrides(base_request):
36
+ """Build payloads for X-Rewrite-URL and X-Original-URL."""
37
+
38
+ with open(override_file, "r", encoding="utf-8") as file:
39
+ data = yaml.safe_load(file)
40
+
41
+ parsed_url = urlsplit(base_request["url"])
42
+ root_url = urlunsplit((parsed_url.scheme, parsed_url.netloc, "/", "", ""))
43
+
44
+ payloads = []
45
+
46
+ for header in data["payloads"]["keys"]:
47
+ payload = {header: parsed_url.path}
48
+ headers = {**base_request["headers"], **payload}
49
+
50
+ request = clone_request(base_request, headers=headers)
51
+
52
+ payloads.append(build_task(technique="URL Override", payload=payload, request=request))
53
+
54
+ return payloads
@@ -0,0 +1,15 @@
1
+ from GainAccess.core.tasks import build_task, clone_request
2
+
3
+
4
+ def build_methods(base_request):
5
+ """Build payloads for HTTP method testing."""
6
+
7
+ methods = ["POSTX", "OPTIONS", "HEAD", "TRACE", "GET"]
8
+ payloads = []
9
+
10
+ for method in methods:
11
+ request = clone_request(base_request, method=method)
12
+
13
+ payloads.append(build_task(technique="HTTP Method", payload=method, request=request))
14
+
15
+ return payloads
@@ -0,0 +1,45 @@
1
+ import yaml
2
+ from pathlib import Path
3
+ from urllib.parse import urlencode, urlsplit, urlunsplit, parse_qsl
4
+
5
+ from GainAccess.core.tasks import build_task, clone_request
6
+
7
+
8
+ params_path = Path(__file__).resolve().parent.parent / "db" / "payloads" / "params.yaml"
9
+
10
+
11
+ def build_params(base_request):
12
+ """Build payloads for parameter testing."""
13
+
14
+ with open(params_path, "r", encoding="utf-8") as file:
15
+ data = yaml.safe_load(file)
16
+
17
+ keys = data["payloads"]["keys"]
18
+ values = data["payloads"]["values"]
19
+
20
+ parsed_url = urlsplit(base_request["url"])
21
+ base_query = parse_qsl(parsed_url.query, keep_blank_values=True)
22
+
23
+ payloads = []
24
+
25
+ for category, category_keys in keys.items():
26
+ category_values = values.get(category, [])
27
+
28
+ for key in category_keys:
29
+ for value in category_values:
30
+ payload = [(key, value)]
31
+ query = base_query + payload
32
+
33
+ url = urlunsplit((
34
+ parsed_url.scheme,
35
+ parsed_url.netloc,
36
+ parsed_url.path,
37
+ urlencode(query),
38
+ parsed_url.fragment
39
+ ))
40
+
41
+ request = clone_request(base_request, url=url)
42
+
43
+ payloads.append(build_task(technique="Param Testing", payload=urlencode(payload), request=request))
44
+
45
+ return payloads
@@ -0,0 +1,28 @@
1
+ import yaml
2
+ from pathlib import Path
3
+ import re
4
+
5
+ from GainAccess.core.tasks import build_task, clone_request
6
+
7
+
8
+ path_file = Path(__file__).resolve().parent.parent / "db" / "payloads" / "path_manipulation.yaml"
9
+
10
+ # {id}
11
+ # {encoded_id} is a fully encoded id or a partially encoded id
12
+ # {case_id} is an ID with modified letter casing
13
+
14
+ def build_paths(base_request):
15
+ with open(path_file, "r", encoding="utf-8") as file:
16
+ data = yaml.safe_load(file)
17
+
18
+ payloads = []
19
+
20
+ for category, paths in data["payloads"].items():
21
+ for path in paths:
22
+ if "{id}" in path:
23
+ path = path.replace("{id}", "{GAINACCESS-ID}")
24
+
25
+ request = clone_request(base_request, payload=path)
26
+ payloads.append(build_task(technique="Path Manipulation", payload=path, request=request))
27
+
28
+ return payloads
@@ -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,26 @@
1
+ GainAccess/__init__.py,sha256=x38Oy2k9DZ0nzC62W640HrQYryTPeEriDqLDmQkb0P0,148
2
+ GainAccess/main.py,sha256=TRGg1A1T6aH_tg6eGMZdqDFRJ1_0S37Y-xqvgDWdB7U,4888
3
+ GainAccess/core/analyzer.py,sha256=YuAxzYwjj34TeJiOGI_VhQmdQDnhl8PP_VkycB_gGdA,3657
4
+ GainAccess/core/colors.py,sha256=qUr6-ut7oJxMEj3_MEult4vQuGfV7zjotKerptskRVw,133
5
+ GainAccess/core/planner.py,sha256=juniHr1MnUYP3mZEd_9cJn7jwbm9BBzl4QNcYn3Ut9Y,2332
6
+ GainAccess/core/reporter.py,sha256=oZDfDnst9FPegSkR9w9ffy7TXxhdHgJNRgkyyovnfOY,70
7
+ GainAccess/core/requester.py,sha256=FKXfuzV3Basy16aJZfrvKC0k9PVRQqqvb0hTanSTQwA,935
8
+ GainAccess/core/scanner.py,sha256=IRSpS9BLOsD2RoKAV2EGaTu7mZwCmDu6H41e9Z8ukd4,4829
9
+ GainAccess/core/tasks.py,sha256=eGM2RZYeIPWAomPDm4KMX8bgOJrAbAxa26XoM5QZVSg,1310
10
+ GainAccess/core/utils.py,sha256=P_Y6oAOJD2lDjViQgFYq-VT27yJv_nU0qiQP1fhhmmo,1928
11
+ GainAccess/db/payloads/api.yaml,sha256=YXUAamoExsMwtoUnv1s6-8qx303IccX7UzKZwQ40Koc,339
12
+ GainAccess/db/payloads/forwarded_header.yaml,sha256=wwo0x9RAjhA9Teh_H5z1VJXbUUVDsc4cniSQAlKiQk8,518
13
+ GainAccess/db/payloads/params.yaml,sha256=O3C2feNA2Pq0_tMIL2TMgigETSXHwcijm4SvEfIZslU,1367
14
+ GainAccess/db/payloads/path_manipulation.yaml,sha256=IyHqtg8__A5unqr2BTZy1yC9qyL6An3oFeoXkUTh2Gk,916
15
+ GainAccess/db/payloads/url_override.yaml,sha256=IslvVBmtwlfG0FovlGx2wQv7df0QZoIFKHjJc2G38_c,363
16
+ GainAccess/techniques/api_testing.py,sha256=e7qYoRfP7poSsLzZaujNdFUPIUOIdAZNt05JIJ3qmRk,1378
17
+ GainAccess/techniques/header_manipulation.py,sha256=1mEzBw--RiNRkuyYKEXhq0IqpDWWePQ3Vw3QlHt7q04,1647
18
+ GainAccess/techniques/method_fuzzing.py,sha256=N42CIct6Fm34045P7Ecn62uiN9dZAxmwdPHQT19szE8,427
19
+ GainAccess/techniques/param_testing.py,sha256=56ExjihDIqSLCd6B737gDvQyvsXM8hTEcu5v9aovod4,1362
20
+ GainAccess/techniques/path_manipulation.py,sha256=oihrpJ1PE4oOclVlpyq2lsmqgsjb9r_BXT5H4g2AhJg,834
21
+ gainaccess-0.1.0.dist-info/licenses/LICENSE,sha256=m7Krf4zU9i-gbrcHAA9-CnWLRTDm676XSSb0upNp7Go,1062
22
+ gainaccess-0.1.0.dist-info/METADATA,sha256=YiXlek5TXKouzB18wfSazrhO92F_hW1hsemKltE7NMQ,2872
23
+ gainaccess-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
24
+ gainaccess-0.1.0.dist-info/entry_points.txt,sha256=vscROZ0PdtAFLXSP_zrNq4eDW19JWVg2VOP5ZagJwCE,52
25
+ gainaccess-0.1.0.dist-info/top_level.txt,sha256=vjZPfqTvW44ljFyBea39_wbogUE49elZ4DZWVZMtAao,11
26
+ gainaccess-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ gainaccess = GainAccess.main:main
@@ -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 @@
1
+ GainAccess