Step 1: Identity and Operating System Enumeration
Purpose: ตรวจสอบว่าปัจจุบันเราเป็นใคร มีสิทธิ์อะไร และกำลังทำงานอยู่บนระบบปฏิบัติการอะไร
whoami
id
hostname
uname -a
cat /etc/os-release
pwd
uid=33(www-data) gid=33(www-data) groups=33(www-data)
Step 2: Enumerate Sudo Permissions
Purpose: ตรวจสอบว่าผู้ใช้ปัจจุบันได้รับอนุญาตให้เรียกคำสั่งใดผ่าน sudo
sudo -l
for Non-interactive:
sudo -n -l
Looking for:
| Finding |
ความเสี่ยงที่ต้องวิเคราะห์ |
NOPASSWD |
สามารถเรียกคำสั่งที่กำหนดโดยไม่ต้องใช้ Password |
(root) |
คำสั่งสามารถทำงานด้วยสิทธิ์ root |
(ALL : ALL) |
อาจได้รับอนุญาตให้เลือก User และ Group |
SETENV |
อาจควบคุม Environment Variables ได้ |
| Custom Script |
ตรวจสอบ Ownership และ Write Permission |
Wildcard * |
ตรวจสอบขอบเขต Argument ที่ได้รับอนุญาต |
Step 3: Enumerate SUID and SGID Binaries
Purpose: ค้นหา Executable ที่มี Special Permissions
SUID
find / -type f -perm -4000 -ls 2>/dev/null
SGID
find / -type f -perm -2000 -ls 2>/dev/null
Looking for:
ตรวจสอบว่าไฟล์เป็นของ User ใด อยู่ใน Directory ใด และเป็น System Binary หรือ Custom Binary
-rwsr-xr-x 1 root root ...
| Permission |
ความหมาย |
-rwsr-xr-x |
SUID Enabled |
-rwxr-sr-x |
SGID Enabled |
root root |
Owner และ Group เป็น root |
Step 4: Enumerate Linux Capabilities
Purpose: ตรวจสอบ Executable ที่ได้รับสิทธิ์พิเศษผ่าน Linux Capabilities
getcap -r / 2>/dev/null
Looking for:
| Capability |
ความสามารถ |
CAP_SETUID |
เปลี่ยน User ID |
CAP_SETGID |
เปลี่ยน Group ID |
CAP_DAC_OVERRIDE |
ข้ามข้อจำกัด File Permission บางประเภท |
CAP_DAC_READ_SEARCH |
ข้ามข้อจำกัดการอ่านและค้นหาไฟล์ |
CAP_SYS_ADMIN |
สิทธิ์ในการจัดการระบบหลายประเภท |
CAP_SYS_PTRACE |
ตรวจสอบหรือควบคุม Process ภายใต้เงื่อนไขที่กำหนด |
CAP_SETFCAP |
กำหนด File Capabilities |
| Decision: วิเคราะห์ว่า Capability ที่ได้รับเหมาะสมกับหน้าที่ของ Executable หรือไม่ |
|
Step 5: Enumerate Scheduled Tasks
Purpose: ตรวจสอบ Scheduled Tasks ที่อาจทำงานด้วยสิทธิ์สูง
cat /etc/crontab
ls -la /etc/cron.d/
ls -la /etc/cron.daily/
ls -la /etc/cron.hourly/
ls -la /etc/cron.weekly/
ls -la /etc/cron.monthly/
crontab -l
Looking for:
| Finding |
สิ่งที่ต้องตรวจสอบ |
| Root Cron Job |
Job ทำงานด้วยสิทธิ์ของใคร |
| Custom Script |
ใครเป็นเจ้าของ Script |
| Writable Script |
ผู้ใช้ทั่วไปแก้ไขได้หรือไม่ |
| Relative Path |
มีการระบุ Absolute Path หรือไม่ |
| Writable Directory |
Directory ที่เกี่ยวข้องมี Permission เหมาะสมหรือไม่ |
| Decision: ตรวจสอบทั้งตัว Scheduled Task, Script และ Directory ที่เกี่ยวข้อง |
|
Step 6: Enumerate Writable Files and Directories
Purpose: ตรวจสอบไฟล์และ Directory ที่ผู้ใช้ปัจจุบันสามารถเขียนได้ โดยเน้นตำแหน่งที่เกี่ยวข้องกับ System Services และ Custom Applications
find /etc /opt /usr/local /var/www \
-type f -writable 2>/dev/null
find /etc /opt /usr/local /var/www \
-type d -writable 2>/dev/null
Looking for:
| Location |
สิ่งที่ต้องตรวจสอบ |
/etc |
System Configuration |
/opt |
Custom Applications |
/usr/local/bin |
Custom Executables |
/usr/local/sbin |
Administrative Executables |
/var/www |
Web Application Files |
| ตรวจสอบ Permission ของไฟล์ที่พบเพิ่มเติมด้วย |
|
ls -la /path/to/file
stat /path/to/file
namei -l /path/to/file
Step 7: Check Critical File Permissions
Purpose: ตรวจสอบ Permission ของไฟล์สำคัญในระบบ Linux
ls -l /etc/passwd
ls -l /etc/shadow
ls -l /etc/group
ls -l /etc/sudoers
ls -ld /etc/sudoers.d
Decision: ตรวจสอบว่าผู้ใช้ทั่วไปสามารถแก้ไขไฟล์สำคัญโดยไม่ได้รับอนุญาตหรือไม่
Step 8: Review Credential Exposure
ตรวจสอบความเสี่ยงจากการจัดเก็บ Credential ไม่เหมาะสม
ตรวจสอบชื่อ Environment Variables ที่อาจเกี่ยวข้องกับข้อมูลสำคัญ
printenv | cut -d= -f1 | grep -iE 'pass|key|secret|token'
ตรวจสอบ Metadata ของ History Files
ls -la ~/.bash_history ~/.zsh_history 2>/dev/null
ตรวจสอบ Configuration Files ของ Application
find /opt /var/www -type f \
\( -name "*.conf" -o -name "*.ini" -o -name ".env" \) \
-readable 2>/dev/null
Looking for: Password, Database Config file, API Token, Shell History, Readable .env
Step 9: Enumerate Linux Internal Services
Purpose: ตรวจสอบ Service ที่กำลังทำงาน รวมถึง Service ที่อาจไม่ได้เปิดให้เข้าถึงจากภายนอก
ss -tlnp
ss -ulnp
ps aux
systemctl list-units --type=service --state=running
Decision: ตรวจสอบ Process Owner, Service Configuration และ Authentication Mechanism ของ Service ที่พบ
Step 10: Enumerate NFS Configuration
Purpose: ตรวจสอบการตั้งค่าของ Network File
cat /etc/exports
findmnt -t nfs,nfs4
ls -l /etc/exports.d/ 2>/dev/null
Looking for: /srv/share *(rw,no_root_squash,no_subtree_check)
Step 11: Enumerate Privileged Group Memberships
Purpose: ตรวจสอบวาผู้ใช้ปัจจุบันเป็นสมาชิกของ Group ที่มีสิทธิ์เกี่ยวข้องกับการจัดการระบบหรือไม่
id
groups
Looking for:
| Group |
ความสามารถที่อาจได้รับ |
sudo |
เรียกคำสั่งผ่าน sudo ตาม Policy |
docker |
จัดการ Docker Daemon |
lxd |
จัดการ LXD Containers |
disk |
เข้าถึง Block Devices ตาม Permission |
adm |
อ่าน System Logs บางประเภท |
shadow |
อาจอ่าน Password Hashes ตาม File Permission |
libvirt |
จัดการ Virtual Machines ตาม Configuration |
| Decision: Group Membership เป็น Indicator ที่ต้องตรวจสอบร่วมกับ Service และ Resource Permissions ไม่ใช่หลักฐานว่าได้รับ root แล้ว |
|
Step 12: Review PATH and Shared Library Configuration
Purpose: ตรวจสอบ Environment Variables และ Dynamic Linking ที่เกี่ยวข้องกับ Executable
echo "$PATH"
printf '%s\n' "$PATH" | tr ':' '\n'
cat /etc/ld.so.conf
ls -la /etc/ld.so.conf.d/
สำหรับตรวจสอบ ELF Binary ที่พบจากขั้นตอน Enumeration:
file /path/to/binary
readelf -d /path/to/binary
strings /path/to/binary
Looking for:
| Finding |
ความเสี่ยงที่ต้องวิเคราะห์ |
| Writable PATH Directory |
การค้นหา Executable อาจไม่ปลอดภัย |
| Relative Command Path |
Program อาจค้นหาคำสั่งผ่าน PATH |
RPATH |
Library Search Path |
RUNPATH |
Library Search Path สำหรับ Dependency |
NEEDED |
Shared Library Dependency |
| Writable Library Directory |
Library Integrity Risk |
Decision: ตรวจสอบว่า Path หรือ Library ที่พบสามารถถูกควบคุมโดยผู้ใช้สิทธิ์ต่ำได้หรือไม่ และ Executable ทำงานภายใต้สิทธิ์ใด
Step 13: Automated Enumeration — LinPEAS
Purpose: ใช้ Automated Enumeration Tool เพื่อช่วยตรวจสอบข้อมูลที่อาจตกหล่นจาก Manual Enumeration
LinPEAS สามารถช่วยตรวจสอบ Sudo Permissions, SUID, Capabilities, Scheduled Tasks, Services และ System Misconfiguration
Step 14: Kernel Version Assessment
Purpose: ตรวจสอบ Kernel Version และ Security Patch Level
uname -r
uname -m
cat /etc/os-release
สำหรับ Debian และ Ubuntu:
dpkg -l | grep linux-image
Looking for: ตรวจสอบ Kernel Version, Architecture, Distribution และ Security Advisory ที่เกี่ยวข้อง
Decision: ไม่ควรสรุปว่ามีช่องโหว่จาก Version Number เพียงอย่างเดียว เนื่องจาก Distribution อาจมีการ Backport Security Patches โดยไม่ได้เปลี่ยน Major Version