Web Attacks From Zero To Hero
Web Attacks From Zero To Hero
Catfactsapi lab
https://github.com/alexwohlbruck/cat-facts
Rest apis:
Client-server architecture
Statelessnerss
Cacheability
Layered system
Enumerate api :
Burpsuit+wfuzz
You must check all api version for example if v1 we must change to v2 and visa versa for checking server
response also we must check all character in api
For example
This command return all response so if we wanna filter only 200 request we can use this command :
https://beautifier.io/ you can check sensitive information in source code with this site if your source
code is unreadable
API8 injection
After installation vapi we can import our library with post man for do something like this in post man :
Import >> upload files >>> home>> dev>>vapi>>>postman>>> and upload vapi.postmanand
vapi_env.postman
Attacking authentication :
For brute force and fuzzing we must use seclists for do this we can use
Cd temp>>> vim req.txt >>> change request in “email”:”admin” , “password” : “admin to FUZZ”
>> mousepad req.txt (basically like notepad but in kali ) >> fuff –request req.txt –request-proto http –w
/usr/share/seclists/passwords/xato-net-10-million-passwords-10000.txt -mc 200
Send request to server with curl so we can send to dashboard with token generated with our request
with curl
Crack token :
Jwt-tool
We can copy token from token request from burp and copy token to jwt and finding the result the
result will same as using jwt.io you can see algorithem and payload
We can use jwt –help to see all function on this app you can copy token from burp suite
You should read jwt attck playbook
Injection :
Fuzzing for sqli ,triggering error messages , verifying sqli , union select to steal data
https://github.com/binderlabs/BASS
for testing owasp top 10 api vuln you can use this lab
we can use burp suite intruder for fuzzing sql injection please payattention fuziing sql is just a name I
setup for my wordlist for name
A simple way for testing sql injection for finding error message is using ‘ character (warning in real
world may not working )
Some data base can actually have code execution depended on database users,privillages and etc
https://github.com/ffuf/ffuf
Testing nosql injection is similar to sqlinjection but you must have different wordlist for this purpose you
Can use seclist and test payload nosql with burp or other tools
Mass assignment:
OWASP attributes the API mass assignment vulnerability as an input validation flaw that allows hackers
to perform advanced attacks by manipulating payload data.The threat arises when the API endpoints
save a request body as it is instead of extracting request parameters one by one.Malicious users
typically exploit the flaw to initialize or overwrite server-side parameters that the developers never
intend to expose.A common development practice is to create a copy of the incoming request and save
it in a database, as it seems appropriate for internal object sharing.However, the approach leads to a
risky configuration since attackers can decipher the properties in request payloads and send additional
parameters to change their effect on the API endpoint.
POST /editdata HTTP/1.1
Host: target.com
...
username=daffa
The response
HTTP/1.1 200 OK
...
{"status":"success","username":"daffainfo","isAdmin":"false"}
Modified Request
POST /editdata HTTP/1.1
Host: target.com
...
username=daffa&admin=true
HTTP/1.1 200 OK
...
{"status":"success","username":"daffainfo","isAdmin":"true"}
impact:
The main impact of a Mass Assignment vulnerability is linked to modifying or creating variables.
Depending on the variables or objects affected, the impact can be more or less significant, ranging from
the simple modification of a value with no impact to a privilege escalation
How To Prevent
If possible, avoid using functions that automatically bind a client’s input into code variables or internal
objects.
Use built-in features to blacklist properties that should not be accessed by clients.
If applicable, explicitly define and enforce schemas for the input data payloads.
https://portswigger.net/web-security/api-testing/lab-exploiting-mass-assignment-vulnerability
SSRF:
Is a vulnerability that’s allow an attacker to have a server side application send request behalf
Access control :
Also known as authorization
Forceful browsing
Idor/bola/bfla
IDOR:
Often used to access information of other objects (e.g another user’s account information)
May need to become combined with another weakness if the object id is not easyto guess
Or brute force
Idor is used when we access objects directly.BFLA or BAC is used when we can abuse functionality, such
as updating the account of another user
Some times applications will user input we can control for access control such as http methods or
headers
We should check to see if modifying the http request will lead to behavior
http method
headers (eg.referer,x-origin-url)
comparing request between different users may help us uncover weakness such as these.
SSRF:
Ssrf occurs when a server-side application makes requestON OUR BEHALF. FOR example
With an ssrf payload we can potentially make an external-facing website make requests to internal
resources that we have no direct access to
Blind ssrf :
As with all blind attacks the server is carrying out some action,but the result or data is not included in
http response
Sql injection :
Sql injection allows us to manipulate queries that are made
To a database and typically leads
To :
Exposure of sensitive data
Data manipulation
Denial of service
Discovery :
Manual payload
Code review
Fuzzing
Dynamic Queries vs Parameterized Queries VS Stored Procedures
First is php code
Second is java
And third is javascript
Xss contexys:
Tools:
Offensive javascript:
Refrence mdn :
By pass web application firewall:
You can check more payload on this site:
https://cheatsheetseries.owasp.org/cheatsheets/XSS_Filter_Evasion_Cheat_Shee
t.html
JWT Json :
Jwt.io +burp
JWT Misconfiguration:
You can download this tools from github
Selelct >>attack >>> embedded jwk >>>
Grab cookie and past cookie instead of cookie in source code with ctrl +shif +c
In application select cookie and paste
MASS ASSIGNMENT :
Example:
Identify parameters:
How we can find and exploit vuln:
Web Sockets :