diff options
| author | Julien "shaddai" Reveret | 2016-04-14 16:04:47 +0200 |
|---|---|---|
| committer | Julien "shaddai" Reveret | 2016-04-14 16:04:47 +0200 |
| commit | 28cf1c090197b590b94e70d97016194d9b4b9cc9 (patch) | |
| tree | 5553a018b24428a3559021d4d0bfe00d3c3647b1 | |
| parent | dac09770e449526b799254bd19c710c664bfe2bd (diff) | |
adding -u option to update rules files
| -rwxr-xr-x | php-malware-finder/phpmalwarefinder | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/php-malware-finder/phpmalwarefinder b/php-malware-finder/phpmalwarefinder index 501ce47..db87349 100755 --- a/php-malware-finder/phpmalwarefinder +++ b/php-malware-finder/phpmalwarefinder | |||
| @@ -40,6 +40,26 @@ else | |||
| 40 | fi | 40 | fi |
| 41 | fi | 41 | fi |
| 42 | 42 | ||
| 43 | update_rules() { | ||
| 44 | SITE="https://raw.githubusercontent.com/nbs-system/php-malware-finder/master/php-malware-finder/" | ||
| 45 | RULES_FILES=('asp.yara' 'common.yara' 'bad_php.yara' 'php.yara' | ||
| 46 | 'whitelist.yara') | ||
| 47 | CONFIG_DIR="/etc/phpmalwarefinder/" | ||
| 48 | |||
| 49 | if [ ! -d $CONFIG_DIR ]; then | ||
| 50 | if [ ! -f ./common.yara ]; then | ||
| 51 | echo "no rules in $CONFIG_DIR or ./, exiting" | ||
| 52 | exit 1 | ||
| 53 | else | ||
| 54 | CONFIG_DIR="./" | ||
| 55 | fi; | ||
| 56 | fi; | ||
| 57 | |||
| 58 | for FILE in ${RULES_FILES[@]}; do | ||
| 59 | wget $SITE/$FILE -O $CONFIG_DIR/$FILE | ||
| 60 | done | ||
| 61 | } | ||
| 62 | |||
| 43 | # Determines the format of the target | 63 | # Determines the format of the target |
| 44 | # Check only the file extension and it's not even accurate | 64 | # Check only the file extension and it's not even accurate |
| 45 | determine_format() { | 65 | determine_format() { |
| @@ -95,11 +115,12 @@ Usage ${0##*/} [-cfhtvl] <file|folder> ... | |||
| 95 | -t Specify the number of threads to use (8 by default) | 115 | -t Specify the number of threads to use (8 by default) |
| 96 | -v Verbose mode | 116 | -v Verbose mode |
| 97 | -l Set language ('asp', 'php') | 117 | -l Set language ('asp', 'php') |
| 118 | -u update rules | ||
| 98 | EOF | 119 | EOF |
| 99 | } | 120 | } |
| 100 | 121 | ||
| 101 | OPTIND=1 | 122 | OPTIND=1 |
| 102 | while getopts "c:fht:vl:" opt; do | 123 | while getopts "c:fht:vl:u" opt; do |
| 103 | case "$opt" in | 124 | case "$opt" in |
| 104 | h) | 125 | h) |
| 105 | show_help | 126 | show_help |
| @@ -120,6 +141,10 @@ while getopts "c:fht:vl:" opt; do | |||
| 120 | l) | 141 | l) |
| 121 | FORMAT=${OPTARG} | 142 | FORMAT=${OPTARG} |
| 122 | ;; | 143 | ;; |
| 144 | u) | ||
| 145 | update_rules | ||
| 146 | exit 0 | ||
| 147 | ;; | ||
| 123 | '?') | 148 | '?') |
| 124 | show_help | 149 | show_help |
| 125 | exit 1 | 150 | exit 1 |
