diff --git a/scan.py b/scan.py index 62488e4..972a201 100644 --- a/scan.py +++ b/scan.py @@ -12,7 +12,6 @@ import os import re import fnmatch -import textwrap whitelist = [ '/lp-msh-scanner/', @@ -301,7 +300,7 @@ def is_hacked(filename): if filename[0] != '/': filename = os.getcwd() + '/' + filename - return {'filename': filename, + return {'filename': filename[0:200], 'score': total_score, 'mtime': os.stat(filename).st_mtime, 'ctime': os.stat(filename).st_ctime, @@ -611,13 +610,14 @@ def is_hacked(filename): cleanup_available = True if cleanup_available and line_num == 1: cleanup_available = False - return {'filename': join(textwrap.wrap(filename, 200), + + return {'filename': filename[0:200], 'score': total_score, 'mtime': os.stat(filename).st_mtime, 'ctime': os.stat(filename).st_ctime, 'details': score_details, 'cleanup': cleanup_available} - # print total_score, filename, '::'.join(score_details).encode('utf-8') + #print total_score, filename, '::'.join(score_details).encode('utf-8') # from subprocess import Popen # if clean_PCT4: @@ -671,6 +671,7 @@ if __name__ == '__main__': for root, dirnames, filenames in os.walk(basedir): for filename in filenames: if fnmatch.fnmatch(filename, '*.php') or \ + fnmatch.fnmatch(filename, '*.txt') or \ fnmatch.fnmatch(filename, '*.js'): hacked = is_hacked(os.path.join(root, filename)) if hacked is not False and hacked['score'] >= MIN_SCORE: @@ -679,11 +680,13 @@ if __name__ == '__main__': filename = basedir root = os.getcwd() if fnmatch.fnmatch(filename, '*.php') or \ + fnmatch.fnmatch(filename, '*.txt') or \ fnmatch.fnmatch(filename, '*.js'): hacked = is_hacked(os.path.join(root, filename)) if hacked is not False and hacked['score'] >= MIN_SCORE: results.append(hacked) + results.sort(key=lambda x: x['score'], reverse=True) if SERIALIZER == 'yaml':