Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

server-scan

БесплатноБез исполняемых скриптовНе проверен

Comprehensive Magento 2 server security investigation and compromise detection. Use when investigating a potentially compromised server, scanning for malware…

ProxiBlueот ProxiBlue★ 17 звёзд на GitHub

Об этом скилле

Server Security Check — Magento 2 Compromise Investigation

You are performing a comprehensive security investigation on a Magento 2 server. Execute each phase systematically. Report findings as you go — do not wait until the end.

IMPORTANT: This skill requires SSH access to the target server. Ask the user for:

  1. SSH connection details (user@host -p port)
  2. Root access method (su password, sudo, or root SSH)
  3. Webroot path (default: /var/www/webroot/ROOT or /var/www/html)

Set these as variables for the investigation:

SSH_CMD="ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no USER@HOST -p PORT"
WEBROOT="/var/www/webroot/ROOT"

PHASE 1: RAPID TRIAGE (run first, report immediately)

1.1 Server Identity & Age

# When was this server created?
stat /etc/machine-id
ls -lt --time=ctime /etc/ssh/ssh_host_*_key | head -1
cat /etc/hostname
uname -a

1.2 Active Threats Check

# Processes masquerading as kernel threads (run by non-root = MALICIOUS)
ps aux | grep -E '\[(kswapd|rcu_sched|mm_percpu|raid5|kstrp|watchdog|ksmd|xenbus|kthreadd|slub_flush)\]' | grep -v root

# GSocket reverse shell
ps aux | grep -E 'defunct|gs-netcat|gsocket'

# Deleted executables still running (common for in-memory malware)
ls -la /proc/*/exe 2>/dev/null | grep deleted

# Processes running from suspicious directories
ls -la /proc/*/cwd 2>/dev/null | grep -E 'pub/media|/tmp|/dev/shm'

# Suspicious listening ports
ss -tlnp | grep -v -E ':80|:443|:22|:3306|:6379|:9200|:9000'

# Check for rootkit via LD_PRELOAD
cat /etc/ld.so.preload 2>/dev/null

# Connections to known C2 infrastructure
netstat -an 2>/dev/null | grep -E '45\.77\.95\.4|109\.205\.213|193\.32\.162|gsocket\.ninja'

1.3 Crontab Analysis

# All user crontabs — look for base64, curl, wget, gsocket
crontab -l 2>/dev/null
for user in $(cut -f1 -d: /etc/passwd); do
  crons=$(crontab -l -u $user 2>/dev/null)
  [ -n "$crons" ] && echo "=== $user ===" && echo "$crons"
done

# Look for encoded/obfuscated cron entries
grep -r 'base64\|eval\|gsocket\|defunct\|GS_ARGS\|curl.*-o\|wget.*-O' /var/spool/cron/ /etc/cron* 2>/dev/null

# Check profile files for persistence
grep -l 'gsocket\|defunct\|GS_ARGS\|base64' ~/.profile ~/.bashrc ~/.bash_profile /etc/profile.d/* 2>/dev/null

If Phase 1 finds active threats: STOP and report to user before continuing.


PHASE 2: FILESYSTEM MALWARE SCAN

2.1 PHP Files in Media Directories (should NOT exist except errors/ and tcpdf/)

# Find ALL PHP-executable files in pub/media
find $WEBROOT/pub/media/ -type f \( \
  -name "*.php" -o -name "*.php3" -o -name "*.php4" -o -name "*.php5" \
  -o -name "*.php7" -o -name "*.php8" -o -name "*.pht" -o -name "*.phtml" \
  -o -name "*.phar" -o -name "*.inc" -o -name "*.module" -o -name "*.shtml" \
  -o -name "*.pgif" \
\) -not -path "*/errors/*" -not -path "*/tcpdf/*" -ls 2>/dev/null

# Find files with double extensions (image.jpg.php)
find $WEBROOT/pub/media/ -type f -regextype posix-extended \
  -regex ".*\.(jpg|jpeg|png|gif|svg|webp|ico|css|js)\.(php|phtml|phar|inc|sh|pl|py|cgi).*" -ls 2>/dev/null

2.2 Upload Directory Scan (primary attack vectors)

# PolyShell target: custom_options/quote
find $WEBROOT/pub/media/custom_options/ -type f ! -name '.htaccess' -ls 2>/dev/null

# SessionReaper target: customer_address
find $WEBROOT/pub/media/customer_address/ -type f -ls 2>/dev/null | head -50
find $WEBROOT/pub/media/customer_address/ -type f 2>/dev/null | wc -l

# Other sensitive upload dirs
find $WEBROOT/pub/media/customer/ -type f ! -name '.htaccess' -ls 2>/dev/null
find $WEBROOT/pub/media/import/ -type f ! -name '.htaccess' -ls 2>/dev/null
find $WEBROOT/pub/media/downloadable/ -type f ! -name '.htaccess' -ls 2>/dev/null
find $WEBROOT/pub/media/tmp/ -type f -name "*.php" -ls 2>/dev/null

2.3 GIF89a / PNG Polyglot Detection (images containing PHP)

# Files claiming to be images but containing PHP code
find $WEBROOT/pub/media/ -type f \( -name "*.jpg" -o -name "*.jpeg" -o -name "*.png" \
  -o -name "*.gif" -o -name "*.webp" -o -name "*.ico" \) \
  -exec sh -c 'head -c 500 "{}" | grep -Pql "<\?php|eval\(|base64_decode|shell_" && echo "SUSPECT: {}"' \; 2>/dev/null

# Use `file` command to detect mismatches (says "PHP" or "text" for images = bad)
find $WEBROOT/pub/media/ -type f \( -name "*.jpg" -o -name "*.gif" -o -name "*.png" \) \
  -not -path "*/cache/*" -not -path "*/.thumbs/*" \
  -exec sh -c 'type=$(file -b "{}"); echo "$type" | grep -qi "php\|text\|ascii" && echo "MISMATCH: {} = $type"' \; 2>/dev/null

2.4 PHP Code Hidden in Non-PHP Files

# Search for PHP tags inside image, JS, CSS, and text files
grep -rl '<?php\|eval(\|base64_decode\|shell_exec\|system(\|passthru\|exec(' \
  $WEBROOT/pub/media/ \
  --include="*.jpg" --include="*.jpeg" --include="*.png" --include="*.gif" \
  --include="*.svg" --include="*.webp" --include="*.ico" \
  --include="*.css" --include="*.txt" --include
Полный SKILL.md на GitHub

Установить server-scan в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл server-scan?

Comprehensive Magento 2 server security investigation and compromise detection. Use when investigating a potentially compromised server, scanning for malware, detecting webshells, or performing post-incident forensics.

Как установить скилл server-scan?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл server-scan запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить server-scan с