ineedcodes 1.6.0 → 1.7.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.
- package/package.json +2 -1
- package/skills/401-403-bypass-techniques/SKILL.md +348 -0
- package/skills/active-directory-acl-abuse/BLOODHOUND_PATHS.md +281 -0
- package/skills/active-directory-acl-abuse/SKILL.md +295 -0
- package/skills/active-directory-certificate-services/ADCS_ESC_MATRIX.md +197 -0
- package/skills/active-directory-certificate-services/SKILL.md +303 -0
- package/skills/active-directory-kerberos-attacks/KERBEROS_ATTACK_CHAINS.md +226 -0
- package/skills/active-directory-kerberos-attacks/SKILL.md +311 -0
- package/skills/ai-ml-security/SKILL.md +425 -0
- package/skills/android-pentesting-tricks/FRIDA_SCRIPTS.md +394 -0
- package/skills/android-pentesting-tricks/SKILL.md +369 -0
- package/skills/anti-debugging-techniques/ANTI_DEBUG_MATRIX.md +117 -0
- package/skills/anti-debugging-techniques/SKILL.md +407 -0
- package/skills/api-auth-and-jwt-abuse/SKILL.md +76 -0
- package/skills/api-authorization-and-bola/SKILL.md +48 -0
- package/skills/api-recon-and-docs/SKILL.md +61 -0
- package/skills/api-sec/SKILL.md +49 -0
- package/skills/arbitrary-write-to-rce/SKILL.md +361 -0
- package/skills/auth-sec/SKILL.md +41 -0
- package/skills/authbypass-authentication-flaws/SKILL.md +441 -0
- package/skills/bba-ad-attacker/SKILL.md +420 -0
- package/skills/bba-api-security/SKILL.md +95 -0
- package/skills/bba-attack-planner/SKILL.md +186 -0
- package/skills/bba-binary-exploit/SKILL.md +65 -0
- package/skills/bba-bizlogic-hunter/SKILL.md +304 -0
- package/skills/bba-bug-bounty/SKILL.md +245 -0
- package/skills/bba-cicd-redteam/SKILL.md +515 -0
- package/skills/bba-cloud-security/SKILL.md +97 -0
- package/skills/bba-container-escape/SKILL.md +161 -0
- package/skills/bba-credential-tester/SKILL.md +346 -0
- package/skills/bba-crypto-analyst/SKILL.md +54 -0
- package/skills/bba-ctf-solver/SKILL.md +166 -0
- package/skills/bba-detection-engineer/SKILL.md +93 -0
- package/skills/bba-engagement-planner/SKILL.md +68 -0
- package/skills/bba-exploit-chainer/SKILL.md +280 -0
- package/skills/bba-exploit-guide/SKILL.md +96 -0
- package/skills/bba-forensics-analyst/SKILL.md +512 -0
- package/skills/bba-graphql-hunter/SKILL.md +145 -0
- package/skills/bba-hardware-hacker/SKILL.md +57 -0
- package/skills/bba-jwt-cracker/SKILL.md +133 -0
- package/skills/bba-llm-redteam/SKILL.md +149 -0
- package/skills/bba-malware-analyst/SKILL.md +305 -0
- package/skills/bba-mobile-pentester/SKILL.md +350 -0
- package/skills/bba-osint-collector/SKILL.md +645 -0
- package/skills/bba-payload-crafter/SKILL.md +347 -0
- package/skills/bba-phishing-operator/SKILL.md +516 -0
- package/skills/bba-poc-validator/SKILL.md +249 -0
- package/skills/bba-privesc-advisor/SKILL.md +98 -0
- package/skills/bba-purple-team/SKILL.md +56 -0
- package/skills/bba-recon-advisor/SKILL.md +215 -0
- package/skills/bba-red-team-operator/SKILL.md +61 -0
- package/skills/bba-report-generator/SKILL.md +145 -0
- package/skills/bba-reverse-engineer/SKILL.md +298 -0
- package/skills/bba-social-engineer/SKILL.md +341 -0
- package/skills/bba-ssrf-hunter/SKILL.md +120 -0
- package/skills/bba-stig-analyst/SKILL.md +108 -0
- package/skills/bba-subdomain-takeover/SKILL.md +141 -0
- package/skills/bba-swarm-orchestrator/SKILL.md +351 -0
- package/skills/bba-threat-modeler/SKILL.md +574 -0
- package/skills/bba-vuln-scanner/SKILL.md +305 -0
- package/skills/bba-web-hunter/SKILL.md +285 -0
- package/skills/bba-wireless-pentester/SKILL.md +539 -0
- package/skills/binary-protection-bypass/PROTECTION_BYPASS_MATRIX.md +168 -0
- package/skills/binary-protection-bypass/SKILL.md +295 -0
- package/skills/browser-exploitation-v8/SKILL.md +334 -0
- package/skills/browser-exploitation-v8/V8_EXPLOITATION_PATTERNS.md +288 -0
- package/skills/business-logic-vuln/SKILL.md +33 -0
- package/skills/business-logic-vulnerabilities/CHECKLIST.md +375 -0
- package/skills/business-logic-vulnerabilities/METHODOLOGY.md +337 -0
- package/skills/business-logic-vulnerabilities/SCENARIOS.md +1095 -0
- package/skills/business-logic-vulnerabilities/SKILL.md +711 -0
- package/skills/classical-cipher-analysis/SKILL.md +663 -0
- package/skills/clickjacking/SKILL.md +163 -0
- package/skills/cmdi-command-injection/SKILL.md +687 -0
- package/skills/code-obfuscation-deobfuscation/SKILL.md +391 -0
- package/skills/container-escape-techniques/DOCKER_ESCAPE_CHAINS.md +296 -0
- package/skills/container-escape-techniques/SKILL.md +339 -0
- package/skills/cors-cross-origin-misconfiguration/SCENARIOS.md +152 -0
- package/skills/cors-cross-origin-misconfiguration/SKILL.md +270 -0
- package/skills/crlf-injection/SKILL.md +179 -0
- package/skills/csp-bypass-advanced/SKILL.md +259 -0
- package/skills/csrf-cross-site-request-forgery/SKILL.md +526 -0
- package/skills/csv-formula-injection/SKILL.md +144 -0
- package/skills/dangling-markup-injection/SKILL.md +321 -0
- package/skills/defi-attack-patterns/SKILL.md +355 -0
- package/skills/dependency-confusion/SKILL.md +178 -0
- package/skills/deserialization-insecure/JAVA_GADGET_CHAINS.md +511 -0
- package/skills/deserialization-insecure/SKILL.md +725 -0
- package/skills/dns-rebinding-attacks/SKILL.md +337 -0
- package/skills/email-header-injection/SKILL.md +349 -0
- package/skills/expression-language-injection/SKILL.md +243 -0
- package/skills/file-access-vuln/SKILL.md +33 -0
- package/skills/format-string-exploitation/SKILL.md +312 -0
- package/skills/ghost-bits-cast-attack/PAYLOAD_COOKBOOK.md +448 -0
- package/skills/ghost-bits-cast-attack/SKILL.md +799 -0
- package/skills/graphql-and-hidden-parameters/SKILL.md +50 -0
- package/skills/hack/SKILL.md +162 -0
- package/skills/hash-attack-techniques/SKILL.md +491 -0
- package/skills/heap-exploitation/HOUSE_OF_TECHNIQUES.md +244 -0
- package/skills/heap-exploitation/IO_FILE_EXPLOITATION.md +256 -0
- package/skills/heap-exploitation/SKILL.md +217 -0
- package/skills/http-host-header-attacks/SKILL.md +323 -0
- package/skills/http-parameter-pollution/SKILL.md +208 -0
- package/skills/http2-specific-attacks/SKILL.md +350 -0
- package/skills/idor-broken-object-authorization/SKILL.md +336 -0
- package/skills/injection-checking/EXTRA_INJECTION_TYPES.md +450 -0
- package/skills/injection-checking/SKILL.md +50 -0
- package/skills/insecure-source-code-management/SKILL.md +161 -0
- package/skills/ios-pentesting-tricks/IOS_RUNTIME_TRICKS.md +411 -0
- package/skills/ios-pentesting-tricks/SKILL.md +418 -0
- package/skills/jndi-injection/SKILL.md +265 -0
- package/skills/jwt-oauth-token-attacks/SKILL.md +301 -0
- package/skills/kernel-exploitation/KERNEL_HEAP_TECHNIQUES.md +293 -0
- package/skills/kernel-exploitation/KERNEL_MITIGATION_BYPASS.md +224 -0
- package/skills/kernel-exploitation/SKILL.md +307 -0
- package/skills/kubernetes-pentesting/SKILL.md +348 -0
- package/skills/lattice-crypto-attacks/SKILL.md +497 -0
- package/skills/linux-lateral-movement/SKILL.md +348 -0
- package/skills/linux-privilege-escalation/KERNEL_EXPLOITS_CHECKLIST.md +260 -0
- package/skills/linux-privilege-escalation/SKILL.md +346 -0
- package/skills/linux-privilege-escalation/SUID_CAPABILITIES_TRICKS.md +305 -0
- package/skills/linux-security-bypass/SKILL.md +345 -0
- package/skills/llm-prompt-injection/JAILBREAK_PATTERNS.md +306 -0
- package/skills/llm-prompt-injection/SKILL.md +357 -0
- package/skills/macos-process-injection/DYLIB_XPC_TECHNIQUES.md +373 -0
- package/skills/macos-process-injection/SKILL.md +384 -0
- package/skills/macos-security-bypass/SKILL.md +337 -0
- package/skills/macos-security-bypass/TCC_BYPASS_MATRIX.md +200 -0
- package/skills/memory-forensics-volatility/SKILL.md +323 -0
- package/skills/memory-forensics-volatility/VOLATILITY_CHEATSHEET.md +225 -0
- package/skills/mobile-ssl-pinning-bypass/SKILL.md +531 -0
- package/skills/network-protocol-attacks/NAME_RESOLUTION_POISONING.md +226 -0
- package/skills/network-protocol-attacks/SKILL.md +330 -0
- package/skills/nosql-injection/SKILL.md +341 -0
- package/skills/ntlm-relay-coercion/COERCION_METHODS.md +253 -0
- package/skills/ntlm-relay-coercion/SKILL.md +267 -0
- package/skills/oauth-oidc-misconfiguration/SKILL.md +46 -0
- package/skills/open-redirect/SKILL.md +380 -0
- package/skills/path-traversal-lfi/SKILL.md +802 -0
- package/skills/prototype-pollution/SKILL.md +190 -0
- package/skills/prototype-pollution-advanced/KNOWN_GADGETS.md +253 -0
- package/skills/prototype-pollution-advanced/SKILL.md +338 -0
- package/skills/race-condition/SKILL.md +526 -0
- package/skills/recon-and-methodology/SKILL.md +389 -0
- package/skills/recon-for-sec/SKILL.md +29 -0
- package/skills/request-smuggling/H2_SMUGGLING_VARIANTS.md +498 -0
- package/skills/request-smuggling/SKILL.md +314 -0
- package/skills/reverse-shell-techniques/SHELL_CHEATSHEET.md +196 -0
- package/skills/reverse-shell-techniques/SKILL.md +290 -0
- package/skills/rsa-attack-techniques/RSA_ATTACK_CATALOG.md +432 -0
- package/skills/rsa-attack-techniques/SKILL.md +437 -0
- package/skills/saml-sso-assertion-attacks/SKILL.md +41 -0
- package/skills/sandbox-escape-techniques/PYTHON_SANDBOX_ESCAPE.md +349 -0
- package/skills/sandbox-escape-techniques/SECCOMP_BYPASS.md +332 -0
- package/skills/sandbox-escape-techniques/SKILL.md +250 -0
- package/skills/smart-contract-vulnerabilities/SKILL.md +314 -0
- package/skills/smart-contract-vulnerabilities/SOLIDITY_VULN_PATTERNS.md +460 -0
- package/skills/sqli-sql-injection/SCENARIOS.md +575 -0
- package/skills/sqli-sql-injection/SKILL.md +489 -0
- package/skills/sqli-sql-injection/SQLMAP_ADVANCED.md +642 -0
- package/skills/ssrf-server-side-request-forgery/SCENARIOS.md +226 -0
- package/skills/ssrf-server-side-request-forgery/SKILL.md +323 -0
- package/skills/ssrf-server-side-request-forgery/URL_PARSER_TRICKS.md +650 -0
- package/skills/ssti-server-side-template-injection/ENGINE_PAYLOADS.md +456 -0
- package/skills/ssti-server-side-template-injection/SCENARIOS.md +319 -0
- package/skills/ssti-server-side-template-injection/SKILL.md +344 -0
- package/skills/stack-overflow-and-rop/ROP_ADVANCED_TECHNIQUES.md +249 -0
- package/skills/stack-overflow-and-rop/SKILL.md +304 -0
- package/skills/steganography-techniques/SKILL.md +348 -0
- package/skills/steganography-techniques/STEGO_TOOLS_GUIDE.md +335 -0
- package/skills/subdomain-takeover/SKILL.md +247 -0
- package/skills/symbolic-execution-tools/ANGR_COOKBOOK.md +437 -0
- package/skills/symbolic-execution-tools/SKILL.md +419 -0
- package/skills/symmetric-cipher-attacks/BLOCK_CIPHER_ATTACKS.md +364 -0
- package/skills/symmetric-cipher-attacks/SKILL.md +462 -0
- package/skills/traffic-analysis-pcap/SKILL.md +341 -0
- package/skills/tunneling-and-pivoting/SKILL.md +343 -0
- package/skills/type-juggling/SKILL.md +291 -0
- package/skills/unauthorized-access-common-services/PORT_SERVICE_MATRIX.md +340 -0
- package/skills/unauthorized-access-common-services/SKILL.md +388 -0
- package/skills/upload-insecure-files/SCENARIOS.md +158 -0
- package/skills/upload-insecure-files/SKILL.md +543 -0
- package/skills/vm-and-bytecode-reverse/SKILL.md +450 -0
- package/skills/vr-cheatsheet-authentication_bypass/SKILL.md +184 -0
- package/skills/vr-cheatsheet-dangerous_functions/SKILL.md +200 -0
- package/skills/vr-cheatsheet-linux_commands/SKILL.md +40 -0
- package/skills/vr-cheatsheet-rce/SKILL.md +177 -0
- package/skills/vr-cheatsheet-reverse_engineering/SKILL.md +144 -0
- package/skills/vr-cheatsheet-sqli/SKILL.md +270 -0
- package/skills/vr-cheatsheet-ssrf/SKILL.md +173 -0
- package/skills/vr-cheatsheet-xss/SKILL.md +177 -0
- package/skills/vr-methodology-mindset_and_tips/SKILL.md +51 -0
- package/skills/vr-template-vulnerability_report_template/SKILL.md +59 -0
- package/skills/vr-writeup-CVE-2026-9136/SKILL.md +171 -0
- package/skills/vr-writeup-ZVE-2026-3795/SKILL.md +350 -0
- package/skills/vr-writeup-api_key_leak/SKILL.md +103 -0
- package/skills/waf-bypass-techniques/SKILL.md +290 -0
- package/skills/waf-bypass-techniques/WAF_PRODUCT_MATRIX.md +202 -0
- package/skills/web-cache-deception/CACHE_POISONING_TECHNIQUES.md +637 -0
- package/skills/web-cache-deception/SKILL.md +222 -0
- package/skills/websocket-security/SKILL.md +454 -0
- package/skills/windows-av-evasion/AMSI_BYPASS_TECHNIQUES.md +289 -0
- package/skills/windows-av-evasion/SKILL.md +342 -0
- package/skills/windows-lateral-movement/CREDENTIAL_DUMPING.md +308 -0
- package/skills/windows-lateral-movement/SKILL.md +335 -0
- package/skills/windows-privilege-escalation/SKILL.md +328 -0
- package/skills/windows-privilege-escalation/TOKEN_POTATO_TRICKS.md +216 -0
- package/skills/windows-privilege-escalation/UAC_BYPASS_METHODS.md +225 -0
- package/skills/xslt-injection/SKILL.md +281 -0
- package/skills/xss-cross-site-scripting/ADVANCED_XSS_TRICKS.md +276 -0
- package/skills/xss-cross-site-scripting/SCENARIOS.md +278 -0
- package/skills/xss-cross-site-scripting/SKILL.md +379 -0
- package/skills/xxe-xml-external-entity/SCENARIOS.md +112 -0
- package/skills/xxe-xml-external-entity/SKILL.md +554 -0
- package/src/agent.js +1 -1
- package/src/session.js +47 -11
- package/src/skills.js +30 -6
- package/src/ui.js +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: graphql-and-hidden-parameters
|
|
3
|
+
description: >-
|
|
4
|
+
GraphQL and hidden parameter testing playbook. Use when exploring introspection, batching, undocumented fields, hidden parameters, schema abuse, and GraphQL authorization gaps.gated: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# SKILL: GraphQL and Hidden Parameters — Introspection, Batching, and Undocumented Fields
|
|
8
|
+
|
|
9
|
+
> **AI LOAD INSTRUCTION**: Use this skill when GraphQL exists or when REST documentation suggests optional, deprecated, or undocumented fields. Focus on schema discovery, hidden parameter abuse, and batching as a force multiplier.
|
|
10
|
+
|
|
11
|
+
## 1. GRAPHQL FIRST PASS
|
|
12
|
+
|
|
13
|
+
```graphql
|
|
14
|
+
query { __typename }
|
|
15
|
+
query {
|
|
16
|
+
__schema {
|
|
17
|
+
types { name }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
If introspection is restricted, continue with:
|
|
23
|
+
|
|
24
|
+
- field suggestions and error-based discovery
|
|
25
|
+
- known type probes like `__type(name: "User")`
|
|
26
|
+
- JS and mobile bundle route extraction
|
|
27
|
+
|
|
28
|
+
## 2. HIGH-VALUE GRAPHQL TESTS
|
|
29
|
+
|
|
30
|
+
| Theme | Example |
|
|
31
|
+
|---|---|
|
|
32
|
+
| IDOR | `user(id: "victim")` |
|
|
33
|
+
| batching | array of login or object fetch operations |
|
|
34
|
+
| hidden fields | admin-only fields exposed in type definitions |
|
|
35
|
+
| nested authz gaps | related object fields with weaker checks |
|
|
36
|
+
|
|
37
|
+
## 3. HIDDEN PARAMETER DISCOVERY
|
|
38
|
+
|
|
39
|
+
Look for:
|
|
40
|
+
|
|
41
|
+
- fields present in admin docs but not public docs
|
|
42
|
+
- `additionalProperties` or permissive schemas
|
|
43
|
+
- frontend code using richer request bodies than visible UI controls
|
|
44
|
+
- mobile endpoints carrying role, org, feature-flag, or internal filter fields
|
|
45
|
+
|
|
46
|
+
## 4. NEXT ROUTING
|
|
47
|
+
|
|
48
|
+
- If hidden fields affect privilege: [api authorization and bola](../api-authorization-and-bola/SKILL.md)
|
|
49
|
+
- If GraphQL batching changes auth or rate behavior: [api auth and jwt abuse](../api-auth-and-jwt-abuse/SKILL.md)
|
|
50
|
+
- If endpoint discovery is incomplete: [api recon and docs](../api-recon-and-docs/SKILL.md)
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hack
|
|
3
|
+
description: >-
|
|
4
|
+
Entry P0 primary router for HackSkills. Use when the task involves web
|
|
5
|
+
application testing, API security assessment, recon, vulnerability triage,
|
|
6
|
+
exploit path planning, or choosing the right next category skill before any
|
|
7
|
+
deep topic skill.gated: true
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# HACKING SKILLS / HackSkills
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
This is a top-level routing skill for **bug bounty, web security, API security, and authorized penetration testing**.
|
|
15
|
+
|
|
16
|
+
Its core role is not to replace all specialized techniques, but to help the agent:
|
|
17
|
+
|
|
18
|
+
1. First determine the testing phase (Recon / Validation / Privilege Escalation / Chain building)
|
|
19
|
+
2. Then select the correct vulnerability category
|
|
20
|
+
3. Avoid relying only on baseline model memory; prefer structured methodology
|
|
21
|
+
4. Prioritize boundary conditions AI often misses but that matter in real engagements
|
|
22
|
+
|
|
23
|
+
## Trust Model
|
|
24
|
+
|
|
25
|
+
- This knowledge base emphasizes content safety and auditability.
|
|
26
|
+
- Use this only within **authorized targets**, **legitimate research**, **defensive validation**, and **bug-bounty-approved rules**.
|
|
27
|
+
- Do not use these techniques for unauthorized attacks.
|
|
28
|
+
|
|
29
|
+
## When to Use This Skill
|
|
30
|
+
|
|
31
|
+
Use this skill first in the following scenarios:
|
|
32
|
+
|
|
33
|
+
- You just received a new bug bounty target and do not know where to start
|
|
34
|
+
- You need to decide whether to load XSS / SQLi / SSRF / IDOR / JWT / API tracks first
|
|
35
|
+
- You want the agent to perform Web/API security testing with a more stable methodology
|
|
36
|
+
- You need to route scattered findings to the right attack surface
|
|
37
|
+
- You want AI to miss fewer critical test points in security work
|
|
38
|
+
|
|
39
|
+
## Operating Model
|
|
40
|
+
|
|
41
|
+
### Step 1: Start with Recon and context validation
|
|
42
|
+
|
|
43
|
+
Collect first:
|
|
44
|
+
|
|
45
|
+
- Target type: classic web, REST API, mobile backend, admin panel, payment flow, file upload, GraphQL
|
|
46
|
+
- Identity and permission model: anonymous, regular user, admin, multi-tenant
|
|
47
|
+
- Input locations: URL, query parameters, JSON, headers, cookies, filenames, imported files, templates, reflection points
|
|
48
|
+
- Output locations: HTML, attributes, JS, PDF, email, logs, background tasks, mobile endpoints
|
|
49
|
+
|
|
50
|
+
### Step 2: Route by observed behavior
|
|
51
|
+
|
|
52
|
+
| Signal | Priority direction |
|
|
53
|
+
|---|---|
|
|
54
|
+
| Input reflects into HTML / JS | XSS / SSTI |
|
|
55
|
+
| Server actively fetches URL / hostname | SSRF |
|
|
56
|
+
| Accepts XML / Office / SVG | XXE |
|
|
57
|
+
| Path, filename, or download endpoint is controllable | Path Traversal / LFI |
|
|
58
|
+
| Many object IDs appear in APIs | IDOR / BOLA / BFLA |
|
|
59
|
+
| Login, reset password, 2FA, sessions | Auth Bypass / JWT / OAuth |
|
|
60
|
+
| Multi-step transactions, coupons, pricing, inventory | Business Logic |
|
|
61
|
+
| MongoDB / JSON query syntax exposure | NoSQL Injection |
|
|
62
|
+
| CLI tools, image processing, importers | Command Injection |
|
|
63
|
+
| HTTP parsing anomalies / front-back framing mismatch | Request Smuggling |
|
|
64
|
+
| Node.js JSON handling / controllable `__proto__` | Prototype Pollution |
|
|
65
|
+
| PHP weak comparison / 0e hash / loose conditions | Type Juggling |
|
|
66
|
+
| Repeated parameter names / WAF-app parsing mismatch | HTTP Parameter Pollution |
|
|
67
|
+
| One-time operations (coupon/inventory/reset) | Race Condition |
|
|
68
|
+
| XML/XSLT template processing | XSLT Injection |
|
|
69
|
+
| Accessible .git/.svn/.env paths | Insecure SCM |
|
|
70
|
+
| CSV/Excel export features | CSV Formula Injection |
|
|
71
|
+
| WebSocket protocol upgrades | WebSocket Security |
|
|
72
|
+
| Internal package names / supply-chain inventory | Dependency Confusion |
|
|
73
|
+
|
|
74
|
+
### Step 3: Use the most likely-hit testing order
|
|
75
|
+
|
|
76
|
+
1. Recon / Methodology
|
|
77
|
+
2. API Security / Auth / IDOR
|
|
78
|
+
3. XSS / SQLi / SSRF / SSTI / XXE
|
|
79
|
+
4. Business Logic / Race Condition
|
|
80
|
+
5. Chained exploits and privilege-escalation paths
|
|
81
|
+
|
|
82
|
+
## Core Skill Map
|
|
83
|
+
|
|
84
|
+
If you have the full repository, prioritize using these topic documents together:
|
|
85
|
+
|
|
86
|
+
- [Recon and Methodology](../recon-and-methodology/SKILL.md)
|
|
87
|
+
- [XSS Cross Site Scripting](../xss-cross-site-scripting/SKILL.md)
|
|
88
|
+
- [SQLi SQL Injection](../sqli-sql-injection/SKILL.md)
|
|
89
|
+
- [SSRF Server Side Request Forgery](../ssrf-server-side-request-forgery/SKILL.md)
|
|
90
|
+
- [XXE XML External Entity](../xxe-xml-external-entity/SKILL.md)
|
|
91
|
+
- [SSTI Server Side Template Injection](../ssti-server-side-template-injection/SKILL.md)
|
|
92
|
+
- [IDOR Broken Object Authorization](../idor-broken-object-authorization/SKILL.md)
|
|
93
|
+
- [CMDi Command Injection](../cmdi-command-injection/SKILL.md)
|
|
94
|
+
- [Path Traversal LFI](../path-traversal-lfi/SKILL.md)
|
|
95
|
+
- [CSRF Cross Site Request Forgery](../csrf-cross-site-request-forgery/SKILL.md)
|
|
96
|
+
- [API Security Router](../api-sec/SKILL.md)
|
|
97
|
+
- [JWT OAuth Token Attacks](../jwt-oauth-token-attacks/SKILL.md)
|
|
98
|
+
- [OAuth OIDC Misconfiguration](../oauth-oidc-misconfiguration/SKILL.md)
|
|
99
|
+
- [CORS Cross Origin Misconfiguration](../cors-cross-origin-misconfiguration/SKILL.md)
|
|
100
|
+
- [SAML SSO Assertion Attacks](../saml-sso-assertion-attacks/SKILL.md)
|
|
101
|
+
- [Authentication Bypass](../authbypass-authentication-flaws/SKILL.md)
|
|
102
|
+
- [Business Logic Vulnerabilities](../business-logic-vulnerabilities/SKILL.md)
|
|
103
|
+
- [Upload Insecure Files](../upload-insecure-files/SKILL.md)
|
|
104
|
+
- [NoSQL Injection](../nosql-injection/SKILL.md)
|
|
105
|
+
- [Request Smuggling](../request-smuggling/SKILL.md)
|
|
106
|
+
- [Prototype Pollution](../prototype-pollution/SKILL.md)
|
|
107
|
+
- [Type Juggling (PHP)](../type-juggling/SKILL.md)
|
|
108
|
+
- [HTTP Parameter Pollution](../http-parameter-pollution/SKILL.md)
|
|
109
|
+
- [Race Condition](../race-condition/SKILL.md)
|
|
110
|
+
- [XSLT Injection](../xslt-injection/SKILL.md)
|
|
111
|
+
- [Insecure Source Code Management](../insecure-source-code-management/SKILL.md)
|
|
112
|
+
- [CSV Formula Injection](../csv-formula-injection/SKILL.md)
|
|
113
|
+
- [WebSocket Security](../websocket-security/SKILL.md)
|
|
114
|
+
- [Dependency Confusion](../dependency-confusion/SKILL.md)
|
|
115
|
+
- [Ghost Bits Cast Attack](../ghost-bits-cast-attack/SKILL.md)
|
|
116
|
+
|
|
117
|
+
Previously separate mini skills such as payload-selection and brute-selection were merged back into their main skills to avoid router overload and selection noise.
|
|
118
|
+
|
|
119
|
+
## High-Value Expert Intuitions
|
|
120
|
+
|
|
121
|
+
These are points many baseline models miss, but they are frequently effective in real bug bounty work:
|
|
122
|
+
|
|
123
|
+
1. **The same filtering logic is often reused across multiple pages**: if one point is bypassable, similar pages usually are too.
|
|
124
|
+
2. **Parameter names are an attack surface too**: WAFs often inspect values but not names.
|
|
125
|
+
3. **Second-order vulnerabilities are common**: safe at storage time does not mean safe when later read into a dangerous context.
|
|
126
|
+
4. **BOLA is fundamentally 'authenticated but unauthorized'**: replaying with account A/B switching is critical.
|
|
127
|
+
5. **Older API versions are most likely to miss patches**: fixing v2 does not mean v1 was retired.
|
|
128
|
+
6. **Business-logic vulnerabilities often bring highest impact**: scanners miss them and they persist longer.
|
|
129
|
+
7. **Race conditions should prioritize one-time actions**: coupon redemption, claims, resets, invites, trials, inventory deduction.
|
|
130
|
+
8. **For JWT attacks, check key and algorithm context first**: do not blindly spray payloads; verify `alg`, `kid`, JWKS, and key source first.
|
|
131
|
+
|
|
132
|
+
## Suggested Prompts
|
|
133
|
+
|
|
134
|
+
Use this skill as a router to make the agent clarify phase and goal first:
|
|
135
|
+
|
|
136
|
+
- "First, plan the testing route for this target using bug bounty methodology.
|
|
137
|
+
- "This is a REST API; prioritize BOLA, BFLA, Mass Assignment, and JWT angles.
|
|
138
|
+
- "This parameter triggers server-side requests; list key validation points from an SSRF perspective.
|
|
139
|
+
- "This feature is a payment/coupon/inventory flow; prioritize business logic and race-condition analysis.
|
|
140
|
+
- "I only see login and password-reset flows; analyze via Auth Bypass + OAuth/JWT + CSRF.
|
|
141
|
+
|
|
142
|
+
## Installation Notes
|
|
143
|
+
|
|
144
|
+
Recommended skill name:
|
|
145
|
+
|
|
146
|
+
- `hack`
|
|
147
|
+
|
|
148
|
+
Recommended search keywords:
|
|
149
|
+
|
|
150
|
+
- `HackSkills`
|
|
151
|
+
- `HACKING SKILLS`
|
|
152
|
+
- `bug bounty`
|
|
153
|
+
- `bug bounty hunter`
|
|
154
|
+
|
|
155
|
+
## Guidelines
|
|
156
|
+
|
|
157
|
+
- Prioritize routing by target type and observed behavior, not random payload enumeration.
|
|
158
|
+
- When payloads are needed, prefer quick-start / first-pass samples in the corresponding main skill instead of adding another intermediate router.
|
|
159
|
+
- Prioritize reusable filters, shared components, and cross-page reproduction paths.
|
|
160
|
+
- Confirm authentication, authorization, and version boundaries before deeper exploitation.
|
|
161
|
+
- Preserve explainable, auditable, reproducible testing processes.
|
|
162
|
+
- When full repository context is available, return to topic documents for finer exploitation details.
|
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hash-attack-techniques
|
|
3
|
+
description: >-
|
|
4
|
+
Hash attack playbook. Use when exploiting length extension, MD5/SHA1
|
|
5
|
+
collisions, HMAC timing leaks, birthday attacks, or hash-based proof
|
|
6
|
+
of work in CTF and authorized testing scenarios.gated: true
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# SKILL: Hash Attack Techniques — Expert Cryptanalysis Playbook
|
|
10
|
+
|
|
11
|
+
> **AI LOAD INSTRUCTION**: Expert hash attack techniques for CTF and security assessments. Covers length extension attacks, MD5/SHA1 collision generation, meet-in-the-middle hash attacks, HMAC timing side channels, birthday attacks, and proof-of-work solving. Base models often incorrectly apply length extension to HMAC or SHA-3, or fail to distinguish between identical-prefix and chosen-prefix collisions.
|
|
12
|
+
|
|
13
|
+
## 0. RELATED ROUTING
|
|
14
|
+
|
|
15
|
+
- [rsa-attack-techniques](../rsa-attack-techniques/SKILL.md) when hash weaknesses affect RSA signature schemes
|
|
16
|
+
- [symmetric-cipher-attacks](../symmetric-cipher-attacks/SKILL.md) when hash is used in key derivation
|
|
17
|
+
- [classical-cipher-analysis](../classical-cipher-analysis/SKILL.md) when analyzing hash-like constructions in classical ciphers
|
|
18
|
+
|
|
19
|
+
### Quick attack selection
|
|
20
|
+
|
|
21
|
+
| Scenario | Attack | Tool |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| `H(secret \|\| msg)` known, extend message | Length extension | HashPump, hash_extender |
|
|
24
|
+
| Need two files with same MD5 | Identical-prefix collision | fastcoll |
|
|
25
|
+
| Need specific MD5 prefix match | Chosen-prefix collision | hashclash |
|
|
26
|
+
| Byte-by-byte HMAC comparison | Timing attack | Custom script |
|
|
27
|
+
| Find any collision | Birthday attack | O(2^(n/2)) |
|
|
28
|
+
| Proof of work: find hash with leading zeros | Brute force | hashcat, Python |
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 1. LENGTH EXTENSION ATTACK
|
|
33
|
+
|
|
34
|
+
### 1.1 Vulnerable vs Non-Vulnerable
|
|
35
|
+
|
|
36
|
+
| Hash | Vulnerable | Why |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| MD5 | Yes | Merkle-Damgard construction |
|
|
39
|
+
| SHA-1 | Yes | Merkle-Damgard construction |
|
|
40
|
+
| SHA-256 | Yes | Merkle-Damgard construction |
|
|
41
|
+
| SHA-512 | Yes | Merkle-Damgard construction |
|
|
42
|
+
| SHA-3 / Keccak | No | Sponge construction |
|
|
43
|
+
| HMAC-* | No | Double hashing prevents extension |
|
|
44
|
+
| SHA-256 truncated | No (if truncated) | Missing internal state bits |
|
|
45
|
+
| BLAKE2 | No | Different construction |
|
|
46
|
+
|
|
47
|
+
### 1.2 Attack Mechanism
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
Given: MAC = H(secret || original_message)
|
|
51
|
+
Known: original_message, len(secret), MAC value
|
|
52
|
+
Compute: H(secret || original_message || padding || extension)
|
|
53
|
+
WITHOUT knowing the secret!
|
|
54
|
+
|
|
55
|
+
How: The MAC value IS the internal hash state after processing
|
|
56
|
+
(secret || original_message || padding).
|
|
57
|
+
Initialize hash with this state, continue hashing extension.
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 1.3 Padding Calculation (MD5/SHA)
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
def md5_padding(message_len_bytes):
|
|
64
|
+
"""Calculate MD5/SHA padding for given message length."""
|
|
65
|
+
bit_len = message_len_bytes * 8
|
|
66
|
+
|
|
67
|
+
# Pad with 0x80 + zeros until length ≡ 56 (mod 64)
|
|
68
|
+
padding = b'\x80'
|
|
69
|
+
padding += b'\x00' * ((55 - message_len_bytes) % 64)
|
|
70
|
+
|
|
71
|
+
# Append original length as 64-bit little-endian (MD5)
|
|
72
|
+
# or big-endian (SHA)
|
|
73
|
+
padding += bit_len.to_bytes(8, 'little') # MD5
|
|
74
|
+
# padding += bit_len.to_bytes(8, 'big') # SHA
|
|
75
|
+
|
|
76
|
+
return padding
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 1.4 Tool Usage
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# HashPump
|
|
83
|
+
hashpump -s "known_mac_hex" \
|
|
84
|
+
-d "original_data" \
|
|
85
|
+
-k 16 \ # secret length
|
|
86
|
+
-a "extension_data"
|
|
87
|
+
|
|
88
|
+
# Output: new_mac, new_data (original + padding + extension)
|
|
89
|
+
|
|
90
|
+
# hash_extender
|
|
91
|
+
hash_extender --data "original" \
|
|
92
|
+
--secret 16 \
|
|
93
|
+
--append "extension" \
|
|
94
|
+
--signature "known_mac_hex" \
|
|
95
|
+
--format md5
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 1.5 Python Implementation
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
import struct
|
|
102
|
+
|
|
103
|
+
def md5_extend(original_mac, original_data_len, secret_len, extension):
|
|
104
|
+
"""
|
|
105
|
+
Perform MD5 length extension attack.
|
|
106
|
+
original_mac: hex string of H(secret || original_data)
|
|
107
|
+
"""
|
|
108
|
+
# Parse MAC into MD5 internal state (4 × 32-bit words, little-endian)
|
|
109
|
+
h = struct.unpack('<4I', bytes.fromhex(original_mac))
|
|
110
|
+
|
|
111
|
+
# Calculate total length after padding
|
|
112
|
+
total_original = secret_len + original_data_len
|
|
113
|
+
padding = md5_padding(total_original)
|
|
114
|
+
forged_len = total_original + len(padding) + len(extension)
|
|
115
|
+
|
|
116
|
+
# Continue MD5 from saved state with extension
|
|
117
|
+
# (requires MD5 implementation that accepts initial state)
|
|
118
|
+
from hashlib import md5
|
|
119
|
+
# Most stdlib md5 doesn't expose state setting
|
|
120
|
+
# Use: hlextend library or custom MD5
|
|
121
|
+
|
|
122
|
+
import hlextend
|
|
123
|
+
sha = hlextend.new('md5')
|
|
124
|
+
new_hash = sha.extend(extension, original_data, secret_len,
|
|
125
|
+
original_mac)
|
|
126
|
+
new_data = sha.payload # includes original + padding + extension
|
|
127
|
+
|
|
128
|
+
return new_hash, new_data
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 2. MD5 COLLISION ATTACKS
|
|
134
|
+
|
|
135
|
+
### 2.1 Identical-Prefix Collision (fastcoll)
|
|
136
|
+
|
|
137
|
+
Two messages with same prefix but different content, producing identical MD5.
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# Generate collision pair
|
|
141
|
+
fastcoll -p prefix_file -o collision1.bin collision2.bin
|
|
142
|
+
|
|
143
|
+
# Result: MD5(collision1.bin) == MD5(collision2.bin)
|
|
144
|
+
# Files differ in exactly 128 bytes (two MD5 blocks)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### 2.2 Chosen-Prefix Collision (hashclash)
|
|
148
|
+
|
|
149
|
+
Two messages with different chosen prefixes, appended with computed suffixes to collide.
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# hashclash (Marc Stevens)
|
|
153
|
+
./hashclash prefix1.bin prefix2.bin
|
|
154
|
+
|
|
155
|
+
# Result: MD5(prefix1 || suffix1) == MD5(prefix2 || suffix2)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 2.3 UniColl (Single-Block Near-Collision)
|
|
159
|
+
|
|
160
|
+
Produces two messages differing in a single byte within one MD5 block, with same hash.
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
Application: forge two PDF/PE files with same MD5
|
|
164
|
+
- File 1: benign content
|
|
165
|
+
- File 2: malicious content
|
|
166
|
+
- Same MD5 hash
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### 2.4 Collision Applications
|
|
170
|
+
|
|
171
|
+
| Application | Technique | Impact |
|
|
172
|
+
|---|---|---|
|
|
173
|
+
| Certificate forgery | Chosen-prefix | Rogue CA certificate (proven in 2008) |
|
|
174
|
+
| Binary substitution | Identical-prefix + conditional | Two executables, same MD5, different behavior |
|
|
175
|
+
| PDF collision | UniColl | Two PDFs showing different content |
|
|
176
|
+
| Git commit collision | Chosen-prefix (SHAttered for SHA1) | Two commits with same hash |
|
|
177
|
+
| CTF: bypass MD5 check | fastcoll | Two different inputs accepted as same |
|
|
178
|
+
|
|
179
|
+
### 2.5 CTF MD5 Collision Tricks
|
|
180
|
+
|
|
181
|
+
```php
|
|
182
|
+
// PHP: md5($_GET['a']) == md5($_GET['b']) && $_GET['a'] != $_GET['b']
|
|
183
|
+
|
|
184
|
+
// Method 1: Array trick (not real collision)
|
|
185
|
+
?a[]=1&b[]=2 // md5(array) returns NULL, NULL == NULL
|
|
186
|
+
|
|
187
|
+
// Method 2: Real collision (fastcoll output, URL-encoded binary)
|
|
188
|
+
?a=<collision1_urlencoded>&b=<collision2_urlencoded>
|
|
189
|
+
|
|
190
|
+
// Method 3: 0e magic hashes (loose comparison ==)
|
|
191
|
+
// md5("240610708") = "0e462097431906509019562988736854"
|
|
192
|
+
// md5("QNKCDZO") = "0e830400451993494058024219903391"
|
|
193
|
+
// PHP: "0e..." == "0e..." is TRUE (both evaluate to 0 as floats)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## 3. SHA-1 COLLISION
|
|
199
|
+
|
|
200
|
+
### 3.1 SHAttered Attack (2017)
|
|
201
|
+
|
|
202
|
+
First practical SHA-1 collision: two PDF files with same SHA-1.
|
|
203
|
+
|
|
204
|
+
- Complexity: ~2^63 SHA-1 computations
|
|
205
|
+
- Cost: ~$110K on GPU clusters (2017 prices)
|
|
206
|
+
- Tool: shattered.io provides the collision PDFs
|
|
207
|
+
|
|
208
|
+
### 3.2 SHA-1 Chosen-Prefix Collision (2020)
|
|
209
|
+
|
|
210
|
+
- Complexity: ~2^63.4 computations
|
|
211
|
+
- Practical for attacking PGP/GnuPG key servers
|
|
212
|
+
- Demonstrates SHA-1 is broken for collision resistance
|
|
213
|
+
|
|
214
|
+
### 3.3 Impact
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
SHA-1 should NOT be used for:
|
|
218
|
+
✗ Digital signatures
|
|
219
|
+
✗ Certificate fingerprints
|
|
220
|
+
✗ Git commit integrity (migration to SHA-256 in progress)
|
|
221
|
+
✗ Deduplication based on hash
|
|
222
|
+
|
|
223
|
+
SHA-1 is still OK for:
|
|
224
|
+
✓ HMAC-SHA1 (collision resistance not required)
|
|
225
|
+
✓ HKDF-SHA1 (PRF security suffices)
|
|
226
|
+
✓ Non-adversarial checksums
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## 4. BIRTHDAY ATTACK
|
|
232
|
+
|
|
233
|
+
### 4.1 Generic Birthday Bound
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
For n-bit hash: expected collisions after ~2^(n/2) hashes
|
|
237
|
+
|
|
238
|
+
Hash Bits Birthday bound
|
|
239
|
+
MD5 128 2^64
|
|
240
|
+
SHA-1 160 2^80
|
|
241
|
+
SHA-256 256 2^128
|
|
242
|
+
|
|
243
|
+
CTF application: if hash is truncated to k bits,
|
|
244
|
+
collision in ~2^(k/2) attempts
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### 4.2 Birthday Attack Implementation
|
|
248
|
+
|
|
249
|
+
```python
|
|
250
|
+
import hashlib
|
|
251
|
+
import os
|
|
252
|
+
|
|
253
|
+
def birthday_attack(hash_func, output_bits, max_attempts=2**28):
|
|
254
|
+
"""Find collision for truncated hash."""
|
|
255
|
+
mask = (1 << output_bits) - 1
|
|
256
|
+
seen = {}
|
|
257
|
+
|
|
258
|
+
for _ in range(max_attempts):
|
|
259
|
+
msg = os.urandom(16)
|
|
260
|
+
h = int(hash_func(msg).hexdigest(), 16) & mask
|
|
261
|
+
|
|
262
|
+
if h in seen and seen[h] != msg:
|
|
263
|
+
return seen[h], msg # collision!
|
|
264
|
+
seen[h] = msg
|
|
265
|
+
|
|
266
|
+
return None
|
|
267
|
+
|
|
268
|
+
# Example: find collision for first 32 bits of SHA-256
|
|
269
|
+
result = birthday_attack(hashlib.sha256, 32)
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## 5. HMAC TIMING ATTACK
|
|
275
|
+
|
|
276
|
+
### 5.1 Vulnerable Comparison
|
|
277
|
+
|
|
278
|
+
```python
|
|
279
|
+
# VULNERABLE: early-exit string comparison
|
|
280
|
+
def verify_hmac(received, expected):
|
|
281
|
+
return received == expected # Python == compares left to right
|
|
282
|
+
|
|
283
|
+
# The comparison may short-circuit on first differing byte,
|
|
284
|
+
# leaking timing information
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### 5.2 Attack Strategy
|
|
288
|
+
|
|
289
|
+
```python
|
|
290
|
+
import requests
|
|
291
|
+
import time
|
|
292
|
+
|
|
293
|
+
def hmac_timing_attack(url, data, hmac_len=32):
|
|
294
|
+
"""Byte-by-byte HMAC recovery via timing."""
|
|
295
|
+
known = ""
|
|
296
|
+
|
|
297
|
+
for pos in range(hmac_len * 2): # hex chars
|
|
298
|
+
best_char = ""
|
|
299
|
+
best_time = 0
|
|
300
|
+
|
|
301
|
+
for c in "0123456789abcdef":
|
|
302
|
+
candidate = known + c + "0" * (hmac_len * 2 - len(known) - 1)
|
|
303
|
+
times = []
|
|
304
|
+
|
|
305
|
+
for _ in range(50): # multiple samples for accuracy
|
|
306
|
+
start = time.perf_counter_ns()
|
|
307
|
+
requests.get(url, params={**data, "mac": candidate})
|
|
308
|
+
elapsed = time.perf_counter_ns() - start
|
|
309
|
+
times.append(elapsed)
|
|
310
|
+
|
|
311
|
+
avg_time = sorted(times)[len(times)//2] # median
|
|
312
|
+
if avg_time > best_time:
|
|
313
|
+
best_time = avg_time
|
|
314
|
+
best_char = c
|
|
315
|
+
|
|
316
|
+
known += best_char
|
|
317
|
+
print(f"Position {pos}: {known}")
|
|
318
|
+
|
|
319
|
+
return known
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### 5.3 Constant-Time Comparison (Defense)
|
|
323
|
+
|
|
324
|
+
```python
|
|
325
|
+
import hmac
|
|
326
|
+
|
|
327
|
+
# SECURE: constant-time comparison
|
|
328
|
+
def verify_hmac_secure(received, expected):
|
|
329
|
+
return hmac.compare_digest(received, expected)
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## 6. MEET-IN-THE-MIDDLE (HASH)
|
|
335
|
+
|
|
336
|
+
### 6.1 Concept
|
|
337
|
+
|
|
338
|
+
Split hash computation into two halves, precompute one, match against the other.
|
|
339
|
+
|
|
340
|
+
```
|
|
341
|
+
Hash computation: H = f(g(x₁), h(x₂))
|
|
342
|
+
|
|
343
|
+
Precompute: table[g(x₁)] = x₁ for all x₁ in space₁
|
|
344
|
+
Search: for each x₂ in space₂:
|
|
345
|
+
if h(x₂) in table:
|
|
346
|
+
found! (x₁, x₂)
|
|
347
|
+
|
|
348
|
+
Time: O(2^(n/2)) instead of O(2^n)
|
|
349
|
+
Space: O(2^(n/2))
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## 7. HASH PROOF-OF-WORK
|
|
355
|
+
|
|
356
|
+
### 7.1 Common CTF PoW Formats
|
|
357
|
+
|
|
358
|
+
```python
|
|
359
|
+
# Format 1: Find x such that SHA256(prefix + x) starts with N zero bits
|
|
360
|
+
import hashlib
|
|
361
|
+
|
|
362
|
+
def solve_pow_prefix(prefix, zero_bits):
|
|
363
|
+
target = '0' * (zero_bits // 4)
|
|
364
|
+
i = 0
|
|
365
|
+
while True:
|
|
366
|
+
candidate = prefix + str(i)
|
|
367
|
+
h = hashlib.sha256(candidate.encode()).hexdigest()
|
|
368
|
+
if h.startswith(target):
|
|
369
|
+
return str(i)
|
|
370
|
+
i += 1
|
|
371
|
+
|
|
372
|
+
# Format 2: Find x such that SHA256(x) ends with specific suffix
|
|
373
|
+
def solve_pow_suffix(suffix_hex, hash_func=hashlib.sha256):
|
|
374
|
+
i = 0
|
|
375
|
+
while True:
|
|
376
|
+
h = hash_func(str(i).encode()).hexdigest()
|
|
377
|
+
if h.endswith(suffix_hex):
|
|
378
|
+
return str(i)
|
|
379
|
+
i += 1
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### 7.2 GPU-Accelerated PoW
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
# hashcat for SHA256 PoW
|
|
386
|
+
hashcat -a 3 -m 1400 --hex-charset \
|
|
387
|
+
"0000000000000000000000000000000000000000000000000000000000000000:prefix" \
|
|
388
|
+
"?a?a?a?a?a?a?a?a"
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## 8. RAINBOW TABLES & SALTING
|
|
394
|
+
|
|
395
|
+
### 8.1 Rainbow Table Attack
|
|
396
|
+
|
|
397
|
+
```
|
|
398
|
+
Precomputed chain: password → hash → reduce → password₂ → hash₂ → ...
|
|
399
|
+
Lookup: given hash h, check if h appears in any chain
|
|
400
|
+
Time-memory tradeoff: less space than full table, more time than direct lookup
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### 8.2 Salt Defeats Rainbow Tables
|
|
404
|
+
|
|
405
|
+
```
|
|
406
|
+
Without salt: H(password) — same password always produces same hash
|
|
407
|
+
With salt: H(salt || password) — different salt per user
|
|
408
|
+
|
|
409
|
+
Rainbow tables are password-specific, not (salt+password)-specific
|
|
410
|
+
Each unique salt requires a separate table → infeasible
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### 8.3 Modern Password Hashing
|
|
414
|
+
|
|
415
|
+
| Algorithm | Salt | Iterations | Memory-Hard | Recommended |
|
|
416
|
+
|---|---|---|---|---|
|
|
417
|
+
| MD5 | No | 1 | No | Never |
|
|
418
|
+
| SHA-256 | No | 1 | No | Never for passwords |
|
|
419
|
+
| bcrypt | Yes | Configurable | No | Yes |
|
|
420
|
+
| scrypt | Yes | Configurable | Yes | Yes |
|
|
421
|
+
| Argon2 | Yes | Configurable | Yes | Best choice |
|
|
422
|
+
| PBKDF2 | Yes | Configurable | No | Acceptable |
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## 9. DECISION TREE
|
|
427
|
+
|
|
428
|
+
```
|
|
429
|
+
Hash-related challenge — what's the scenario?
|
|
430
|
+
│
|
|
431
|
+
├─ Have H(secret || message), need to extend?
|
|
432
|
+
│ ├─ Hash is MD5/SHA1/SHA256/SHA512?
|
|
433
|
+
│ │ └─ Yes → Length extension attack
|
|
434
|
+
│ │ └─ Need: MAC value, original message, secret length
|
|
435
|
+
│ │ └─ Tool: HashPump or hash_extender
|
|
436
|
+
│ │
|
|
437
|
+
│ └─ Hash is SHA3/HMAC/BLAKE2?
|
|
438
|
+
│ └─ Length extension doesn't work
|
|
439
|
+
│ └─ Look for other vulnerabilities
|
|
440
|
+
│
|
|
441
|
+
├─ Need two inputs with same hash?
|
|
442
|
+
│ ├─ MD5?
|
|
443
|
+
│ │ ├─ Same prefix → fastcoll (seconds)
|
|
444
|
+
│ │ ├─ Different prefixes → hashclash (hours)
|
|
445
|
+
│ │ └─ CTF PHP loose comparison → 0e magic hashes
|
|
446
|
+
│ │
|
|
447
|
+
│ ├─ SHA-1?
|
|
448
|
+
│ │ └─ SHAttered (expensive, use precomputed if possible)
|
|
449
|
+
│ │
|
|
450
|
+
│ └─ SHA-256+?
|
|
451
|
+
│ └─ No practical collision attack
|
|
452
|
+
│ └─ Look for logic flaws instead
|
|
453
|
+
│
|
|
454
|
+
├─ Need to forge HMAC?
|
|
455
|
+
│ ├─ Timing side channel available?
|
|
456
|
+
│ │ └─ Byte-by-byte timing attack
|
|
457
|
+
│ │
|
|
458
|
+
│ ├─ Key is short/weak?
|
|
459
|
+
│ │ └─ Brute force key with hashcat
|
|
460
|
+
│ │
|
|
461
|
+
│ └─ No weakness?
|
|
462
|
+
│ └─ HMAC is secure — look elsewhere
|
|
463
|
+
│
|
|
464
|
+
├─ Hash is truncated (short output)?
|
|
465
|
+
│ └─ Birthday attack — collision in 2^(bits/2)
|
|
466
|
+
│
|
|
467
|
+
├─ Proof of work?
|
|
468
|
+
│ └─ Brute force with parallel computation
|
|
469
|
+
│ ├─ Python multiprocessing for < 28 bits
|
|
470
|
+
│ ├─ hashcat/GPU for > 28 bits
|
|
471
|
+
│ └─ Optimize: pre-increment string, avoid re-encoding
|
|
472
|
+
│
|
|
473
|
+
└─ Password hash cracking?
|
|
474
|
+
├─ No salt → rainbow tables (pre-computed)
|
|
475
|
+
├─ Known salt → hashcat / John the Ripper
|
|
476
|
+
└─ Memory-hard (Argon2/scrypt) → limited by memory, slow brute force
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
## 10. TOOLS
|
|
482
|
+
|
|
483
|
+
| Tool | Purpose | Usage |
|
|
484
|
+
|---|---|---|
|
|
485
|
+
| **HashPump** | Length extension attack | `hashpump -s MAC -d data -k secret_len -a extension` |
|
|
486
|
+
| **hash_extender** | Length extension (multiple algorithms) | `hash_extender --data D --secret L --append E --sig MAC` |
|
|
487
|
+
| **fastcoll** | MD5 identical-prefix collision | `fastcoll -p prefix -o out1 out2` |
|
|
488
|
+
| **hashclash** | MD5 chosen-prefix collision | `hashclash prefix1 prefix2` |
|
|
489
|
+
| **hashcat** | Password/hash cracking (GPU) | `hashcat -m MODE -a ATTACK hash wordlist` |
|
|
490
|
+
| **John the Ripper** | Password cracking (CPU/GPU) | `john --wordlist=rockyou.txt hashes.txt` |
|
|
491
|
+
| **CyberChef** | Quick hash computation and encoding | Web-based |
|