Category: Internet Security

What To Do If Your WordPress Website Gets Hacked

What To Do If Your WordPress Website Gets Hacked

What To Do If Your WordPress Website Gets Hacked 1

 

With WordPress being so popular and the vast amount of themes and plugins, it is a favorite target for hackers. In 99% of cases, your WordPress website is not actually targeted, most of the hacks are automated and carried out by bots.

 

Why do hackers hack WordPress websites?

Usually, they are using your site to make money. They do this by finding an exploit that allows them to upload file(s) or inject an existing file with their code. The code most commonly used is mailing scripts to send spam and fake login pages for things like banks, PayPal, etc (phishing). They may also insert ads into your website’s files. In the vast majority of cases, we see, your sites are not specifically targeted and they are not actually after you.

 

How was my WordPress website hacked?

Hackers use bots that scan your WordPress website for vulnerabilities both known and unknown. There are some comprehensive scanning tools out there that will scan your WordPress site for 1000’s of vulnerabilities, and other possible weaknesses such as out of date server software (PHP, Apache, Mysql, etc..). If an exploit is found then the bot will try and use it, usually to upload a script or inject code. Once this has been done files and permissions can be changed/added as needed. Most commonly hackers gain access through out of date WordPress core files, plugins, and themes. Always keep everything up to date and if a plugin is not actively maintained by its developers then you really should get rid of it.

 

How do I know if my WordPress website is hacked?

 

In many cases, you will not know. The hacker that is using your website to make $$ will usually try and keep things quiet. Often you do not know until you are notified by us that your site has been compromised. Our systems constantly monitor your websites for suspicious activity such as mailing scripts, mail sending, and many other forms of malicious code. Other hints that something is awry may be:

  • Website suddenly showing a white page or 500 error
  • Ads and popups that you did not add.
  • Decreased website performance.
  • Logins stop working and mail recovery of login / password no longer working.
  • Your website and or pages of your website redirect to another site.

 

How do I recover my WordPress website after being hacked?

The hackers usually will hide malicious code (backdoors) throughout your website and they can be hard to track down and eliminate them all. If you miss one they will be back in no time at all. The best way to recover your site from a hack is from backup, but before you do that you need to find out when your site was hacked.

 

Finding out when your website was hacked

First thing we need to do is find some of the hacked and or compromised files. There are a variety of ways that this can be accomplished:

  • Use something like Wordfence to scan for malicious files (careful though it can remove legitimate files)
  • Scan for malicious files from SSH (see below)
  • Ask us to run a scan on your account

Scanning from SSH is quick and easy, here I will include the 3 most common types of base64 and variations that we see, these usually are enough to help you quickly identify compromised or added malicious files.

Make sure you are in your website directory using the cd command, for example, “cd public_html”

find . -type f -name '*.php' | xargs grep -l "eval *("

 

This scans for  “eval”. This will return quite a few false positives as there are legitimate uses for this code in WordPress. Here is what I get from a fresh WordPress 4.8 install with this command:

./wp-includes/functions.php
./wp-includes/class-snoopy.php
./wp-includes/class-json.php
./wp-admin/includes/class-pclzip.php

 

These are legitimate and clean files in WordPress 4.8 that come with “eval”. Now lets scan specifically for “base64_decode”.

find . -type f -name '*.php' | xargs grep -l "base64_decode *("

 

Here again is the results from our fresh WordPress 4.8 install:

./wp-includes/class-wp-customize-widgets.php
./wp-includes/class-wp-simplepie-sanitize-kses.php
./wp-includes/class-smtp.php
./wp-includes/class-phpmailer.php
./wp-includes/ID3/module.audio.ogg.php
./wp-includes/IXR/class-IXR-message.php
./wp-includes/SimplePie/Sanitize.php
./wp-includes/random_compat/random_bytes_com_dotnet.php
./wp-admin/includes/file.php

 

These are all legitimate files that include base64 in WordPress 4.8. One last scan for “gzinflate”.

find . -type f -name '*.php' | xargs grep -l "gzinflate *("

 

Again results from our fresh WordPress 4.8 install:

./wp-includes/class-requests.php
./wp-includes/class-wp-http-encoding.php
./wp-includes/SimplePie/File.php
./wp-includes/SimplePie/gzdecode.php
./wp-admin/includes/class-pclzip.php

 

To verify whether the results are indeed bad files you need to compare them against clean WordPress files. Found some suspicious files in a plugin directory? Download a fresh copy of that plugin and compare the files.

Checking when a file was last changed

Once you have a confirmed list of “bad” files you want to check the date they were last changed, you can do so using the “stat” command.

stat date-test.txt

File: ‘date-test.txt

Size: 17

Blocks: 8

