-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
178 lines (163 loc) · 5.2 KB
/
index.html
File metadata and controls
178 lines (163 loc) · 5.2 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
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
<!DOCTYPE html>
<html lang="en" >
<head>
<script type="text/javascript" src="./md5.js"></script>
<script type="text/javascript">
var booStorage = false;
if ( typeof (Storage) !== "undefined") {
booStorage = true;
} else {
alert("Local Storage not available. Data will not be persisted.");
}
var clearStorage = function() {
localStorage.clear();
objStorage = {};
document.getElementById('list').innerHTML = "Storage Cleared!!"
}
var saveStorage = function() {
var uriContent = "data:application/octet-stream," + encodeURIComponent(JSON.stringify(objStorage));
var newWindow = window.open(uriContent, 'The Goods!');
}
var objStorage = {};
var onReady = function() {
var dropZone = document.getElementById('drop_zone');
dropZone.addEventListener('dragover', handleDragOver, false);
dropZone.addEventListener('drop', handleFileSelect, false);
if (localStorage.objStorage) {
objStorage = JSON.parse(localStorage.objStorage);
console.log("Retrieved Storage Obj: ", objStorage);
outputFormatter();
}
}
function handleFileSelect(evt) {
evt.stopPropagation();
evt.preventDefault();
var files = evt.dataTransfer.files;
for (var i = 0, f; f = files[i]; i++) {
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
storageFormatter({
data : e.target.result,
file : theFile
});
//outputFormatter(theFile);
};
})(f);
reader.readAsBinaryString(f);
}
}
var storageFormatter = function(obj) {
var now = Math.round(new Date().getTime() / 1000);
var hash = hex_md5(obj.data);
var historyItem = {
time : now,
hash : hash,
fileType : obj.file.type,
fileSize : obj.file.size,
fileDate : obj.file.lastModifiedDate ? obj.file.lastModifiedDate.toString() : 'n/a',
//fileLocation : obj.file.mozFullPath ? obj.file.mozFullPath : "n/a",
fileData : obj.data
};
if (objStorage[obj.file.name] === null || objStorage[obj.file.name] === undefined) {
var so = {
fileName : obj.file.name,
history : []
};
so.history.push(historyItem);
objStorage[obj.file.name] = so;
outputFormatter();
} else {
var so = objStorage[obj.file.name];
var diff = false;
for (var i = 0; i < so.history.length; i++) {
if (so.history[i].hash != hash) {
diff = true;
break;
}
}
if (diff) {
so.history.push(historyItem);
outputFormatter();
}
}
localStorage.objStorage = JSON.stringify(objStorage);
}
var outputFormatter = function() {
var output = [];
for (var key in objStorage) {
output.push('<li><strong>', escape(key), '</strong> <ul>');
for (var i = 0; i < objStorage[key].history.length; i++) {
output.push('<li>[', i, "] ", " <strong> Time: </strong>", objStorage[key].history[i].time, " <strong> Last Mod: </strong>", objStorage[key].history[i].fileDate, " <strong> Hash: </strong>", objStorage[key].history[i].hash, " <strong> Type: </strong>", objStorage[key].history[i].fileType, " <strong> Size: </strong>", objStorage[key].history[i].fileSize,
//" <strong> Local Path: </strong>",objStorage[key].history[i].fileLocation,
'</li>');
}
output.push('</ul></li>');
}
document.getElementById('list').innerHTML = '<ul>' + output.join('') + '</ul>';
}
function handleDragOver(evt) {
evt.stopPropagation();
evt.preventDefault();
evt.dataTransfer.dropEffect = 'copy';
}
// Dean Edwards/Matthias Miller/John Resig
function init() {
// quit if this function has already been called
if (arguments.callee.done)
return;
// flag this function so we don't do the same thing twice
arguments.callee.done = true;
// kill the timer
if (_timer)
clearInterval(_timer);
onReady();
};
/* for Mozilla/Opera9 */
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", init, false);
}
/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
if (this.readyState == "complete") {
init(); // call the onload handler
}
};
/*@end @*/
/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) {// sniff
var _timer = setInterval(function() {
if (/loaded|complete/.test(document.readyState)) {
init();
// call the onload handler
}
}, 10);
}
/* for other browsers */
window.onload = init;
</script>
</head>
<body>
<p>
PenTest File Tracker v0.0.1a
</p>
<div>
<div id="drop_zone" style="width:150px;border:1px dashed black;">
<p style="text-align: center">Drop files here</p>
</div>
<div>
<br/>
<button id="clear" title="Click here to clear out the storage" onclick="clearStorage();">
Clear Storage
</button>
<button id="clear" title="Click here to Download the File List" onclick="saveStorage();">
Show Me the Goods
</button>
</div>
<output id="list" style="font-size:10pt;"></output>
</div>
</body>