Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
228 changes: 149 additions & 79 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">

<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.25/jspdf.plugin.autotable.min.js"></script>
<script src="https://unpkg.com/docx@7.1.0/build/index.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.25/jspdf.plugin.autotable.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
<script src="https://unpkg.com/docx@7.1.0/build/index.js"></script>

<style>
:root {
Expand Down Expand Up @@ -247,14 +248,19 @@ <h2 class="fw-bold text-dark mb-1">Evidence Validation Suite</h2>
<i class="bi bi-file-earmark-pdf-fill"></i> Hash PDF
</button>
</div>
<div class="col-6 col-md-2">
<button class="btn-tile bg-word" onclick="generateHashWord()">
<i class="bi bi-file-word-fill"></i> Hash Word
</button>
</div>
<div class="col-6 col-md-2">
<button class="btn-tile bg-email" onclick="generateEmailReport()">
<i class="bi bi-envelope-paper"></i> Email PDF
<div class="col-6 col-md-2">
<button class="btn-tile bg-word" onclick="generateHashWord()">
<i class="bi bi-file-word-fill"></i> Hash Word
</button>
</div>
<div class="col-6 col-md-2">
<button class="btn-tile bg-csv" onclick="downloadSelectedExcel()">
<i class="bi bi-file-earmark-spreadsheet-fill"></i> Excel Report
</button>
</div>
<div class="col-6 col-md-2">
<button class="btn-tile bg-email" onclick="generateEmailReport()">
<i class="bi bi-envelope-paper"></i> Email PDF
</button>
</div>
<div class="col-6 col-md-2">
Expand Down Expand Up @@ -286,12 +292,13 @@ <h5 class="fw-bold">Drag & Drop Evidence Files Here</h5>
<thead>
<tr class="table-header">
<th width="5%" class="ps-4"><input type="checkbox" id="selectAll" onclick="toggleAll(this)"></th>
<th width="5%">#</th>
<th width="30%">Filename</th>
<th width="20%">MD5 Hash</th>
<th width="40%">SHA-256 (Section 63 BSA Compliant)</th>
</tr>
</thead>
<th width="5%">#</th>
<th width="25%">Filename</th>
<th width="20%">MD5 Hash</th>
<th width="25%">SHA-256 (Section 63 BSA Compliant)</th>
<th width="25%">SHA-3 (Keccak-256)</th>
</tr>
</thead>
<tbody id="hashTableBody" style="background: white;"></tbody>
</table>
</div>
Expand Down Expand Up @@ -494,12 +501,13 @@ <h6 class="fw-bold mt-3">Yahoo/Outlook:</h6>
<td class="fw-bold text-dark">
${file.name}
${isEml ? '<span class="badge bg-danger text-white ms-2">EMAIL</span>' : ''}
</td>
<td class="hash-font md5">Calculating...</td>
<td class="hash-font sha256">Calculating...</td>
</tr>
`);
fileQueue.push({ file, rowId });
</td>
<td class="hash-font md5">Calculating...</td>
<td class="hash-font sha256">Calculating...</td>
<td class="hash-font sha3">Calculating...</td>
</tr>
`);
fileQueue.push({ file, rowId });
});
if (!isProcessing) processQueue();
}
Expand All @@ -516,12 +524,14 @@ <h6 class="fw-bold mt-3">Yahoo/Outlook:</h6>
reader.onload = function(e) {
const wordArray = CryptoJS.lib.WordArray.create(e.target.result);
setTimeout(() => {
if (row) {
row.querySelector('.md5').innerText = CryptoJS.MD5(wordArray).toString();
row.querySelector('.sha256').innerText = CryptoJS.SHA256(wordArray).toString();
}
processQueue();
}, 50);
if (row) {
row.querySelector('.md5').innerText = CryptoJS.MD5(wordArray).toString();
row.querySelector('.sha256').innerText = CryptoJS.SHA256(wordArray).toString();
row.querySelector('.sha3').innerText = calculateSHA3FromWordArray(wordArray);
console.info(`[System Console] SHA-3 calculated for ${file.name}`);
}
processQueue();
}, 50);
};
reader.readAsArrayBuffer(file);
}
Expand Down Expand Up @@ -612,7 +622,7 @@ <h6 class="fw-bold mt-3">Yahoo/Outlook:</h6>

