Skip to content
Open
Show file tree
Hide file tree
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
159 changes: 156 additions & 3 deletions quark/webreport/analysis_report_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<head>
<title>Quark Report</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

Expand Down Expand Up @@ -341,6 +342,72 @@
background-color: #939393;
color: white;
}

.tooltiptext {
visibility: hidden;
width: 140px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px;
position: absolute;
z-index: 1;
bottom: 150%;
left: 50%;
margin-left: -75px;
opacity: 1;
transition: opacity 0.3s;
}

.tooltiptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}
/* The Modal (background) */
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

/* Modal Content */
.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}

/* The Close Button */
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}

.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
</style>
</head>

Expand Down Expand Up @@ -405,8 +472,21 @@ <h4>Sample Information</h4>
<div class="row" style="margin-left: auto;margin-top: 20px;">
<dt class="col-sm-3 sample-info-lable">File name</dt>
<dd class="col-sm-9 sample-info-lable">$filename$</dd>
<dt class="col-sm-3 sample-info-lable">MD5</dt>
<dd class="col-sm-9 sample-info-lable">$md5$</dd>
<dt class="col-sm-3 sample-info-lable">
MD5
</dt>
<dd class="col-sm-1 sample-info-lable">
<span class="material-symbols-outlined" onclick="copyToClipboard('md5Hash')" style="cursor:pointer" onmouseout="resetToolTip('tooltipCopy')" onmouseover="showTooltip('tooltipCopy', 'Copy to clipboard')">
content_copy
</span>
<span class="tooltiptext" id="tooltipCopy">Copy to clipboard</span>
</dd>
<dd class="col-sm-8 sample-info-lable">
<a id="md5Hash" href="https://www.virustotal.com/gui/file/$md5$" target="_blank" onmouseout="resetToolTip('tooltipVT')" onmouseover="showTooltip('tooltipVT', 'Go to VirusTotal')">
$md5$
</a>
<span class="tooltiptext" id="tooltipVT">Go to VirusTotal report</span>
</dd>
<dt class="col-sm-3 sample-info-lable">File size</dt>
<dd class="col-sm-9 sample-info-lable">$filesize$ Mb</dd>
<dt class="col-sm-3 sample-info-lable">Labels</dt>
Expand Down Expand Up @@ -471,12 +551,22 @@ <h3>The labels with 100% confidence crimes</h3>
</div>
</div>
</div>
<!-- The Modal -->
<button id="myBtn" onclick='showModal("{\"a\" : \"s\"}")'>Open Modal</button>
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close" onclick="closeModal()">&times;</span>
<div id="titleModal"></div>
<pre></pre>
</div>
</div>
</section>
</body>
$report_data$
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous">
</script>
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.min.js"></script>
<script>
labels = document.getElementsByClassName('label-container')
Expand Down Expand Up @@ -640,6 +730,69 @@ <h3>The labels with 100% confidence crimes</h3>
}
}
}
function copyToClipboard(id) {
// Get the text field
var copyText = document.getElementById(id).textContent;
navigator.clipboard.writeText(copyText);
var tooltip = document.getElementById("tooltipCopy");
tooltip.innerHTML = "Copied";
}

function resetToolTip(id) {
var tooltip = document.getElementById(id);
tooltip.style.visibility='hidden';
}

function showTooltip(id, message){
var tooltip = document.getElementById(id);
tooltip.innerHTML = message;
tooltip.style.visibility='visible';
}

// Get the modal
var modal = document.getElementById("myModal");

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks the button, open the modal
function showModal(text) {
var divTag = document.getElementById("titleModal");
var jsonCrime = JSON.parse(text);
var confidence = jsonCrime["confidence"]
var classCrime = ""
if(confidence === "20%"){
classCrime = "alert alert-success"
} else if (confidence === "40%") {
classCrime = "alert alert-info"
} else if (confidence === "60%") {
classCrime = "alert alert-primary"
} else if (confidence === "80%") {
classCrime = "alert alert-alert"
} else if (confidence === "100%") {
classCrime = "alert alert-danger"
} else {
classCrime = "alert alert-dark"
}
var titleRule = jsonCrime["crime"]
divTag.className = classCrime
divTag.innerText = titleRule
var ruleFormatted = JSON.stringify(jsonCrime, null, '\t');
modal.style.display = "block";
modal.getElementsByTagName('pre')[0].innerText = ruleFormatted
}

// When the user clicks on <span> (x), close the modal
function closeModal() {
modal.style.display = "none";
}

// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>

</html>
3 changes: 2 additions & 1 deletion quark/webreport/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,11 @@ def insert_report_html(self, data):
description = crime["crime"]
confidence = crime["confidence"]
rule_number = crime["rule"].split('.')[0]
crime_text = str(crime).replace("'", '\\"')
contentHTML += f"""
<tr>
<td><p class="fw-normal mb-1">{rule_number}</p></td>
<td><p class="fw-normal mb-1">{description}</p></td>
<td onclick='showModal("{crime_text}")'><p class="fw-normal mb-1">{description}</p></td>
<td>
<span class="badge {confidence_badge[confidence]}">
{confidence}
Expand Down