IO Block: 4096   regular file

Device: 803h/2051d

Inode: 27798301

Links: 1Access: (0664/-rw-rw-r–)

Uid: ( 1020/xoiwjrbc)

Gid: ( 1020/xoiwjrbc)

Access: 2017-07-03 08:11:22.511398107 -0400

Modify: 2017-07-03 08:11:22.511398107 -0400

Change: 2017-07-03 08:11:22.511398107 -0400

 

Sometimes the hackers script will attempt to hide file activity by modifying the Access and Modify time-stamps to match other files on your WordPress installation, but change time cannot be modified. Now that you have a general idea of when files were changed or modified you can move on to the best option of recovering from a hack, and that is backups.

 

Using backups to recover from hacked WordPress

Due to the complexity and difficulty of cleaning files and databases (yes they might have also added to your database) you best option for recovery is restoring files and database(s) from backup. This is the reason why we went through the above steps of finding a somewhat accurate date as to when the site was compromised. At Kickassd we provide complimentary R1soft backups that are taken daily and stored for 30 days. In the majority of cases a hack becomes apparent inside of that 30 day window, and our R1soft backups allow you to quickly and easily recover your website.

But some hackers will gain access and sit silently for months before using their backdoors. In these cases for most the only option is to clean their website which is a comprehensive and and complex task which is beyond the scope of this article. If you use our hosting services and find this is the case please don’t hesitate to let us know!

The post What To Do If Your WordPress Website Gets Hacked appeared first on Kickassd – The Web Hosting Blog.

OpenVPN On Centos 7 With CSF Easy Setup

OpenVPN On Centos 7 With CSF Easy Setup

Internet-Security

Using a VPN in your everyday internet activity is smart and I highly encourage people to take up this practice. Using a VPN in this way encrypts your connection so not even your ISP can see what you are doing. Any sites you visit will not see your home IP but the VPN IP and this is a large and important step to keeping yourself and your information safe online. Also if you are a website owner where security is a priority this can greatly help you secure your site. Lockdown any admin sections and sensitive logins to the VPN IP. Have other people that need access? No problem, simply create them their own OpenVPN config file.

You do not need to be a Linux guru to accomplish this and it is easier than you might think!

First step is to get yourself a VPS / Cloud Server. RadVPS is a great choice for this, and their smallest server (1024MB RAM) will work perfectly. Create the server with CentOS 7 operating system and wait for confirmed server deployment. Now you can login with SSH using something like Putty and run the following commands:

yum update -y

Check everything that was updated and if you see an update regarding “kernel” go ahead and reboot the server (type “reboot”), give it a few minutes and login again.

Install OpenVPN With Nyr’s Installer

There is really an awesome installer on GitHub written by and maintained by Nyr that automates the entire process and really makes it simple. Check it out here:

https://github.com/Nyr/openvpn-install

To install simply do:

wget https://git.io/vpn -O openvpn-install.sh && bash openvpn-install.sh

Once it is done login to your server with SFTP and grab the config file. Now let’s make this VPN more secure using CSF (Config Server Firewall). CSF is a powerful and flexible Firewall that makes it easy to secure you server from many different types of attacks.

Install CSF

yum install perl -y

yum install bind-utils -y

yum install perl-libwww-perl -y

yum install unzip -y

cd /usr/src
wget https://download.configserver.com/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh

Configure CSF To Play Nice With OpenVPN

We need to do a little extra work for these 2 to play nice.

nano /etc/csf/csfpre.sh

Paste the following into that file:

iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -s 10.8.0.0/24 -j ACCEPT
iptables -A FORWARD -j REJECT
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -j SNAT --to-source 123.123.123.123

Note: replace 123.123.123.123 with your actual server IP. Save, exit, and restart csf.

csf -r

Add The OpenVPN Port And Remove Others

nano /etc/csf/csf.conf

First option you will see is Testing = “1”. Change that to > Testing = “0” 

Now scroll down until you see the port lines, you want to remove all ports except 22 (SSH), and add port 1194 which is OpenVPN assuming you went with the default setting on install. It should look like this when done:

# Allow incoming TCP ports
TCP_IN = "22,1194"

# Allow outgoing TCP ports
TCP_OUT = "22,1194"

# Allow incoming UDP ports
UDP_IN = "1194"

# Allow outgoing UDP ports
# To allow outgoing traceroute add 33434:33523 to this list
UDP_OUT = "1194"

Save, exit, and restart CSF. Your server is now secured from bad guys quite well.

Additional Security

I also highly recommend that you setup public/private keys and disable password authentication this adds a great extra layer of security to your server!

 

The post OpenVPN On Centos 7 With CSF Easy Setup appeared first on Kickassd – The Web Hosting Blog.