Skip to content

Commit 544ac51

Browse files
scumdestroygitbook-bot
authored andcommitted
GitBook: [master] 33 pages and 5 assets modified
1 parent 5e64696 commit 544ac51

21 files changed

+2241
-23
lines changed

.gitbook/assets/image (14).png

67.3 KB
Loading

.gitbook/assets/image (15).png

58.4 KB
Loading

.gitbook/assets/image (16).png

9.2 KB
Loading

.gitbook/assets/image (17).png

48.8 KB
Loading

.gitbook/assets/image (18).png

108 KB
Loading

SUMMARY.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* [CSRF](bug-bounty-web-hacking/csrf.md)
1111
* [HTTP Methods Vulns.](bug-bounty-web-hacking/http-methods-vulns..md)
1212
* [IDORs / Auth. Bugs](bug-bounty-web-hacking/untitled.md)
13+
* [LFI](bug-bounty-web-hacking/lfi.md)
1314
* [SSRF](bug-bounty-web-hacking/ssrf.md)
1415
* [SSTI](bug-bounty-web-hacking/ssti.md)
1516
* [PHP : grep Payloads](bug-bounty-web-hacking/php-grep-payloads.md)
@@ -23,14 +24,14 @@
2324
* [Other extensions](burp-suite/other-extensions.md)
2425
* [Turbo Intruder](burp-suite/turbo-intruder.md)
2526

26-
## API attacks
27+
## API Penetration Testing
2728

28-
* [API attacks](api-attacks/api-attacks.md)
29-
* [API/SOAP/WSDL Tricks](api-attacks/api-soap-wsdl-tricks.md)
30-
* [Checklist](api-attacks/checklist.md)
31-
* [Common endpoints](api-attacks/common-endpoints.md)
32-
* [JSON testing in APIs](api-attacks/json-testing-in-apis.md)
33-
* [31 days of API security tricks](api-attacks/31-days-of-api-security-tricks.md)
29+
* [API attacks](api-penetration-testing/api-attacks.md)
30+
* [API/SOAP/WSDL Tricks](api-penetration-testing/api-soap-wsdl-tricks.md)
31+
* [Checklist](api-penetration-testing/checklist.md)
32+
* [Common endpoints](api-penetration-testing/common-endpoints.md)
33+
* [JSON testing in APIs](api-penetration-testing/json-testing-in-apis.md)
34+
* [31 days of API security tricks](api-penetration-testing/31-days-of-api-security-tricks.md)
3435

3536
## Tools
3637

@@ -39,3 +40,14 @@
3940
* [Recon-ng](tools/recon-ng.md)
4041
* [Wfuzz](tools/wfuzz.md)
4142

