Skip to content

Commit

Permalink
feat: add small evolution percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanguy-Boisset committed Nov 16, 2023
1 parent d222ff7 commit 4ae7982
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 7 deletions.
22 changes: 22 additions & 0 deletions ad_miner/sources/html/bootstrap/css/custom.css
Expand Up @@ -368,3 +368,25 @@ a:hover{
height: 90%;
margin: 5;
}

.evol-col {
padding-left: 0;
padding-right: 0;
}

.col-0 {
display: none;
}

.evolution-percentage-div {
text-align: right;
}

.icon-evolution {
font-size: small;
}

.percentage-evolution {
font-size: small;
font-weight: 800;
}
22 changes: 22 additions & 0 deletions ad_miner/sources/html/bootstrap/css/main_page.css
Expand Up @@ -450,6 +450,28 @@ a:hover{
margin: 5;
}

.evol-col {
padding-left: 0;
padding-right: 0;
}

.col-0 {
display: none;
}

.evolution-percentage-div {
text-align: right;
}

.icon-evolution {
font-size: small;
}

.percentage-evolution {
font-size: small;
font-weight: 800;
}

.highlighted {
transform: scale(1.4);
transition: 0.3s ease;
Expand Down
14 changes: 11 additions & 3 deletions ad_miner/sources/html/components/smolcard/smolcard_header.html
Expand Up @@ -21,9 +21,17 @@
<div class="smolcard card border-left-{{color}} shadow py-2 evolution-display" style="display: none" onclick="location.href='{{href}}';">
<div class="card-body smolcard-body">
<div class="sb-row no-gutters align-items-center">
<div
class="text-xs text-{{color}} font-weight-bold text-uppercase mb-1 smolcard-title">
{{title}}
<div class="container">
<div class="row">
<div
class="text-xs text-{{color}} font-weight-bold text-uppercase mb-1 smolcard-title col-{{width_evolution_big}} evol-col">
{{title}}
</div>
<div class="col-{{width_evolution_small}} evolution-percentage-div evol-col">
<i class="bi bi-{{arrow_dir}} icon-evolution" style="color: {{evolution_color}};"></i>
<span class="percentage-evolution" style="color: {{evolution_color}};">&nbsp;{{evolution_sign}}{{evolution_percent}}</span>
</div>
</div>
</div>
<div style="text-align: center;">
<canvas id="card-chart-{{id}}" class="chart smol-evolution-chart" style="width: 80%"></canvas>
Expand Down
4 changes: 2 additions & 2 deletions ad_miner/sources/modules/description.json
Expand Up @@ -468,7 +468,7 @@
"poa": "Ensure that the existing privileges on this ADCS server are legitimate and limit them to administrators optimaly."
},
"dangerous_paths": {
"title": "List of the main paths to become a domain administrator",
"title": "Main paths to become a domain administrator",
"description": "List of the main paths to become a domain administrator",
"risk": "This representation exposes the most common links to become domain administrator, which means the more likely to be used during an attack.",
"poa": "Tackling the most common paths is a good approach to limit the risk of a compromission as it removes most of the paths to domain administrator."
Expand Down Expand Up @@ -504,7 +504,7 @@
"poa": "Regularly review and clean up SID History entries for users and groups that no longer require access to resources in old domains."
},
"cross_domain_admin_privileges":{
"title":"List of users that have powerful cross-domain privileges.",
"title":"Users that have powerful cross-domain privileges",
"description": "Users privileges are not limited to their domains. Sometimes some users may have direct or non-direct local admin or even domain admin privilege on a foreign domain.",
"risk": "Cross-domain privileges are quite dangerous and will help attackers to pivot to other domains if they manage to compromise a domain",
"poa": "Review these privileges, this list should be as little as possible."
Expand Down
51 changes: 49 additions & 2 deletions ad_miner/sources/modules/smolcard_class.py
Expand Up @@ -200,9 +200,50 @@ def render(self, page_f, return_html=False):
self.description = ""

try:
evolution_chart_data = self.evolution_data[self.id]
evolution_chart_data = self.evolution_data[self.id]
except KeyError:
evolution_chart_data = []

if len(evolution_chart_data) >= 2:
percent = "%"
width_evolution_big = 9
try:
evolution_percent = abs(round((evolution_chart_data[-1] - evolution_chart_data[-2]) / evolution_chart_data[-2], 3) * 100)
except ZeroDivisionError:
# If the stats staggers at zero, it's a great thing
if evolution_chart_data[-2] == 0:
evolution_percent = 0.0
else:
evolution_percent = '<i class="bi bi-infinity"></i>'

if evolution_chart_data[-1] >= evolution_chart_data[-2]:
# Downgrade
evolution_sign = "+"
evolution_color = "red"
arrow_dir = "caret-up-fill"
else:
# Upgrade
evolution_sign = "-"
evolution_color = "#03bf03"
arrow_dir = "caret-down-fill"
if isinstance(evolution_percent, float) and evolution_percent < 5:
# If the stats staggers at zero, it's a great thing
if evolution_chart_data[-1] == 0:
evolution_color = "#03bf03"
# Neutral
else:
evolution_color = "orange"
# Handles very big variations
if isinstance(evolution_percent, float) and evolution_percent >= 1000:
evolution_percent = str(round(evolution_percent / 1000, 2)) + "k"
else:
evolution_sign = ""
evolution_percent = ""
evolution_color = ""
arrow_dir = ""
percent = ""
width_evolution_big = 12


template_data = {
"category": self.category,
Expand All @@ -216,7 +257,13 @@ def render(self, page_f, return_html=False):
"id": md5(self.description_reduced.encode('utf-8')).hexdigest()[:8],
"rgb_color": rgb_color,
"evolution_chart_data": evolution_chart_data,
"evolution_labels": self.evolution_labels
"evolution_labels": self.evolution_labels,
"evolution_sign": evolution_sign,
"evolution_percent": str(evolution_percent) + percent,
"evolution_color": evolution_color,
"arrow_dir": arrow_dir,
"width_evolution_big": width_evolution_big,
"width_evolution_small": 12 - width_evolution_big
}

html_line = self.fillTemplate(html_raw, template_data)
Expand Down

0 comments on commit 4ae7982

Please sign in to comment.