SuperScan: Website file change monitoring tool
Core functions:
SuperScan is an upgraded script designed to promptly remind webmasters of any changes to their files, including additions, modifications or deletions. It works by scanning the specified directory and comparing the hash of the current file with the hash value stored in the database that was previously scanned.
Efficient and lightweight:
SuperScan tools are efficient and do not affect server performance. Scanning an account with 1500 files takes about 0.75 seconds. It allows frequent scans without overwhelming the webmaster, only reports changes since the last scan and provides daily summary reports.
Forensic support and security enhancement:
SuperScan also supports forensic investigations, which stores the last modified date and time of the file in the database, as well as the hash value of the most recently scanned. It can run outside of the website space to prevent casual hacks and can even alert webmasters of coding issues by changing the error_log file.
As a certified ethical hacker, I know that prevention is the best strategy to stop hacking, but if a hacker really breaks through the line of defense, the sooner you know, the faster you can take action to limit your losses.
Previously, I introduced a script called hashscan to track website changes. The script executes via daily CRON, reads files in a specified directory (for example, the public_html directory of an account on the server), generates hash values (for files with a specific file extension), and transfers them with previously scanned in the database Compare hash values. This is a great way for website owners to get them to discover files that hackers have added, changed, or deleted in a timely manner.
This article will introduce an updated version of this script called SuperScan.
Advantages of SuperScan:
The main advantage of SuperScan is that it can report any changes to files in your account, whether the file changes are added, changed or deleted. SuperScan was designed to avoid overwhelming website administrators. It only provides reports of changes since the last scan (default is one hour, but can be configured via CRON) and summary reports (default is daily, but can also be configured via CRON).
Since it takes about 0.75 seconds to scan an account with 1500 files, SuperScan can run frequently without affecting server performance.
To support forensic investigations, the file's last modified date and time, as well as the hash value of the most recently scanned (and previous scans of the changed file) are saved in the database.
No need to change the scanner file, as all variables are set in the required configuration script. You can select the specific file extension (or all file extensions) to scan in the configuration script, or if you select all file extensions, you can select the file extension to ignore. In addition, you can specify directories that the scanner will not scan.
While SuperScan files can be tested within the website space, I recommend moving them out of the website space via CRON for production use to prevent casual hacking.
Finally, an additional benefit is that changes to the (no extension) error_log file are captured and can draw the attention of the website administrator to the encoding issues missing during the testing process.
SuperScan Logic:
The logical flow of SuperScan is as follows:
Database, variables and working arrays:
To avoid details here, I have added comments to all scripts.
In short, there are three tables in the database:
Warning #1: I have to emphasize that the $testing variable set by configure.php will trigger a large amount of output, so it can only be used for testing and not during CRON jobs!
Warning #2: Since path/to/file is used as a key, it must be unique. This means multiple accounts can never scan the same file.
Warning #3: Additionally, Windows servers will use backslashes, which will be changed to slashes immediately because they will cause characters in the database to be lost. Additionally, using apostrophes in file names will cause problems with database queries.
Work arrays are designed to take advantage of PHP's functions that access keys ($file_path; this is also a file structure iterator, so never change $iter->key()).
$baseline is read before starting the scan, $current is the result of the scan, and the $added, $altered and $deleted arrays accumulate changes from $baseline and are used to update the $baseline for the next scan.
File:
superscan.zip file contains 7 files:
Cleaning:
Create $report when a file change is detected and store and send emails when it is not a "negative report". A summary report is used to get a "warm, vague feeling" when you don't receive a change report.
During the cleaning process, records in the history and scan tables for more than 30 days are automatically cleared to prevent the database from growing infinitely, large arrays are destroyed (reset to empty), and the database is closed.
Summary:
I believe SuperScan has been greatly improved over my previous efforts and is a tool worth upgrading. It can frequently notify changed files, and "negative reporting" won't overwhelm the webmaster with unnecessary "unchanged" notifications.
Download SuperScan code from GitHub
Acknowledgements:
SuperScan was suggested by Han Wechgelaer (NL) who emailed to extend my previous hashscan script to capture history of account file changes, as well as perform more frequent evaluations and add daily summary.
Han was very generous with providing his startup copy on this project, and between us, this evolved into SuperScan. Without Han’s gentle supervision and help, SuperScan would never have started, and of course it would not have become the excellent tool today.
I would love to know how you view this script, or if you have any questions or feedback.
FAQs on detecting hacked files with Cron.php SuperScan:
Cron.php SuperScan is a powerful tool designed to detect and identify hacked files in the system. It works by scanning system files regularly (usually set by the user) and alerting any suspicious or modified files when they are detected. This tool is especially useful for webmasters and system administrators who need to maintain system security and integrity.
Setting up Cron.php SuperScan involves uploading scripts to your server and configuring them to run regularly. This can be done through the server's control panel or through the command line. Once the setup is complete, the script will automatically scan your system files and alert you of any potential threats.
Cron.php SuperScan detects various file types that are usually associated with hackers. This includes PHP files, HTML files, JavaScript files, and more. It can also detect hidden files and directories that may be used by hackers to unauthorized access to your system.
Cron.php SuperScan provides a more comprehensive and automated solution compared to other file scanning tools. While other tools may require manual scanning and analysis, Cron.php SuperScan automates the process, saving you time and effort. It also provides detailed reports of its results, making it easier for you to identify and address potential threats.
While Cron.php SuperScan is an effective tool for detecting hacked files, it does not prevent hackers. Its main function is to alert you of potential threats so that you can take appropriate measures. However, using this tool regularly can help you maintain your system's security and reduce the risk of successful hacking.
Scan frequency depends on your specific needs and the level of security required by the system. However, it is generally recommended to run Cron.php SuperScan at least once a day for optimal security.
If Cron.php SuperScan detects a hacked file, action must be taken immediately. This may include deleting files, recovering files from a clean backup, or contacting a cybersecurity professional for further assistance.
Yes, Cron.php SuperScan allows you to customize its settings to suit your specific needs. This includes setting the scan frequency, specifying the file type to scan, and configuring alert notifications.
Cron.php SuperScan is designed to work with most PHP-enabled systems. However, it may be compatible with not all systems, so it is recommended to check system requirements before installation.
Cron.php SuperScan is a paid tool, which means it needs to be used for a paid basis. But, given the level of security it offers and the potential cost of a successful hack, it is a worthwhile investment for most businesses and individuals.
The above is the detailed content of Quickly Detect Hacked Files via CRON/PHP: SuperScan. For more information, please follow other related articles on the PHP Chinese website!