43+
## WAF Bypasses
44+
45+
* [General WAF torment](waf-bypasses/general-waf-torment.md)
46+
* [Cloudflare](waf-bypasses/cloudflare.md)
47+
* [Testing Methodology/Evasion techniques](waf-bypasses/testing-methodology-evasion-techniques.md)
48+
* [Tools and Resources](waf-bypasses/tools-and-resources.md)
49+
50+
## Enumeration
51+
52+
* [Port 139, 445 : SMB/NetBIOS](enumeration/port-139-445-smb-netbios.md)
53+
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
---
2+
description: >-
3+
This challenge is Inon Shkedy's 31 days API Security Tips
4+
https://twitter.com/inonshkedy
5+
---
6+
7+
# 31 days of API security tricks
8+
9+
-API TIP: 1/31-
10+
11+
Older APIs versions tend to be more vulnerable and they lack security mechanisms. Leverage the predictable nature of REST APIs to find old versions. Saw a call to api/v3/login? Check if api/v1/login exists as well. It might be more vulnerable.
12+
13+
-API TIP: 2/31-
14+
15+
Never assume there’s only one way to authenticate to an API! Modern apps have many API endpoints for AuthN: /api/mobile/login \| /api/v3/login \| /api/magic\_link; etc.. Find and test all of them for AuthN problems.
16+
17+
-API TIP:3/31-
18+
19+
Remember how SQL Injections used to be extremely common 5-10 years ago, and you could break into almost every company? BOLA \(IDOR\) is the new epidemic of API security. As a pentester, if you understand how to exploit it, your glory is guaranteed.
20+
21+
Learn more about BOLA : [https://medium.com/@inonst/a-deep-dive-on-the-most-critical-api-vulnerability-bola-1342224ec3f2](https://medium.com/@inonst/a-deep-dive-on-the-most-critical-api-vulnerability-bola-1342224ec3f2)
22+
23+
-API TIP: 4/31-
24+
25+
Testing a Ruby on Rails App & noticed an HTTP parameter containing a URL? Developers sometimes use "Kernel\#open" function to access URLs == Game Over. Just send a pipe as the first character and then a shell command \(Command Injection by design\)
26+
27+
Learn more about the open function: [https://apidock.com/ruby/Kernel/open](https://apidock.com/ruby/Kernel/open)
28+
29+
-API TIP:5/31-
30+
31+
Found SSRF? use it for:
32+
33+
* Internal port scanning
34+
* Leverage cloud services\(like 169.254.169.254\)
35+
* Use [http://webhook.site](http://webhook.site/) to reveal IP Address & HTTP Library
36+
* Download a very large file \(Layer 7 DoS\)
37+
* Reflective SSRF? disclose local mgmt consoles
38+
39+
-API TIP: 6/31-
40+
41+
Mass Assignment is a real thing. Modern frameworks encourage developers to use MA without understanding the security implications. During exploitation, don't guess object's properties names, simply find a GET endpoint that returns all of them.
42+
43+
[![Infographic](api_files/image001.jpg)](https://camo.githubusercontent.com/c9590bb2d38418b08741940544a235dcb8e6c8f4/68747470733a2f2f7062732e7477696d672e636f6d2f6d656469612f454e7073573235585941416a454a453f666f726d61743d6a7067)
44+
45+
- API TIP: 7/31 -
46+
47+
A company exposes an API for developers? This is not the same API which is used by mobile / web application. Always test them separately. Don't assume they implement the same security mechanisms.
48+
49+
- API TIP: 8/31 -
50+
51+
Pentest for REST API? Give it a chance and check if the API supports SOAP also. Change the content-type to "application/xml", add a simple XML in the request body, and see how the API handles it.
52+
53+
Sometimes the authentication is done in a different component that is shared between REST & SOAP APIs == SOAP API may support JWT
54+
55+
If the API returns stack trace with a DUMPling, it's probably vulnerable\*\*
56+
57+
- API TIP: 9/31 -
58+
59+
Pentest for APIs? Trying to find BOLA \(IDOR\) vulnerabilities? IDs in the HTTP bodies/headers tend to be more vulnerable than IDs in URLs. Try to focus on them first.
60+
61+
-API TIP: 10/31-
62+
63+
Exploiting BFLA \(Broken Function Level Authorization\)? Leverage the predictable nature of REST to find admin API endpoints! E.g: you saw the following API call GET /api/v1/users/<id> Give it a chance and change to DELETE / POST to create/delete users.
64+
65+
- API TIP: 11/31 -
66+
67+
The API uses Authorization header? Forget about CSRF! If the authentication mechanism doesn't support cookies, the API is protected against CSRF by design.
68+
69+
-API TIP : 12/31-
70+
71+
Testing for BOLA \(IDOR\)? Even if the ID is GUID or non-numeric, try to send a numeric value. For example: /?user\_id=111 instead of user\_id=[email protected] Sometimes the AuthZ mechanism supports both and it's easier the brute force numbers.
72+
73+
-API TIP: 13/31-
74+
75+
\*Use Mass Assignment to bypass security mechanisms. E.g., "enter password" mechanism:
76+
77+
* POST /api/reset\_pass requires old password.
78+
* PUT /api/update\_user is vulnerable to MA == can be used to update pass without sending the old one \(For CSRF\)\*
79+
80+
- API TIP: 14/31 -
81+
82+
Got stuck during an API pentest? Expand your attack surface! Find sub/sibling domains using [http://Virustotal.com](http://virustotal.com/) & [http://Censys.io](http://censys.io/). Some of these domains might expose the same APIs with different configurations/versions.
83+
84+
-API TIP:15/31-
85+
86+
Static resource==photo,video,.. Web Servers\(IIS, Apache\) treat static resources differently when it comes to authorization. Even if developers implemented decent authorization, there's a good chance you can access static resources of other users.
87+
88+
-API TIP: 16/31-
89+
90+
Even if you use another web proxy, always use Burp in the background. The guys at @PortSwigger are doing a really good job at helping you manage your pentest. Use the “tree view” \(free version\) feature to see all API endpoints you’ve accessed.
91+
92+
-API TIP:17/31-
93+
94+
Mobile Certificate Pinning? Before you start reverse engineering & patching the client app, check for both iOS & Android clients and older versions of them. There's a decent chance that the pinning isn't enabled in one of them. Save time.
95+
96+
-API TIP: 18/31-
97+
98+
Companies & developers tend to put more resources \(including security\) into the main APIs. Always look for the most niche features that nobody uses to find interesting vulnerabilities. POST /api/profile/upload\_christmas\_voice\_greeting
99+
100+
-API TIP:19/31-
101+
102+
Which features do you find tend to be more vulnerable? I'll start:
103+
104+
* Organization's user management
105+
* Export to CSV/HTML/PDF
106+
* Custom views of dashboards
107+
* Sub user creation&management
108+
* Object sharing \(photos, posts,etc\)
109+
110+
- API TIP:20/31-
111+
112+
Testing AuthN APIs? If you test in production, there's a good chance that AuthN endpoints have anti brute-force protection. Anyhow, DevOps engineers tend to disable rate limiting in non-production environments. Don't forget to test them :\)
113+
114+
A good example of this issue: Facebook Breach \(Found by @sehacure\) [http://www.anandpraka.sh/2016/03/how-i-could-have-hacked-your-facebook.html](http://www.anandpraka.sh/2016/03/how-i-could-have-hacked-your-facebook.html)
115+
116+
-API TIP:21/30-
117+
118+
Got stuck during an API pentest? Expand the attack surface! Use [http://archive.com](http://archive.com/), find old versions of the web-app and explore new API endpoints. Can't use the client? scan the .js files for URLs. Some of them are API endpoints.
119+
120+
-API TIP:22/31-
121+
122+
APIs tend to leak PII by design. BE engineers return raw JSON objects and rely on FE engineers to filter out sensitive data. Found a sensitive resource \(e.g, receipt\)? Find all the EPs that return it: /download\_receipt,/export\_receipt, etc..
123+
124+
Some of the endpoints might leak excessive data that should not be accessible by the user.
125+
126+
This is an example for OWASP Top 10 For APIs - \#3 - Excessive Data Exposure
127+
128+
-API TIP:23/31-
129+
130+
Found a way to download arbitrary files from a web server? Shift the test from black-box to white-box. Download the source code of the app \(DLL files: use IL-spy; Compiled Java - use Luyten\) Read the code and find new issues!
131+
132+
-API TIP:24/31-
133+
134+
Got stuck during an API pentest? Expand your attack surface! Remember: developers often disable security mechanisms in non-production environments \(qa/staging/etc\); Leverage this fact to bypass AuthZ, AuthN, rate limiting & input validation.
135+
136+
-API TIP:25/31-
137+
138+
Found an "export to PDF" feature? There's a good chance the developers use an external library to convert HTML --> PDF behind the scenes. Try to inject HTML elements and cause "Export Injection".
139+
140+
Learn more about Export Injection: [https://medium.com/@inonst/export-injection-2eebc4f17117](https://medium.com/@inonst/export-injection-2eebc4f17117)
141+
142+
-API TIP:26/31-
143+
144+
Looking for BOLA \(IDOR\) in APIs? got 401/403 errors? AuthZ bypass tricks:
145+
146+
* Wrap ID with an array {“id”:111} --> {“id”:\[111\]}
147+
* JSON wrap {“id”:111} --> {“id”:{“id”:111}}
148+
* Send ID twice URL?id=<LEGIT>&id=<VICTIM>
149+
* Send wildcard {"user\_id":"\*"}
150+
151+
In some cases, the AuthZ mechanism expects a plain string \(an ID in this case\), and if it receives a JSON instead it won't perform the AuthZ checks. Then, when the input goes to the data fetching component, it might be okay with a JSON instead of string\(e.g: it flattens the JSON\)
152+
153+
-API TIP:27/31-
154+
155+
BE Servers no longer responsible for protecting against XSS. APIs don't return HTML, but JSON instead. If API returns XSS payload? - E.g: {"name":"In<script>alert\(21\)</script>on} That's fine! The protection always needs to be on the client side
156+
157+
-API TIP:28/31-
158+
159+
Pentest for .NET apps? Found a param containing file path/name? Developers sometimes use "Path.Combine\(path\_1,path\_2\)" to create full path. Path.Combine has weird behavior: if param\#2 is absolute path, then param\#1 is ignored.
160+
161+
Leverage it to control the path
162+
163+
Learn more: [https://www.praetorian.com/blog/pathcombine-security-issues-in-aspnet-applications](https://www.praetorian.com/blog/pathcombine-security-issues-in-aspnet-applications)
164+
165+
-API TIP:29/30-
166+
167+
APIs expose the underlying implementation of the app. Pentesters should leverage this fact to better understand users, roles, resources & correlations between them and find cool vulnerabilities & exploits. Always be curious about the API responses.
168+
169+
-API TIP:30/31-
170+
171+
Got stuck during an API pentest? Expand your attack surface! If the API has mobile clients, download old versions of the APK file to explore old/legacy functionality and discover new API endpoints.
172+
173+
Remember: companies don’t always implement security mechanisms from day one && DevOps engineers don’t often deprecate old APIs. Leverage these facts to find shadow API endpoints that don’t implement security mechanism \(authorization, input filtering & rate limiting\)
174+
175+
Download old APK versions of android apps: [https://apkpure.com](https://apkpure.com/)
176+
177+
-API TIP: 31/31-
178+
179+
Found a limit / page param? \(e.g: /api/news?limit=100\) It might be vulnerable to Layer 7 DoS. Try to send a long value \(e.g: limit=999999999\) and see what happens :\)
180+
181+
Source
182+
183+
All of this information is taken from twitter of Inon Shkedy
184+
185+
Links:
186+
187+
* [Inon Shkedy](https://twitter.com/inonshkedy)
188+
* [Traceableai](https://twitter.com/traceableai/)
189+
* [OWASP API PROJECT](https://github.com/OWASP/API-Security)
190+
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# API attacks
2+
3+
4+
5+
* access controls - authorization/authentication
6+
* basically, proving who you say you are / granting access to resources
7+
8+
the server process for auth. checks goes like..
9+
10+
* if account/session exists
11+
* if request/resource is in access scope of client
12+
* if any cookies/tokens needed
13+
* if the way to route to the resource was valid
14+
* if any other conditions the server expects are met
15+
16+
measuring success : if server returns a token/session id, further requests will be granted
17+
18+
how to test for access controls?
19+
20+
* enumerate potential restricted endpoints
21+
* modify session tokens
22+
* attempt to bypass restrictions with IDOR
23+
* modify request with parameters like "&admin=true" or "test=1"
24+
* modify referrer headers to things the app will expect \(say you came from some other part of the app\)
25+
26+
**INPUT VALIDATION**
27+
28+
* input is ANYTHING a server takes in : from user, third party apps, elsewhere
29+
30+
**parameters to test::**
31+
32+
* within request header
33+
* parameters within the URL
34+
* parameters in the request
35+
* file uploads \(PUT/DELETE requests\)
36+
* input validation bugs :: -improper parameterization of requests in logic
37+
* lack of input sanitation/escaping
38+
* improper handling of parameters
39+
* file upload bugs, unicode bugs \(what can you pass into server for data and how is it handled\)
40+
41+
**input validation fuzzing**
42+
43+
* RCE, XSS, LFI/RFI, SQL injection, request splitting, deserialization, XXE, encoding errors with junk characters/emojis, file upload vulnerabilities, SSRF
44+
* you can use burp, gobuster, dirb, etc
45+
46+
47+
**Rate limiting - ways to test**
48+
49+
* make requests in varying states of authentication
50+
* as a unauthenticated user
51+
* a legit ones
52+
* as a developer
53+
* as a bot
54+
* with a deactivated account
55+
* with bogus credentials
56+
57+
you can make a gross amount of requests and enumerate or find DDOS ways
58+
59+
**Restricting HTTP methods**
60+
61+
* what the app supports and what it expects is important before fuzzing
62+
* sometimes scope of methods is too broad leading a user to be able to PUT DELETE POST etc parts of the API
63+
* even if they aren't included, an app can be lazy and have nothing to parse and will do weird shit
64+
65+
**3rd party API abuse - sometimes APIs rely on other APIs**
66+
67+
* there is usually trust between the two
68+
* request splitting - making additional requests to a third party API thru target API
69+
* SSRF - APIs that resolve URLs can be tricked into making requests to the server itself \(to gain data, enumeration, cloud access\)
70+
* mishandled input from 3rd party
71+
72+
Information Disclosure
73+
74+
How to find it:
75+
76+
* use wappalyzer and look for ruby and angular or ruby/react combo
77+
* These usually follow pattern of /model/id or model/subresource/id
78+
79+
In proxy history ::
80+
81+
* Look for giant JSON encoded blobs in page sources
82+
* Watch for API calls
83+
84+
85+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# API/SOAP/WSDL Tricks
2+
3+
4+
5+
* sql injection test
6+
* wildcards : \* and %
7+
* ' or 1=1--
8+
* empty strings or ' or "='
9+
10+
_Login then login then login then login_
11+
12+
* try normal, then mix up correct, expired and faulty session IDs
13+
14+
Login, get sessionID
15+
16+
* logout
17+
* make request while logged out w/ sssionID
18+
* request with expired ID
19+
* request with faulty sessionID
20+
* how about two IDs log in simultaneously and send requests
21+
22+
send
23+
24+
* Username and password
25+
* just password
26+
* just username
27+
* username and username
28+
* password and password
29+
* nothing just <login> </logiN>
30+
* <user\_name> <pass\_word>
31+
* <user> <pass>
32+
* <username> <pass>
33+
* <user> bigboy </user>
34+
* mypassword </password>
35+
* make payloads gigantic
36+
37+
**xpath injection:**
38+
39+
<login>
40+
string\(//user\[username/text\(\)='' or '1' = '1' and password/text\(\)='' or '1' = '1'\]\)
41+
</login>
42+
43+
44+
45+
Looking for BOLA \(IDOR\) in APIs? got 401/403 errors?
46+
47+
AuthZ bypass tricks:
48+
49+
* Wrap ID with an array {“id”:111} --> {“id”:\[111\]}
50+
* JSON wrap {“id”:111} --> {“id”:{“id”:111}}
51+
* Send ID twice URL?id=<LEGIT>&id=<VICTIM>
52+
* Send wildcard {"user\_id":"\*"}
53+

0 commit comments

Comments
 (0)