Beispiel #1
0
def show_task(args):

    if args.task_show:

        if os.path.isfile(paths.DATABASE_PATH):
            datadase = TaskDB(paths.DATABASE_PATH)
            datadase.connect()
            rows = datadase.select_taskid(args.task_show)

            for row in rows:
                msg = "Taskid: %s, Status: %s, Value: %s" % (
                    row[1], row[2], unserialize_object(row[3]))
                logger.sysinfo(msg)

            if len(rows) == 0:
                logger.error(
                    "The %s session is not exist! So we show all sessions as follow:  "
                    % (args.task_show))
                rows = datadase.select_all()
                for row in rows:
                    msg = "Taskid: %s, Status: %s, Value: %s" % (
                        row[1], row[2], unserialize_object(row[3]))
                    logger.sysinfo(msg)
            else:
                datas = []
                file = os.path.join(paths.DATA_PATH, args.task_show)

                if os.path.isfile(file):
                    hashdb = TaskDataDB(file)
                    hashdb.connect()
                    for _row in hashdb.select_all():
                        data = {
                            "id": _row[0],
                            "tid": _row[1],
                            "flag": _row[2],
                            'target_host': _row[3],
                            'target_port': _row[4],
                            'url': _row[5],
                            'module_name': _row[6],
                            "req": unserialize_object(_row[7]),
                            "res": unserialize_object(_row[8]),
                            "other": unserialize_object(_row[9])
                        }

                        if conf.OUT != None:
                            datas.append(data)
                        else:
                            print_dic(data)

                    if conf.OUT != None:
                        output_excal(datas, conf.OUT.task_show)
                else:
                    logger.error("The %s session_file is not exist. " %
                                 (args.task_show))
        else:
            logger.error("The storage_file is not exist. ")

        sys.exit()
Beispiel #2
0
async def scan(name, tm, pm):
    pm.load()
    targets = tm.load()
    engine = VulScanEngine(name, targets, pm)
    results = []
    async for result in engine.enum():
        results.append(result)

    if conf.OUT:
        output_excal(results, conf.OUT, name)
Beispiel #3
0
 def _get_data(self):
     if conf.OUT != None:
         logger.info('(%s) Task sort out the data. ' % self.name)
         datas = []
         for _row in self.hashdb.select_all():
             data = {
                 "id": _row[0],
                 "flag": _row[1],
                 'target_host': _row[2],
                 'target_port': _row[3],
                 'url': _row[4],
                 "data": unserialize_object(_row[5]),
                 "res": unserialize_object(_row[6]),
                 "other": unserialize_object(_row[7])
             }
             datas.append(data)
         output_excal(datas, conf.OUT, self.name)