当前位置: 移动技术网 > 网络运营>安全>工具 > 新兴开源扫描器Golismero插件编写-UI插件编写

新兴开源扫描器Golismero插件编写-UI插件编写

2018年03月30日  | 移动技术网网络运营  | 我要评论
概述

Golismero是一款开源的Web扫描器,它不但自带不少的安全测试工具,而且还可导入分析市面流行的扫描工具的结果,比如Openvas,Wfuzz, SQLMap, DNS recon等,并自动分析。Golismero采用插件形式的框架结构,由纯python编写,并集成了许多开源的安全工具,可以运行在Windows,Linux, BSD,OS X等系统上,几乎没有系统依赖性,唯一的要求就是python的版本不低于2.7,其官网是:https://golismero-project.com。

    Golismero采用了插件式的框架结构,提供了一系列的接口,用户只要继承并且实现这些接口,就可以自定义自己的插件。根据插件的功能,可分为四类,每个类别的插件的接口都不同,所以在编写自定义插件的时候,注意选择好相应的插件类型。
a. ImportPlugin(导入插件)
     导入插件主要是用来加载其他安全工具的扫描结果
b. TestingPlugin(测试插件)
    测试插件主要是用来测试或者渗透入侵的插件
c. ReportPlugin(报表插件)
    报表插件主要是对测试结果生成报表。
d. UIPlugin(界面插件)
    界面插件主要是用于和用户交互的,显示当前系统的运行情况。


插件编写

UIPlugin编写
这是Golismero的界面插件,主要用于展示当前系统的运行详细状态信息,其接口类如下:
接口类
 

golismero.api.plugin.UIPlugin

 

基类  
+ golismero.api.plugin._InformationPlugin
   + golismero.api.plugin.Plugin
     +Object

接口基类:

_init_

x.__init__(...) initializes x; see help(type(x)) for signature

check_params(options, *audits)
Parameters:  

options (OrchestratorConfig) – Orchestrator settings.
audits (AuditConfig) – Audit settings.
Raises:    
AttributeError – A critical configuration option is missing.
ValueError – A configuration option has an incorrect value.
TypeError – A configuration option has a value of a wrong type.
Exception – An error occurred while validating the settings.

recv_info(info)

Callback method to receive data to be processed.
This is the most important method of a plugin. Here’s where most of the logic resides.
[Parameters]: 
info (Data) – Data to be processed.

recv_msg(message)

Callback method to receive control messages to be processed.
Parameters:   
message (Message) – incoming message to process
Returns:  Shared plugin state variables.

state

Return type:    PluginState

update_status(progress=None)

Plugins can call this method to tell the user of the current progress of whatever the plugin is doing.
Warning Do not override this method!
Note This method may not be supported in future versions of GoLismero.
Parameters:   
progress (float | None) – Progress percentage [0, 100] as a float, or None to indicate progress can’t be measured.

    下面就以编写一个显示各个插件运行时间logtime插件为例,UI控件必须放置在\plugins\ui目录下,每个插件都需要一个后缀名为.golismero的说明文档,以及相应python脚本文件。定义logtime的配置说明文件plugins\ui\logtime.golismero,代码如下:

[Core]
Name = Logtime UI
[Documentation]
Description = Show time plugin runs in console.
Author = GoLismero project team
Version = 0.1
Website = https://www.freebuf.com
Copyright = Copyright (C) 2011-2013 GoLismero Project
License = GNU Public License

