Showing posts with label CSRF. Show all posts
Showing posts with label CSRF. Show all posts

Wednesday, 8 May 2013

How to Change anyones Password using CSRF Vulnerability

---------------------------------------------------
CSRF Vulnerability Exploitation
(Cross Site Request Forgery)
---------------------------------------------------

Hello, After a long time it's my Second Post on CSRF Vulnerability Exploitation, CSRF is one of mine favorite website Vulnerability and comes into OWASP Top 10 Vulnerabilities List. And today, I thought to share this skill and knowledge with you all readers.

------------------------------------------------------------------------------------------------------------------------
# What is CSRF (Cross Site Request Forgery) {XSRF} ?
------------------------------------------------------------------------------------------------------------------------
                               CSRF is also called XSRF and full form is Cross Site Request Forgery - is a type of Web Vulnerability and flaw in Web pages mostly in Login pages, Password Changing Box and Input Box of web pages, that allows an attacker to force browser's to send HTTP Request to Server and Perform many types of Web attacks. Mostly CSRF is used in Sending and Tranfering Money and Funds from one Account to another Bank account without any knowledge to Victim and Second is CSRF is widely used in Password Changing method without any knowledge to victim so an attacker can easily gain access to any normal users Account. For example : Suppose an attacker discover CSRF Vulnerability in Facebook Password Changing box, then that attacker can change any normal users Password, and even Admin can get hack and this leads to Website Defacement. CSRF is very dangerous attack in Web Hacking methods. CSRF discovered in 2000 in many login pages and Passwords Input box of Social Websites, that allows an attacker to Hack and Hijack Accounts of Bank users and also send funds from one account to another account, This is called CSRF
------------------------------------------------------------------------------------------------------------------------
# What can an attacker do with CSRF Vulnerability ? 
------------------------------------------------------------------------------------------------------------------------
  • Change any users : username, ID, Password, E-mail
  • Hack Website Admin Account
  • Completely Deface website
  • Tranfer Money and Funds to any account
  • Credit Card Frauding and Stealing
  • Can Also create more vulnerabilities like :-
            1. SQL Injection
            2. XSS (Cross Site Scripting)
            3. Buffer Overflow
            5. Brute Force Attack
------------------------------------------------------------------------------------------------------------------------
# How to Exploit CSRF Vulnerability ?
------------------------------------------------------------------------------------------------------------------------
                        So, here is your main question ? well now I'll teach you how can you Explode CSRF Vulnerability, Simply I m using DVWA Pen-testing Lab to show you CSRF tutorial, Note: If you also want to learn this Attack then you'll need CSRF Vulnerable website or DVWA Penetration Testing Lab in your System. So you can learn this attack without doing any Crime. Simply here, I won't show you how to transfer funds from bank to another bank a/c, I'll show you how an attacker can change password and Hack website.  And here we go... :D
------------------------------------------------------------------------------------------------------------------------
# Requirements :
------------------------------------------------------------------------------------------------------------------------
# Steps to Exploit CSRF Vulnerability

                                       Suppose I found a Vulnerability in a website that can change Password of any user just on one click that's we call CSRF attack, here we'll do same and hack website admin password or any users password to learn CSRF Attack.

2. Start your XAMPP Server and Pen-test lab.

Click on Image to ENLARGE it.
3. Well, after all choose CSRF Column and Get Started.
4. There, you'll see it give us an option to Change Password.
5. First of all, Suppose you're an attacker and you want to Change the Admin password of DVWA Website, without any knowledge to Admin. How will you do ? ..!Yes we'll  use CSRF attack here, Okay.! then start your both browser's Chrome as Victim and Mozilla Firefox as an attacker. Start DVWA in Chrome and login as Admin with the username = Admin and Password = password. and in Firefox login as a normal user like :- Username: gordonb & Password: abc123.
------------------------------------------------------------------------------------------------------------------------
Make Sure you did all above Process and Method Correctly

6. So, now you're an attacker and you're also the Victim. & always remember to put Security Level at = "LOW" in this Tutorial
7. Small test before attacking to Victim. Select CSRF Column in DVWA Page (Use Chrome here) & change password from abc123 to 123456.


Click on Image to Enlarge it
8. Click on Change Password, & Just Look at URL (Link)


Click on Image to Enlarge it
9. Now, Just Observe the URL.


Click on Image to Enlarge it

