This repository has been archived by the owner on Jun 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
triage.py
56 lines (42 loc) · 1.8 KB
/
triage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
# This file is part of Viper - https://github.com/viper-framework/viper
# See the file 'LICENSE' for copying permission.
from viper.common.abstracts import Module
from viper.core.database import Database
from viper.core.session import __sessions__
class Triage(Module):
cmd = 'triage'
description = "Perform some initial triaging and tagging of the file"
authors = ['nex']
def __init__(self):
super(Triage, self).__init__()
self.parser.add_argument('-a', '--all', action='store_true', help="Triage all files")
def _triage_file_type(self, obj):
tags = []
# TODO: extend this triaging with as many relevant tags as possible.
# For example, avoid "exe" or other too common or obvious attributes.
if 'PE32' in obj.type:
if 'DLL' in obj.type:
self.log('info', "{} is a DLL".format(obj.name))
tags.append('dll')
elif 'native' in obj.type:
self.log('info', "{} is a Windows driver".format(obj.name))
tags.append('driver')
return tags
def run(self):
super(Triage, self).run()
db = Database()
if self.args and self.args.all:
samples = db.find(key='all')
for sample in samples:
tags = []
tags.extend(self._triage_file_type(sample))
db.add_tags(sample.sha256, tags)
# We're running against the already opened file.
else:
if not __sessions__.is_set():
self.log('error', "No open session. This command expects a file to be open.")
return
tags = []
tags.extend(self._triage_file_type(__sessions__.current.file))
db.add_tags(__sessions__.current.file.sha256, tags)