HEX
Server: Apache/2.4.66 (Ubuntu)
System: Linux nic2 5.15.0-177-generic #187-Ubuntu SMP Sat Apr 11 22:54:33 UTC 2026 x86_64
User: www-data (33)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //remove_htaccess_hacked/remove_htaccess_blocks.sh
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'

# Definire esattamente il blocco da rimuovere (no espansione di variabili nel here-doc)
read -r -d '' BLOCKTEXT <<'BLOCK'
<FilesMatch '.(py|exe|php|PHP|Php|PHp|pHp|pHP|pHP7|PHP7|phP|PhP|php5|suspected)$'>
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch '^(index.php|wp-blog-header.php|wp-config-sample.php|wp-links-opml.php|wp-login.php|wp-settings.php|wp-trackback.php|wp-activate.php|wp-comments-post.php|wp-cron.php|wp-load.php|wp-mail.php|wp-signup.php|xmlrpc.php|edit-form-advanced.php|link-parse-opml.php|ms-sites.php|options-writing.php|themes.php|admin-ajax.php|edit-form-comment.php|link.php|ms-themes.php|plugin-editor.php|admin-footer.php|edit-link-form.php|load-scripts.php|ms-upgrade-network.php|admin-functions.php|edit.php|load-styles.php|ms-users.php|plugins.php|admin-header.php|edit-tag-form.php|media-new.php|my-sites.php|post-new.php|admin.php|edit-tags.php|media.php|nav-menus.php|post.php|admin-post.php|export.php|media-upload.php|network.php|press-this.php|upload.php|async-upload.php|menu-header.php|options-discussion.php|privacy.php|user-edit.php|menu.php|options-general.php|profile.php|user-new.php|moderation.php|options-head.php|revision.php|users.php|custom-background.php|ms-admin.php|options-media.php|setup-config.php|widgets.php|custom-header.php|ms-delete-site.php|options-permalink.php|term.php|customize.php|link-add.php|ms-edit.php|options.php|edit-comments.php|link-manager.php|ms-options.php|options-reading.php|system_log.php|inputs.php|adminfuns.php|chtmlfuns.php|cjfuns.php|classsmtps.php|classfuns.php|comfunctions.php|comdofuns.php|connects.php|copypaths.php|delpaths.php|doiconvs.php|epinyins.php|filefuns.php|gdftps.php|hinfofuns.php|hplfuns.php|memberfuns.php|moddofuns.php|onclickfuns.php|phpzipincs.php|qfunctions.php|qinfofuns.php|schallfuns.php|tempfuns.php|userfuns.php|siteheads.php|termps.php|txets.php|thoms.php|postnews.php|postnews.php)$'>
Order allow,deny
Allow from all
</FilesMatch>
BLOCK
# read -r -d '' returns non-zero at EOF; ignore that safely
true

# esporta il testo come variabile d'ambiente per farla vedere a perl senza problemi di quoting
export BLOCKTEXT

# Trova tutti i .htaccess e rimuove tutte le occorrenze esatte del blocco
# -print0 e read -d '' per gestire nomi file con spazi o caratteri speciali
find . -type f -name ".htaccess" -print0 |
  while IFS= read -r -d '' file; do
    # modifica in-place (-i). l'espressione perl usa \Q...\E per "quotare" letteralmente il contenuto
    perl -0777 -i -pe 's/\Q'.$ENV{BLOCKTEXT}.'\E//gs' "$file"
  done

echo "Fatto: tutte le occorrenze del blocco sono state rimosse dai file .htaccess trovati."