Hosting & Domaining Forum

Hosting Discussion => Hosting Security and Technology => Vulnerabilities => Topic started by: weeaysmwy on Sep 20, 2023, 12:02 AM

Title: Backdoor Shell Overwrites .htaccess Files
Post by: weeaysmwy on Sep 20, 2023, 12:02 AM
Hello there. I encountered an issue - my hosting account got infiltrated by a backdoor shell, which replaced all htaccess files on websites and now continuously redirects mobile devices to third-party sites. The process of overwriting the files with 644 permissions does not yield any results since the files are overwritten again after 30 minutes.

Unfortunately, I am unsure of the exact date when this happened, but I noticed it over the weekend.

Has anyone dealt with a similar parasite and knows how to handle it?

I managed to locate the infection (it came through the built-in plugin tinymce.com compat3x) and successfully removed it. Many thanks to aybolit for their assistance in cleaning up the remnants.

Now, the question is: what measures can be taken to protect oneself in the future and seal the vulnerability? My WordPress site has been updated to the latest version, but I am uncertain if plugins like AntiVirus would be effective in preventing the infiltration of shells.

Could someone provide a reliable solution to ensure a high probability of avoiding such issues in the future?
Title: Re: Backdoor Shell Overwrites .htaccess Files
Post by: Ensurnded on Sep 20, 2023, 01:39 AM
Dealing with website security can be challenging, but there are several steps you can take to protect yourself and reduce the chances of similar issues happening in the future. Here are some recommendations:

1. Keep your software up to date: Always ensure that your WordPress installation, themes, and plugins are running on the latest versions. Most updates include security patches that address vulnerabilities.

2. Use reputable plugins: Stick to well-known and trusted plugins from reliable sources. Avoid installing plugins from unknown or unreliable developers, as they might introduce security risks.

3. Disable unused plugins and themes: Remove any plugins or themes that you're no longer using. Having unused software increases the potential attack surface.

4. Use strong login credentials: Choose unique, complex passwords for your WordPress admin account and database. Enforce password strength requirements and consider using a password manager to store your passwords securely.

5. Enable two-factor authentication (2FA): Implementing 2FA adds an extra layer of security to your login process by requiring a second form of verification, such as a code sent to your mobile device.

6. Regularly backup your website: Perform regular backups of your website files and databases. This ensures you have a clean copy to restore from in case of an attack or compromise.

7. Install a security plugin: Consider using a reputable security plugin like Wordfence or Sucuri. These plugins can help identify vulnerabilities, scan for malicious files, and provide additional protective measures.

8. Monitor your website regularly: Keep an eye on your website's performance, traffic, and visitor behavior. Any anomalies might indicate a potential security issue.

9. Web hosting security: Evaluate the security measures offered by your hosting provider. Look for features like firewall protection, malware scanning, and intrusion detection systems.

10. Periodic security audits: Conduct periodic security audits of your website to identify and fix any vulnerabilities.


additional recommendations to further enhance the security of your WordPress website:

1. Limit plugin usage: Minimize the number of plugins you use on your website. Each plugin can introduce potential vulnerabilities, so only install those that are necessary.

2. Remove unused themes: Similar to plugins, remove any unused themes from your WordPress installation. Old and inactive themes can be potential entry points for attackers.

3. Use secure hosting: Choose a reputable hosting provider that prioritizes security. Look for providers that offer features like regular backups, SSL certificates, and server-side security measures.

4. Implement a web application firewall (WAF): A WAF can help filter out malicious traffic and block suspicious requests. Consider using a WAF service or installing a WAF plugin for your WordPress site.

5. Harden your WordPress installation: Take additional steps to harden your WordPress installation by making modifications to your wp-config.php file. This includes adding security keys, disabling file editing, and limiting login attempts.

6. Regularly update themes and plugins: In addition to keeping your WordPress core up to date, make sure to regularly update your themes and plugins to the latest versions. Developers often release updates to fix security vulnerabilities.

7. Monitor file changes: Keep an eye on file modifications and monitor for any unauthorized changes. There are plugins available that can help you with this, such as Wordfence or Sucuri.

8. Educate yourself and your team: Stay informed about the latest security threats and best practices. Educate yourself and your team on topics like phishing attacks, social engineering, and safe browsing habits.


few more recommendations to further enhance your website's security:

