@gpzhang2001/sharpkit-skills 0.2.1

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 (84) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +12 -0
  3. package/THIRD_PARTY_NOTICES.md +48 -0
  4. package/lib/index.d.ts +2027 -0
  5. package/lib/index.d.ts.map +1 -0
  6. package/lib/index.js +70 -0
  7. package/lib/index.js.map +1 -0
  8. package/package.json +46 -0
  9. package/skills/analysis/counterevidence.md +185 -0
  10. package/skills/analysis/fix_verification.md +129 -0
  11. package/skills/analysis/severity_calibration.md +130 -0
  12. package/skills/analysis/source_aware_discovery.md +211 -0
  13. package/skills/cloud/aws.md +231 -0
  14. package/skills/cloud/azure.md +262 -0
  15. package/skills/cloud/gcp.md +194 -0
  16. package/skills/cloud/kubernetes.md +223 -0
  17. package/skills/coordination/root_agent.md +105 -0
  18. package/skills/coordination/source_aware_whitebox.md +47 -0
  19. package/skills/custom/api_spec_testing.md +61 -0
  20. package/skills/custom/dependency_cve_scanning.md +341 -0
  21. package/skills/custom/npx_confusion.md +233 -0
  22. package/skills/custom/source_aware_sast.md +192 -0
  23. package/skills/frameworks/django.md +214 -0
  24. package/skills/frameworks/fastapi.md +191 -0
  25. package/skills/frameworks/nestjs.md +225 -0
  26. package/skills/frameworks/nextjs.md +228 -0
  27. package/skills/protocols/graphql.md +276 -0
  28. package/skills/protocols/oauth.md +185 -0
  29. package/skills/reconnaissance/asset_discovery.md +150 -0
  30. package/skills/reconnaissance/infrastructure_lifecycle.md +226 -0
  31. package/skills/scan_modes/deep.md +164 -0
  32. package/skills/scan_modes/diff.md +86 -0
  33. package/skills/scan_modes/quick.md +68 -0
  34. package/skills/scan_modes/standard.md +99 -0
  35. package/skills/technologies/active_directory.md +233 -0
  36. package/skills/technologies/auth0.md +188 -0
  37. package/skills/technologies/electron_desktop_apps.md +181 -0
  38. package/skills/technologies/firebase.md +263 -0
  39. package/skills/technologies/grafana_prometheus.md +189 -0
  40. package/skills/technologies/llm_applications.md +257 -0
  41. package/skills/technologies/supabase.md +268 -0
  42. package/skills/tooling/agent_browser.md +551 -0
  43. package/skills/tooling/ffuf.md +72 -0
  44. package/skills/tooling/httpx.md +82 -0
  45. package/skills/tooling/hurl.md +99 -0
  46. package/skills/tooling/hypothesis.md +100 -0
  47. package/skills/tooling/katana.md +102 -0
  48. package/skills/tooling/naabu.md +68 -0
  49. package/skills/tooling/nmap.md +66 -0
  50. package/skills/tooling/nuclei.md +67 -0
  51. package/skills/tooling/python.md +109 -0
  52. package/skills/tooling/semgrep.md +72 -0
  53. package/skills/tooling/sqlmap.md +67 -0
  54. package/skills/tooling/subfinder.md +66 -0
  55. package/skills/vulnerabilities/agentic_system_security.md +207 -0
  56. package/skills/vulnerabilities/argument_injection.md +157 -0
  57. package/skills/vulnerabilities/authentication_jwt.md +166 -0
  58. package/skills/vulnerabilities/broken_function_level_authorization.md +154 -0
  59. package/skills/vulnerabilities/browser_security.md +192 -0
  60. package/skills/vulnerabilities/business_logic.md +178 -0
  61. package/skills/vulnerabilities/csrf.md +198 -0
  62. package/skills/vulnerabilities/header_injection.md +216 -0
  63. package/skills/vulnerabilities/http_request_smuggling.md +255 -0
  64. package/skills/vulnerabilities/idor.md +217 -0
  65. package/skills/vulnerabilities/information_disclosure.md +187 -0
  66. package/skills/vulnerabilities/insecure_deserialization.md +210 -0
  67. package/skills/vulnerabilities/insecure_file_uploads.md +194 -0
  68. package/skills/vulnerabilities/llm_prompt_injection.md +187 -0
  69. package/skills/vulnerabilities/mass_assignment.md +153 -0
  70. package/skills/vulnerabilities/nosql_injection.md +288 -0
  71. package/skills/vulnerabilities/open_redirect.md +165 -0
  72. package/skills/vulnerabilities/path_traversal_lfi_rfi.md +218 -0
  73. package/skills/vulnerabilities/prototype_pollution.md +142 -0
  74. package/skills/vulnerabilities/race_conditions.md +181 -0
  75. package/skills/vulnerabilities/rce.md +250 -0
  76. package/skills/vulnerabilities/semantic_confusion.md +189 -0
  77. package/skills/vulnerabilities/sql_injection.md +190 -0
  78. package/skills/vulnerabilities/ssrf.md +186 -0
  79. package/skills/vulnerabilities/ssti.md +270 -0
  80. package/skills/vulnerabilities/subdomain_takeover.md +167 -0
  81. package/skills/vulnerabilities/weak_password_detection.md +200 -0
  82. package/skills/vulnerabilities/xss.md +206 -0
  83. package/skills/vulnerabilities/xxe.md +223 -0
  84. package/src/index.ts +89 -0
