Commit Graph

23 Commits

Author SHA1 Message Date
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
Gabor Gyorvari
4f41362a46 extending patterns and whitelists 2016-08-15 15:07:23 +02:00
Gabor Gyorvari
dbeec3d29e extending patterns and whitelists 2016-08-12 21:39:10 +02:00
Gabor Gyorvari
5783ead57a extending patterns from 3rd samples source 2016-05-05 07:42:39 +02:00
Gabor Gyorvari
7e06f846ae first commit 2016-05-05 07:35:23 +02:00