Giter VIP home page Giter VIP logo

reporter's Introduction

Reporter

This project can be used to create a penetration test report based on findings and some extra report content. The findings and issue content are merged and inserted into a LaTeX template. This template is them compiled to PDF.

Setup

Use python 3.10.

Clone https://github.com/JJK96/textile_parser and install using pip install -e .

Clone this project using git clone --recurse-submodules. Then install the project using pip install -e ..

Dependencies

Install basictex to have the necessary tools to compile LaTeX: brew install --cask basictex

In order to use the provided functionality for creating standard issues, the program fzf should be installed.

To use diffing of standard issues and report issues, diff is required.

To use the provided tooling for editing, installing Visual Studio Code is recommended, but not required.

Mac OS

brew install --cask basictex
brew install fzf

Ubuntu

sudo apt install texlive-latex-base texlive-latex-recommended texlive-latex-extra texlive-luatex latexmk fonts-open-sans

Make sure you have at least texlive-luatex version 2021.20220204, so that lua-ul.sty is included.

Usage

Creating a new report

To create a new report, use the following command:

reporter init <report_name>
reporter init -l nl <report_name>

This will create a new directory with the name <report_name> with the LaTeX template "report.tex" and the directory "issues" with one example issue. This new project is created based on the report_init directory.

Adding report content

Report settings

The settings for the report can be edited in reporter.ini. These settings include the preferred language, title of the report, company name, etc.

Report content

Other report content can be added in report.tex, the file should be self-explanatory.

Issue

The report can be created by adding new issues to the issue directory. Each issue has it’s own directory, with an arbitrary name. In the directory, the issue file should have a name that starts with "issue" or ends with ".issue". All other files in the directory are interpreted as evidence.

To aid in creating an issue the command create-issue (alias ci) is provided:

reporter create-issue --title "This is the title"

It is also possible to easily create an issue based on an issue from the standard issue library.

reporter create-standard-issue

This opens fzf with all the files in the standard issue library. There one issue can be selected. This issue is then copied to the issues directory.

Evidence

To aid in creating a new evidence, the command create-evidence (alias ce) is provided:

reporter create-evidence <location> <output-file>

This will create a new evidence with the given location (hostname) and store it in the given output file.

Paths

To ensure that paths are formatted correctly, wrap them in the LaTeX command \path{…​}

Images

To add an image, store it in the folder images in the report and insert the \image{…​} command.

Example:

$ ls images
test_image.png

Then anywhere in the report:

\image{test_image}

Pentesting tools

To avoid having to put pentesting tools with footnotes everywhere in the report, there is a framework for managing pentesting tools. The description of the tools are added in the static_content of the report. Through tools.tex, the tool definitions are inserted in the report.

If a tools is used in evidence, it can be referred to using \tool{toolname}. This will insert a reference to the tool description in the place of the tool.

The appendix of the report will contain a list of all the tools used, including their descriptions and URLs.

A tool can be manually declared with

\declaretool[link]{toolname}{description}

Compiling the report

The report can be compiled with the following command:

reporter generate

This creates the directory .cache/output with all the files necessary for compilation, compiles the report and copies the resulting PDF report to the current directory.

Tooling

Reports created with the reporter init command contain a .vscode directory with settings for Visual Studio Code. These settings suggest some plugins for LaTeX editing and compiling, textile support, spelling checking and code review tools. The following popup is shown when VS Code is started.

vscode popup

Installing the plugins is recommended. The LaTeX report can be compiled by clicking the green arrow when editing the report.tex file.

How it works

On a high level, the application uses a LaTeX Jinja template and several sources of information provided through either a given template or a given report to compile a PDF file.

The directory templates contains several report templates. A template contains the content and templates for a report. The default template templates/default is used as a fallback for files that have not been overridden in other templates. A template contains the following information:

  • The LaTeX template in ./report. The LaTeX template contains no text, all text is loaded using jinja.

  • Static images in ./static_images, these images can be used by the template

  • Static content in ./static_content, this content contains text and placeholders that will be used during jinja templating. Based on the selected language, the correct static content is loaded.

  • Dynamic content based on issues, such as counts, summaries, etc.

  • Dynamic content in ./dynamic_text.py, this Python module is optionally included and can be used to add information to the jinja context using Python scripts.

  • ./reporter.py can be used to override the Reporter class in reporter/reporter.py for advanced customization.

In addition to the information provided by the template, information from the report is added:

  • ./report.tex contains user-provided information that should be added to the report

  • ./reporter.ini contains user-provided settings for the report, including the title and customer name

  • Issues and evidences. The directory issues in a report contains all issues and evidences for the report. These issues are parsed and merged with the jinja context.

Compilation steps

The steps for compiling the report are as follows:

  1. Create the .cache directory in which the report is built.

  2. Symlink all files in the report directory to the .cache/output directory.

  3. Copy all LaTeX templates and store them in the .cache/templates directory.

  4. Template all LaTeX templates in .cache/templates and store the output in .cache/output.

  5. Copy the necessary supportive files. These files are stored in necessary_files and contain a Makefile used to build the project and some other necessary files.

  6. Run Make in the .cache/output directory to build the report

  7. Copy the report PDF file to the report directory.

Overriding LaTeX templates

When copying the template files to .cache/templates, the LaTeX templates are loaded first from parent themes/templates, then from the template itself, and finally from the report directory. his means that it is possible to override any of the LaTeX templates by copying it from .cache/templates to the report directory and editing it. These files may contain Jinja tags (\BLOCK{…​} and \VAR{…​}).

Extra content can be loaded from .yaml files in the report directory. e.g.

content.yaml

some_variable: test

conclusion.tex

\VAR{some_variable}

Dradis/Textile parsing

For Textile parsing of Dradis content Textile-Parser is used. This library parses a Dradis file and returns a dictionary containing all fields. The markup in the fields, like bullets, footnotes, etc. is converted to LaTeX and is inserted directly in the resulting Dradis Issue.

Non-standard issue fields:

#[Number]#
4

Normally, issues are numbered from 1 to n starting with the highest-severity vulnerability as 1. It is possible to override this automatic number for specific issues by setting the number field in the issue.

#[Label]#
mylabel

To refer to an issue somewhere else in the text, the label field can be used to set a label. It can then be used to reference the issue somewhere in the text using \ref{mylabel}.

#[Location]#
server1, server2

Normally the location where an issue is found is determined as the combination of the locations of all evidences. This can be overriden by setting the location field in the issue.

Report initiation

When running reporter init, the report_init directory is used to create a new report. The directories report_init/base and report_init/types/<type_name> contain the files that make up the report directory. Files in these directories are templated using jinja, based on the static content in the template.

The LaTeX template

The latex template is stored in the templates/default/report/ folder. The heart of the template is the report.cls latex class file. This file contains all kinds of commands and macro’s to simplify the syntax for creating a latex support. It defines the colors for different risk levels of risks. It also defines the title page format and uses variables to fill the variable content.

Custom templates

It is possible to extend or override the existing template by creating a new template in the templates folder. The file templates/new_template/parents.txt contains one parent template per line (i.e. default). When loading content, a fallthrough system is used so that files that are missing in the template are loaded from the parent template. Any file in templates/new_template/report will override a file with the same name in the report directory of parent reports. The directory static_images can be created in a report. These images are copied to the .cache/output folder in any new reports.

In addition, it is possible to add a file for generating dynamic content. To do this, create a file named dynamic_text.py in the directory of the new template. This file should contain a content like the following:

from reporter.dynamic_text import Generator


class English(Generator):
    def generate(self):
        self.content['anything'] = "This dynamically created value"

generators = {
    "en": English,
}

It is also possible to extend the reporter class. For this, add a file named reporter.py in the directory of the new template. This file should contain a content like the following:

from reporter.reporter import Reporter as Base


class Reporter(Base):
    ...
    def process_issues(self, content, issues):
        """Do something with the content based on the issues"""
    ...

Notable commands/macro’s

\companyname{Company B.V.}

Set the company name.

\assignment{CONTENT}

Describe the assignment, what did we do, etc.

\managementConclusion{CONTENT}

Describe the conclusion of the project to the management

\begin{code}
    Some code $${{With highlighted text}}$$.
\end{code}

\begin{code}[filename.py]
    Some code $$*{{With highlighted text in a different color}}*$$.
\end{code}

Code listings based on lstlistings package.

Issue

For creating an issue, the issue environment is available. This environment is normally filled based on the Textile formatted issue and evidence files. The format is described below.

\begin{issue}
\descriptionfield{Thes issue is ... }
\solution{You should ... }
\location{Hostname.domain}
\cvss{0.0}
\cvssvector{CVSS3.1:AV/N...}

\begin{evidence}{Hostname}

Some text ...

\begin{code}
Verbatim code snippet
\end{code}

Some more text ...
\end{evidence}

\end{issue}

Colors

The following colors are available

Color

Use

critical

Critical risk

high

High risk

medium

Medium risk

low

Low risk

none

Informational risk

codebg

Background for code listings

highlight

Highlighted code in listing

reporter's People

Contributors

jjk96 avatar

Watchers

 avatar

Forkers

blupblob

reporter's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.