64 Commits
Author SHA1 Message Date
Gabor Gyorvari 55e75079df Little return value fix 2026-06-02 06:46:11 +02:00
Thomas SchmidtandClaude Sonnet 4.6 31fa36c82a Fix multiple bugs and improve robustness
- Fix date format in report(): H:m:s -> H:i:s (m=month, i=minutes)
- Fix loadWhitelists(): skip lines shorter than 32 chars to avoid empty hash entries
- Fix updateCombinedWhitelist(): return false on hash mismatch after download
- Fix scan(): handle file_get_contents() failure for unreadable files
- Fix scanFunc_RE(): suppress and handle invalid regex patterns gracefully
- Fix addWordpressChecksums(): validate version format, handle network/JSON errors, support both API response formats
- Add 30s HTTP timeout to updateCombinedWhitelist() network requests
- Fix composer.json minimum PHP version: 5.2 -> 5.3 (anonymous functions require 5.3)
- Add .gitignore for .idea/, whitelist.dat, vendor/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-01 16:12:36 +02:00
Gabor Gyorvari 7ac65c0c8d Hide error arg fix 2024-05-22 14:04:07 +02:00
Gabor Gyorvari 2e8b9c604f Merge remote-tracking branch 'origin/master' 2022-11-18 14:10:57 +01:00
Gabor Gyorvari 802ead97cc Flag usage fix about wordpress version checksum 2022-11-18 14:10:45 +01:00
Fot0nandGitHub e4755feeef Make it compatible with php 8.1
strftime was deprecated.
2022-09-19 13:49:05 +03:00
Elliot Kendall 77ebd8abd7 Cast $needle in calls to strpos/stripos to string to avoid automatic ordinal conversion of integer patterns 2022-07-25 09:52:27 -07:00
Gabor Gyorvari 34ea02323b New flag to specify custom white list file 2021-04-01 12:44:15 +02:00
Michael Palmer 78bee49176 https://github.com/scr34m/php-malware-scanner/issues/66 2021-02-24 13:36:10 +01:00
Gabor Gyorvari 22b51a1ee3 Change addWordpressChecksums to public, fix #58 2020-10-05 10:59:13 +02:00
Gabor Gyorvari e9a45d4bdc Allowing multiple use of -d option and braces in path syntax, closes #56 2020-08-18 15:36:52 +02:00
Gabor Gyorvari 2973e55871 Change function visibility to allow usage as library 2020-06-23 19:37:29 +02:00
Christos BotsikasandGitHub d67a865bf0 Use array() instead of the short array syntax []
Short array syntax [] was added in PHP 5.4 but the scanner should be able to work with [PHP >=5.2.0](https://github.com/scr34m/php-malware-scanner/blob/master/composer.json#L9).
2019-07-24 12:32:59 +02:00
Gabor Gyorvari b290826f82 New option to disable statistics 2019-05-28 09:17:11 +02:00
PROMETEUSWEB\PrometeusWeb 4990f94239 Set scan method to public to allow for direct scan of single files in library mode 2019-03-01 11:02:38 +01:00
Gabor Gyorvari 79e7067803 Merge branch 't43' 2018-12-31 11:10:53 +01:00
Gabor Gyorvari 507603ae56 Combined whitelist release 2018-12-31 11:10:31 +01:00
Gabor Gyorvari e61092bc24 Fix double whitelist checks 2018-12-10 21:59:02 +01:00
Gabor Gyorvari afc4cd4ef9 Update to live URL for big data 2018-12-10 13:05:21 +01:00
Gabor Gyorvari 5cf90cd371 Working with pre generated big hash database for whitelisting 2018-12-10 13:02:03 +01:00
Gabor Gyorvari f3c8758adf New argument to scan every file 2018-10-28 06:36:59 +01:00
Győrvári GáborandGitHub 516662c80c Merge pull request #34 from marek-knappe/wordpress-whitelist
Added wordpress files md5sum whitelisting
2018-10-25 14:01:10 +02:00
Marek Knappe 3ce01f42ae Added wordpress files md5sum whitelisting 2018-10-23 17:52:10 +10:00
Győrvári GáborandGitHub f080b656cf Merge pull request #33 from marek-knappe/fix-cli-relative-directory
Add real path conversion for cli scan.php to have relative path.
2018-10-23 09:24:00 +02:00
Marek Knappe cbdb812572 Add real path conversion for cli scan.php to have relative path.
Also it runs for cwd() dir if no dir given Closes #31
2018-10-23 17:11:03 +10:00
Marek Knappe 936c7cb667 Fixed ANSI color with Quitting message - closes #30 2018-10-23 16:10:52 +10:00
Gabor Gyorvari a6360c56a0 Short argument names 2018-09-05 19:56:43 +02:00
Gabor Gyorvari f9647806c8 Output formatting argument 2018-09-05 13:01:21 +02:00
Gabor Gyorvari 34a89a9518 Added new argument to display matching pattern's line number in the file. 2018-08-25 18:13:45 +02:00
Gabor Gyorvari 8b01805952 Variables naming normalisation 2018-03-02 19:29:50 +01:00
Gabor Gyorvari 072189bd8e Few improvements to make library like behaving to be composer friendly 2018-03-02 19:28:03 +01:00
Gabor Gyorvari ceb278bf6c Allow multiple extension argument to be used 2018-03-02 18:44:51 +01:00
Gabor Gyorvari 99801506e7 Code style formatting 2018-03-02 18:36:24 +01:00
nichogeniusandGitHub 60578297b3 Bug fix - forgot '/' in the new path
Bug fix - forgot '/' in the new path
patterns weren't loading :(
2017-08-20 13:34:23 -06:00
nichogeniusandGitHub 697ed3c9ab Updated flags, pattern paths
added
--all-output
--pattern
--no-stop

removed --verbose/-v

put color in the pattern comments
updated paths to pattern files to either base64_patterns, or definitions
2017-08-20 13:29:58 -06:00
nichogeniusandGitHub 85072b5eaf 2 typos = 1 fixed bug
typo in showHelp - ignore spelled incorrectly
typo in pattern file load for the b64 keyword file... broke part of base64 mode.
2017-08-19 22:29:23 -06:00
nichogeniusandGitHub b5c31c97fc added a forgotten flag to the help
looks like i forgot to add the --no-color option to the help display.
2017-08-19 20:52:08 -06:00
nichogeniusandGitHub b503b8124c Added Comments and Documentation
Added Comments and Documentation
2017-08-19 19:55:04 -06:00
nichogeniusandGitHub 015cc6f668 fixed -m checksum flag
fixed -m checksum flag
2017-08-19 17:55:19 -06:00
nichogeniusandGitHub 7a8a2c1c77 updated flags
updated flags

checksum can be -m for md5
comment can be -c for comment
2017-08-19 17:50:46 -06:00
nichogeniusandGitHub dea08acd2e large 'scan' function broken up comment flag added
scan function has been broken up into a multiple functions which should make it more modular if future scan types are needed.
--comment, -a flag was added which prints the first comment to appear prior to the matched pattern in the pattern file.
2017-08-19 17:46:09 -06:00
nichogeniusandGitHub dc60cea192 Bug Fixes, added time/checksum flags, organized
--Fixed a bug with the out function.  Previous updates of mine did not update all calls to the out function which I changed the parameters for.  Fixed this by replacing the out function with an 'error' function.
--Alphabetized function definitions and did some general tidying up
--Made all functions private except the constructor.
--Created parseArgs function to handle reading in options.
--Fixed a bug with 'extra-check' where htaccess and googleBot were being pushed to the pattern array each time a file was scanned. 
 This bug was created when I moved the pattern initialize code to the constructor.  Moved extra-check code with the rest of the initialize pattern calls.
--Added -no-color, -time, and -checksum flags.  I'd prefer if the output was only as spammy as the user requests.  Time should be helpful in tracing when the attack occurred and if files are related to the same hack.  Time and checksum do not display by default.  no-color flag makes it easier to dump to plain text files.
2017-08-19 12:57:49 -06:00
nichogeniusandGitHub 44aafb0972 Cleaned up pattern whitespace and comment handling
checking for comments and whitespace lines in pattern files should only be done once when the patterns are loaded.
Added this code to the loadPatterns() function and removed it from the 3 scan loops.
2017-08-18 07:31:33 -06:00
nichogeniusandGitHub 1909eb0781 Pattern Loading Moved To Constructor
It makes more sense to put the one time pattern load code into the constructor rather than the scan method.
2017-08-16 01:39:44 -06:00
nichogeniusandGitHub 575278613e Verbose Bug fix and pattern loading optimization
Verbose flag was not proceeding with the next scan due to !found being set.  Added a check to see if it is verbose when it decides to do the next scan.

Patterns should be loaded once and only once.  The files aren't large so not a problem with memory, however it might impact performance if we are loading the same 3 files ever time we scan a file.
2017-08-16 01:29:58 -06:00
nichogeniusandGitHub 62e25eb5f8 Several Significant changes to scan.php
- Gave each flag option a short or long option; like i:ignore or d:directory or k:hide-ok
- Added a verbose option that instructs the scan to scan a file for ALL matches and not just stop at the first one.
- Restructured the output code to allow for the verbose flag, mainly a new function printPath and where the md5 hash is computed
- Modified the output to be cleaner, checksum is printed first as it is fix-width and to make it easier to paste into the whitelist file.
- Modified the output to be 'bash safe', ie when I accidentally paste my scan results into my terminal, the '#' should make sure everything is treated as a comment.  This is in contrast to possibly attempting to execute absolute paths to potentially malicious PHP scripts and the usage of the '>' which tells the shell to write to a file.  Also enclosed each path in {} for similar purposes.
- Printing the matched string/pattern in $color... might change later depending on  preference.
2017-08-16 00:11:54 -06:00
nichogeniusandGitHub b7942d6874 preg_match 's' flag changed to 'm'
the 's' flag tells preg_match to operate in multi-line mode.  the 'm' flag does the same, but allows line begin and ends to still be matched which is useful in some cases.
2017-08-15 12:04:59 -06:00
nichogeniusandGitHub ab8a6c471a Added new flag options
Added a single short flag for every long flag and a single long flag for every short flag.
This now gives us 2 ways to set each flag.
Also updated the showhelp.
Dropped an unnecessary 'else' statement.
2017-08-15 09:14:31 -06:00
nichogeniusandGitHub 857999aee2 Added case-insensitive search logic
Added case-insensitive search logic

will search patterns_raw.txt, patterns_iraw.txt and patterns_re.txt
2017-07-26 05:17:53 -06:00
nichogeniusandGitHub 0a198f82f5 using strpos instead of substr_count
don't know if it's faster, but I don't see a reason to count the number of times a line exists in a file for our use case.
2017-07-26 05:00:04 -06:00