-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsnippets ppt.py
180 lines (129 loc) · 3.78 KB
/
snippets ppt.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
from org.sleuthkit.autopsy.report \
import GeneralReportModuleAdapter
class NotKnownBackup(
GeneralReportModuleAdapter):
moduleName = "Copy Not Known Files"
def getName(self):
return self.moduleName
def getDescription(self):
return "Copy Not Known Files,”
def getRelativeFilePath(self):
return "hashes.csv"
---------------------------------------
from java.util.logging \
import Level
from org.sleuthkit.autopsy.coreutils \
import Logger
class NotKnownBackup(
GeneralReportModuleAdapter):
...
_logger = None
def log(self, level, msg):
if self._logger == None:
self._logger = \
Logger.getLogger(
self.moduleName)
self._logger.logp(
level,
self.__class__.__name__,
inspect.stack()[1][3], msg)
---------------------------------------
class NotKnownBackup(
GeneralReportModuleAdapter):
...
def generateReport(self,
baseReportDir,
progressBar):
fileName = \
os.path.join(baseReportDir,
self.getRelativeFilePath())
report = codecs.open(fileName,
'w', "utf8")
print(report, baseReportDir, progressBar)
---------------------------------------
def generateReport(self,
baseReportDir,
progressBar):
...
sleuthkitCase = Case.\
getCurrentCase().\
getSleuthkitCase()
files = sleuthkitCase.\
findAllFilesWhere(
"NOT meta_type = " +
str(TskData.
TSK_FS_META_TYPE_ENUM.
TSK_FS_META_TYPE_DIR.
getValue()))
print(files, baseReportDir, progressBar)
---------------------------------------
def generateReport(self,
baseReportDir,
progressBar):
...
if not os.path.exists(
config.output_path):
os.mkdir(output_path)
defaultcontentDir = \
os.path.join(output_path,
"Other")
if not os.path.exists(
defaultcontentDir):
os.mkdir(defaultcontentDir)
print(files, baseReportDir, progressBar)
---------------------------------------
for idx, file in enumerate(files):
if file.MIMEType:
typedir = \
file.MIMEType.\
replace("/", "_")
contentDir = \
os.path.join(
output_path,
typedir)
else:
typedir = "other"
contentDir = \
defaultcontentDir
---------------------------------------
id = "%12d" % file.getId()
filepath = os.path.join(
contentDir,
id + "-" + file.getName())
isKnown = (file.getKnown() ==
TskData.FileKnown.UNKNOWN)
line = [typedir,
file.getName(),
file.getParentPath(),
str(file.getId()),
str(file.getMd5Hash())]
---------------------------------------
if not isKnown:
try:
if not os.path.exists(
contentDir):
os.mkdir(contentDir)
ContentUtils.writeToFile(
file, File(filepath))
report.write(u','.join(line)
+ "\n")
except:
self.log(Level.WARNING,
str(sys.exc_info()[0]) + "-" +
str(sys.exc_info()[1]) + "\n" +
u','.join(line))
---------------------------------------
class NotKnownBackup(
GeneralReportModuleAdapter):
...
def generateReport(self,
baseReportDir,
progressBar):
...
report.close()
Case.getCurrentCase().\
addReport(
fileName,
self.moduleName,
"Copy Not Known Files")
print(files, baseReportDir, progressBar)