Exploit databaseDownload repository ZIP
GH-2ac443a4770bc275362d75839ef772a3
ikow/wp2shell
Sources for CVE-2026-63030
50 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files5
ikow/wp2shellRevision fdf42ae8b203
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
wp2shell-patch/patch.sh
Shell · 4,887 bytes#!/bin/bash
#
# wp2shell Emergency Patch Script
# Applies temporary mitigations for CVE-2026-63030 + CVE-2026-60137
#
# Usage: sudo bash patch.sh /path/to/wordpress
#
# This script:
# 1. Patches the batch array alignment bug (prevents desync)
# 2. Adds re-entrancy guard to serve_request()
# 3. Fixes the SQL injection in WP_Query author__not_in
#
# For permanent fix: update to WordPress 6.9.5 / 7.0.2
#
set -euo pipefail
WP_DIR="${1:-.}"
if [ ! -f "$WP_DIR/wp-includes/version.php" ]; then
echo "[-] WordPress not found at: $WP_DIR"
echo " Usage: $0 /path/to/wordpress"
exit 1
fi
WP_VERSION=$(grep "^\$wp_version" "$WP_DIR/wp-includes/version.php" | grep -oP "'[^']+'" | tr -d "'")
echo "[*] WordPress version: $WP_VERSION"
echo "[*] WordPress path: $WP_DIR"
# Check if already patched
if grep -q "is_dispatching" "$WP_DIR/wp-includes/rest-api/class-wp-rest-server.php" 2>/dev/null; then
echo "[+] Already patched (re-entrancy guard present)"
exit 0
fi
echo "[*] Backing up files..."
cp "$WP_DIR/wp-includes/rest-api/class-wp-rest-server.php" \
"$WP_DIR/wp-includes/rest-api/class-wp-rest-server.php.bak"
cp "$WP_DIR/wp-includes/class-wp-query.php" \
"$WP_DIR/wp-includes/class-wp-query.php.bak"
cp "$WP_DIR/wp-includes/rest-api.php" \
"$WP_DIR/wp-includes/rest-api.php.bak"
# ─── Fix 1: Batch array alignment ────────────────────────────────────────────
echo "[*] Applying Fix 1: Batch array alignment..."
sed -i.tmp '
/if ( is_wp_error( \$single_request ) ) {/{
N
/\$has_error.*= true;/{
N
/\$validation\[\].*= \$single_request;/{
/\$matches\[\]/!{
s/\$validation\[\].*= \$single_request;/\$matches[] = $single_request;\n\t\t\t\t$validation[] = $single_request;/
}
}
}
}
' "$WP_DIR/wp-includes/rest-api/class-wp-rest-server.php"
# ─── Fix 2: Re-entrancy guard in serve_request() ─────────────────────────────
echo "[*] Applying Fix 2: Re-entrancy guard..."
sed -i.tmp '
/public function serve_request( \$path = null ) {/a\
\t\tif ( $this->is_dispatching() ) {\
\t\t\treturn false;\
\t\t}
' "$WP_DIR/wp-includes/rest-api/class-wp-rest-server.php"
# ─── Fix 3: Re-entrancy guard in rest_api_loaded() ───────────────────────────
echo "[*] Applying Fix 3: rest_api_loaded() guard..."
# Add guard before the serve_request call in rest-api.php
sed -i.tmp '
/Return an error message if query_var is not a string/i\
\t// Short-circuit if REST dispatch is already in flight.\
\tif ( isset( $GLOBALS["wp_rest_server"] )\
\t\t&& $GLOBALS["wp_rest_server"] instanceof WP_REST_Server\
\t\t&& $GLOBALS["wp_rest_server"]->is_dispatching()\
\t) {\
\t\treturn;\
\t}\
' "$WP_DIR/wp-includes/rest-api.php"
# ─── Fix 4: SQL injection in author__not_in ───────────────────────────────────
echo "[*] Applying Fix 4: SQL injection fix..."
# This is the most complex fix - replace the vulnerable code block
php -r "
\$file = '$WP_DIR/wp-includes/class-wp-query.php';
\$content = file_get_contents(\$file);
\$old = <<<'PHP'
if ( ! empty( \$query_vars['author__not_in'] ) ) {
if ( is_array( \$query_vars['author__not_in'] ) ) {
\$query_vars['author__not_in'] = array_unique( array_map( 'absint', \$query_vars['author__not_in'] ) );
sort( \$query_vars['author__not_in'] );
}
\$author__not_in = implode( ',', (array) \$query_vars['author__not_in'] );
\$where .= \" AND {\$wpdb->posts}.post_author NOT IN (\$author__not_in) \";
PHP;
\$new = <<<'PHP'
if ( ! empty( \$query_vars['author__not_in'] ) ) {
\$author__not_in_id_list = wp_parse_id_list( \$query_vars['author__not_in'] );
if ( count( \$author__not_in_id_list ) > 0 ) {
sort( \$author__not_in_id_list );
\$where .= sprintf(
\" AND {\$wpdb->posts}.post_author NOT IN (%s) \",
implode( ',', \$author__not_in_id_list )
);
\$query_vars['author__not_in'] = \$author__not_in_id_list;
}
PHP;
if (strpos(\$content, 'wp_parse_id_list') !== false) {
echo 'Already patched (wp_parse_id_list present)' . PHP_EOL;
exit(0);
}
\$result = str_replace(\$old, \$new, \$content);
if (\$result === \$content) {
echo 'WARNING: Could not apply SQL injection patch (code pattern not found)' . PHP_EOL;
echo 'Manual patching required for class-wp-query.php' . PHP_EOL;
exit(1);
}
file_put_contents(\$file, \$result);
echo 'SQL injection patch applied.' . PHP_EOL;
"
# Cleanup temp files
find "$WP_DIR/wp-includes" -name "*.tmp" -delete 2>/dev/null || true
echo ""
echo "[+] All patches applied successfully!"
echo " Backups saved with .bak extension"
echo ""
echo " Recommended: update to WordPress 6.9.5 / 7.0.2 for the official fix"