Commit 87e257d8 by dorp

refactored templates (step 1)

parent 989ea9e7
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
\hline
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time}\\
\hline
\subsection*{Binwalk (v. \VAR{selected_analysis['plugin_version']})}
Plugin Version & \VAR{selected_analysis['plugin_version'] | filter_chars} \\
\hline
\multicolumn{2}{|p{14.5cm}|}{Signature Analysis:} \\
\multicolumn{2}{|p{14.5cm}|}{} \\
\multicolumn{2}{|p{14.5cm}|}{\VAR{selected_analysis['signature_analysis'] | filter_chars}} \\
\hline
Entropy Graph & \includegraphics[scale = 0.7]{\VAR{selected_analysis['entropy_analysis_graph'] | base64_to_png('entropy_analysis_graph', tmp_dir)}} \\
\hline
{\fontfamily{lmss}\selectfont
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
\BLOCK{if selected_analysis['summary']}
\multicolumn{2}{|p{14.5cm}|}{Summary:} \\
\multicolumn{2}{|p{14.5cm}|}{Signature Analysis:} \\
\multicolumn{2}{|p{14.5cm}|}{} \\
\BLOCK{for data in selected_analysis['summary']}
\multicolumn{2}{|p{14.5cm}|}{\VAR{data | filter_chars}} \\
\BLOCK{endfor}
\multicolumn{2}{|p{14.5cm}|}{\VAR{selected_analysis['signature_analysis'] | filter_chars}} \\
\hline
\BLOCK{endif}
\end{longtable}
\ No newline at end of file
Entropy Graph & \includegraphics[scale = 0.7]{\VAR{selected_analysis['entropy_analysis_graph'] | base64_to_png('entropy_analysis_graph', tmp_dir)}} \\
\hline
\BLOCK{if selected_analysis['summary']}
\multicolumn{2}{|p{14.5cm}|}{Summary:} \\
\multicolumn{2}{|p{14.5cm}|}{} \\
\BLOCK{for data in selected_analysis['summary']}
\multicolumn{2}{|p{14.5cm}|}{\VAR{data | filter_chars}} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
}
\ No newline at end of file
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
\hline
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
\hline
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
\subsection*{Exploit Mitigation (v. \VAR{selected_analysis['plugin_version']})}
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
\hline
\BLOCK{if selected_analysis['summary']}
NX
&
\BLOCK{for selected_summary in selected_analysis['summary']}
\BLOCK{if selected_summary | contains('NX')}
\VAR{selected_summary | filter_chars} (\VAR{ selected_analysis['summary'][selected_summary] | elements_count })
\BLOCK{endif}
\BLOCK{endfor} \\
\hline
Canary
&
\BLOCK{for selected_summary in selected_analysis['summary']}
\BLOCK{if selected_summary | contains('Canary')}
\VAR{selected_summary | filter_chars} (\VAR{ selected_analysis['summary'][selected_summary] | elements_count })
\BLOCK{endif}
\BLOCK{endfor} \\
\hline
PIE
&
\BLOCK{for selected_summary in selected_analysis['summary']}
\BLOCK{if selected_summary | contains('PIE')}
\VAR{selected_summary | filter_chars} (\VAR{ selected_analysis['summary'][selected_summary] | elements_count })
\BLOCK{endif}
\BLOCK{endfor} \\
\hline
RELRO
&
\BLOCK{for selected_summary in selected_analysis['summary']}
\BLOCK{if selected_summary | contains('RELRO')}
\VAR{selected_summary | filter_chars} (\VAR{ selected_analysis['summary'][selected_summary] | elements_count })
\BLOCK{endif}
\BLOCK{endfor} \\
{\fontfamily{lmss}\selectfont
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
\BLOCK{if selected_analysis['summary']}
NX
&
\BLOCK{for selected_summary in selected_analysis['summary']}
\BLOCK{if selected_summary | contains('NX')}
\VAR{selected_summary | filter_chars} (\VAR{ selected_analysis['summary'][selected_summary] | elements_count })
\BLOCK{endif}
\BLOCK{endfor} \\
\hline
Canary
&
\BLOCK{for selected_summary in selected_analysis['summary']}
\BLOCK{if selected_summary | contains('Canary')}
\VAR{selected_summary | filter_chars} (\VAR{ selected_analysis['summary'][selected_summary] | elements_count })
\BLOCK{endif}
\BLOCK{endfor} \\
\hline
PIE
&
\BLOCK{for selected_summary in selected_analysis['summary']}
\BLOCK{if selected_summary | contains('PIE')}
\VAR{selected_summary | filter_chars} (\VAR{ selected_analysis['summary'][selected_summary] | elements_count })
\BLOCK{endif}
\BLOCK{endfor} \\
\hline
RELRO
&
\BLOCK{for selected_summary in selected_analysis['summary']}
\BLOCK{if selected_summary | contains('RELRO')}
\VAR{selected_summary | filter_chars} (\VAR{ selected_analysis['summary'][selected_summary] | elements_count })
\BLOCK{endif}
\BLOCK{endfor} \\
\hline
\BLOCK{endif}
\end{longtable}
\BLOCK{endif}
\end{longtable}
}
\ No newline at end of file
\subsection*{hashes (v. \VAR{selected_analysis['plugin_version']})}
\subsection*{Hashes (v. \VAR{selected_analysis['plugin_version']})}
{\fontfamily{lmss}\selectfont
\begin{tabular}{|p{3cm}|p{11.5cm}|}
......
\subsection*{file type (v. \VAR{selected_analysis['plugin_version']})}
\subsection*{File Type (v. \VAR{selected_analysis['plugin_version']})}
{\fontfamily{lmss}\selectfont
\begin{longtable}{|p{3cm}|p{11.5cm}|}
......
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
\subsection*{\VAR{plugin_name | plugin_name | filter_chars} (v. \VAR{selected_analysis['plugin_version'] | filter_chars})}
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
\hline
{\fontfamily{lmss}\selectfont
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
\BLOCK{endfor}
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
\hline
\BLOCK{endif}
\end{longtable}
\ No newline at end of file
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
}
\ No newline at end of file
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
\hline
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
\subsection*{IPs and URIs (v. \VAR{selected_analysis['plugin_version']})}
Plugin Version & \VAR{selected_analysis['plugin_version']}\\
\hline
IPs v4
\BLOCK{for ip in selected_analysis['ips_v4'] | check_list | filter_list}
& \VAR{ip} \\
\BLOCK{endfor}
\hline
IPs v6
\BLOCK{for ip in selected_analysis['ips_v6'] | check_list | filter_list}
& \VAR{ip} \\
\BLOCK{endfor}
\hline
{\fontfamily{lmss}\selectfont
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
IPs v4
\BLOCK{for ip in selected_analysis['ips_v4'] | check_list | filter_list}
& \VAR{ip} \\
\BLOCK{endfor}
\hline
URIs
\BLOCK{for uri in selected_analysis['uris'] | check_list | filter_list}
& \VAR{uri} \\
\BLOCK{endfor}
\hline
IPs v6
\BLOCK{for ip in selected_analysis['ips_v6'] | check_list | filter_list}
& \VAR{ip} \\
\BLOCK{endfor}
\hline
\BLOCK{if selected_analysis['summary']}
\multicolumn{2}{|p{14.5cm}|}{Summary:} \\
\multicolumn{2}{|p{14.5cm}|}{} \\
\BLOCK{for data in selected_analysis['summary']}
\multicolumn{2}{|p{14.5cm}|}{\VAR{data | filter_chars}} \\
URIs
\BLOCK{for uri in selected_analysis['uris'] | check_list | filter_list}
& \VAR{uri} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\BLOCK{if selected_analysis['summary']}
\multicolumn{2}{|p{14.5cm}|}{Summary:} \\
\multicolumn{2}{|p{14.5cm}|}{} \\
\BLOCK{for data in selected_analysis['summary']}
\multicolumn{2}{|p{14.5cm}|}{\VAR{data | filter_chars}} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
}
\ No newline at end of file
\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
......@@ -37,102 +38,91 @@
\section*{Analysis}
\BLOCK{if "base64_decoder" in analysis}
\subsection*{base64 decoder}
{\fontfamily{lmss}\selectfont
\input{base64_decoder.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "binwalk" in analysis}
\subsection*{binwalk}
{\fontfamily{lmss}\selectfont
\input{binwalk.tex}
}
\BLOCK{endif}
\BLOCK{if "cpu_architcture" in analysis}
\subsection*{cpu architecture}
{\fontfamily{lmss}\selectfont
\newpage
\BLOCK{if "cpu_architecture" in analysis}
\input{cpu_architecture.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "crypto_material" in analysis}
\subsection*{crypto material}
{\fontfamily{lmss}\selectfont
\input{crypto_material.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "exploit_mitigations" in analysis}
\subsection*{exploit mitigations}
{\fontfamily{lmss}\selectfont
\input{exploit_mitigations.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "file_hashes" in analysis}
\input{file_hashes.tex}
\BLOCK{endif}
\newpage
\BLOCK{if "file_type" in analysis}
\input{file_type.tex}
\BLOCK{endif}
\newpage
\BLOCK{if "init_systems" in analysis}
\subsection*{init systems}
{\fontfamily{lmss}\selectfont
\input{init_systems.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "ip_and_uri_finder" in analysis}
\subsection*{ip and uri finder}
{\fontfamily{lmss}\selectfont
\input{ip_and_uri_finder.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "software_components" in analysis}
\subsection*{software components}
{\fontfamily{lmss}\selectfont
\input{software_components.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "printable_strings" in analysis}
\subsection*{printable strings}
{\fontfamily{lmss}\selectfont
\input{printable_strings.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "users_and_passwords" in analysis}
\subsection*{users and passwords}
{\fontfamily{lmss}\selectfont
\input{users_and_passwords.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "string_evaluator" in analysis}
\subsection*{string evaluator}
{\fontfamily{lmss}\selectfont
\input{string_evaluator.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "unpacker" in analysis}
\subsection*{unpacker}
{\fontfamily{lmss}\selectfont
\input{unpacker.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "malware_scanner" in analysis}
\subsection*{malware scanner}
{\fontfamily{lmss}\selectfont
\input{malware_scanner.tex}
}
\BLOCK{endif}
\end{document}
......
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
\subsection*{Malware (v. \VAR{selected_analysis['plugin_version']})}
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
\hline
MD5 & \VAR{selected_analysis['md5']} \\
\hline
{\fontfamily{lmss}\selectfont
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
System Version & \VAR{selected_analysis['system_version']} \\
\hline
MD5 & \VAR{selected_analysis['md5']} \\
\hline
Scanners Number & \VAR{selected_analysis['number_of_scanners']} \\
\hline
System Version & \VAR{selected_analysis['system_version']} \\
\hline
Positives & \VAR{selected_analysis['positives']} \\
\hline
Scanners Number & \VAR{selected_analysis['number_of_scanners']} \\
\hline
Scanners
\BLOCK{for scanner in selected_analysis['scanners']}
& \VAR{scanner} \\
\BLOCK{endfor}
\hline
Positives & \VAR{selected_analysis['positives']} \\
\hline
Scanns
\BLOCK{for scan in selected_analysis['scans']}
\BLOCK{for value in selected_analysis['scans'][scan]}
& \VAR{scan} :: \VAR{value}:\VAR{selected_analysis['scans'][scan][value]} \\
Scanners
\BLOCK{for scanner in selected_analysis['scanners']}
& \VAR{scanner} \\
\BLOCK{endfor}
\BLOCK{endfor}
\hline
\hline
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
Scanns
\BLOCK{for scan in selected_analysis['scans']}
\BLOCK{for value in selected_analysis['scans'][scan]}
& \VAR{scan} :: \VAR{value}:\VAR{selected_analysis['scans'][scan][value]} \\
\BLOCK{endfor}
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
}
\ No newline at end of file
\begin{tabular}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time}\\
\hline
\subsection*{String Stats (v. \VAR{selected_analysis['plugin_version']})}
Plugin Version & \VAR{selected_analysis['plugin_version']}\\
\hline
String Count & \VAR{selected_analysis['strings'] | elements_count}\\
\hline
\end{tabular}
\ No newline at end of file
{\fontfamily{lmss}\selectfont
\begin{tabular}{|p{3cm}|p{11.5cm}|}
\hline
String Count & \VAR{selected_analysis['strings'] | elements_count}\\
\hline
\end{tabular}
}
\ No newline at end of file
\begin{tabular}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time}\\
\hline
\subsection*{String Eval Stats (v. \VAR{selected_analysis['plugin_version']})}
Plugin Version & \VAR{selected_analysis['plugin_version']}\\
\hline
String Count & \VAR{selected_analysis['string_eval'] | elements_count}\\
\hline
\end{tabular}
\ No newline at end of file
{\fontfamily{lmss}\selectfont
\begin{tabular}{|p{3cm}|p{11.5cm}|}
\hline
String Count & \VAR{selected_analysis['string_eval'] | elements_count}\\
\hline
\end{tabular}
}
\ No newline at end of file
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
\subsection*{Unpacker (v. \VAR{selected_analysis['plugin_version']})}
Plugin Version & \VAR{selected_analysis['plugin_version'] | filter_chars} \\
\hline
{\fontfamily{lmss}\selectfont
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Plugin & \VAR{selected_analysis['plugin_used'] | filter_chars} \\
\hline
Plugin & \VAR{selected_analysis['plugin_used'] | filter_chars} \\
\hline
Extracted & \VAR{selected_analysis['number_of_unpacked_files']} \\
\hline
Extracted & \VAR{selected_analysis['number_of_unpacked_files']} \\
\hline
\BLOCK{if selected_analysis['output']}
\multicolumn{2}{|p{14.5cm}|}{Output:}\\
\multicolumn{2}{|p{14.5cm}|}{}\\
\multicolumn{2}{|p{14.5cm}|}{\VAR{selected_analysis['output'] | split_output_lines | filter_chars }} \\
\hline
\BLOCK{endif}
\BLOCK{if selected_analysis['output']}
\multicolumn{2}{|p{14.5cm}|}{Output:}\\
\multicolumn{2}{|p{14.5cm}|}{}\\
\multicolumn{2}{|p{14.5cm}|}{\VAR{selected_analysis['output'] | split_output_lines | filter_chars }} \\
Entropy & \VAR{selected_analysis['entropy'] | nice_number} \\
\hline
\BLOCK{endif}
Entropy & \VAR{selected_analysis['entropy'] | nice_number} \\
\hline
\end{longtable}
\ No newline at end of file
\end{longtable}
}
\ No newline at end of file
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time}\\
\hline
Plugin Version & \VAR{selected_analysis['plugin_version']}\\
\hline
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\ No newline at end of file
......@@ -123,6 +123,11 @@ def create_jinja_environment(templates_to_use='default'):
return environment
def plugin_name(name):
parts = name.split('_')
return ' '.join(('{}{}'.format(part[0:1].upper(), part[1:]) for part in parts))
def _add_filters_to_jinja(environment):
environment.filters['number_format'] = byte_number_filter
environment.filters['nice_unix_time'] = nice_unix_time
......@@ -131,6 +136,7 @@ def _add_filters_to_jinja(environment):
environment.filters['elements_count'] = len
environment.filters['base64_to_png'] = convert_base64_to_png_filter
environment.filters['check_list'] = lambda x: x if x else ['list is empty']
environment.filters['plugin_name'] = plugin_name
environment.filters['filter_list'] = filter_chars_in_list
environment.filters['split_hash'] = split_hash
environment.filters['split_output_lines'] = split_output_lines
......@@ -156,4 +162,4 @@ class Engine:
except jinja2.TemplateNotFound:
logging.warning('Falling back on generic template for {}'.format(plugin))
template = self._environment.get_template(GENERIC_TEMPLATE)
return template.render(selected_analysis=analysis, tmp_dir=self._tmp_dir)
return template.render(plugin_name=plugin, selected_analysis=analysis, tmp_dir=self._tmp_dir)
......@@ -33,5 +33,5 @@ def test_request_firmware_data_bad_response(monkeypatch): # pylint: disable=inv
def test_create_request_url():
assert create_request_url('X', None) == '{}/rest/firmware/X'.format(DEFAULT_URL)
assert create_request_url('X', 'Y') == 'Y/rest/firmware/X'
assert create_request_url('X', None) == '{}/rest/firmware/X?summary=true'.format(DEFAULT_URL)
assert create_request_url('X', 'Y') == 'Y/rest/firmware/X?summary=true'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment