Tìm kiếm toàn bộ file *.PHP trên Linux

Để hiển thị toàn bộ file *.PHP ở thư mục hiện tại, bạn hãy sử dụng 1 trong 2 lệnh bên dưới:

find . -print | grep -i '.*[.]php'

hoặc

find . -type f -name '*.php' -printf '%TY-%Tm-%Td %TT %p\n' | sort

Mình thường dùng phương pháp này để kiểm tra có bị up file malware, shell lên server hay không.

Update bổ sung thêm câu lệnh tìm kiếm một số dạng malware, shell thông dụng trên server:

pcregrep -rlM '\<\?php.*\n.*\$GLOBALS' /home/domain.com/public_html/
  • -r: tìm kiếm recursive cả sub-directory
  • -l: list file name only
  • -M: tìm kiếm multiple line