Python脚本文件plugins\ui\logtime.py,内容如下:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
__license__ = """
"""
from golismero.api.audit import get_audit_count
from golismero.api.config import Config
from golismero.api.data import Data
from golismero.api.plugin import UIPlugin, get_plugin_info
from golismero.main.console import Console, colorize
from golismero.messaging.codes import MessageType, MessageCode, MessagePriority
import time
class LogTimePlugin(UIPlugin):
    """
    This demo shows how to write a UI plugin to melismero, it will show how long
    each plugin runs, more infos plz refer to the following links.
    https://www.freebuf.com
    """
    #----------------------------------------------------------------------
    def __init__(self):
        """
        we init a dictionary to record the time when plugins start and stop
        {"pluginname1":{'start':12123123,'stop':999999},
         "pluginname2":{'start':12123123,'stop':999999},}
        """
        self._logplugindic={}
    #--------------------------------------------------------------------------
    def check_params(self, options, *audits):
        """
        Usually, we just judge the audits whether 'audit' is empty. But you
        have check the input arguments if your plugin requires them.
        """
        if not audits:
            raise ValueError("No targets selected!")   
    #--------------------------------------------------------------------------   
    def recv_info(self, info):
        """
        Process the data if you wanna handle them.
        As we just wanna log the time when plugin start/stop, so we don't
        care about the detailed info about the data 'info'
        """
        pass
    #--------------------------------------------------------------------------
    def recv_msg(self, message):   
        # Process status messages
        if message.message_type == MessageType.MSG_TYPE_STATUS:
            plugin_name = message.plugin_name
            if not plugin_name:
                return
            if message.message_code == MessageCode.MSG_STATUS_PLUGIN_BEGIN:
                nowtimesec=time.time()
                self._logplugindic[plugin_name]=dict(start=nowtimesec)
            elif message.message_code == MessageCode.MSG_STATUS_PLUGIN_END:
                nowtimesec=time.time()
                try:
                    self._logplugindic[plugin_name]['stop']=nowtimesec
                    # we do something about 'self._logplugindic'
                    # ....
                    # now , i just print how long plugin runs
                    showplugname = get_plugin_info(plugin_name).display_name
                    if not showplugname:
                        showplugname = plugin_name
                    if not self._logplugindic[plugin_name] or not self._logplugindic[plugin_name]['start']:
                        text = "[#] Plugin '%s' runs for ... i don't know " % (showplugname)
                    else:
                        runtime = self._logplugindic[plugin_name]['stop']-self._logplugindic[plugin_name]['start']
                        text = "[#] Plugin '%s' runned for %d seconds" % (showplugname, runtime)
                except:
                    text = "[#] Error occurs"               
                Console.display(text)

    上面每个函数都给出了注释(因为是我这个编辑器不支持中文,所以只好用中式英文来说明了,大家将就看吧),功能很简单,就是记录在扫描过程中,统计每个插件的运行时间,并显示出来。
    执行python golismero.py –plugin-list,看看我们的插件是否被识别出来,执行结果如下:

/----------------------------------------------\
| GoLismero 2.0.0b1 - The Web Knife            |
| Contact: golismero.project<@>gmail.com       |
|                                              |
| Daniel Garcia Garcia a.k.a cr0hn (@ggdaniel) |
| Mario Vilas (@Mario_Vilas)                   |
\----------------------------------------------/
-------------
 Plugin list
-------------
-= Import plugins =-
…………………………………………………….<此处省略N多>
-= UI plugins =-
console:
    Console user interface.
disabled:
    Empty user interface.
logtime:
    Show time plugin runs in console

    可以看到我们的插件可以被正确识别,接下来执行时,将UI界面切换到我们刚写的UI界面插件上,执行
python golismero –ui-mode logtime ww.jike521.com -o result.html
其结果如下:

