From c62db2e70379175ba7c3528aff9769e1b5831f62 Mon Sep 17 00:00:00 2001 From: Gabor Gyorvari Date: Tue, 6 Mar 2018 20:09:53 +0100 Subject: [PATCH] Update README --- README.md | 72 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 9e7bfc4..75b3265 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,14 @@ PHP malware scanner =================== -Traversing directories for files with php extensions and testing files against text or regexp rules, the rules based on self gathered samples and publicly vailable malwares/webshells. +Traversing directories for files with php extensions and testing files against text or regexp rules, the rules based on self gathered samples and publicly available malwares/webshells. The goal is to find infected files and fight against kiddies, because to easy to bypass rules. +How to install? +--- + +Simply clone the repository or use `composer require scr34m/php-malware-scanner` to do it. + How to use? ----------- @@ -27,24 +32,22 @@ Usage: php scan.php -d -t --time Show time of last file change ``` -Ignore argument could be used multiple times and accept glob style matching ex.: "cache*", "??-cache.php" or "/cache" etc. +Ignore argument could be used multiple times and accept glob style matching ex.: "`cache*`", "`??-cache.php`" or "`/cache`" etc. -Extension argument defaults to .php . +Extension argument defaults to "`.php`" and also can be used multiple times too. ---base64 is an alternative scan mode which ignores the main pattern files and uses a large list of php keywords and functions that have been converted to base64. Slower and prone to false positives, but gives additional base64 scanning coverage. These pattern files are located in base64_patterns and were derived from php 7 keywords and functions. Not many PHP extensions are included. - ---comment flag will display the last comment to appear in the pattern file before the matched pattern, so documenting the pattern files is important. - ---pattern flag will display the pattern string that was matched. +* `--base64` is an alternative scan mode which ignores the main pattern files and uses a large list of php keywords and functions that have been converted to base64. Slower and prone to false positives, but gives additional base64 scanning coverage. These pattern files are located in base64_patterns and were derived from php 7 keywords and functions. Not many PHP extensions are included. +* `--comment` flag will display the last comment to appear in the pattern file before the matched pattern, so documenting the pattern files is important. +* `--pattern` flag will display the pattern string that was matched. Patterns -------- -There are three main pattern files the cover different typtes of pattern matching. There is one pattern per line. All lines where the very first character is a '#' is considered a comment and not used as a pattern. Whitespace in the pattern files is not used. +There are three main pattern files the cover different types of pattern matching. There is one pattern per line. All lines where the very first character is a "`#`" is considered a comment and not used as a pattern. Whitespace in the pattern files is not used. --patterns_raw.txt -- Raw string matching --patterns-iraw.txt -- Case insensitive raw string matching --patterns-re.txt -- Regular expression matching. +* `-patterns_raw.txt` - Raw string matching +* `-patterns-iraw.txt` - Case insensitive raw string matching +* `-patterns-re.txt`- Regular expression matching. Whitelisting ------------ @@ -53,27 +56,32 @@ See [whitelist.txt](https://github.com/scr34m/php-malware-scanner/blob/master/wh Tools --------- --text2base64.py - Takes a plaintext string as input and returns 3 base64 string equivalents. - Python script that needs to be executed from the terminal to be used. - - Marking as executable is required. - ~$ chmod +x text2base64.py + +**text2base64.py** + +Takes a plaintext string as input and returns 3 base64 string equivalents. +Python script that needs to be executed from the terminal to be used. + +Marking as executable is required. +``` +~$ chmod +x text2base64.py +``` + +It is worth noting that the presence of one of the three output strings in a block of text does not 100% guarantee that the string was +present in the original code. It is guaranteed that IF the subject string was present in the original code, then one of the three +output strings will be present in the base64 version. + +``` +./text2base64.py 'base64_decode' +YmFzZTY0X2RlY29kZ +Jhc2U2NF9kZWNvZG +iYXNlNjRfZGVjb2Rl +``` - It is worth noting that the presence of one of the three output strings in a block of text does not 100% guarantee that the string was - present in the original code. It is guaranteed that IF the subject string was present in the original code, then one of the three - output strings will be present in the base64 version. - - usage: - ./text2base64.py 'base64_decode' - YmFzZTY0X2RlY29kZ - Jhc2U2NF9kZWNvZG - iYXNlNjRfZGVjb2Rl - - An example: The presence of 'YmFzZTY0X2RlY29kZ' does not guarantee that 'base64_decode' is in the plain text code. - It is guaranteed that IF 'base64_decode' was present in the plain text code, then one of these three base64 strings WILL be present. - The presence of 'YmFzZTY0X2RlY29kZ' in a block of code may be because 'ase64_decod' was in the original code. - Note the missing edge characters which is due to bit misalignments and character bleed. +An example: The presence of 'YmFzZTY0X2RlY29kZ' does not guarantee that 'base64_decode' is in the plain text code. +It is guaranteed that IF 'base64_decode' was present in the plain text code, then one of these three base64 strings WILL be present. +The presence of 'YmFzZTY0X2RlY29kZ' in a block of code may be because 'ase64_decod' was in the original code. +ote the missing edge characters which is due to bit misalignment and character bleed. Resources ---------