diff options
| author | Julien "shaddai" Reveret | 2015-10-08 17:44:47 +0200 |
|---|---|---|
| committer | Mathieu Deous | 2015-10-29 14:55:04 +0100 |
| commit | ff0c609ce15299fcd0da5f5b471d3519495977ff (patch) | |
| tree | b217ff3ed047ad0f63c4e39b8f400eebafa0d1a3 /poc.py | |
| parent | 1b88cf3b85d8e3225fb55526f53cbf4df75d9813 (diff) | |
reorganized git repo
Diffstat (limited to 'poc.py')
| -rw-r--r-- | poc.py | 30 |
1 files changed, 0 insertions, 30 deletions
| @@ -1,30 +0,0 @@ | |||
| 1 | #!/usr/bin/env python | ||
| 2 | |||
| 3 | import fnmatch | ||
| 4 | import os | ||
| 5 | import sys | ||
| 6 | import time | ||
| 7 | |||
| 8 | try: | ||
| 9 | import yara | ||
| 10 | except ImportError: | ||
| 11 | print 'Please install python-yara' | ||
| 12 | sys.exit(0) | ||
| 13 | |||
| 14 | if len(sys.argv) != 2: | ||
| 15 | print 'Usage: %s folder_to_scan' % sys.argv[0] | ||
| 16 | |||
| 17 | rules = yara.compile('malwares.yara') | ||
| 18 | |||
| 19 | for cpt, (root, dirnames, filenames) in enumerate(os.walk(sys.argv[1])): | ||
| 20 | for filename in fnmatch.filter(filenames, '*.ph*'): | ||
| 21 | if not cpt % 1000: | ||
| 22 | time.sleep(3) | ||
| 23 | fname = os.path.join(root, filename) | ||
| 24 | if os.stat(fname).st_size: | ||
| 25 | matches = rules.match(os.path.join(root, filename), fast=True) | ||
| 26 | if matches: | ||
| 27 | matches = matches.pop() # only one match, since we're scaning files | ||
| 28 | print str(matches) + fname | ||
| 29 | print '\n'.join(hex(m[0]) + ':' + m[1] + ': ' + m[2] for m in matches.strings) | ||
| 30 | |||
