Use Cookies to login account

Tram Ho

Hello everyone, the promise from “Stealing Cookies by taking advantage of XSS security errors” – Link until now has the opportunity to implement.

As in the previous article, we took advantage of the XSS security hole to steal Cookies, so after we have Cookies, what can we do ??? In this article, I will guide you how to use Cookies to login account with the EditThisCookie tool (available on FF and Chrome, search immediately) ^^.

The implementation context is that the company is applying the idea to answer a few questions about 7 Core Values ​​in order to be logged in …. so sad and skinny (maybe I can get anywhere> “<), and the idea is Using Cookies to login will save you from having to answer questions (ahihi).

A. Search for WSM Cookies

In the past, when WSM was still corn, XSS holes were full, it was stolen, after several errors, it also patched a bunch, maybe left somewhere that I have not found yet, let’s go get the main Cookie by using the traditional way: v You need a tool to send API requests, use Jmeter ^^

Let’s research API to send to get any Cookie:

  1. Homepage: https://wsm.sun-asterisk.vn/ >>> send this to get CSRFToken
  2. Random questions: https://fitm.sun-asterisk.vn//core_values/questions/random_question?language=en >>> send this to get questions about 7 core values
  3. Valid answer: https://fitm.sun-asterisk.vn//core_values/questions/valid_answer >>> have questions in 2 then send this to submit answers
  4. GetCookie: https://wsm.sun-asterisk.vn/en/users/sign_in >>> If the answer is 3, then 4 will sign_in succeed, we will get the necessary Cookie. ❤️❤️❤️

Regarding the sending methods of requests, the Config elements, and the Parameters needed to send requests, you can get when the Inspect Element (F12) browser when making sign_in wsm. Now I will guide the creation of a plan running on the Jmeter tool, reviewing Jmeter knowledge and getting Cookies, a couple of jobs ^^

Test plan structure as above, first I add HTTP Cookie Manager to manage Cookies of the entire Test plan, then create a Thread group with the requests listed above, respectively: 1. Homepage -> 2. Random questions -> 3. Valid answer -> 4. GetCookie

  1. Homepage: Method GET https://wsm.sun-asterisk.vn/

This request has no param, after calling, the response will have CSRFToken, I create Regular Expression Extractor to get CSRFToken as shown below.

  1. Random questions: Method GET https://fitm.sun-asterisk.vn//core_values/questions/random_question?language=en

This request also has no param, after calling, in the response will have questions about 7 core values ​​and the options of the answer, I created Regular Expression Extractor to get questions and answers only. Note, the question has 1 token of the question but the answer has up to 4 tokens, I just need to get the first sentence is enough, regardless of whether the first answer is right or wrong. ?

question_token

answer_tokens

  1. Valid answer Method POST https://fitm.sun-asterisk.vn//core_values/questions/valid_answer

This request needs Request Heades as below:

Parameters passed are the questions_token and answer_tokens that we get in 2. Random questions, you pay attention to call variables $ {question_token} and $ {answer_tokens} okay:

After sending the request successfully, there will be 1 result token in the response, this result can be true or false, just get the token and then calculate:

  1. GetCookie Method POST https://wsm.sun-asterisk.vn/en/users/sign_in

This request needs Request Heades as below, here you need to pass the CSRFToken retrieved in 1. Homepage, pay attention to call back $ {CSRFToken}:

The transmission parameter includes: authenticity_token: $ {CSRFToken} is already taken at 1. Homepage user [token_core_value]: is $ {tokencorevalue} retrieved at 3. Valid answer user [email]: is your email user [ password]: is your password

ahihi, cover carefully then

After sending the request successfully, there will be a Cookie in the response, this is the purpose I need to get:

At this point, I need BeanShell PostProcessor to print Cookies into txt file, just a little colorful for fun, yes, no. ^^

OK, the script will look like this:

User comes 1. Homepage, he receives 1 question 7 core value 2. Random questions, he submits the answer 3. Valid answer, then he will sign in, sign in successfully he will get 4. GetCookie ^^

The problem is in step 3. Valid answer, we can not control whether the answer is true or false, the Test Plan we created above will receive a random question and get the first answer option. Tell right or wrong to submit. So to solve the problem, I ran a series of 10 consecutive times to receive random 10 pairs of questions / answers, just 1 pair returns the correct result, I will have Cookies and print out the text file for me. ? Config thread group as shown below:

Test play and see what results, grab 2 Cookie lun ^^

B. Using Cookies of WSM to login and by pass question 7 core value

Actually, the step to get a new cookie is difficult, until this step, you only use the Tool, you search the EditThisCookie tool:

Copy the Cookie obtained above, go to the WSM homepage and paste the Cookie into the EditThisCookie tool, then click Save:

F5 plays to see the miracle, you have successfully signed in WSM with the obtained Cookie, demo clip:

Demo video

Here let me end the article, hoping that you can see the dangers of XSS security.

Share the news now

Source : Viblo