cpd-sec 0.2.9__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.
cpd/utils/parser.py ADDED
@@ -0,0 +1,63 @@
1
+ from typing import Dict, Tuple, Optional
2
+ from urllib.parse import urlparse
3
+
4
+ def parse_raw_request(raw_content: str, scheme: str = "https") -> Dict:
5
+ """
6
+ Parse a raw HTTP request (string) into components for HttpClient.
7
+
8
+ Args:
9
+ raw_content: The raw HTTP request string.
10
+ scheme: The protocol scheme (http/https). Default is https.
11
+
12
+ Returns:
13
+ Dict containing url, method, headers, and body.
14
+ """
15
+ lines = raw_content.strip().splitlines()
16
+ if not lines:
17
+ raise ValueError("Empty request content")
18
+
19
+ # 1. Parse Request Line
20
+ # GET /api/folders HTTP/2
21
+ req_line_parts = lines[0].split()
22
+ if len(req_line_parts) < 2:
23
+ raise ValueError(f"Invalid request line: {lines[0]}")
24
+
25
+ method = req_line_parts[0].upper()
26
+ path = req_line_parts[1]
27
+
28
+ # 2. Parse Headers
29
+ headers = {}
30
+ body = None
31
+ line_idx = 1
32
+
33
+ while line_idx < len(lines):
34
+ line = lines[line_idx]
35
+ if line == "":
36
+ # End of headers, start of body
37
+ body = "\n".join(lines[line_idx+1:])
38
+ break
39
+
40
+ if ":" in line:
41
+ key, val = line.split(":", 1)
42
+ headers[key.strip()] = val.strip()
43
+ line_idx += 1
44
+
45
+ # 3. Construct URL
46
+ # Needs Host header
47
+ host = headers.get("Host")
48
+ if not host:
49
+ # Fallback if no Host header (unlikely for valid requests)
50
+ raise ValueError("Missing Host header in raw request")
51
+
52
+ # Handle full URL in path (proxy style) vs relative path
53
+ if path.startswith("http"):
54
+ url = path
55
+ else:
56
+ url = f"{scheme}://{host}{path}"
57
+
58
+ return {
59
+ "url": url,
60
+ "method": method,
61
+ "headers": headers,
62
+ "body": body
63
+ }
@@ -0,0 +1,153 @@
1
+ Metadata-Version: 2.4
2
+ Name: cpd-sec
3
+ Version: 0.2.9
4
+ Summary: A high-concurrency CLI tool for detecting web cache poisoning vulnerabilities.
5
+ Author: kankburhan
6
+ Author-email: kankburhan@gmail.com
7
+ Requires-Python: >=3.9,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.9
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Requires-Dist: aiohttp (>=3.9.1,<4.0.0)
16
+ Requires-Dist: click (>=8.1.7,<9.0.0)
17
+ Requires-Dist: requests (>=2.31.0,<3.0.0)
18
+ Project-URL: Repository, https://github.com/kankburhan/cpd
19
+ Description-Content-Type: text/markdown
20
+
21
+ # CachePoisonDetector (CPD)
22
+
23
+ A high-concurrency CLI tool for detecting web cache poisoning vulnerabilities.
24
+
25
+ ## Overview
26
+ CPD is a security tool designed to identify vulnerabilities in web caching systems that allow cache poisoning attacks.
27
+
28
+ ## Installation
29
+
30
+ 1. Clone the repository:
31
+ ```bash
32
+ git clone https://github.com/kankburhan/cpd.git
33
+ cd cpd
34
+ ```
35
+
36
+ 2. Install dependencies using Poetry:
37
+ ```bash
38
+ poetry install
39
+ ```
40
+ *Alternatively, calculate dependencies to requirements.txt and use pip:*
41
+ ```bash
42
+ pip install .
43
+ ```
44
+
45
+ ## Usage
46
+
47
+ CPD supports multiple input methods and extensive configuration options.
48
+
49
+ ### 1. Basic Scan (`--url`)
50
+ Scan a single target URL.
51
+
52
+ ```bash
53
+ # Using poetry
54
+ poetry run cpd scan --url https://example.com
55
+
56
+ # As an installed package
57
+ cpd scan -u https://example.com
58
+ ```
59
+
60
+ ### 2. Pipeline Mode (Stdin)
61
+ Pipe URLs from other tools (like `waybackurls`, `gau`, `subfinder`, or `cat`) directly into CPD. This is ideal for mass scanning.
62
+
63
+ ```bash
64
+ # Scan URLs found by waybackurls
65
+ waybackurls target.com | cpd scan
66
+
67
+ # Scan URLs from a file using cat
68
+ cat urls.txt | cpd scan --concurrency 20
69
+ ```
70
+
71
+ ### 3. File Input (`--file`)
72
+ Read URLs from a text file (one URL per line).
73
+
74
+ ```bash
75
+ cpd scan --file urls.txt
76
+ ```
77
+
78
+ ### 4. Raw Request Scan (`--request-file`)
79
+ Scan using a raw HTTP request definition (e.g., copied from Burp Suite).
80
+
81
+ ```bash
82
+ # Save your request to a file (e.g. request.txt)
83
+ cpd scan --request-file request.txt
84
+ ```
85
+
86
+ **Alternative: Direct String (`--raw`)**
87
+ *Use with caution due to shell escaping characters.*
88
+ ```bash
89
+ cpd scan --raw "GET /api/foo HTTP/1.1
90
+ Host: example.com"
91
+ ```
92
+
93
+ ### 5. Advanced Options
94
+
95
+ #### Custom Headers (`--header`)
96
+ Add custom headers to every request (e.g., cookies, authorization). You can use this flag multiple times.
97
+
98
+ ```bash
99
+ cpd scan -u https://admin.example.com \
100
+ -h "Cookie: session=12345" \
101
+ -h "Authorization: Bearer XYZ"
102
+ ```
103
+
104
+ #### Output to File (`--output`)
105
+ Save the findings to a JSON file.
106
+
107
+ ```bash
108
+ cpd scan -u https://example.com --output results.json
109
+ ```
110
+
111
+ #### Concurrency (`--concurrency`)
112
+ Control the number of simultaneous requests (default: 50).
113
+
114
+ ```bash
115
+ cpd scan -f targets.txt --concurrency 100
116
+ ```
117
+
118
+ #### Verbosity (`--verbose`, `--quiet`)
119
+ Control output levels.
120
+
121
+ ```bash
122
+ cpd scan -u https://example.com -v # Debug logging
123
+ cpd scan -u https://example.com -q # Only show findings
124
+ ```
125
+
126
+ ### 5. Utilities
127
+
128
+ #### Validate Finding (`validate`)
129
+ Manually verify a vulnerability claim step-by-step.
130
+
131
+ ```bash
132
+ cpd validate --url https://target.com --header "X-Forwarded-Host: evil.com"
133
+ ```
134
+
135
+ #### Update Tool (`update`)
136
+ Check for and install the latest version of CPD.
137
+
138
+ ```bash
139
+ cpd update
140
+ ```
141
+
142
+ ## Features
143
+ - **Auto Update Check**: Automatically checks for new versions on run. ![Auto Update](https://img.shields.io/badge/Auto%20Update-Enabled-brightgreen)
144
+ - **High Concurrency**: Built with `asyncio` and `aiohttp` for speed.
145
+ - **Smart Baseline**: Establishes a stable baseline to reduce false positives.
146
+ - **Advanced Poisoning**:
147
+ - **Header Injection**: `X-Forwarded-Host`, `X-Forwarded-Scheme`, `Fastly-Client-IP`, etc.
148
+ - **Path Normalization**: Exploits backend URL decoding differences (`/foo\bar`).
149
+ - **Fat GET**: Sends request bodies with GET requests.
150
+ - **Unkeyed Query Params**: Injects parameters to test cache key inclusion.
151
+ - **Method Override**: Tests `X-HTTP-Method-Override`.
152
+ - **Pipeline Ready**: Designed to integrate into your reconnaissance workflow.
153
+
@@ -0,0 +1,16 @@
1
+ cpd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ cpd/cli.py,sha256=FBPVafWzqsU3wGy43SmTbk6_bPQFdaTLkSCwrMl4aMg,12796
3
+ cpd/engine.py,sha256=JNRYjkdpHHmePmPqtPWw3Hnky9hY8LRRoGOAvr67pio,3126
4
+ cpd/http_client.py,sha256=6EF9_cVWVyF2rr6fH7gnxVsIXXCir4JVmxsPw3eWzhE,1400
5
+ cpd/logic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ cpd/logic/baseline.py,sha256=5O7eO34oBwLMEtA1vZTNaNKBDQsS8D4Ny9K3MebxDUA,1777
7
+ cpd/logic/poison.py,sha256=ZdCCCc4neMS-MOlMlaqXT1KRsVu6hhVxyXL1vglxB10,31129
8
+ cpd/logic/validator.py,sha256=HYgTNAnaISU5Nxkn-qcDdkjagEnbSYyfp2jlKuKoG8s,2584
9
+ cpd/main.py,sha256=zfDYCwxYZnbzSmQUKqRNLb_tYDXV6caVejsj5Nr2umM,62
10
+ cpd/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ cpd/utils/logger.py,sha256=ZMv9lJ0P70dhTP_t1Pxzt7AR6t3f93feOrjR0U-B46w,2324
12
+ cpd/utils/parser.py,sha256=u42IIqcUk5Tb2mpaK6r_9uCBbpVUFllZgQivlLmPs1w,1752
13
+ cpd_sec-0.2.9.dist-info/METADATA,sha256=1LPtVacFfNqBT2w9mPJWth3trWxSRx1F916e76Z0yto,4288
14
+ cpd_sec-0.2.9.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
15
+ cpd_sec-0.2.9.dist-info/entry_points.txt,sha256=0xoiZMQwikuXkO4m6FcGFJuyxqNmFKHLoCSxOaHymIc,57
16
+ cpd_sec-0.2.9.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.2.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ cpd=cpd.main:cli
3
+ cpd-sec=cpd.main:cli
4
+