10. So, This is called CSRF Vulnerability. You know a what an attacker can force victim's browser to send request to HTTP Server and Change anyone's password. Now I'll show you how an attacker Exploit CSRF Vulnerability and Change Password
11. Okay, let's start our attack - Open chrome start DVWA login as Victim with the username: Admin & Password: password. Also Start Firefox as an attacker with username: gordonb & Password: abc123. 
12. Take Firefox, Gordon as an attacker and the victim is Chrome user Admin, the task is to hack and Change Admin password using CSRF Exploitation Code.
13. Simply, we've to force victim's browser to send request to Server through HTTP of Changing password, we'll do it using HTML and Javascript.
14. Now, an attacker will create a HTML scripted page and host it on any free hosting server like 00webhost.com. here we're penetesting so we'll use our own XAMPP Server to host our own files. 
15. Start notepad, Copy below Script & save it on this location C:\xampp\htdocs as Attack.html.
------------------------------------------------------------------------------------------------------------------------
<html>
<body onload=�document.frames[0].submit()�>
<form action=�http://127.0.0.1/dvwa/vulnerabilities/csrf/?password_new=654321&password_conf=654321&Change=Change#� method=�POST�>
<input name=�field1� value=�foo�>
<input name=�field2� value=�bar�>
</form>
</body>
</html>
------------------------------------------------------------------------------------------------------------------------


16. After saving it, now come into Chrome browser as Victim, login as admin,  and Suppose a Firefox attacker sends you mail with the link of Attack.html that is crafted into a Text file and Suppose the victim or admin Click on it. Then Victim will be redirected to the link http://127.0.0.1/dvwa/vulnerabilities/csrf/?password_new=654321&password_conf=654321&Change=Change# That means now the password of the admin is changed to 654321, so this is called CSRF Vulnerability Exploitation.
17. Let's do test on yourself, Just Copy this "http://127.0.0.1/Attack.html" link in your Chrome browser but remember you must be login in DVWA as Admin with the Security Level = "LOW".
18. That Attack.html file will change admin's password and an attacker can easily get access to admin a/c and deface website Completely. When your victim will visit and just click on your link of attack.html file he will redirected to this page :-

19. And you're done :D......! Now admin password is changed with your password 654321. That's it this is called CSRF. 
20. CSRF is really very dangerous attack in Web Application Vulnerabilities Exploitation. what if an attacker discover same vulnerability in Facebook ? then an attacker easily change any user Password without any knowledge to Victim. Below, I give away some special hacking methods of CSRF and Advanced CSRF Vulnerability Exploitation Method PDF E-books to learn CSRF Completely.
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------

This is How CSRF Attack Works :)



Share it and Feel free to Comment :]
------------------------------------------------------------------------------------------------------------------------
Note : This is for Educational Purpose only, I'll be not responsible for any type of Miss-use of above method, Do and learn at your own Risk.
------------------------------------------------------------------------------------------------------------------------

Monday, 18 March 2013

Cross Site Request Forgery (CSRF) Attack Tutorial




? What is Cross site request Forgery (CSRF) ? 

                                    Cross-site request forgery (XSRF or CSRF) is a method of attacking a web site in which an intruder masquerades as a legitimate and trusted user. An XSRF attack can be used to modify firewall settings, post unauthorized data on a forum or conduct fraudulent financial transactions. A compromised user may never know that such an attack has occurred. If the user does find out about an attack, it may only be after the damage has been done and a remedy may be impossible.

An XSRF attack can be executed by stealing the identity of an existing user and then hacking into a Web server using that identity. An attacker may also trick a legitimate user into unknowingly sending Hypertext Transfer Protocol (HTTP) requests that return sensitive user data to the intruder.



? Requirements ?      







? How to Perform CSRF attack ?



1.              # Setup your Pen-testing lab using DVWA

  • Create Pen-test lab using DVWA (Click here to learn)
  • Start your DVWA and change Security Level to "Low"

  • Select "CSRF" from the left Navigaton Menu :-



2.        # Now it's time to Perform CSRF attack.
  • Basic CSRF test of Vulnerability.
  • Well !! default password of DVWA is "password".
  • Change the current password with any new password








  • After changing password do not click anywhere in webpage of DVWA and you will get a successful message of password change as shown in the below Image >>








  • But what is the real purpose of this method ? What we got by doing this Process ? Now the most important in this CSRF attack is URL, after getting successful message of password changed, just look at URL of webpage.














  • See how the URL string has the below two parameteres seperated by a "&".

    a. password_new=w0rm
    b. password_conf=w0rm
  • This is DVWA's  example of bad implementation of how to change a password on a web application  for the following reasons :-
    a. http is being used instead of https, which means this password change was in clear text.
    b. An attacker could manipulate the URL string using the address bar or curl to change the password.

  • # Now it's time to Address bar CSRF test.
  • In the URL, after password_new=,replace w0rm with w0rm3d.
  • In the URL, after password_conf=,replace w0rm with w0rm3d.
  • Now Reload your webpage.
  • And now see your Password will be changed :)

  • Now Copy that URL into Notepad.












  • CSRF Vulnerability is really very serious vulnerability to change admin password or any user password with Cookie stealing or SET attacks.
  • CSRF vulnerability basically found in HTML form or pages using that URL you will not require authenciation permission and you can Explode CSRF Vulnerability.
  • URL that we got after second process is the CSRF Vulnerability which can be exploded and can be hacked !!...