Skip to content

My Website Has Been Hacked: What Should You Do Step by Step?

On a hacked website, the first thing to do is take a full backup of the files and database without touching any file, and keep the server logs as evidence. Then close access, trace the attack, and if necessary file a criminal complaint and notify under KVKK.

Nurullah Okatan · Content Writer
· Updated: · 14 min read

My Website Has Been Hacked: What Should You Do Step by Step?

On a hacked website, the first thing to do is take a full backup without touching the files and keep the server logs as evidence. Then find the attacker's entry point and close it, and restore the site from a clean backup. If personal data was leaked, the KVKK notification and the criminal complaint to the prosecutor's office should also be started on the same days.

What should you do in the first hour after you notice your site has been hacked?

Do not delete any files in the first hour. According to the WPBeginner guide, a full backup of the site should be taken before you begin deleting files or making any other changes. This backup should include both the files and the database. During cleanup, any content deleted by mistake can be restored from this copy. The files left by the attacker are also examined later on this copy. Do not leave the backup on the server; download it to your own computer or a separate disk.

Quick Actions to Take: First Steps

According to the article 'My Website Has Been Hacked. What Should I Do?' by lawyer Burak Sağlam, the following records from the time of the attack and afterward should be kept as evidence:

  • server logs
  • access records
  • error messages
  • records showing intrusion attempts
  • reports from security software

On many hosting panels, old log files are automatically deleted at regular intervals. For this reason, download the records without waiting and keep them in their original state in a separate folder.

If the site is showing a harmful page to visitors, it should be taken offline. A fake payment form, redirection to another site, or a file download warning are examples of this. It is enough to put up a maintenance page and grant access to the admin panel only from your own IP address. Change the admin, database, and hosting panel passwords within the same hour. For basic concepts about the site's infrastructure, you can browse the Web Design & Development articles.

AI assistant for this topic

Türk Bilişim AI answers your questions instantly
Online
  1. Hi! Ask whatever you're curious about.

Tracing the attack with your hosting provider

The hosting provider sees the server-side records more broadly than you do. According to the WPBeginner guide, two questions should be put to the provider. The first is how they think the attacker accessed the site. The second is whether they have a recent clean backup. The answer to the first shows which door needs to be closed. The answer to the second determines how long the cleanup will take.

The same guide recommends immediately inspecting PHP files in the /wp-content/uploads/ folder. This folder is used for images, documents, and other media files. The presence of an executable PHP file there most likely points to a backdoor left by the attacker. These files should be noted with their location and creation dates before they are deleted.

There are three ways to tell modified files apart:

  1. For core files, compare them with clean copies of the same version downloaded from the official source. On WordPress sites, the command 'wp core verify-checksums' with WP-CLI performs this comparison.
  2. Sort the files by modification date; files changed during the attack period stand out.
  3. In the code, look for concealed commands such as 'eval', functions that decode encoded text, and redirects added to the .htaccess file.

If you need support on the server side, the Infrastructure & Support services section brings together hosting, maintenance, and backup topics.

Looking for API Development & Integration?

Closing the access paths the attacker used

As long as the entry point the attacker used stays open, a cleaned site will be hacked again. Direct root login to the server should be closed. Root is the account that can modify every file on the server. If its password is compromised, the attacker gains control of the entire server. Instead, open a separate user with sudo privileges. This way administrative commands are logged, and the root password is never transmitted over the network.

If possible, disable password login entirely and require SSH key authentication. Passwords can be guessed or obtained from another leak. With an SSH key, the private key stays only on your computer, and bots that brute-force passwords against the server get nowhere.

File transfer is another commonly used entry point. Use SFTP or FTPS instead of FTP, and if you do not need it, disable FTP entirely.

ProtocolHow the connection is madeHow the password is transmitted over the networkWhen it is used
FTPClassic unencrypted file transferAs plain text, which an eavesdropper can readShould not be used, should be disabled
SFTPWorks over an SSH connectionEncrypted, supports login with an SSH keyThe first choice on servers with SSH access
FTPSTLS encryption is added to FTPEncrypted, requires a certificate on the serverOnly when a tool that relies on FTP is the only option

