mft.py
1.29 KB
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
import os
import logger
import tomb
from modules.module import Module
from runcmd import runProcess
import pytsk3
def getInstance():
return MFTModule()
class MFTModule(Module):
def __init__(self):
self.name = "mft"
self.description = "Extracts NTFS MFT"
self.requiredVars = ["ntfsvol"]
self.vars = {}
def dumpMFT(self,ntfsvol,file):
img = pytsk3.Img_Info(url=ntfsvol)
fs = pytsk3.FS_Info(img)
file_entry = fs.open_meta(inode=0)
offset = 0
size = file_entry.info.meta.size
BUFF_SIZE = 1024*1024
mft = open(file,'wb')
while offset < size:
available_to_read = min(BUFF_SIZE, size - offset)
data = file_entry.read_random(offset, available_to_read)
if not data:
break
offset += len(data)
mft.write(data)
mft.close()
img.close()
def execute(self):
path = tomb.getPath() + self.name + "/"
if(not os.path.exists(path)):
os.mkdir(path)
logger.msgLog("Extracting MFT from volumes: " + repr(self.vars['ntfsvol'].value), "mft", logger.TYPE_INFO)
for vol in self.vars['ntfsvol'].value:
self.dumpMFT("/dev/" + vol,path + vol + ".bin")