1. Secure your login page: Protect your WordPress login page by limiting access attempts and implementing measures like reCAPTCHA to prevent automated login attempts.

2. Use a secure hosting environment: Consider using a managed WordPress hosting service that specializes in website security. These providers often have built-in security features and regular scanning for malware or vulnerabilities.

3. Implement SSL/TLS encryption: Install an SSL certificate on your website to enable HTTPS. This ensures that data transmitted between your visitors' browsers and your website is encrypted, making it harder for attackers to intercept sensitive information.

4. Regularly scan for malware: Perform regular malware scans on your website to identify any malicious files or code. Many security plugins offer this functionality, allowing you to detect and remove any potential threats.

5. Monitor user privileges: Limit user access to your WordPress site. Only provide administrative privileges to trusted users who need them. Regularly review and revoke access for any inactive or unnecessary user accounts.

6. Disable file editing in WordPress dashboard: Prevent unauthorized modifications to your website's files by disabling the file editing feature in the WordPress dashboard. You can do this by adding the following line to your wp-config.php file:
  define('DISALLOW_FILE_EDIT', true);

7. Use a content delivery network (CDN): Consider leveraging a CDN to help protect against distributed denial-of-service (DDoS) attacks and improve website performance.

8. Stay informed about security best practices: Keep yourself updated with the latest security practices and vulnerabilities specific to WordPress. Follow credible security blogs and subscribe to newsletters or forums dedicated to WordPress security.


When a backdoor shell infiltrates a website, it often targets critical files like .htaccess to maintain persistence and redirect traffic. Here are some additional details about backdoor shells and their impact on .htaccess files:

1. What is a backdoor shell? A backdoor shell is a malicious script or code that provides unauthorized access to a system. Once installed, it enables attackers to execute arbitrary commands, modify files, and control the compromised website remotely.

2. How do backdoor shells overwrite .htaccess files? Attackers may gain access to your website through vulnerabilities in plugins, themes, or weak passwords. Once inside, they often replace the .htaccess file with their own version containing malicious code. This modified .htaccess file redirects incoming traffic to third-party websites.

3. Purpose of overwriting .htaccess files: By modifying the .htaccess file, attackers can control how web requests are processed, including redirects, URL rewriting, or preventing access to specific files or directories. This allows them to manipulate incoming traffic to serve their own malicious purposes.

4. Continuously overwritten .htaccess files: If the attackers have maintained access to your hosting account, they can continuously overwrite the .htaccess file even if you restore it with proper permissions (644). This persistence may indicate that the original source of the attack has not been fully eliminated.

5. Cleaning up the backdoor shell: It's crucial to remove the backdoor completely from your website. This involves not only restoring the .htaccess file but also identifying any other compromised files and removing them. Professional assistance may be required to ensure a thorough cleanup.

6. Strengthening .htaccess security: While it's important to restore a clean .htaccess file, it's equally essential to strengthen its security. You can add rules to protect against common exploits, restrict access to critical files, prevent directory listings, or set up IP-based restrictions. However, note that incorrect .htaccess modifications can break your site, so proceed with caution or seek expert help.
Title: Re: Backdoor Shell Overwrites .htaccess Files
Post by: lerryjim on Sep 20, 2023, 03:53 AM
In the event of such an occurrence, I took the following measures:
1) Transferred the site files from the server to my local computer using FTP.
2) Ran a scan on these files using an antivirus software (I employed a free utility provided by drWeb). As a result, I obtained a list of infected files. I made sure that only unnecessary files were affected and no essential files were contaminated.
3) Consequently, I eradicated the infected files on the server, thus resolving the problem at hand.

It is unfortunate, however, that I was unable to uncover the source of the malware. It serves as a reminder that staying vigilant and proactive against such threats is of utmost importance in our increasingly digitized world.
Title: Re: Backdoor Shell Overwrites .htaccess Files
Post by: vingler on Sep 20, 2023, 05:02 AM
If the results are not a concern, one can scan and use scripts to make replacements, among other things. However, none of these approaches can guarantee the complete detection of an infection. As stated earlier, the surefire method to eliminate it is to erase everything and reinstall clean copies. It is crucial that the copies are truly clean and not just filled with empty shells.

Empty shells can still pose a potential risk, so it's important to be cautious and thorough in the process. Taking these steps will help ensure a more secure environment free from any lingering threats.