After the access paths are closed, renew the database password and the WordPress secret keys (salt keys). When the keys change, all open sessions are terminated. Türk Bilişim, which calls itself Turkey's best Custom Web App & SaaS firm, has been working as a digital agency since 1998 and provides maintenance and support after launch. If you want to hand off the task of tightening server access to a team, the firm's Cyber Security & SSL service works in this area.

Criminal complaint and KVKK notification for a hacked site

According to lawyer Burak Sağlam, hacking a website constitutes a cybercrime under the Turkish Penal Code. For this reason, the first legal step is usually to file a criminal complaint with the Chief Public Prosecutor's Office. The petition should clearly state when the attack was discovered, the affected domain name, and the damage observed.

Methods to Recover Your Website

If the site holds customer, member, or employee information, a second obligation arises. The data controller must notify the breach to the Personal Data Protection Board and to the affected persons. According to the same article, if notification is not made or the data controller is negligent in data security, KVKK can impose administrative fines. Compiling a list of the types of data leaked (name, email, phone, address, payment information) speeds up the notification.

The logs saved in the first hour and the full backup taken are the basis of the legal process. They are submitted together with the criminal complaint. The prosecutor's office may send them for expert examination. The examination tries to establish the source of the attack, its timing, and which data were accessed. To show that the records were not altered later, take a hash value of each file and write them into a separate document. Do not work on the original files; always perform the examination on copies.

Returning with a clean backup and making a new attack harder

According to SiteGround's guide, a 30-day backup should also be stored separately from the hosting provider's own backup system. If the provider's server is compromised, the backups there carry the same risk. A cloud storage service or a separate server is suitable for this copy. An attack can go unnoticed for several weeks; a long backup history makes it possible to return to a clean point.

To choose the backup to restore, find the date of the first suspicious entry in the logs. Use the nearest backup taken before that date. After restoring, perform these checks:

  1. Confirm that no PHP files remain in the upload folder.
  2. Check the administrator user list for accounts you do not recognize.
  3. Compare the core files again with official copies.
  4. Install theme, plugin and core updates before opening the site.

Do not skip the last step, because a clean backup may also contain the vulnerability the attack used.

In the weeks after cleanup, install a file integrity monitoring tool that sends an email alert for every changed file. Also check the security issues report in Google Search Console regularly. For those who want to hand over backup and recovery planning to a team, Türk Bilişim's Data Backup & Business Continuity service covers this process. The only way to see that backups really work is to perform a restore test on a staging environment once a month.

Looking for Mobile App?

Frequently asked questions

Do I need to completely delete and rebuild a hacked site?

In most cases you do not; a clean backup and closed access routes are enough. If there is no clean backup, or if the backdoors have spread into the database, the core, theme and plugins are reinstalled from scratch and the content is transferred manually.

What should I do if Google has flagged my site as dangerous?

After finishing the cleanup, open the security issues report in Google Search Console. There, submit a review request and briefly describe the fixes you made. The warning is lifted when the review concludes positively.

How long does cleanup take?

The duration depends on whether a clean backup exists and on the number of files the attack has spread to. If a current, clean backup exists, the work is mostly limited to restoring and running the checks. If there is no backup, file-by-file inspection is required and the time increases.

Can a site with up-to-date plugins still be hacked?

Yes. A stolen FTP password, an SSH login left open with root access, or a vulnerability in another site on the same server can also lead to an attack. An up-to-date plugin does not protect the site as long as access routes remain open.

Have a project?

Türk Bilişim · Free Quote

Get a free quote for your Android App Development project

Leave your number and we will get back to you right away. The call is free.

Read the privacy notice

Nurullah Okatan Content Writer

The editorial desk of a team delivering websites, e-commerce and software projects since 1998.

LinkedInInstagramFacebook

Share this article

Comments

Comments

No comments yet.

Write a comment

Your rating (optional)

Privacy notice

We will send a confirmation link to your email so that your comment can appear.

Regional Services

Looking for Web Design & Development in your city?

We also provide this service in your region. Related regional pages:

See all regional services

Türk Bilişim · Digital Transformation Advisor

Online
Hi! Tell us the project or idea on your mind and let’s begin together.
Ask anything, Türk Bilişim AI answers instantly.