@@ -0,0 +1,276 @@
1
+ ---
2
+ name: graphql
3
+ description: GraphQL security testing covering introspection, resolver injection, batching attacks, and authorization bypass
4
+ ---
5
+
6
+ # GraphQL
7
+
8
+ Security testing for GraphQL APIs. Focus on resolver-level authorization, field/edge access control, batching abuse, and federation trust boundaries.
9
+
10
+ ## Attack Surface
11
+
12
+ **Operations**
13
+ - Queries, mutations, subscriptions
14
+ - Persisted queries / Automatic Persisted Queries (APQ)
15
+
16
+ **Transports**
17
+ - HTTP POST/GET with `application/json` or `application/graphql`
18
+ - WebSocket: graphql-ws, graphql-transport-ws protocols
19
+ - Multipart for file uploads
20
+
21
+ **Schema Features**
22
+ - Introspection (`__schema`, `__type`)
23
+ - Directives: `@defer`, `@stream`, custom auth directives (@auth, @private)
24
+ - Custom scalars: Upload, JSON, DateTime
25
+ - Relay: global node IDs, connections/cursors, interfaces/unions
26
+
27
+ **Architecture**
28
+ - Federation (Apollo, GraphQL Mesh): `_service`, `_entities`
29
+ - Gateway vs subgraph authorization boundaries
30
+
31
+ ## Reconnaissance
32
+
33
+ **Endpoint Discovery**
34
+ ```
35
+ POST /graphql {"query":"{__typename}"}
36
+ POST /api/graphql {"query":"{__typename}"}
37
+ POST /v1/graphql {"query":"{__typename}"}
38
+ POST /gql {"query":"{__typename}"}
39
+ GET /graphql?query={__typename}
40
+ ```
41
+
42
+ Check for GraphiQL/Playground exposure with credentials enabled (cross-origin with cookies can leak data via postMessage bridges).
43
+
44
+ **Schema Acquisition**
45
+
46
+ If introspection enabled:
47
+ ```graphql
48
+ {__schema{types{name fields{name args{name}}}}}
49
+ ```
50
+
51
+ If disabled, infer schema via:
52
+ - `__typename` probes on candidate fields
53
+ - Field suggestion errors (submit near-miss names to harvest suggestions)
54
+ - "Expected one of" errors revealing enum values
55
+ - Type coercion errors exposing field structure
56
+ - Error taxonomy: different codes for "unknown field" vs "unauthorized field" reveal existence
57
+
58
+ **Schema Mapping**
59
+
60
+ Map: root operations, object types, interfaces/unions, directives, custom scalars. Identify sensitive fields: email, tokens, roles, billing, API keys, admin flags, file URLs. Note cascade paths where child resolvers may skip auth under parent assumptions.
61
+
62
+ ## Key Vulnerabilities
63
+
64
+ ### Authorization Bypass
65
+
66
+ **Field-Level IDOR**
67
+
68
+ Test with aliases comparing owned vs foreign objects in single request:
69
+ ```graphql
70
+ query {
71
+ own: order(id:"OWNED_ID") { id total owner { email } }
72
+ foreign: order(id:"FOREIGN_ID") { id total owner { email } }
73
+ }
74
+ ```
75
+
76
+ **Edge/Child Resolver Gaps**
77
+
78
+ Parent resolver checks auth, child resolver assumes it's already validated:
79
+ ```graphql
80
+ query {
81
+ user(id:"FOREIGN") {
82
+ id
83
+ privateData { secrets } # Child may skip auth check
84
+ }
85
+ }
86
+ ```
87
+
88
+ **Relay Node Resolution**
89
+
90
+ Decode base64 global IDs, swap type/id pairs:
91
+ ```graphql
92
+ query {
93
+ node(id:"VXNlcjoxMjM=") { ... on User { email } }
94
+ }
95
+ ```
96
+ Ensure per-type authorization is enforced inside resolvers. Verify connection filters (owner/tenant) apply before pagination; cursor tampering should not cross ownership boundaries.
97
+
98
+ **Mutation Bypass**
99
+ - Probe mutations for partial updates bypassing validation (JSON Merge Patch semantics)
100
+ - Test mutations that accept extra fields passed to downstream logic
101
+
102
+ ### Batching & Alias Abuse
103
+
104
+ **Enumeration via Aliases**
105
+ ```graphql
106
+ query {
107
+ u1:user(id:"1"){email}
108
+ u2:user(id:"2"){email}
109
+ u3:user(id:"3"){email}
110
+ }
111
+ ```
112
+ Bypasses per-request rate limits; exposes per-field vs per-request auth inconsistencies.
113
+
114
+ **Array Batching**
115
+
116
+ If supported (non-standard), submit multiple operations to achieve partial failures and bypass limits.
117
+
118
+ ### Input Manipulation
119
+
120
+ **Type Confusion**
121
+ ```
122
+ {id: 123} vs {id: "123"}
123
+ {id: [123]} vs {id: null}
124
+ {id: 0} vs {id: -1}
125
+ ```
126
+
127
+ **Duplicate Keys**
128
+ ```json
129
+ {"id": 1, "id": 2}
130
+ ```
131
+ Parser precedence varies; may bypass validation. Also test default argument values.
132
+
133
+ **Extra Fields**
134
+
135
+ Send unexpected keys in input objects; backends may pass them to resolvers or downstream logic.
136
+
137
+ ### Cursor Manipulation
138
+
139
+ Decode cursors (usually base64) to:
140
+ - Manipulate offsets/IDs
141
+ - Skip filters
142
+ - Cross ownership boundaries
143
+
144
+ ### Directive Abuse
145
+
146
+ **@defer/@stream**
147
+ ```graphql
148
+ query {
149
+ me { id }
150
+ ... @defer { adminPanel { secrets } }
151
+ }
152
+ ```
153
+ May return gated data in incremental delivery. Confirm server supports incremental delivery.
154
+
155
+ **Custom Directives**
156
+
157
+ @auth, @private and similar directives often annotate intent but do not enforce—verify actual checks in each resolver path.
158
+
159
+ ### Complexity Attacks
160
+
161
+ **Fragment Bombs**
162
+ ```graphql
163
+ fragment x on User { friends { ...x } }
164
+ query { me { ...x } }
165
+ ```
166
+ Test depth/complexity limits, query cost analyzers, timeouts.
167
+
168
+ **Wide Selection Sets**
169
+
170
+ Abuse selection sets and fragments to force overfetching of sensitive subfields.
171
+
172
+ ### Federation Exploitation
173
+
174
+ **SDL Exposure**
175
+ ```graphql
176
+ query { _service { sdl } }
177
+ ```
178
+
179
+ **Entity Materialization**
180
+ ```graphql
181
+ query {
182
+ _entities(representations:[
183
+ {__typename:"User", id:"TARGET_ID"}
184
+ ]) { ... on User { email roles } }
185
+ }
186
+ ```
187
+ Gateway may enforce auth; subgraph resolvers may not. Look for cross-subgraph IDOR via inconsistent ownership checks.
188
+
189
+ ### Subscription Security
190
+
191
+ - Authorization at handshake only, not per-message
192
+ - Subscribe to other users' channels via filter args
193
+ - Cross-tenant event leakage
194
+ - Abuse filter args in subscription resolvers to reference foreign IDs
195
+
196
+ ### Persisted Query Abuse
197
+
198
+ - APQ hashes leaked from client bundles
199
+ - Replay privileged operations with attacker variables
200
+ - Hash bruteforce for common operations
201
+ - Validate hash→operation mapping enforces principal and operation allowlists
202
+
203
+ ### CORS & CSRF
204
+
205
+ - Cookie-auth with GET queries enables CSRF on mutations via query parameters
206
+ - GraphiQL/Playground cross-origin with credentials leaks data
207
+ - Missing SameSite and origin validation
208
+
209
+ ### File Uploads
210
+
211
+ GraphQL multipart spec:
212
+ - Multiple Upload scalars
213
+ - Filename/path traversal tricks
214
+ - Unexpected content-types, oversize chunks
215
+ - Server-side ownership/scoping for returned URLs
216
+
217
+ ## WAF Evasion
218
+
219
+ **Query Reshaping**
220
+ - Comments and block strings (`"""..."""`)
221
+ - Unicode escapes
222
+ - Alias/fragment indirection
223
+ - JSON variables vs inline args
224
+ - GET vs POST vs `application/graphql`
225
+
226
+ **Fragment Splitting**
227
+
228
+ Split fields across fragments and inline spreads to avoid naive signatures:
229
+ ```graphql
230
+ fragment a on User { email }
231
+ fragment b on User { password }
232
+ query { me { ...a ...b } }
233
+ ```
234
+
235
+ ## Bypass Techniques
236
+
237
+ **Transport Switching**
238
+ ```
239
+ Content-Type: application/json
240
+ Content-Type: application/graphql
241
+ Content-Type: multipart/form-data
242
+ GET with query params
243
+ ```
244
+
245
+ **Timing & Rate Limits**
246
+ - HTTP/2 multiplexing and connection reuse to widen timing windows
247
+ - Batching to bypass rate limits
248
+
249
+ **Naming Tricks**
250
+ - Case/underscore variations
251
+ - Unicode homoglyphs (server-dependent)
252
+ - Aliases masking sensitive field names
253
+
254
+ **Cache Confusion**
255
+ - CDN caching without Vary on Authorization
256
+ - Variable manipulation affecting cache keys
257
+ - Redirects and 304/206 behaviors leaking partial responses
258
+
259
+ ## Testing Methodology
260
+
261
+ 1. **Fingerprint** - Identify endpoints, transports, stack (Apollo, Hasura, etc.), GraphiQL exposure
262
+ 2. **Schema mapping** - Introspection or inference to build complete type graph
263
+ 3. **Principal matrix** - Collect tokens for unauth, user, premium, admin roles with at least one valid object ID per subject
264
+ 4. **Field sweep** - Test each resolver with owned vs foreign IDs via aliases in same request
265
+ 5. **Transport parity** - Verify same auth on HTTP, WebSocket, persisted queries
266
+ 6. **Federation probe** - Test `_service` and `_entities` for subgraph auth gaps
267
+ 7. **Edge cases** - Cursors, @defer/@stream, subscriptions, file uploads
268
+
269
+ ## Validation Requirements
270
+
271
+ - Paired requests (owner vs non-owner) showing unauthorized access
272
+ - Resolver-level bypass: parent checks present, child field exposes data
273
+ - Transport parity proof: HTTP and WebSocket for same operation
274
+ - Federation bypass: `_entities` accessing data without subgraph auth
275
+ - Minimal payloads with exact selection sets and variable shapes
276
+ - Document exact resolver paths that missed enforcement
@@ -0,0 +1,185 @@
1
+ ---
2
+ name: oauth
3
+ description: OAuth 2.0 and OIDC flow security testing covering redirect manipulation, token leakage, PKCE bypass, and client misconfiguration
4
+ ---
5
+
6
+ # OAuth 2.0 / OIDC
7
+
8
+ OAuth and OIDC failures often enable account takeover, token theft, and cross-client token confusion. Treat every redirect, client identifier, and token exchange as an authorization boundary — not a convenience layer.
9
+
10
+ ## Attack Surface
11
+
12
+ **Flows**
13
+ - Authorization code (with/without PKCE)
14
+ - Implicit (legacy), hybrid, device authorization, client credentials
15
+ - Refresh token rotation, token introspection, revocation
16
+
17
+ **Endpoints**
18
+ - `/authorize`, `/token`, `/userinfo`, `/introspect`, `/revoke`, `/logout`
19
+ - `/.well-known/openid-configuration`, `/jwks.json`
20
+ - Dynamic client registration (if enabled)
21
+
22
+ **Token Types**
23
+ - Authorization codes, access tokens, refresh tokens, ID tokens
24
+ - Opaque vs JWT formats; reference tokens vs self-contained JWTs
25
+
26
+ **Client Types**
27
+ - Public clients (SPAs, mobile) vs confidential (server-side)
28
+ - Multiple redirect URIs, wildcard/pattern matching, custom URI schemes
29
+
30
+ ## Reconnaissance
31
+
32
+ **Discovery**
33
+ ```
34
+ GET /.well-known/openid-configuration
35
+ GET /oauth2/.well-known/openid-configuration
36
+ GET /.well-known/oauth-authorization-server
37
+ ```
38
+
39
+ Extract: `authorization_endpoint`, `token_endpoint`, `registration_endpoint`, supported `response_types`, `code_challenge_methods_supported`, `grant_types_supported`.
40
+
41
+ **Client Enumeration**
42
+ - Inspect JS bundles, mobile APK/IPA configs, GitHub repos for `client_id`, redirect URIs, scopes
43
+ - Check error messages for client validation hints ("invalid redirect_uri", "unregistered client")
44
+
45
+ ## Key Vulnerabilities
46
+
47
+ ### Redirect URI Manipulation
48
+
49
+ **Open Redirect Chains**
50
+ - Register or guess permissive redirect patterns: `https://app.com/callback`, path-prefix only, subdomain wildcards
51
+ - Test: append paths, fragments, query injection, `@` tricks, encoded slashes, backslash variants
52
+
53
+ ```
54
+ https://app.com/callback.evil.com
55
+ https://app.com/callback%2f..%2f@evil.com
56
+ https://app.com/callback?next=https://evil.com
57
+ com.app://callback (mobile custom scheme)
58
+ ```
59
+
60
+ **Redirect URI Validation Bypasses**
61
+ - Trailing slash, case, port, scheme downgrade (`http` vs `https`)
62
+ - Path normalization differentials between IdP validator and consuming app
63
+ - `redirect_uri` parameter pollution (first vs last wins)
64
+ - Wildcard subdomain acceptance: `*.app.com` → register `attacker.app.com` or find dangling subdomain
65
+
66
+ ### Authorization Code Issues
67
+
68
+ **Code Leakage**
69
+ - Codes in URL fragments, Referer headers, browser history, server logs, analytics
70
+ - Code replay before expiry; missing one-time-use enforcement
71
+ - Code sent to wrong redirect_uri if binding is weak
72
+
73
+ **Code Injection / Mix-Up**
74
+ - Attacker initiates flow, victim completes login, code delivered to attacker's redirect
75
+ - Mix-up attack: swap `client_id` between authorize and token steps
76
+ - Missing `redirect_uri` binding at token endpoint
77
+
78
+ ### State and Nonce
79
+
80
+ - Missing, predictable, or reusable `state` → CSRF on OAuth login (session fixation, account linking)
81
+ - Missing `nonce` in OIDC → ID token injection/replay
82
+ - `state` not bound to client session or PKCE verifier
83
+
84
+ ### PKCE Bypass
85
+
86
+ - `code_challenge_method` downgrade: accept `plain` instead of `S256`
87
+ - Missing PKCE requirement on public clients
88
+ - `code_verifier` not validated or compared case-insensitively with weak matching
89
+ - Authorization code issued without challenge, token endpoint accepts any verifier
90
+
91
+ ### Client Authentication
92
+
93
+ **Public Client Abuse**
94
+ - Token endpoint accepts requests without `client_secret` for confidential clients
95
+ - `client_id` only authentication on token/introspection endpoints
96
+ - Dynamic registration with attacker-controlled redirect URIs
97
+
98
+ **Secret Leakage**
99
+ - Hardcoded secrets in mobile apps, SPAs, or public repos
100
+ - `client_secret` accepted in query string or logged in access logs
101
+
102
+ ### Scope and Token Issues
103
+
104
+ - Scope escalation: request `admin`/`offline_access`/`openid profile email` beyond app need; server grants all requested scopes
105
+ - Refresh token not rotated or reuse not detected → persistent access
106
+ - Access token accepted across services (missing audience/resource binding)
107
+ - Token introspection returns `active:true` without proper auth on introspection endpoint
108
+
109
+ ### OpenID Connect Specific
110
+
111
+ - ID token accepted as access token at resource servers (token confusion)
112
+ - `acr`, `amr`, `auth_time` not validated for step-up requirements
113
+ - Userinfo endpoint returns PII without matching access token scope
114
+ - `sub` collision across issuers if `iss` not validated
115
+
116
+ ## Advanced Techniques
117
+
118
+ **Referer Leakage**
119
+ - Embed authorized redirect as subresource on attacker page; harvest `code` from Referer if policy allows
120
+
121
+ **Device Flow Abuse**
122
+ - Poll `device_code` endpoint with guessed codes; slow rate limits only
123
+ - User approves attacker-initiated device login
124
+
125
+ **Account Linking**
126
+ - OAuth login links attacker's IdP identity to victim's local account without re-auth
127
+ - Email collision: same email from different IdP providers
128
+
129
+ ## Testing Methodology
130
+
131
+ 1. **Map flows** — Identify all grant types, clients, and redirect URIs in use
132
+ 2. **Redirect matrix** — For each client, fuzz redirect_uri validation with encoding and parser tricks
133
+ 3. **CSRF** — Initiate OAuth without `state`; swap sessions mid-flow
134
+ 4. **PKCE** — Replay codes with wrong/missing verifier; downgrade challenge method
135
+ 5. **Token exchange** — Swap codes/tokens between clients; test cross-audience acceptance
136
+ 6. **Mobile/deep links** — Custom schemes, intent filters, universal links hijacking
137
+
138
+ ## Validation
139
+
140
+ 1. Demonstrate stolen authorization code or token via redirect manipulation or Referer leak
141
+ 2. Show account takeover or access to victim resources with attacker's OAuth session
142
+ 3. Prove CSRF: victim completes login into attacker's linked session without consent UI bypass where applicable
143
+ 4. Document exact validation gap (redirect binding, PKCE, state, audience)
144
+ 5. Provide full authorize → callback → token request chain with before/after evidence
145
+
146
+ ## False Positives
147
+
148
+ - Redirect URI rejected consistently across all bypass attempts
149
+ - Public client correctly requires PKCE S256 with strict verifier validation
150
+ - `state`/`nonce` enforced and bound; CSRF test fails as expected
151
+ - Token audience/issuer correctly validated at resource server
152
+ - Custom scheme redirects require app ownership proof (verified Android/iOS app links)
153
+
154
+ ## Impact
155
+
156
+ - Full account takeover via stolen authorization codes or tokens
157
+ - Persistent access through refresh token theft
158
+ - Cross-tenant or cross-client data access via token confusion
159
+ - PII exposure from userinfo or ID token claim leakage
160
+
161
+ ## Pro Tips
162
+
163
+ 1. Always capture the full redirect chain including intermediate 302 locations
164
+ 2. Compare authorize-step and token-step parameter binding (`redirect_uri`, `client_id`, PKCE)
165
+ 3. Test both web and mobile clients — validation rules often differ
166
+ 4. Check logout/revocation — tokens may remain valid after "logout"
167
+ 5. Chain with open redirect or XSS on the legitimate redirect_uri to exfiltrate codes
168
+
169
+ ## Tooling
170
+
171
+ The sandbox ships **jwt_tool** (already cloned at `/home/pentester/tools/jwt_tool`) plus `curl` — enough for the token side of OAuth/OIDC.
172
+
173
+ - **jwt_tool** (ticarpi) — inspect and tamper ID tokens / JWT access tokens: `alg:none`, `HS256`/`RS256` key confusion, `kid` injection, claim editing (`sub`, `aud`, `iss`, `exp`):
174
+ ```
175
+ python3 /home/pentester/tools/jwt_tool/jwt_tool.py <ID_TOKEN> # decode/inspect
176
+ python3 /home/pentester/tools/jwt_tool/jwt_tool.py <ID_TOKEN> -X a # alg:none
177
+ python3 /home/pentester/tools/jwt_tool/jwt_tool.py <ID_TOKEN> -X k -pk pub.pem # RS256->HS256 confusion
178
+ ```
179
+ - **curl** — drive the authorize → callback → token chain by hand so you control every parameter (`redirect_uri`, `client_id`, `state`, PKCE `code_challenge`/`code_verifier`) and can test the binding/downgrade cases above.
180
+
181
+ Humans often use Burp's **EsPReSSO** (RUB-NDS) SSO extension for flow visualization; it is GUI-only, so prefer manual `curl` + `jwt_tool` in-sandbox.
182
+
183
+ ## Summary
184
+
185
+ OAuth security hinges on strict redirect URI binding, unguessable state/nonce, PKCE for public clients, and consistent token audience validation. Any gap in the authorize-to-token chain is a potential account takeover.
@@ -0,0 +1,150 @@
1
+ ---
2
+ name: asset-discovery
3
+ description: Passive asset and attack-surface discovery via certificate transparency, TLS SAN pivoting, passive DNS, and ASN/IP enumeration to find hosts beyond subdomain brute force
4
+ ---
5
+
6
+ # Asset Discovery
7
+
8
+ Most engagements start from a small seed (one domain, one org name) but the real attack surface is far larger: forgotten hosts, staging/internal-named services, acquisitions, and infrastructure that never appears in a wordlist. Build a broad, deduplicated inventory using passive intelligence — certificate transparency, TLS certificate metadata, passive DNS, and ASN/IP data — then collapse it into a probed, classified attack surface. The aim is coverage and pivoting: every certificate, DNS record, and IP is a lead to more assets.
9
+
10
+ Only use this skill when all subdomains and related assets of the target are in scope — broad discovery pulls in hosts far beyond the seed.
11
+
12
+ ## Attack Surface
13
+
14
+ - Hosts discoverable via issued certificates (CT logs) but absent from DNS brute force
15
+ - Internal/staging/pre-prod hostnames leaked in certificate SAN lists
16
+ - Sibling and acquisition domains sharing certificates, ASNs, or IP ranges with the seed
17
+ - Wildcard and short-lived certs revealing naming conventions (`*.internal.example.com`, `k8s-*`, `argocd.*`)
18
+ - ASN-owned IP ranges hosting services with no DNS name at all
19
+ - Virtual hosts co-located on shared IPs (multiple apps behind one address)
20
+ - Non-HTTP services on discovered hosts (databases, brokers, admin ports)
21
+
22
+ ## High-Value Sources
23
+
24
+ ### Certificate Transparency (CT)
25
+
26
+ CT logs record nearly every publicly-trusted certificate. Query by domain (matches SAN/CN) and by organization name.
27
+
28
+ - **crt.sh** (free, no key):
29
+ - By domain incl. subdomains: `curl -s 'https://crt.sh/?q=%25.example.com&output=json' | jq -r '.[].name_value' | sed 's/^\*\.//' | sort -u`
30
+ - By organization: `https://crt.sh/?O=Example+Inc&output=json`
31
+ - **Censys / Shodan / Fofa** (API keys): search certs by `parsed.names`, `parsed.subject.organization`, or a specific `fingerprint_sha256`, then pivot to every host serving that cert.
32
+ - Cross-check multiple indexes (`certspotter`, Google CT, `chaos`) — no single log is complete.
33
+ - **Wildcards** (`*.corp.example.com`) reveal internal naming schemes even when individual hosts resolve privately; use them to seed targeted guesses (`grafana.corp`, `ci.corp`, `vault.corp`).
34
+
35
+ ### TLS Certificate SAN/CN
36
+
37
+ - **SAN expansion**: one cert often lists many hostnames (marketing + api + admin + internal) — extract every SAN, not just the queried name.
38
+ - **Shared-cert pivot**: the same cert fingerprint served on multiple IPs ties disparate assets to one owner.
39
+ - **Issuer/org pivot**: certs sharing `subject.organization`/`organizationalUnit` frequently belong to the same target.
40
+ - **Active read** catches names never submitted to public CT: `echo | openssl s_client -connect HOST:443 -servername HOST 2>/dev/null | openssl x509 -noout -text | grep -A1 'Subject Alternative Name'`
41
+ - **Internal leak signal**: SANs like `localhost`, `*.internal`, `*.svc.cluster.local`, `*.local`, or RFC1918-style names on a public cert expose internal naming and sometimes internal services fronted publicly.
42
+
43
+ ### Passive DNS
44
+
45
+ - Forward-resolve every name (A/AAAA/CNAME); keep CNAME chains — they reveal third-party providers and CDNs.
46
+ - **Reverse DNS (PTR)** on discovered IPs surfaces co-located hostnames.
47
+ - **Historical/passive DNS** (SecurityTrails, VirusTotal, `chaos`, passivedns providers) recovers names that no longer resolve but may still front live infra.
48
+
49
+ ### ASN & IP Ranges
50
+
51
+ - Map a known IP to its ASN and netblock: `whois -h whois.cymru.com " -v <IP>"` or a BGP/ASN lookup.
52
+ - If the org runs its own ASN, enumerate all announced prefixes and treat them as candidate assets.
53
+ - For cloud-hosted targets the IP belongs to the provider, not the org — pivot via cert/vhost instead of netblock.
54
+
55
+ ## Recommended Tooling
56
+
57
+ These tools are available in the sandbox and are pipeline-friendly with JSON output:
58
+
59
+ - **`subfinder`** — passive subdomain aggregation across many sources incl. CT: `subfinder -d example.com -all -recursive -silent -oJ -o subs.jsonl`
60
+ - **`httpx`** — live probing plus cert/SAN grab in one pass: `httpx -l hosts.txt -tls-grab -json` (see methodology).
61
+ - **`naabu`** — port sweep for non-HTTP services: `naabu -list hosts.txt -top-ports 100 -verify -silent`
62
+ - **`curl` + `jq`** — direct **crt.sh** JSON queries for CT (no key needed) and other index APIs.
63
+ - **`openssl s_client`** — active read of a live host's cert to extract SANs/CN.
64
+ - **`dig`** / **`nslookup`** — forward/reverse (PTR) resolution and CNAME chains.
65
+ - **`whois`** — ASN/netblock lookups (e.g. `whois -h whois.cymru.com`).
66
+
67
+ Cross-source results — CT + passive DNS + `subfinder` together beat any single source. If you need a tool that is not installed, install it into the sandbox at runtime.
68
+
69
+ ## Key Techniques
70
+
71
+ ### Iterative Seed Expansion
72
+
73
+ Every new name, PTR result, CNAME target, and cert SAN becomes a fresh seed. Loop CT → SAN extraction → passive DNS → ASN/range expansion until the asset set stops growing.
74
+
75
+ ### Cert-Fingerprint Pivoting
76
+
77
+ Search Censys/Shodan by a cert's `fingerprint_sha256` to find every other host presenting the same certificate — the strongest cross-asset link for tying acquisitions and shadow infra to the target.
78
+
79
+ ### Naming-Convention Inference
80
+
81
+ Wildcard SANs and observed hostnames expose the org's naming scheme; generate targeted candidates from it (`<service>.<env>.example.com`) rather than blind brute force.
82
+
83
+ ### IP-First Discovery
84
+
85
+ For ASN-owned ranges, sweep IPs directly with `naabu`/`httpx` and read served certs (`httpx -tls-grab`, or `openssl s_client`) to find services that have no DNS name at all.
86
+
87
+ ## Advanced Techniques
88
+
89
+ - **Active SAN harvesting** across whole ranges with `httpx -tls-grab` (or `openssl s_client`) recovers internal hostnames never logged to public CT.
90
+ - **Favicon and response hashing** (`httpx -favicon`, hash pivots in Shodan) clusters instances of the same app across unrelated hostnames.
91
+ - **Vhost differentials**: probe a single IP with multiple `Host:` values to unmask co-located apps behind one address.
92
+ - **Historical CT/DNS diffing** highlights recently issued certs and newly appearing hosts — high-signal for fresh or misconfigured deployments.
93
+
94
+ ## Consolidation & Probing
95
+
96
+ 1. **Dedupe** names and IPs into one inventory; record source(s) per asset for confidence.
97
+ 2. **Live probe** with `httpx`, capturing status/title/tech/server and cert SANs in one pass — each grabbed SAN feeds back as a new seed:
98
+ `httpx -l hosts.txt -sc -title -server -td -tls-grab -json -o assets.jsonl`
99
+ 3. **Classify** assets by function from title/tech/path signals: app, API, marketing, auth, CI/CD, observability, storage, admin, VCS, mail. Cluster by role, not by a specific product.
100
+ 4. **Port sweep** interesting hosts with `naabu` for non-HTTP services (DBs, caches, brokers, mgmt ports).
101
+ 5. **Prioritize** by exposure and value, then hand each finding to the right specialist skill:
102
+ - Exposed dashboards / debug / observability / metadata leaks → `information_disclosure`
103
+ - Login/admin panels with default or weak creds → `weak_password_detection`
104
+ - Dangling DNS / unclaimed provider resources → `subdomain_takeover`
105
+ - Cloud consoles/metadata surfaces → `aws` / `gcp` / `kubernetes`
106
+
107
+ ## Testing Methodology
108
+
109
+ 1. **Seed** - domains, org/legal names, known IPs, email domains, code-host org
110
+ 2. **Certificate transparency** - pull all logged certs per seed domain and org name (crt.sh, Censys/Shodan)
111
+ 3. **SAN/CN extraction** - parse every Subject CN and SAN with `httpx -tls-grab` (or `openssl s_client`); each new name is a new seed
112
+ 4. **Passive DNS** - resolve forward and reverse with `dig`; harvest historical records
113
+ 5. **ASN/IP mapping** - `whois` the netblock/ASN to expand owned ranges, then sweep for live hosts
114
+ 6. **Active TLS pivot** - `httpx -tls-grab` on live IPs/ports to grab SANs missing from public CT
115
+ 7. **Consolidate & probe** - dedupe, `httpx` probe, classify, and route to specialists
116
+
117
+ ## Validation
118
+
119
+ 1. Confirm each discovered asset actually resolves and serves content (live `httpx` result, not just a passive hit)
120
+ 2. Attribute assets to the target via matching cert org, shared cert fingerprint, or DNS under a seed domain
121
+ 3. Deduplicate vhost aliases and CDN edges down to distinct origins so the surface is not inflated
122
+ 4. Record provenance (which source produced each asset) for reproducibility
123
+
124
+ ## False Positives
125
+
126
+ - CDN/edge hostnames and provider default names that are not org-owned
127
+ - Shared-hosting neighbors on the same IP (vhost co-tenancy, not the target's asset)
128
+ - Stale historical DNS entries pointing at reassigned infrastructure
129
+ - Wildcard-cert-implied hostnames that never actually resolve or serve content
130
+
131
+ ## Impact
132
+
133
+ - Expanded attack surface: forgotten, staging, and internal-named hosts brute force misses
134
+ - Discovery of misconfigured or unauthenticated services fronted by leaked internal hostnames
135
+ - Attribution of shadow infra, acquisitions, and sibling domains to the target
136
+ - A prioritized, classified inventory that feeds every downstream specialist skill
137
+
138
+ ## Pro Tips
139
+
140
+ 1. Loop the pipeline — every SAN, PTR, and CNAME target is a new seed until the set converges.
141
+ 2. crt.sh is the cheapest high-yield source (no key); Censys/Shodan add cert-fingerprint and vhost pivoting when keys exist.
142
+ 3. Always cert-grab live hosts with `httpx -tls-grab` (or `openssl s_client`) — active SANs catch internal hostnames never sent to public CT.
143
+ 4. Internal-looking SANs (`*.internal`, `*.svc.cluster.local`, staging names) are the highest-signal leads.
144
+ 5. Wildcard SANs reveal naming conventions — seed targeted guesses instead of blind brute force.
145
+ 6. Cluster by function, not product name, so the workflow generalizes to any exposed service.
146
+ 7. Keep JSON output throughout so stages chain cleanly (`subfinder` → `dig` → `httpx` → `naabu`).
147
+
148
+ ## Summary
149
+
150
+ Broad passive discovery — CT + TLS SAN pivoting + passive DNS + ASN/IP mapping, looped until convergence — finds the assets brute force misses, especially internal-named and forgotten services leaked through certificates. Build the inventory with `subfinder`, `httpx`, `naabu`, and CT/DNS/cert queries, probe and classify it generically, then route each interesting asset to the specialist skill for its class.