const text = await readFile(files[i]);
const emailData = parseEml(text);
const sha256 = await calculateSHA256(files[i]);
const hashes = await calculateHashes(files[i]);

// HEADER WITH WRAPPED FILENAME
doc.setFillColor(0, 51, 102);
Expand Down Expand Up @@ -646,8 +656,9 @@ <h6 class="fw-bold mt-3">Yahoo/Outlook:</h6>
['Message-ID', emailData.messageId],
['Originating IP', emailData.serverIP],
['DKIM Status', emailData.dkim],
['SHA-256 Hash', sha256]
],
['SHA-256 Hash', hashes.sha256],
['SHA-3 (Keccak-256) Hash', hashes.sha3]
],
theme: 'grid',
headStyles: {
fillColor: [0, 51, 102],
Expand Down Expand Up @@ -713,12 +724,13 @@ <h6 class="fw-bold mt-3">Yahoo/Outlook:</h6>
if (tr.querySelector('input').checked) {
const cells = tr.querySelectorAll('td');
rows.push([
cells[1].innerText,
cells[2].innerText,
cells[4].innerText
]);
}
});
cells[1].innerText,
cells[2].innerText,
cells[4].innerText,
cells[5].innerText
]);
}
});

if (rows.length === 0) {
alert("Please select files to include in report.");
Expand All @@ -727,7 +739,7 @@ <h6 class="fw-bold mt-3">Yahoo/Outlook:</h6>

doc.autoTable({
startY: 70,
head: [['#', 'Filename', 'SHA-256']],
head: [['#', 'Filename', 'SHA-256', 'SHA-3 (Keccak-256)']],
body: rows,
theme: 'grid',
headStyles: {
Expand All @@ -741,10 +753,11 @@ <h6 class="fw-bold mt-3">Yahoo/Outlook:</h6>
},
columnStyles: {
0: { cellWidth: 40 },
1: { cellWidth: 300 },
2: { cellWidth: 450, font: 'courier' }
}
});
1: { cellWidth: 250 },
2: { cellWidth: 260, font: 'courier' },
3: { cellWidth: 260, font: 'courier' }
}
});

doc.save("Hash_Report.pdf", { compress: true });
}
Expand Down Expand Up @@ -776,28 +789,38 @@ <h6 class="fw-bold mt-3">Yahoo/Outlook:</h6>
})],
shading: { fill: "003366" }
}),
new TableCell({
children: [new Paragraph({
children: [new TextRun({ text: "SHA-256", bold: true, color: "FFFFFF" })],
alignment: AlignmentType.CENTER
})],
shading: { fill: "003366" }
})
]
}));
new TableCell({
children: [new Paragraph({
children: [new TextRun({ text: "SHA-256", bold: true, color: "FFFFFF" })],
alignment: AlignmentType.CENTER
})],
shading: { fill: "003366" }
}),
new TableCell({
children: [new Paragraph({
children: [new TextRun({ text: "SHA-3 (Keccak-256)", bold: true, color: "FFFFFF" })],
alignment: AlignmentType.CENTER
})],
shading: { fill: "003366" }
})
]
}));

document.querySelectorAll("#hashTableBody tr").forEach(tr => {
if (tr.querySelector('input').checked) {
const cells = tr.querySelectorAll('td');
rows.push(new TableRow({
children: [
new TableCell({ children: [new Paragraph(cells[1].innerText)] }),
new TableCell({ children: [new Paragraph(cells[2].innerText)] }),
new TableCell({ children: [new Paragraph({
children: [new TextRun({ text: cells[4].innerText, font: "Courier New", size: 18 })]
})] })
]
}));
new TableCell({ children: [new Paragraph(cells[2].innerText)] }),
new TableCell({ children: [new Paragraph({
children: [new TextRun({ text: cells[4].innerText, font: "Courier New", size: 18 })]
})] }),
new TableCell({ children: [new Paragraph({
children: [new TextRun({ text: cells[5].innerText, font: "Courier New", size: 18 })]
})] })
]
}));
}
});

