-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpeobject.py
53 lines (44 loc) · 1.66 KB
/
peobject.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
import json
from print_object import PrintObject
class PEObject(PrintObject):
def __init__(self, task, data, hash_engine, create_time, section):
PrintObject.__init__(self, data, hash_engine)
self.process = self.get_filename(task)
self.pid = task.UniqueProcessId
self.ppid = task.InheritedFromUniqueProcessId
self.create_time = create_time
self.section = section
def get_generator(self):
section_str = 'pe:{0}'.format(self.section) if self.section else 'pe'
return [
str(self.process),
int(self.pid),
int(self.ppid),
str(self.create_time),
str(section_str),
str(self.get_algorithm()),
str(self.get_hash())
]
def get_unified_output(self):
return [
('Process', '25'),
('Pid', '4'),
('PPid', '4'),
('Create Time', '28'),
('Section', '18'),
('Algorithm', '6'),
('Generated Hash', '100')
]
def _json(self):
return json.dumps(self._dict())
def _dict(self):
ret = {}
section_str = 'pe:{0}'.format(self.section) if self.section else 'pe'
ret['Process'] = str(self.process)
ret['Pid'] = int(self.pid)
ret['PPid'] = int(self.ppid)
ret['Create Time'] = str(self.create_time)
ret['Section'] = str(section_str)
ret['Algorithm'] = str(self.get_algorithm())
ret['Generated Hash'] = str(self.get_hash())
return ret