From db97c383f3621f4cde717a1a0f52e82b6a7819b6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 30 Aug 2023 08:32:24 +0200 Subject: [PATCH] Continued: - formatted template block - added average blocks --- daemon.py | 4 +++- templates/views/index.html | 1 + templates/views/scoreboard.html | 25 +++++++++++++++++++++---- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/daemon.py b/daemon.py index 9f96e11..bfa0e41 100755 --- a/daemon.py +++ b/daemon.py @@ -86,7 +86,9 @@ def api_scoreboard(mode: str, amount: int): elif mode == "detection_mode": database.cursor.execute("SELECT detection_mode, COUNT(domain) AS cnt FROM instances GROUP BY detection_mode ORDER BY cnt DESC LIMIT ?", [amount]) elif mode == "avg_peers": - database.cursor.execute("SELECT software, AVG(total_peers) AS average FROM instances WHERE software IS NOT NULL GROUP BY software HAVING average > 0 ORDER BY average DESC LIMIT ?", [amount]) + database.cursor.execute("SELECT software, AVG(total_peers) AS average FROM instances WHERE software IS NOT NULL AND total_peers IS NOT NULL GROUP BY software HAVING average > 0 ORDER BY average DESC LIMIT ?", [amount]) + elif mode == "avg_blocks": + database.cursor.execute("SELECT software, AVG(total_blocks) AS average FROM instances WHERE software IS NOT NULL AND total_blocks IS NOT NULL GROUP BY software HAVING average > 0 ORDER BY average DESC LIMIT ?", [amount]) elif mode == "obfuscator": database.cursor.execute("SELECT software, COUNT(domain) AS cnt FROM instances WHERE has_obfuscation = 1 GROUP BY software ORDER BY cnt DESC LIMIT ?", [amount]) elif mode == "obfuscation": diff --git a/templates/views/index.html b/templates/views/index.html index 88024a9..4630c10 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -63,6 +63,7 @@
  • Error codes
  • Detection modes
  • Average peers
  • +
  • Average blocks
  • Obfuscating software
  • Obfuscation statistics
  • Block level statistics
  • diff --git a/templates/views/scoreboard.html b/templates/views/scoreboard.html index 04bf8b9..2f76194 100644 --- a/templates/views/scoreboard.html +++ b/templates/views/scoreboard.html @@ -1,6 +1,21 @@ {% extends "base.html" %} -{% block title %}Scoreboard - {% if mode == 'software' %}TOP {{amount}} used software{% elif mode == 'detection_mode' %}Detection mode statistics{% elif mode == 'block_level' %}TOP {{amount}} block level statistics{% elif mode == 'obfuscation' %}Obfuscation statistics{% elif mode == 'obfuscator' %}TOP {{amount}} obfuscating software{% elif mode == 'avg_peers' %}TOP {{amount}} average peer count{% elif mode == 'command' %}TOP {{amount}} commands{% elif mode == 'error_code' %}TOP {{amount}} error codes{% elif mode == 'reference' %}TOP {{amount}} referencing instances{% elif mode == 'blocked' %}TOP {{amount}} deferated instances{% elif mode == 'blocker' %}TOP {{amount}} deferating instances{% endif %}{% endblock %} +{% block title %} + Scoreboard - + {% if mode == 'software' %}TOP {{amount}} used software + {% elif mode == 'detection_mode' %}Detection mode statistics + {% elif mode == 'block_level' %}TOP {{amount}} block level statistics + {% elif mode == 'obfuscation' %}Obfuscation statistics + {% elif mode == 'obfuscator' %}TOP {{amount}} obfuscating software + {% elif mode == 'avg_peers' %}TOP {{amount}} average peer count + {% elif mode == 'avg_blocks' %}TOP {{amount}} average block count + {% elif mode == 'command' %}TOP {{amount}} commands + {% elif mode == 'error_code' %}TOP {{amount}} error codes + {% elif mode == 'reference' %}TOP {{amount}} referencing instances + {% elif mode == 'blocked' %}TOP {{amount}} deferated instances + {% elif mode == 'blocker' %}TOP {{amount}} deferating instances + {% endif %} +{% endblock %} {% block header %} {% if mode == 'blocker' %} @@ -19,6 +34,8 @@

    Detection mode statistics

    {% elif mode == 'avg_peers' %}

    TOP {{amount}} average peer count

    + {% elif mode == 'avg_blocks' %} +

    TOP {{amount}} average block count

    {% elif mode == 'obfuscator' %}

    TOP {{amount}} obfuscating software

    {% elif mode == 'obfuscation' %} @@ -36,7 +53,7 @@ № - {% if mode in ('software', 'avg_peers', 'obfuscator') %}Software + {% if mode in ('software', 'avg_peers', 'avg_blocks', 'obfuscator') %}Software {% elif mode == 'obfuscation' %}Obfuscation status {% elif mode == 'detection_mode' %}Detection mode {% elif mode == 'error_code' %}Error code @@ -45,7 +62,7 @@ {% if mode == 'reference' %}References - {% elif mode == 'avg_peers' %}Average + {% elif mode in('avg_peers', 'avg_blocks') %}Average {% elif mode in('software', 'error_code', 'obfuscator', 'obfuscation', 'block_level', 'detection_mode', 'command') %}Total {% else %}Blocks {% endif %} @@ -63,7 +80,7 @@ {{entry['domain']}} {% elif mode == 'block_level' %} {{entry['domain']}} - {% elif mode in ('avg_peers', 'obfuscator') %} + {% elif mode in ('avg_peers', 'avg_blocks', 'obfuscator') %} {{entry['domain']}} {% elif mode in ('software', 'detection_mode', 'command') %} {{entry['domain']}} -- 2.39.5