Commit Graph

54 Commits

Author SHA1 Message Date
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 Botsikas
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ábor
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ábor
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
nichogenius
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
nichogenius
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
nichogenius
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
nichogenius
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
nichogenius
b503b8124c Added Comments and Documentation
Added Comments and Documentation
2017-08-19 19:55:04 -06:00
nichogenius
015cc6f668 fixed -m checksum flag
fixed -m checksum flag
2017-08-19 17:55:19 -06:00
nichogenius
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
nichogenius
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
nichogenius
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
nichogenius
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
nichogenius
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
nichogenius
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
nichogenius
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
nichogenius
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
nichogenius
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
nichogenius
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
nichogenius
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
nichogenius
1c7963149e Bug fix for last commit
comment and empty line filters were in the wrong place
2017-07-26 03:09:47 -06:00
nichogenius
8122d11eff Whitespace and Comment handling for pattern files
The pattern files are large and complex enough to justify some whitespace and comments to explain what each entry is.

Added logic to check if the line is empty or if the first character is equal to '#' before using it as a pattern.  Simply skips over empty and commented lines.
2017-07-25 23:55:37 -06:00
Gabor Gyorvari
cd78f4a8ac Separate patterns from code 2017-02-22 13:56:09 +01:00
Gabor Gyorvari
acb58f1c2e New ignore argument to exclude files and folders with glob style matching 2017-01-11 19:10:59 +01:00
Gabor Gyorvari
b522a23a74 Case insensitive extension check, removed problematic whitelist 2016-12-29 08:31:27 +01:00
Gabor Gyorvari
5675fb8e79 New arguments to follow symlinked directories, default is not to follow 2016-12-27 17:51:39 +01:00
Gabor Gyorvari
1f6efc124b Patterns update from manul samples 2016-12-27 17:45:47 +01:00
Gabor Gyorvari
91174b5a60 Remove too regular patterns 2016-12-27 15:48:48 +01:00
screwloose83
608caf6d5e Removed unneeded time zone and comment. 2016-12-10 16:09:29 +01:00
screwloose83
d12f5982b2 Added Extra Patterns for Scanning.
Added Extra Patterns for scanning from samples i found on my server.
Added extra-check it checks for googlebot and htaccess useful for cleaning up left over files.
2016-12-10 16:09:29 +01:00