示例#1
0
def main():
    parser = optparse.OptionParser()
    parser.set_usage('%prog <report_type> [options]')
    parser.add_option('-o',
                      '--output-file',
                      dest='output_file',
                      help='set a specific output file for the report')
    parser.add_option(
        '-s',
        '--session',
        dest='session',
        help=
        'set the session name to pull the default report data for that session'
    )
    parser.add_option('-t',
                      '--template-file',
                      dest='template_file',
                      help='use a custom template file to create the report')
    parser.add_option('-d',
                      '--data-file',
                      dest='data_file',
                      help='input file for data collection (default: %s)' %
                      DEFAULT_DATA_PATH)

    opts, args = parser.parse_args()

    if len(args) != 1:
        parser.print_usage()
        sys.exit(1)

    report_type = args[0]
    try:
        mod = utils.find_exploit_report(report_type)
    except utils.LoadError as e:
        sys.exit('Could not load exploit: %s\n'
                 'Make sure the name is correct and you are running from the '
                 'CANVAS root.' % e)

    if opts.data_file:
        data_file = opts.data_file
    elif opts.session:
        data_file = utils.get_reports_path(opts.session, DEFAULT_DATA_FILE)
    else:
        data_file = DEFAULT_DATA_PATH

    if opts.output_file:
        output_file = opts.output_file
    elif opts.session:
        fname = utils.generate_output_filename(module_name)
        output_file = utils.get_reports_path(opts.session, fname)
    else:
        fname = utils.generate_output_filename(module_name)
        output_file = utils.get_reports_path(filename=fname)

    print 'generating report ...'
    mod.generate(data_file=data_file,
                 template_file=opts.template_file,
                 output_file=output_file)

    print 'done. report resides at: %s' % output_file
示例#2
0
 def __init__(self, session_name=None, data_path=None, _backup_overwrite=False):
     self._lock = threading.Lock()
     
     fname = data_path or utils.get_reports_path(session_name, DEFAULT_DATA_FILE)
     file, version = self._open(fname)
     if not version:
         print '\n<%s>' % ('-' * 70)
         print '    An unsupported or old event file was found at:\n      %s' % fname
         
         # _backup_overwrite is an internal argument
         # it should only be used by canvasengine on startup
         if _backup_overwrite:
             # back up
             bak_fname = fname + '.bak'
             os.rename(fname, bak_fname)
             print '    The file was backed up to:\n      %s' % bak_fname
             print '    The original file will be overwritten with new events.'
             
             # overwrite
             file, version = self._open(fname, 'w+b')
         else:
             # unsupported or non-existant version number
             raise VersionError('unsupported event file: %s\n'
                 'You may need to upgrade your version of CANVAS.' % fname)
         
         print '<%s>\n' % ('-' * 70)
     
     self._version = version
     devlog('reports', 'opened event file: %s (version: %s)' % (fname, version))
     
     self._file = file
     self._filename = fname
     self._session_id = uuid.uuid1().hex
示例#3
0
    def getargs(self):
        self.getarg('report_type')
        self.getarg('data_file')
        self.getarg('output_dir')
        self.output_dir = self.output_dir or utils.get_reports_path()
        self.getarg('output_file')
        self.getarg('output_generate')

        if self.output_generate:
            output_file = utils.generate_output_filename('canvas')
        else:
            output_file = self.output_file

        self.output_file = os.path.join(self.output_dir, output_file)
示例#4
0
def dialog_update(gtk, wtree):
    dialog = wtree.get_widget('exploit_dialog')
    signal_ids = []

    widget = wtree.get_widget('report_type')
    widget.set_active(0)

    widget = wtree.get_widget('data_file')
    widget.set_text(DEFAULT_DATA_PATH)
    button = wtree.get_widget('data_file_button')
    sig = button.connect('clicked', select_path, gtk, dialog,
                         gtk.FILE_CHOOSER_ACTION_OPEN, widget)
    signal_ids.append((button, sig))

    widget = wtree.get_widget('output_file')
    fname = utils.generate_output_filename('canvas')
    outpath = utils.get_reports_path(filename=fname)
    widget.set_text(outpath)
    button = wtree.get_widget('output_file_button')
    sig = button.connect('clicked', select_path, gtk, dialog,
                         gtk.FILE_CHOOSER_ACTION_SAVE, widget)
    signal_ids.append((button, sig))

    widget = wtree.get_widget('output_generate')

    def on_toggled(w):
        active = w.get_active()
        for name in ['_label', '', '_button']:
            wtree.get_widget('output_file' + name).set_sensitive(not active)

    widget.connect('toggled', on_toggled)

    def disconnect(w):
        for w, sig in signal_ids:
            w.disconnect(sig)

    sig = dialog.connect('hide', disconnect)
    signal_ids.append((dialog, sig))
示例#5
0
the path to a data pickle, in addition to the URL faraday RPC"""

DOCUMENTATION['Notes']         = NOTES = """This module is not backwards compatible
with reporting pickles created by previous versions of CANVAS.

It should also be noted that the new reporting pickle is not compatible with
with any of the previous CANVAS reporting modules, such as "report_timeline".
"""

PROPERTY                       = {}
PROPERTY['TYPE']               = 'Reporting'
PROPERTY['SITE']               = 'Local'

DEFAULT_DATA_FILE              = 'report.pkl'
DEFAULT_FARADAY_RPC            = 'http://127.0.0.1:9876/'
DEFAULT_DATA_PATH              = utils.get_reports_path(filename=DEFAULT_DATA_FILE)



class Host():
    def __init__(self, ip, host_id):

        self.ip = ip
        self.host_id = host_id
        #{IP:INTERFACE_ID}
        self.dict_interfaces = {}
        #{IP:{PORT:SERVICE_ID}}
        self.dict_services = {}

    def addInterface(self, ip_interface, interface_id):
示例#6
0
the path to a data pickle, in addition to the URL faraday RPC"""

DOCUMENTATION['Notes']         = NOTES = """This module is not backwards compatible
with reporting pickles created by previous versions of CANVAS.

It should also be noted that the new reporting pickle is not compatible with
with any of the previous CANVAS reporting modules, such as "report_timeline".
"""

PROPERTY                       = {}
PROPERTY['TYPE']               = 'Reporting'
PROPERTY['SITE']               = 'Local'

DEFAULT_DATA_FILE              = 'report.pkl'
DEFAULT_FARADAY_RPC            = 'http://127.0.0.1:9876/'
DEFAULT_DATA_PATH              = utils.get_reports_path(filename=DEFAULT_DATA_FILE)



class Host():
    def __init__(self, ip, host_id):

        self.ip = ip
        self.host_id = host_id
        #{IP:INTERFACE_ID}
        self.dict_interfaces = {}
        #{IP:{PORT:SERVICE_ID}}
        self.dict_services = {}

    def addInterface(self, ip_interface, interface_id):