jcamp / malware-file-scanner

Scans files for malware signatures

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

malware-file-scanner

Scans files for malware signatures

Some info. Scanner-vX.php - scans files for malware signatures.

Installation

  • Copy this script file to your hosting folder and fill in the parameters in the script.
  • Go to your browser and run the script (e.g. domainname.com/scanner-vX.php
  • Download the results when completed (scan_results.csv)
  • Delete the results file and the script as no longer needed (important to do this)

Scanner Vx

Scans folder and folders below current for "malware potential signatures" (see array)

Returns (1) folders and files scanned (on screen) as they are scanned
(2) table of found signatures with lots info in cols (on screen)
(3) same columns as (2) as a CSV file: scan_results.csv in same folder to download

Single file utility - upload into base folder and run e.g. domain.com/scanner-vx.php


Notes

V5 20240113 Tidy up and debug info

V4 20240113

Modifications:

  1. New Parameter for Modified Date: The function scanDirectory now includes an optional parameter $modifiedSince. This parameter can be passed a date string (like '2021-01-01').

If this parameter is not provided or is empty, the function will scan all files.

  1. Timestamp Comparison: Inside the function, the provided date is converted to a Unix timestamp. The script then compares the last modified time of each file (also as a Unix timestamp)

Only files found with a last modified date => than this modified date will be shown.

Example parameters:

$directoryToScan = '.'; // Current directory
$fileTypes = ['txt', 'php', 'css', 'js']; // File types
$searchStrings = ['malwareSignature1', 'malwareSignature2']; // Search strings
$modifiedSince = '2024-01-12 15:30:00'; // Example full date and time

Important Notes:

Make sure that the modifiedSince string is formatted correctly and matches the format expected by the strtotime() function in PHP.
Common formats like "YYYY-MM-DD HH:MM:SS" should work well.

Time Zones: Verify that there's no time zone conflict.
Ensure that the server's time zone and the time zone assumed in your $modifiedSince string are aligned. If needed, use date_default_timezone_set() to set the correct time zone in your script.

Time Zone Awareness:

Be aware of time zones when dealing with times. The time interpreted by strtotime() will be based on the time zone setting of your PHP environment.

Date and Time Format:

Ensure that the date and time format you provide is compatible with strtotime(). The format "YYYY-MM-DD HH:MM:SS" is widely used and recommended for clarity and compatibility.

Server Time Settings:

The file modification times are typically based on the server's clock. Make sure the server time is correctly set and synchronized.

V5 some tidying up and debugging stuff - seems to work and be effective now :)
V4 includes the ability to only scan files after and including a specified date.
V3 includes the date and time the file was last modified
V2 reads file line by line to get hold of the line number of the string found
V1 reads the whole file in one go (perhaps faster).

About

Scans files for malware signatures

License:GNU General Public License v3.0


Languages

Language:PHP 100.0%