This repository has been archived by the owner on May 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
598 lines (517 loc) · 20.9 KB
/
index.html
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script>
/*toggle between hiding and showing the dropdown content */
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
window.$ = window.jQuery = require('jquery');
window.Bootstrap = require('bootstrap');
require( 'datatables.net-bs4' )();
const fs = require("fs");
if (!fs.existsSync("cookies.db")) {
// open database in memory
const Database = require('better-sqlite3');
const db = new Database('cookies.db', { verbose: console.log });
var sql = 'CREATE TABLE cookies(creation_utc INTEGER NOT NULL,host_key TEXT NOT NULL,name TEXT NOT NULL,value TEXT NOT NULL,path TEXT NOT NULL,expires_utc INTEGER NOT NULL,is_secure INTEGER NOT NULL,is_httponly INTEGER NOT NULL,last_access_utc INTEGER NOT NULL,has_expires INTEGER NOT NULL DEFAULT 1,is_persistent INTEGER NOT NULL DEFAULT 1,priority INTEGER NOT NULL DEFAULT 1,encrypted_value BLOB DEFAULT \'\',samesite INTEGER NOT NULL DEFAULT -1,UNIQUE (host_key, name, path))';
//console.log(db.exec(sql));
const homedir = require('os').homedir();
if (process.platform === "linux") {
DBPATH = `${homedir}/.config/google-chrome/Default/Cookies`;
} else if (process.platform === "darwin") {
DBPATH = `${homedir}/Library/Application Support/Google/Chrome/Default/Cookies`;
}
fs.copyFile(DBPATH, 'cookies.db', (err) => {
if (err) {
alert(
"This application only supports OSX and Linux. Additionally, it only supports Chromium cookies. " +
"If you do not have Chromium installed or do not have any cookies, we can do nothing for you."
);
throw err
};
//console.log('source.txt was copied to destination.txt');
});
//console.log("DB Created.")
} else {
//console.log("DB Exists.")
}
</script>
<!-- Bootstrap CSS/JS
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
-->
<!-- Datatables with Select and Bootstrap-Responise extensions CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css">
<!--<link rel="stylesheet" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css">-->
<link rel="stylesheet" href="https://cdn.datatables.net/select/1.3.1/css/select.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.20/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.2.3/css/responsive.bootstrap4.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Datatables with Select and Bootstrap-Responise extensions JS -->
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/select/1.3.1/js/dataTables.select.min.js"></script>
<script src="https://cdn.datatables.net/1.10.20/js/dataTables.bootstrap4.min.js"></script>
<script src="https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js"></script>
<script src="https://cdn.datatables.net/responsive/2.2.3/js/responsive.bootstrap4.min.js"></script>
<!-- jQuery Modal -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.css" />
<title>Cookie Monsterrr</title>
<style>
html, body {
width: 100%;
height: 100%;
}
body {
overflow-x: hidden;
}
.dropbtn {
background-color: #3498DB;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
.learnButton:hover, .learnButton:focus {
background-color: #2980B9;
}
/* Dropdown button on hover & focus */
.dropbtn:hover, .dropbtn:focus {
background-color: #2980B9;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #ddd}
/* Show the dropdown menu (use JS to add this class to the .dropdown-content container when the user clicks on the dropdown button) */
.show {display:block;}
.vertScrollbar {
position: relative;
height: 800px;
overflow: auto;
}
.detail {
border-style: solid;
border-color: grey;
margin: 0em;
}
.detail p,b {
margin: 0;
padding: 0;
font-size: 30px;
}
.new{
padding: 0;
}
.modal {
height: auto;
overflow: auto;
}
.modal h2 {
text-align: center;
}
tr.table-danger.selected td {
background-color: #f36473!important;
}
.big-checkbox {
width:30px;
height:30px;
}
.bool-cell {
text-align: center;
}
.select-item {
display: none!important;
}
.wrap-40 {
max-width: 40ch;
word-wrap: break-word;
}
#customSearchbar select {
border-top-left-radius: 8px;
border-bottom-left-radius: 8px;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-right: none;
}
#customSearchbar input {
border-radius: 0;
margin-left: 0;
margin-right: 0;
width: 100%;
}
#customSearchbar label {
margin-bottom: 0;
width: 100%;
}
#customSearchbar button {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
border-left: none;
border-color: rgb(206, 212, 218);
padding-top: 0;
padding-bottom: 0;
}
#customSearchbar button:hover {
color: #6c757d!important;
background-color: transparent!important;
cursor: default;
}
#cookies-dt_filter {
width: 50%;
}
#cookieList, #cookieView {
border: 2px solid #dee2e6;
border-radius: 32px;
}
</style>
<nav id="mainNav" class="navbar navbar-expand-sm bg-dark navbar-dark">
<a class="navbar-brand" href="#">Cookie Monsterrr</a>
<!-- href contains a where the link goes to -->
<ul class="navbar-nav">
<!-- <li class="nav-item active">
<a class="nav-link" href="sample.html">Active</a>
</li> -->
<li class="nav-item">
<!-- <div id="button"> -->
<div id="learnButton">
<!-- <a class="nav-link" href="learn_more.html" target="_blank">Learn More</a> -->
<button class="dropbtn" onclick=" window.open('learn_more.html', '_blank')" >Learn More</button>
</div>
</li>
<li class="nav-item">
<div id="button">
<!-- <a class="nav-link" href="analyze.html" target="_blank">Analyze</a> -->
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">Analyze</button>
<div id="myDropdown" class="dropdown-content">
<a href="analyze.html" target="_blank">Cookie Breakdown</a>
<a href="topCookie.html" target = "_blank"> Most Prevalent Cookies </a>
<a href="#">Link 3</a>
</div>
</div>
</div>
</li>
<li class="nav-item">
<!-- <a class="nav-link" href="https://github.com/utk-cs/2019fall_ant-man/blob/master/README.md" target="_blank">Read Me</a> -->
<!-- <button onclick="location.href='https://github.com/utk-cs/2019fall_ant-man/blob/master/README.md';" target = "_blank" class="dropbtn">Read Me</button> -->
<button class="dropbtn" onclick=" window.open('https://github.com/utk-cs/2019fall_ant-man/blob/master/README.md', '_blank')" >Read Me</button>
</li>
<!-- <li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li> -->
</ul>
</nav>
</head>
<body>
<div id="welcomeModal" class="modal">
<h2>Loading... <span id="loadingProgress">0</span>%</h2>
<!--<p>
Hello, World! This is Cookie Monsterrr, a browser cookie managment tool.
With this tool, you can browse, view, add, modify, our delete your browser cookies!
This is an especially important thing to do.
These days, websites track your every move with cookies that can tell them where you've been.
But not all cookies are bad! Some of them simply keep you logged in after you click that checkbox.
Some of them help websites know whether or not you've enabled their dark theme.
That's why we've made this tool. We made it to give control back to you.
</p>-->
<div class="d-flex justify-content-center">
<img id="loadingWelcome" src="cookie.gif" />
<!--<a id="continueWelcome" href="#" class="btn btn-info" rel="modal:close">Continue</a>-->
</div>
</div>
<div id="mainContent" class="row">
<div class="col-sm-6">
<div id="cookieList" class="col-sm-12">
<table id="cookies-dt" class="table table-striped table-bordered table-md" cellspacing="0" width="100%">
<thead>
<tr>
<th>Creation Date</th>
<th>Website</th>
<th>Name</th>
<th>Value</th>
<th>Path</th>
<th>Expiration Date</th>
<th>Last Access Date</th>
<th>Priority</th>
<th>Is Secure</th>
<th>Is Httponly</th>
<th>Has Expires</th>
<th>Is Persistent</th>
<th>Samesite</th>
</tr>
</thead>
</table>
</div>
</div>
<div class="col-sm-6" style="overflow-x: auto;">
<div id="cookieView" class="cal-sm-12">
<table id="detailedView" class="table table-striped" style="display: none;">
<thead>
<th colspan="2" class="text-center">
<div class="btn-group justify-content-center">
<button type="button" id="Delete" class="btn btn-danger">Delete Cookie</button>
<button type="button" id="Randomize" class="btn btn-warning">Randomize Cookie</button>
<button type="button" id="Modify" class="btn btn-secondary">Modify Cookie</button>
</div>
</th>
</thead>
</table>
</div>
</div>
</div>
<script src="index.js"></script>
<script>
global.$ = require('jquery/dist/jquery');
$(document).ready(function () {
$("#welcomeModal").modal({
escapeClose: false,
clickClose: false,
showClose: false,
fadeDuration: 100,
fadeDelay: 2.0
});
$("#loadingWelcome").show();
$("#continueWelcome").hide();
var viewer = $("#detailedView");
viewer.ready(function(){
viewer.hide();
viewer.on('click', '#Modify', function(){
modifyCookie();
});
viewer.on('click', '#Randomize', function(){
randomizeCookie();
});
viewer.on('click', '#Delete', function(){
try {
var table = $('#cookies-dt').DataTable();
////console.log(globalRowid);
table.row(globalRowid).remove();
$(`#${globalRowid}`).remove();
deleteCookie(globalCookie);
} catch(err) {
throw(err);
}
});
});
setTimeout(() => {
function dateRender(data, type, row) {
if (type === 'search' || type === 'display') {
var simplifiedDate = simpleDate(data)
// var str = simplifiedDate.split(" ");
// return simplifiedDate
findPotential(simplifiedDate);
return simplifiedDate;
}
return data;
}
function findPotential(simplifiedDate) {
var dateHash = {
Jan : 1,
Feb: 2,
Mar: 3,
Apr: 4,
May: 5,
Jun: 6,
Jul: 7,
Aug: 8,
Sep: 9,
Oct: 10,
Nov: 11,
Dec: 12
};
//get rid of all commas in date
simplifiedDate = simplifiedDate.replace(/,/g , '');
var str = simplifiedDate.split(" ");
//getting today's date
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0');
var yyyy = today.getFullYear();
today = mm + '/' + dd + '/' + yyyy;
//change formatting for expiration date
expirationDate = dateHash[str[0]] + '/' + str[1] + '/' + str[2];
var currentDate = new Date(today);
var expireDate = new Date(expirationDate);
//get difference between expiration date and current date in days
var daysApart = ((expireDate.getTime() - currentDate.getTime()) / 1000);
daysApart /= 60;
daysApart /= 1440;
if (daysApart >= 90) {
potentialTracking++;
}
// //console.log(daysApart);
// //console.log(expirationDate);
// //console.log(today);
// //console.log(potentialTracking);
}
function boolRender(data, type, row) {
if (type === 'display') {
return `<input class="big-checkbox" type="checkbox" ${data === 1 ? "checked" : ""} disabled>`
}
return data;
}
var table = $('#cookies-dt').DataTable({
scrollX: true,
scrollY: true,
select: 'single',
responsive: {
details: false
},
language: { infoFiltered: '', lengthMenu: '_MENU_', search: ''},
ajax: function(data, callback, settings) {
var rv = {};
//console.log("z");
retrieveCookies(rv).then(function(){
callback(rv);
});
},
columns: [
{ data: "creation_utc", render: dateRender, responsivePriority: 1 },
{ data: "host_key", className: 'all' },
{ data: "name", className: 'all' },
{ data: "value", className: 'all wrap-40' },
{ data: "path", responsivePriority: 2 },
{ data: "expires_utc", render: dateRender },
{ data: "last_access_utc", render: dateRender },
{ data: "priority" },
{ data: "is_secure", render: boolRender, className: 'bool-cell' },
{ data: "is_httponly", render: boolRender, className: 'bool-cell' },
{ data: "has_expires", render: boolRender, className: 'bool-cell' },
{ data: "is_persistent", render: boolRender, className: 'bool-cell' },
{ data: "samesite", }
],
dom:
"<'row'<'#customSearchbar.col-sm-12 d-flex justify-content-center'lf>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12 d-flex justify-content-center'p>>",
initComplete: function(settings, json){
onTableReady();
}
});
var popularHash = {};
function onTableReady() {
$('#customSearchbar select').removeClass('form-control-sm custom-select-sm');
$('#customSearchbar select').addClass('form-control-md custom-select-md');
$('#customSearchbar input').removeClass('form-control-sm');
$('#customSearchbar input').addClass('form-control-md');
$('#customSearchbar').append(
'<button class="btn btn-outline-secondary">' +
'<i class="fa fa-search"></i>' +
'</button>'
);
/*$('#cookies-dt_info').parent().removeClass('col-md-5');
$('#cookies-dt_info').parent().addClass('col-xl-5');
$('#cookies-dt_paginate').parent().removeClass('col-md-7');
$('#cookies-dt_paginate').parent().addClass('col-xl-7');*/
var numTracking = 0;
var tracking = table.rows(function(idx, data, node){
if (
data["name"] === "_ga" || data["name"] === "__utma" || data["name"] === "__utmz" ||
data["name"] === "_gcl_au" || data["name"] === "__qca" || data["name"] === "s_ecid" ||
data["name"] === "s_vi" || data["name"] === "s_cc" || data["name"] === "s_sq" ||
data["name"] === "s_fid" || data["name"] === "adcloud" || data["name"] === "_sn" ||
data["name"] === "rat_v" || data["name"] === "_ceir"
) {
if(data["host_key"] in popularHash) {
popularHash[data["host_key"]] = 1;
}
else {
popularHash[data["host_key"]] += 1;
}
numTracking++;
return true;
} else {
return false;
}
}).every(function(rowIdx, tableNode, rowLoop){
$(this.node()).addClass('table-danger');
});
resizeElements();
$(window).resize(function(){setTimeout(function(){
resizeElements();
table.responsive.recalc();
}, 10)});
table.on('click', 'tr', function () {
globalRowid = table.row(this).id();
// //console.log(globalRowid);
var rowData = table.row(this).data();
// //console.log(rowData);
var cookieID = {
host_key: rowData["host_key"],
name: rowData["name"],
path: rowData["path"]
};
var cookie = DBI.getCookie(cookieID);
globalCookie = cookie;
updateDetailedView(cookie);
trackChanges(cookie);
$("#detailedView").show();
});
table.on('length.dt', function(e, settings, len){
resizeElements();
});
//console.log(popularHash);
window.localStorage;
localStorage.setItem("numTracked", numTracking);
localStorage.setItem("numCookies", table.rows);
numTracked = Number(localStorage.getItem("numTracked"));
$("#loadingWelcome").hide();
$.modal.close();
};
}, 10);
});
function KeyPress(e){
var evtobj = window.event? event : e
if(evtobj.keyCode == 90 && evtobj.ctrlKey){
//console.log("control z");
undoCookie();
}
}
document.onkeydown = KeyPress;
</script>
</body>
</html>