Blog Sections Open

Cleaning Up Script Injections That Appear Near the Closing HTML Tag

A recurring malware pattern in older PHP hosting environments was script injection near the closing HTML tag, often from files outside the obvious template layer.

If a site starts outputting random external scripts just before </html>, the first mistake is to inspect only templates and chunks. In many infections the injected code lives elsewhere: compromised core files, writable includes, server-level append handlers, or malicious files dropped outside the expected theme structure.

Where to look first

  • recently modified PHP files across the whole project, not only templates
  • .htaccess files and PHP bootstrap files
  • writable upload folders that now contain executable files
  • hosting cron jobs or control-panel injections
  • server logs around the time the infection first appeared

Immediate response checklist

  1. Take the site offline or restrict public access if possible.
  2. Replace the core and theme files from a clean source.
  3. Reset FTP, hosting, database, and manager passwords.
  4. Scan for backdoors, not just visible injected scripts.
  5. Review file permissions and disable unnecessary write access.

On hacked legacy sites, removing the visible script is never enough. The real job is finding the persistence mechanism that keeps putting it back.

Newer post

Fixing Old URLs That Persist After Changing Resource Aliases

Why Evolution CMS can keep redirecting to stale aliases after a slug change and how to clear the right layers.

Older post

Fixing a Blank Manager Editing Pane After Saving a Resource

What to check when the Evolution CMS manager turns white after save and the resource tree stops refreshing automatically.