Hosting issues and possibly site hacking

Hello everyone,

I'm having issues with my OVH hosting. I have an "Archive" folder that I created (which is not a WordPress or Joomla folder) and I can't delete it; I don't even have access to the permissions. Has anyone encountered this problem and what solution should be adopted?

The email from OVH tells me there is a cache.php file, which is a hacker file, inside this folder.

Thanks to everyone.

Hello @LaurentK6

The simplest and fastest solution is to perform a Hosting and Database restoration to a date before your issue. For example, a week earlier.

See the paragraph in my guide: T - Restoring your OVH site to an earlier date

Thanks for this tip; actually I used GEMINI to create a PHP script that directly deletes the file and the folder.

Hello @LaurentK6

What did GEMINI recommend to you?

Which domain?

Don’t forget to back up your site on your PC.

________________________________________________________________

Backups of your site at OVH are not permanent.

Excerpt from my guide: T - Restoration OVH of your site to an earlier date

At OVH, restoring your hosting can only go back a maximum of two weeks.

If your site was hacked three weeks ago, you’re out of luck and will have to delete everything and rebuild your site from scratch.

At OVH, restoring your database can only go back a maximum of two months

Make sure to back up Hosting and Database on your PC once a month.

See the paragraph in my guide: Ua - Complete backup of your site on your PC

See the paragraph in my guide: Ub - Complete restoration of your site from your PC

Hello :slight_smile:

When you encounter difficulties deleting data on a hosting service, don't hesitate to check the file access permissions.

Personally, I like to share this site which is handy for understanding CHMOD permissions for beginners: https://chmodcommand.com/chmod-666/

If you have information about this PHP file, I'm interested! And curious :stuck_out_tongue:

Astérix

Just like me. :grinning_face:

I would add that SFTP is better than FTP when it comes to deleting files whose names contain exotic characters.

The same applies when a directory contains more than 4,998 files.

Actually I no longer had permissions on the folder to delete. I'm posting the GEMINI code below.

here is the code proposed by GEMINI

<?php
// Activate error display
ini_set('display_errors', 1);
error_reporting(E_ALL);

// Set the path to your folder (e.g., 'wp-content/uploads/weird-folder' or 'weird-folder')
$target = '1';

function forceDelete($dir) {
    if (!file_exists($dir)) {
        return "Le dossier n'existe pas à cet emplacement : " . htmlspecialchars($dir);
    }

    if (!is_dir($dir)) {
        chmod($dir, 0777);
        return unlink($dir) ? "Fichier supprimé : $dir" : "Échec suppression fichier : $dir";
    }

    // Force the permissions of the main folder
    chmod($dir, 0777);

    // Iterate over all files and subfolders (including hidden ones like .htaccess)
    $items = array_diff(scandir($dir), array('.', '..'));
    foreach ($items as $item) {
        $path = $dir . DIRECTORY_SEPARATOR . $item;
        chmod($path, 0777);
        if (is_dir($path)) {
            forceDelete($path);
        } else {
            if (!unlink($path)) {
                echo "Impossible de supprimer le fichier : " . htmlspecialchars($path) . "<br>";
            }
        }
    }

    return rmdir($dir) ? "<b>Dossier supprimé avec succès !</b>" : "<b>Échec de la suppression du dossier racine.</b>";
}

echo forceDelete($target);
?>

Thanks @LaurentK6

But could you provide the "line‑by‑line" version?
That would give us better readability.

<?php
// Enable error display
ini_set('display_errors', 1);
error_reporting(E_ALL);

// Set the path to your folder (e.g., 'wp-content/uploads/weird-folder' or 'weird-folder')
$target = '1';

function forceDelete($dir) {
    if (!file_exists($dir)) {
        return "The folder does not exist at this location: " . htmlspecialchars($dir);
    }

    if (!is_dir($dir)) {
        chmod($dir, 0777);
        return unlink($dir) ? "File deleted: $dir" : "Failed to delete file: $dir";
    }

    // Force permissions on the main folder
    chmod($dir, 0777);

    // Iterate over all files and subfolders (including hidden ones like .htaccess)
    $items = array_diff(scandir($dir), array('.', '..'));
    foreach ($items as $item) {
        $path = $dir . DIRECTORY_SEPARATOR . $item;
        chmod($path, 0777);
        if (is_dir($path)) {
            forceDelete($path);
        } else {
            if (!unlink($path)) {
                echo "Unable to delete file: " . htmlspecialchars($path) . "<br>";
            }
        }
    }

    return rmdir($dir) ? "<b>Folder successfully deleted!</b>" : "<b>Failed to delete the root folder.</b>";
}

echo forceDelete($target);
?>

Hello @LaurentK6

I understand the script much better, thank you very much.

Your script works in two steps:

  • force the access rights of a folder to 777 and then delete it
  • and this for all subfolders of the directory tree.

Thank you very much

Thanks for sharing the script!

Thanks to Gemini :wink: