forked from lancemueller/EnCase-EnScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGSI_BookmarkExporterLib.EnScript
163 lines (144 loc) · 5.22 KB
/
GSI_BookmarkExporterLib.EnScript
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
/*
////////////////////// Guidance Software Inc. //////////////////////
GSI_BookmarkExporterLib.Enscript VERSION 1.0 tested on EnCase V5
Maintenance History :
===================
ver 1.0 : 15 March 2005
+ port from EnCase V4
Notes:
-----
This script is released by Guidance Software Inc. as part of its
Scripts package shipped with the Encase Software.
This library contains methods to export bookmark data to an Excel and/or
an HTML file.
This library is a modification of the "GSI_BookmarkExporterLib" of
Encase V4.
Report all bugs and queries to [email protected]
/////////////////////////////////////////////////////////////////////
*/
include "GSI_ExportTableLib"
include "GSI_LogLib"
include "GSI_ModuleLib"
//---//
class BookmarkExporterClass {
NameListClass Fields;
String TableCategory,
Delimiters,
Prefix,
Suffix,
Path;
LogClass Log;
ExportTableClass Table;
bool ShouldExport;
BookmarkExporterClass():
Fields(),
Log(),
Table()
{
Log.Name = "Exporter";
Log.CurPriority = LogClass::INFO;
ShouldExport = true;
TableCategory = "Events";
Delimiters = "\t\n";
Prefix = "";
Suffix = ":";
ShouldExport = false;
}
void FormatKeyAndValue(String key, String value, String &app) {
app += key + ":" + Delimiters[0] + value + Delimiters[1];
}
void InitializeNewFolder(const String &initialpath) {
Log.Debug("initialpath: " + initialpath);
if (ShouldExport) {
Path = initialpath;
Log.Debug("Creating folder: " + Path);
LocalMachine.CreateFolder(Path);
HostFileClass css(LocalMachine);
if (css.Open(Path + "\\gsi.css", HostFileClass::WRITETEXTCRLF)) {
css.Write("BODY { background-color: white; }\n"
"DIV.intro { margin-left: 1%; max-width: 600px; margin-bottom: 25px; text-align: justify; }\n"
"H1 { text-align: center; font-weight: bold; }\n"
"H2 { text-align: center; font-weight: bold; }\n"
"TABLE { width: 100%; background-color: black; font-size: smaller; text-align: right; }\n"
"TR { background-color: white; }\n"
"TH { text-align: center; }\n");
}
}
}
bool CreateTable(const String excelFileName, const String &filename, const String &title) {
String name = NameUtilClass::ReplaceIllegalChar(filename);
return ShouldExport &&
Table.CreateHTML(Path + "\\" + name, title, "gsi.css") &&
Table.CreateExcel(Path + "\\" + excelFileName, title);
}
void Write(const String &intro, ModuleBMFolderClass &folder) {
if (ShouldExport && folder) {
Table.BeginIntroduction();
Table.InsertParagraph(intro);
Table.EndIntroduction();
if (0 < Fields.Count()) {
Table.BeginTable(TableCategory);
Table.BeginRow();
for (NameListClass n = Fields.FirstChild(); n; n++) {
Table.InsertHeading(n.Name());
}
Table.EndRow();
Table.ExcelFile.HorizontalFreeze();
uint i = 0;
for (BookmarkClass bm = folder.BookmarkFolder.FirstChild(); bm; bm++) {
Table.BeginRow();
NameListClass fieldValues = new NameListClass();
if (0 < fieldValues.Parse(bm.Comment(), Delimiters, 0)) {
for (NameListClass n = Fields.FirstChild(); n; n++) {
NameListClass tag = fieldValues.Find(Prefix + n.Name() + Suffix);
if (tag && (++tag)) {
Table.InsertCell(tag.Name());
}
else {
Table.InsertCell("");
}
}
}
Table.EndRow();
}
Table.EndTable();
}
Table.Close();
}
}
void Write(const String &intro, LogRecordClass &folder) {
if (ShouldExport && folder) {
Table.BeginIntroduction();
Table.InsertParagraph(intro);
Table.EndIntroduction();
if (0 < Fields.Count()) {
Table.BeginTable(TableCategory);
Table.BeginRow();
for (NameListClass n = Fields.FirstChild(); n; n++) {
Table.InsertHeading(n.Name());
}
Table.EndRow();
Table.ExcelFile.HorizontalFreeze();
uint i = 0;
for (LogRecordClass bm = folder.FirstChild(); bm; bm++) {
Table.BeginRow();
NameListClass fieldValues = new NameListClass();
if (0 < fieldValues.Parse(bm.Comment(), Delimiters, 0)) {
for (NameListClass n = Fields.FirstChild(); n; n++) {
NameListClass tag = fieldValues.Find(Prefix + n.Name() + Suffix);
if (tag && (++tag)) {
Table.InsertCell(tag.Name());
}
else {
Table.InsertCell("");
}
}
}
Table.EndRow();
}
Table.EndTable();
}
Table.Close();
}
}
}