Expand Down Expand Up @@ -835,9 +858,9 @@ <h6 class="fw-bold mt-3">Yahoo/Outlook:</h6>
});
}

// ===== DOWNLOAD CSV =====
function downloadSelectedCSV() {
let csv = "#,Subject,From,To,Date,Originating IP,DKIM,SHA-256\n";
// ===== DOWNLOAD CSV =====
function downloadSelectedCSV() {
let csv = "#,Subject,From,To,Date,Originating IP,DKIM,SHA-256,SHA-3 (Keccak-256)\n";

let counter = 1;
const promises = [];
Expand All @@ -847,11 +870,11 @@ <h6 class="fw-bold mt-3">Yahoo/Outlook:</h6>
const cells = tr.querySelectorAll('td');
promises.push(
readFile(tr.fileData).then(text => {
const eml = parseEml(text);
return `${counter++},"${eml.subject}","${eml.from}","${eml.to}","${eml.date}","${eml.serverIP}","${eml.dkim}","${cells[4].innerText}"\n`;
})
);
}
const eml = parseEml(text);
return `${counter++},"${eml.subject}","${eml.from}","${eml.to}","${eml.date}","${eml.serverIP}","${eml.dkim}","${cells[4].innerText}","${cells[5].innerText}"\n`;
})
);
}
});

Promise.all(promises).then(rows => {
Expand All @@ -861,8 +884,48 @@ <h6 class="fw-bold mt-3">Yahoo/Outlook:</h6>
a.href = URL.createObjectURL(blob);
a.download = "Email_Report.csv";
a.click();
});
}
});
}

// ===== DOWNLOAD EXCEL =====
function downloadSelectedExcel() {
if (typeof XLSX === 'undefined') {
alert("Excel library loading...");
return;
}

const rows = [["#", "Filename", "MD5", "SHA-256", "SHA-3 (Keccak-256)"]];

document.querySelectorAll("#hashTableBody tr").forEach(tr => {
if (tr.querySelector('input').checked) {
const cells = tr.querySelectorAll('td');
rows.push([
cells[1].innerText,
cells[2].innerText.replace(/\s+EMAIL$/, '').trim(),
cells[3].innerText,
cells[4].innerText,
cells[5].innerText
]);
}
});

if (rows.length === 1) {
alert("Please select files to include in report.");
return;
}

const workbook = XLSX.utils.book_new();
const worksheet = XLSX.utils.aoa_to_sheet(rows);
worksheet["!cols"] = [
{ wch: 6 },
{ wch: 36 },
{ wch: 36 },
{ wch: 68 },
{ wch: 68 }
];
XLSX.utils.book_append_sheet(workbook, worksheet, "Hash Report");
XLSX.writeFile(workbook, "Hash_Report.xlsx");
}

// ===== UTILITY FUNCTIONS =====
function getSelectedEmlFiles() {
Expand All @@ -883,16 +946,23 @@ <h6 class="fw-bold mt-3">Yahoo/Outlook:</h6>
});
}

async function calculateSHA256(file) {
return new Promise(resolve => {
const reader = new FileReader();
reader.onload = e => {
const wordArray = CryptoJS.lib.WordArray.create(e.target.result);
resolve(CryptoJS.SHA256(wordArray).toString());
};
reader.readAsArrayBuffer(file);
});
}
async function calculateHashes(file) {
return new Promise(resolve => {
const reader = new FileReader();
reader.onload = e => {
const wordArray = CryptoJS.lib.WordArray.create(e.target.result);
resolve({
sha256: CryptoJS.SHA256(wordArray).toString(),
sha3: calculateSHA3FromWordArray(wordArray)
});
};
reader.readAsArrayBuffer(file);
});
}

function calculateSHA3FromWordArray(wordArray) {
return CryptoJS.SHA3(wordArray, { outputLength: 256 }).toString();
}

function toggleAll(checkbox) {
document.querySelectorAll('input[name="fileSelect"]').forEach(c => c.checked = checkbox.checked);
Expand Down