summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorW. Kosior <koszko@koszko.org>2025-01-29 21:38:25 +0100
committerW. Kosior <koszko@koszko.org>2025-01-29 21:38:25 +0100
commit87c5edbd25f3d95684029d36ae9bdd1ccba53262 (patch)
tree628324550651d255f18d73605c6ba47746abb49d
parent25a949412c58713cf8226866328d879791bdf057 (diff)
downloadAGH-threat-intel-course-87c5edbd25f3d95684029d36ae9bdd1ccba53262.tar.gz
AGH-threat-intel-course-87c5edbd25f3d95684029d36ae9bdd1ccba53262.zip
Adjust tables for inclusion in target documentHEADmagister
-rwxr-xr-xcountries_motives_sectors_tables.py42
-rw-r--r--countries_table_doc.tex6
-rw-r--r--motives_table_doc.tex6
-rw-r--r--sectors_table_doc.tex6
-rw-r--r--techniques_table.py40
-rw-r--r--techniques_table_doc.tex6
6 files changed, 79 insertions, 27 deletions
diff --git a/countries_motives_sectors_tables.py b/countries_motives_sectors_tables.py
index 2ba2fc6..196379e 100755
--- a/countries_motives_sectors_tables.py
+++ b/countries_motives_sectors_tables.py
@@ -181,11 +181,6 @@ ignored_groups = [
"PachaGroup", "PinchySpider", "Rocke", "SaltySpider", "Yingmob",
"ZombieSpider", "Avalanche", "Boss Spider", "CobaltGroup",
"Cron", "GCMAN", "RetefeGang", "SharkSpider", "VenomSpider",
- # We also omit APT5 because neither the NSA'a Threat Hunting Guidance nor
- # the description from
- # https://web.archive.org/web/20180806122230/https://www.fireeye.com/current-threats/apt-groups.html
- # actually state its origin.
- "APT5"
]
for group in groups_data["groups"]:
@@ -218,18 +213,33 @@ all_traits = [trait for score, trait in all_traits
all_origins = sorted(groups_by_origin)
all_origin_labels = [origin_labels[origin] for origin in all_origins]
-print("{")
-print("\\footnotesize")
-print("\\rowcolors{3}{gray!20}{white!100}")
-print("\\renewcommand*{\\arraystretch}{1.3}")
+origin_heads = ' & '.join(
+ f"\\nohyphens{{\\bfseries {text}}}" for text in all_origin_labels
+)
+type_cap = table_type[0].upper() + table_type[1:]
+head = f"""\
+\\rowcolor{{gray!40}}
+\\bfseries {type_cap} & {origin_heads} & \\bfseries total APT count \\\\"""
+
print("""\
-\\begin{longtable}{\
-p{0.3\\textwidth} \
-p{0.65in} p{0.65in} p{0.65in} p{0.65in} \
->{\\centering\\arraybackslash} p{0.85in} \
-}""")
-print(f"{table_type} & {' & '.join(all_origin_labels)} & total APT count \\\\")
-print("\\hline\\hline \\endhead")
+{
+\\footnotesize
+
+\\begin{longtable}{>{\\raggedright\\arraybackslash}p{1.2in} p{0.76in} p{0.76in} p{0.76in} p{0.76in} >{\centering\\arraybackslash} p{0.65in} }
+
+\\rowcolor{white}
+\\caption{\\nexttabcaption} \\label{\\nexttablabel} \\\\""")
+print(head)
+print("\\endfirsthead")
+print(head)
+print("""
+\\endhead
+
+\\rowcolor{white}
+\\multicolumn{6}{r}{\\textit{Continued on next page}} \\\\
+\\endfoot
+
+\\endlastfoot""")
all_percentages = []
diff --git a/countries_table_doc.tex b/countries_table_doc.tex
index c047332..162cbbe 100644
--- a/countries_table_doc.tex
+++ b/countries_table_doc.tex
@@ -14,9 +14,15 @@
urlcolor={blue!80!black}
}
\usepackage{textcomp}
+\usepackage{hyphenat}
\input{tlp.tex}
+\rowcolors{3}{gray!20}{white!100}
+\renewcommand*{\arraystretch}{1.3}
+\def\nexttabcaption{Targeted States by APT's Origin Country}
+\def\nexttablabel{tab:APT_Countries}
+
\title{Statistics of groups targeting particular countries}
\author{Wojciech Kosior}
diff --git a/motives_table_doc.tex b/motives_table_doc.tex
index 707f62d..50ccb13 100644
--- a/motives_table_doc.tex
+++ b/motives_table_doc.tex
@@ -14,9 +14,15 @@
urlcolor={blue!80!black}
}
\usepackage{textcomp}
+\usepackage{hyphenat}
\input{tlp.tex}
+\rowcolors{3}{gray!20}{white!100}
+\renewcommand*{\arraystretch}{1.3}
+\def\nexttabcaption{APT Motives by Country}
+\def\nexttablabel{tab:APT_Motives}
+
\title{Statistics of groups with particular motivation}
\author{Wojciech Kosior}
diff --git a/sectors_table_doc.tex b/sectors_table_doc.tex
index a3c87e4..793afe3 100644
--- a/sectors_table_doc.tex
+++ b/sectors_table_doc.tex
@@ -14,9 +14,15 @@
urlcolor={blue!80!black}
}
\usepackage{textcomp}
+\usepackage{hyphenat}
\input{tlp.tex}
+\rowcolors{3}{gray!20}{white!100}
+\renewcommand*{\arraystretch}{1.3}
+\def\nexttabcaption{APT Attacked Sectors by Country}
+\def\nexttablabel{tab:APT_Sectors}
+
\title{Statistics of groups targeting particular sectors of industry}
\author{Wojciech Kosior}
diff --git a/techniques_table.py b/techniques_table.py
index 13c9212..9ea23ef 100644
--- a/techniques_table.py
+++ b/techniques_table.py
@@ -7,6 +7,8 @@
import yaml
import sys
+CUTOFF_SCORE = 20
+
def read_APT_data(yaml_path):
if yaml_path:
with open(yaml_path) as inp:
@@ -45,24 +47,40 @@ def technique_popularity_score(tid):
all_tids = sorted(set().union(*groups_by_techniques_by_origin.values()),
key=technique_popularity_score,
reverse=True)
+all_tids = [tid for tid in all_tids
+ if technique_popularity_score(tid) >= CUTOFF_SCORE]
all_origins = sorted(groups_by_origin)
technique_names = dict((t["mitre_id"], t["name"])
for t in profiles_data["techniques"])
-print("{")
-print("\\footnotesize")
-print("\\rowcolors{3}{gray!20}{white!100}")
-print("\\renewcommand*{\\arraystretch}{1.3}")
+origin_heads = ' & '.join(
+ f"\\nohyphens{{\\bfseries {text}}}" for text in all_origins
+)
+head = f"""\
+\\rowcolor{{gray!40}}
+\\bfseries Technique & {origin_heads} & \\bfseries total APT count \\\\"""
+
print("""\
-\\begin{longtable}{\
-p{0.3\\textwidth} \
-p{0.65in} p{0.65in} p{0.65in} p{0.65in} \
->{\\centering\\arraybackslash} p{0.85in} \
-}""")
-print(f"technique & {' & '.join(all_origins)} & total APT count \\\\")
-print("\\hline\\hline \\endhead")
+{
+\\footnotesize
+
+\\begin{longtable}{>{\\raggedright\\arraybackslash}p{1.2in} p{0.76in} p{0.76in} p{0.76in} p{0.76in} >{\centering\\arraybackslash} p{0.65in} }
+
+\\rowcolor{white}
+\\caption{\\nexttabcaption} \\label{\\nexttablabel} \\\\""")
+print(head)
+print("\\endfirsthead")
+print(head)
+print("""
+\\endhead
+
+\\rowcolor{white}
+\\multicolumn{6}{r}{\\textit{Continued on next page}} \\\\
+\\endfoot
+
+\\endlastfoot""")
for tid in all_tids:
name = technique_names[tid]
diff --git a/techniques_table_doc.tex b/techniques_table_doc.tex
index eb55af1..0a5852f 100644
--- a/techniques_table_doc.tex
+++ b/techniques_table_doc.tex
@@ -14,9 +14,15 @@
urlcolor={blue!80!black}
}
\usepackage{textcomp}
+\usepackage{hyphenat}
\input{tlp.tex}
+\rowcolors{3}{gray!20}{white!100}
+\renewcommand*{\arraystretch}{1.3}
+\def\nexttabcaption{APT Techniques by Country}
+\def\nexttablabel{tab:APT_Techniques}
+
\title{Statistics of groups using particular techniques}
\author{Wojciech Kosior}