summaryrefslogtreecommitdiff
path: root/scanner.py
diff options
context:
space:
mode:
authorJulien Voisin2015-03-03 15:58:59 +0100
committerJulien Voisin2015-03-03 15:58:59 +0100
commit807248f9343a4cabb48c3be1a512b27f6377e871 (patch)
tree20e8de5615e900c6bb312d2e8b9446630d4400c5 /scanner.py
First commit!
Diffstat (limited to 'scanner.py')
-rw-r--r--scanner.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/scanner.py b/scanner.py
new file mode 100644
index 0000000..bbd5fa2
--- /dev/null
+++ b/scanner.py
@@ -0,0 +1,44 @@
1import argparse
2import os
3import glob
4import imp
5import sys
6import logging
7import time
8logging.basicConfig(level=logging.INFO)
9
10import modules.grep_count as grep_module
11import modules.entropy as entropy_module
12import modules.whitelist as whitelist_module
13import modules.libfuzzy as fuzzy_module
14
15parser = argparse.ArgumentParser(description='Fuzzy matching for malwares')
16group = parser.add_mutually_exclusive_group(required=True)
17group.add_argument('--save', '-s', help='Path to save the databases', default=None)
18group.add_argument('--filenames', '-f', nargs='*', help='Files to check')
19parser.add_argument('--sleep', '-t', type=int, default=0, help='Sleep between files processing')
20args = parser.parse_args()
21
22
23grep = grep_module.GrepCount()
24entropy = entropy_module.Entropy()
25whitelist = whitelist_module.HashWhitelist()
26fuzzy = fuzzy_module.FuzzyMatcher()
27
28if args.save: # Save the computed database
29 for m in [whitelist, fuzzy]:
30 m.save(args.save + '.' + m.name)
31else:
32 for f in args.filenames:
33 for root, _, filenames in os.walk(f):
34 for filename in filenames:
35 fpath = os.path.join(root, filename)
36
37 grep_results = grep.is_malware(fpath)
38 entropy_results = entropy.is_malware(fpath)
39 fuzzy_results = fuzzy.is_malware(fpath)
40 if grep_results or entropy_results or fuzzy_results:
41 if whitelist.is_malware(fpath) and '/.git/' not in fpath: # Not in whitelist
42 logging.info('MALWARE: ' + fpath)
43
44 time.sleep(args.sleep)