mirror of
https://github.com/myvesta/vesta
synced 2025-08-20 13:24:25 -07:00
New command: v-delete-wordpress-uploads-php-files
This commit is contained in:
parent
928bea0870
commit
b88f0e56bf
2 changed files with 71 additions and 0 deletions
70
bin/v-delete-wordpress-uploads-php-files
Normal file
70
bin/v-delete-wordpress-uploads-php-files
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: delete PHP files from WordPress uploads folder
|
||||||
|
# options: DOMAIN
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable & Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
[ "$(whoami)" != "root" ] && { echo "You must be root to run this command."; exit 1; }
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
DOMAIN="$1"
|
||||||
|
[ -z "$DOMAIN" ] && { echo "Usage: v-delete-wordpress-uploads-php-files DOMAIN"; exit 1; }
|
||||||
|
|
||||||
|
USER="$(/usr/local/vesta/bin/v-search-domain-owner "$DOMAIN")"
|
||||||
|
[ -z "$USER" ] && { echo "Domain $DOMAIN does not exist."; exit 1; }
|
||||||
|
|
||||||
|
WP_PATH="/home/$USER/web/$DOMAIN/public_html"
|
||||||
|
[ ! -f "$WP_PATH/wp-config.php" ] && { echo "WordPress is not installed on this domain."; exit 1; }
|
||||||
|
|
||||||
|
quarantined=0;
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
cd "$WP_PATH" || exit 1
|
||||||
|
|
||||||
|
files=$(find wp-content/uploads/ -type f -name "*.php")
|
||||||
|
|
||||||
|
if [ -z "$files" ]; then
|
||||||
|
echo "= No PHP files found in WordPress uploads folder."
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "= Found PHP files in WordPress uploads folder for domain $DOMAIN :"
|
||||||
|
echo "-------------------------------------"
|
||||||
|
echo "$files"
|
||||||
|
echo "-------------------------------------"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
read -r -p "Do you want to delete these files? (y/n): " RESPONSE < /dev/tty
|
||||||
|
if [ "$RESPONSE" == "y" ] || [ "$RESPONSE" == "Y" ]; then
|
||||||
|
for file in $files; do
|
||||||
|
source_file="/home/$USER/web/$DOMAIN/public_html/$file"
|
||||||
|
destination_file="/srv/wp-uploads-php-files-quarantine/$DOMAIN/$file"
|
||||||
|
destination_folder=$(dirname "$destination_file")
|
||||||
|
mkdir -p "$destination_folder"
|
||||||
|
chown $USER:$USER "$destination_folder"
|
||||||
|
mv "$source_file" "$destination_file"
|
||||||
|
echo "= File $source_file moved to $destination_file"
|
||||||
|
quarantined=1;
|
||||||
|
done
|
||||||
|
chown -R $USER:$USER "/srv/wp-uploads-php-files-quarantine/$DOMAIN"
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
if [ "$RESPONSE" == "n" ] || [ "$RESPONSE" == "N" ]; then
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
if [ $quarantined -eq 1 ]; then
|
||||||
|
echo "= All PHP files moved to quarantine."
|
||||||
|
echo "= You can find them in /srv/wp-uploads-php-files-quarantine/$DOMAIN"
|
||||||
|
else
|
||||||
|
echo "= No PHP files found in WordPress uploads folder."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0;
|
|
@ -33,6 +33,7 @@ declare -a tasks=(
|
||||||
"/usr/local/vesta/bin/v-change-wordpress-admin-passwords"
|
"/usr/local/vesta/bin/v-change-wordpress-admin-passwords"
|
||||||
"/usr/local/vesta/bin/v-fix-wordpress-core"
|
"/usr/local/vesta/bin/v-fix-wordpress-core"
|
||||||
"/usr/local/vesta/bin/v-delete-inactive-wordpress-plugins-and-themes"
|
"/usr/local/vesta/bin/v-delete-inactive-wordpress-plugins-and-themes"
|
||||||
|
"/usr/local/vesta/bin/v-delete-wordpress-uploads-php-files"
|
||||||
"/usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate"
|
"/usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate"
|
||||||
"INTERACTIVE=1 /usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate"
|
"INTERACTIVE=1 /usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue