前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >如何使用WriteHat生成渗透测试报告

如何使用WriteHat生成渗透测试报告

作者头像
FB客服
发布2021-04-16 14:30:18
1.2K0
发布2021-04-16 14:30:18
举报
文章被收录于专栏:FreeBufFreeBuf

关于WriteHat

WriteHat是一款功能强大的渗透测试报告工具,在该工具的帮助下,广大研究人员可以轻松生成渗透测试报告,从此不必再将大量的时间放在Microsoft Word等文字编辑工具身上了。从Markdown到HTML,再到PDF,应有尽有。这款工具由渗透测试人员开发,专为渗透测试人员设计,但是我们也可以用它来生成任意类型的报告。该工具基于Python 3开发,由Django驱动。

功能介绍

轻松生成漂亮美观的渗透测试报告; 动态拖放报告生成器; Markdown支持,包括代码块和图标等等; 剪贴、注释、标题和上传图像支持; 可自定义报告背景/页脚; 为各个报告部分分配操作人员和跟踪状态; 能够克隆和模板化报告; 搜索结果数据库; 支持多种评分类型(CVSS 3.1,DARED); 可以从同一组分析结果轻松生成多个报告; 可扩展的设计使高级用户能够创建高度定制的报告部分; LDAP集成;

安装要求

该工具的使用要求本地主机安装Docker和Docker Compose。我们可以使用apt、pacman和dnf等工具来安装依赖组件:

代码语言:javascript
复制
$ sudo apt install docker.io docker-compose

部署WriteHat

方法一(仅供测试)

WriteHat可以使用下列一行命令轻松完成部署安装:

代码语言:javascript
复制
$ git clone https://github.com/blacklanternsecurity/writehat && cd writehat && docker-compose up

接下来,在浏览器中访问https://127.0.0.1即可使用WriteHat,默认用户名和密码为“admin / PLEASECHANGETHISFORHEA*VENSSAKE”。

方法二

首先,我们还是需要安装Docker和Docker Compose。接下来,在/opt目录中使用下列命令将该项目源码克隆至本地:

代码语言:javascript
复制
$ cd /opt

$ git clone https://github.com/blacklanternsecurity/writehat

$ cd writehat

接下来,在writehat/config/writehat.conf文件中创建安全保护密码,密码将用于:

MongoDB MySQL Django 管理员用户

添加我们的目标主机名,在writehat/config/writehat.conf文件中的allowed_hosts字段中设置。

设置完成后,在nginx/中替换自签名的SSL证书:

代码语言:javascript
复制
writehat.crt
writehat.key

现在,我们就可以使用下列命令测试工具是否配置正确:

代码语言:javascript
复制
$ docker-compose up --build

注意,如果使用了VPN,你则需要在首次使用docker-compose运行服务之前断开VPN连接,这样才能保证Docker能够正确创建虚拟网络。

现在,我们就需要安装并激活Systemd服务了,配置后WriteHat将会在设备启动时自动运行:

代码语言:javascript
复制
$ sudo cp writehat/config/writehat.service /etc/systemd/system/

$ sudo systemctl enable writehat --now

我们可以使用下列命令跟踪服务日志:

代码语言:javascript
复制
$ sudo journalctl -xefu writehat.service

关于用户的创建,我们需要使用writehat/config/writehat.conf中定义的管理员凭证登录https://127.0.0.1/admin,因为有部分操作是只有管理员才能操作的,比如说数据库备份等等:

代码语言:javascript
复制
# Enter the app container

$ docker-compose exec writehat bash

# Promote the user and exit

$ ./manage.py ldap_promote <ldap_username>

$ exit

如何编写自定义报告组件

每一个报告组件都有下列内容组成:

1、writehat/components/中的Python文件; 2、writehat/templates/componentTemplates/中的HTML模板; 3、writehat/static/css/component/中的CSS文件;

我们建议大家直接引用这些目录下的已有文件,如果想要自定义开发的话,请参考下列样例。

components/CustomComponent.py

代码语言:javascript
复制
from .base import *

class CustomComponentForm(ComponentForm):

    summary = forms.CharField(label='Component Text', widget=forms.Textarea, max_length=50000, required=False)

    field_order = ['name', 'summary', 'pageBreakBefore', 'showTitle']

class Component(BaseComponent):

    default_name = 'Custom Report Component'

    formClass = CustomComponentForm

    # the "templatable" attribute decides whether or not that field

    # gets sa*ved if the report is ever converted into a template

    fieldList = {

        'summary': StringField(markdown=True, templatable=True),

    }

    # make sure to specify the HTML template

    htmlTemplate = 'componentTemplates/CustomComponent.html'

    # Font Awesome icon type + color (HTML/CSS)

    # This is just eye candy in the web app

    iconType = 'fas fa-stream'

    iconColor = 'var(--blue)'

    # the "preprocess" function is executed when the report is rendered

    # use this to perform any last-minute operations on its data

    def preprocess(self, context):

        # for example, to uppercase the entire "summary" field:

        #   context['summary'] = context['summary'].upper()

        return context

componentTemplates/CustomComponent.html

代码语言:javascript
复制
{% load custom_tags %}

<section class="l{{ level }} component{% if pageBreakBefore %} page-break{% endif %}" id="container_{{ id }}">

  {% include 'componentTemplates/Heading.html' %}

  <div class='markdown-align-justify custom-component-summary'>

    <p>

      {% markdown summary %}

    </p>

  </div>

</section>

componentTemplates/CustomComponent.css

代码语言:javascript
复制
div.custom-component-summary {

    font-weight: bold;

}

配置完成后,别忘了使用下列命令重启WriteHat服务:

代码语言:javascript
复制
$ docker-compose restart writehat

项目地址

WriteHat:点击底部【阅读原文】获取

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-03-28,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 FreeBuf 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 关于WriteHat
  • 功能介绍
  • 安装要求
  • 部署WriteHat
    • 方法一(仅供测试)
      • 方法二
      • 如何编写自定义报告组件
        • components/CustomComponent.py
          • componentTemplates/CustomComponent.html
            • componentTemplates/CustomComponent.css
            • 项目地址
            相关产品与服务
            容器镜像服务
            容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档