#!/usr/bin/env bash # Copyright 2026 Tailwind Resource Group # SPDX-License-Identifier: Apache-2.0 # Provided as is, with no warranty. License: https://everythingsfine.io/license/ # # php2shell-log-search.sh # # Read-only. Searches web server and PHP logs for signs of php2shell # (CVE-2026-109618 and CVE-2026-109619) scans and attempts. # # Usage: php2shell-log-search.sh LOGFILE... # Give access logs, error logs and PHP-FPM logs. Files that end in .gz # are read with gzip. The access log check expects the combined format. set -u if [ "$#" -eq 0 ]; then echo "usage: $0 LOGFILE..." >&2 exit 2 fi read_log() { case "$1" in *.gz) gzip -dc -- "$1" ;; *) cat -- "$1" ;; esac } for f in "$@"; do if [ ! -r "$f" ]; then echo "skip: cannot read $f" >&2 continue fi echo "== $f" echo "-- Public scanner user agents" read_log "$f" | grep -Ei 'php2shell|php-upload-progress-scan' | head -n 50 echo "-- PHP worker crashes" read_log "$f" | grep -E 'exit signal (Segmentation fault|Aborted|Bus error)|exited on signal (6|7|11)' | head -n 50 echo "-- PHP memory exhaustion" read_log "$f" | grep -E 'Allowed memory size of [0-9]+ bytes exhausted|Out of memory' | head -n 50 echo "-- Clients with the most POST requests to / or /index.php" read_log "$f" | awk '$6 == "\"POST" && ($7 == "/" || $7 ~ /^\/index\.php/) { print $1 }' | sort | uniq -c | sort -rn | head -n 20 done