Question

Can not delete or edit file.

Hello, I am working on a hacked wordpress site. and i have seen many malicious content inside. i have deleted most of those files except one. i can not delete that root file index.php or even can not edit that. can not change the file permission too. changing file permission, bring back the previous permission.

what should i do?

Thank you


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

A quick and rather superficial solution that worked for me:

  1. change the “index.php” file rights as previously explained.
  2. rename the “html” folder, for example to “html_temp” (be careful, your site and everything on it will be off and not operational as long as there is no “html” folder!!)
  3. delete the file “index.php”
  4. upload the proper “index.php” file
  5. rename “html_temp” folder back to “html”

I assume this specific hacked code searches for a root path starting from “html”, thus if you “break” this path it will not run. Consequently, it seems that if you manage to properly replace the “index.php” file you will be actually “protected” by the hacked code, since that proper file will eventually look immutable. Of course this assumption may not cover all cases.

Hope it helps someone in the thread.

Athanasios

I’ve had exactly the same problem. Ended up downloading my wp-content and wp-config to my pc then uploaded all other wordpress files to a new location because, when I deleted every single file and folder from the root, index.php and corrupt htaccess file still reloaded, so nothing on my website included hacked files. I found a cron job with (Ha ha ha) in the title, so deleted that. But that didn’t make any difference to the index.php. Permissions couldn’t be changed either. And to finally delete pyrocrafts.co.uk from its original location, I had to rename it before I was able to delete the folder. Very strange and worrying that something is still lurking in my home directory. Anyway pyrocrafts.co.uk is working well in it’s new home … for now I shall download a backup to a USB stick

@bobbyiliev Thank you. We didn’t get any error any time so it might be recreated after it is deleted. The .htaccess file can be deleted but is being recreated as a hidden file within 3 or 4 seconds.