# Brute Force Attack

## **Introduction**

A Brute Force Attack is the simplest method to gain access to a site or server (or anything that is password protected). It tries various combinations of usernames and passwords again and again until it gets in.

## How to Test

Using Burpsuite, capture the login request.

![](https://2740220163-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lv9UpLMmmAAyhFf0hfM%2F-M4Odu8emtHd3ZMSIjJv%2F-M4Of0F4WCO9FXG01a41%2Fimage.png?alt=media\&token=f41e7eac-ad69-4873-9454-283ae815fff1)

Select the payload type and add the payloads contains possible combination of letters, numbers, and symbols to the list.

![](https://2740220163-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lv9UpLMmmAAyhFf0hfM%2F-M4Odu8emtHd3ZMSIjJv%2F-M4Of7ZsAgTaunmjACal%2Fimage.png?alt=media\&token=91cff9ad-3b67-4617-bfb0-8bc55c22f7d6)

With the payloads it tries to login to the site until it found the right one.

![](https://2740220163-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lv9UpLMmmAAyhFf0hfM%2F-M4Odu8emtHd3ZMSIjJv%2F-M4OfKvnrRoMJnb_ovGW%2Fimage.png?alt=media\&token=9564530a-bee7-4405-bfa2-42665dcefa6f)

Here we can find, for the correct password the length and status of the response changes.

![](https://2740220163-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lv9UpLMmmAAyhFf0hfM%2F-M4Odu8emtHd3ZMSIjJv%2F-M4OfSa_DqueRohm1ztv%2Fimage.png?alt=media\&token=cfe0bf55-1767-4323-be9f-a4f99e7c5ca7)

## How to Fix

### Captcha Implementation:

A CAPTCHA is normally intended to ensure that 'user' input is from a real person. It could help to prevent automated attacks against a website login mechanism.

```
<script src='https://www.google.com/recaptcha/api.js'></script>
```

### Throttling:

The Throttler class provides a very simple way to limit an activity to be performed to a certain number of attempts within a set period of time. This is most often used for performing rate limiting on API’s, or restricting the number of attempts a user can make against a form to help prevent brute force attacks. The class itself can be used for anything that you need to throttle based on actions within a set time interval.

```
$throttler = \Config\Services::throttler(); 
$throttler->check($name, 60, MINUTE);
```

## References:

1. <https://owasp.org/www-community/controls/Blocking_Brute_Force_Attacks>&#x20;
2. <https://developers.google.com/recaptcha/>&#x20;
3. [https://webdesign.tutsplus.com/tutorials/how-to-integrate-no-captcha](https://webdesign.tutsplus.com/tutorials/how-to-integrate-no-captcha-recaptcha-in-your-website--cms-23024)[recaptcha-in-your-website--cms-23024](https://webdesign.tutsplus.com/tutorials/how-to-integrate-no-captcha-recaptcha-in-your-website--cms-23024)&#x20;
4. <https://codeigniter4.github.io/userguide/libraries/throttler.html>