/----------------------------------------------\
| GoLismero 2.0.0b1 - The Web Knife            |
| Contact: golismero.project<@>gmail.com       |
|                                              |
| Daniel Garcia Garcia a.k.a cr0hn (@ggdaniel) |
| Mario Vilas (@Mario_Vilas)                   |
\----------------------------------------------/
GoLismero started at 2013-09-16 16:41:21.146000
[#] Plugin 'Suspicious URL' runned for 4 seconds
[#] Plugin 'OS fingerprinting plugin' runned for 58 seconds
[#] Plugin 'theHarvester' runned for 61 seconds
[#] Plugin 'Web Spider' runned for 65 seconds
[#] Plugin 'OS fingerprinting plugin' runned for 65 seconds
[#] Plugin 'Robots.txt Analyzer' runned for 65 seconds
[#] Plugin 'Web Server fingerprinting plugin' runned for 67 seconds
[#] Plugin 'DNS zone transfer' runned for 82 seconds
[#] Plugin 'DNS zone transfer' runned for 83 seconds
[#] Plugin 'DNS analyzer' runned for 84 seconds
[#] Plugin 'theHarvester' runned for 85 seconds
[#] Plugin 'DNS analyzer' runned for 85 seconds
[#] Plugin 'DNS subdomain bruteforcer' runned for 473 seconds
[#] Plugin 'DNS subdomain bruteforcer' runned for 503 seconds
[#] Plugin 'Default Error page finder' runned for 2 seconds
[#] Plugin 'Bruteforce permutations discovery' runned for 0 seconds
[#] Plugin 'Bruteforce file extensions discovery' runned for 0 seconds
[#] Plugin 'Bruteforce suffixes discovery' runned for 1 seconds
[#] Plugin 'Bruteforce prefixes discovery' runned for 1 seconds
[#] Plugin 'Bruteforce directories discovery' runned for 2 seconds
[#] Plugin 'Nikto' runned for 2 seconds
[#] Plugin 'OpenVAS' runned for 2 seconds
[#] Plugin 'Bruteforce predictables discovery' runned for 5 seconds

    显然,Golismero只能支持单个UI插件,无法同时支持多个UI插件,导致无法支持多路UI输出。最典型的缺陷就是如果将其改造成分布式的部署结构,我们开发一个向统计服务器推送当前状态显示的UIPlugin,又有个和用户交互的UIPlugin时,那么这两个UI Plugin是无法同时启动的

如对本文有疑问, 点击进行留言回复!!

相关文章:

  • 网络刺客2使用指南

    网络刺客2使用指南    “天行”推出网络刺客2已有一年,想当初此软件因其强大的功能被国内“黑”界推为惊世之作。我在得到它后,却有近半年时间在研究、寻找... [阅读全文]
  • 冰河”启示录

    冰河”启示录 作者: 陈经韬 前言:我经常在杂志和报刊上看到此类标题的文章,但大多是骗稿费的,没有任何技术含量.于是一气之下写了这编东西.本人声明如下:(一)... [阅读全文]
  • tfn2k使用方法和对策(3)

        tfn2k使用方法和对策(3) 作者:佳佳 本来想再分两次写完本文,后来发现佳佳要翻译的两篇文章 http://packetstorm... [阅读全文]
  • tfn2k使用方法和对策(2)

        tfn2k使用方法和对策(2) 作者:佳佳     佳佳继续上一次的文章,这一次是攻击测试。 测试环境:     共有5台机器,佳佳是... [阅读全文]
  • 火凤凰2.4使用教程

    今次给大家推荐的是阿风哥的作品:无赖小子。(way).说起来它普及的不广,但是面孔生疏的马儿更加隐蔽。不是众杀毒软件的众矢之的。好像不太容易被查杀。而且作者够仗... [阅读全文]
  • tfn2k使用方法和对策(1)

        tfn2k使用方法和对策(1) 作者:佳佳 今年年初,一些黑客使用DDoS向Yahoo,eBay等著名站点发起攻击,并且使y... [阅读全文]
  • 火凤凰2.0使用教程

    火凤凰是国产木马里最先使用反弹端口的木马,其避开防火墙的能力极其出色,DELPHI编写,功能较多但是不太好用,而且没有配置服务端的改变端口功能,相对而言比较危险... [阅读全文]
  • Nmap网络安全扫描器说明(5)

    Nmap网络安全扫描器说明(5) 作者:作者:Fyodor 译者:quack发布日期:2002-2-6上传日期:2002-2-6来源:不详扫描范例-------... [阅读全文]
  • Nmap网络安全扫描器说明(3)

    Nmap网络安全扫描器说明(3) 作者:作者:Fyodor 译者:quack发布日期:2002-2-6上传日期:2002-2-6来源:不详常规选项-------... [阅读全文]
  • 不需要任何密码就能达到进入中有冰河的机器!!!

    不需要任何密码就能达到进入中有冰河的机器!!!小飞刀 [[冰河第一站]]冰河出现到现在,使用得如此之广,影响如此之大。 却万万没有人想到冰河服务端竟然存在着如此... [阅读全文]
验证码:
移动技术网