Пример #1
0
def check_for_interrupted_scan(config):
    logger = logging.getLogger('changeme')
    if config.fresh:
        logger.debug("Forcing a fresh scan")
        remove_queues()
    elif config.resume:
        logger.debug("Resuming previous scan")
        return

    if os.path.isfile(PERSISTENT_QUEUE):
        scanners = FIFOSQLiteQueue(path=".",
                                   multithreading=True,
                                   name="scanners")
        fingerprints = FIFOSQLiteQueue(path=".",
                                       multithreading=True,
                                       name="fingerprints")
        logger.debug("scanners: %i, fp: %i" %
                     (scanners.qsize(), fingerprints.qsize()))
        if scanners.qsize() > 0 or fingerprints.qsize() > 0:
            if not prompt_for_resume(config):
                remove_queues()
        else:
            remove_queues()

    fp = RedisQueue('fingerprint')
    scanners = RedisQueue('scanners')
    fp_qsize = 0
    scanners_qsize = 0
    logger.debug('scanners: %s, fp: %s' % (scanners_qsize, fp_qsize))
    try:
        fp_qsize = fp.qsize()
    except redis.exceptions.ConnectionError:
        pass
    try:
        scanners_qsize = scanners.qsize()
    except redis.exceptions.ConnectionError:
        pass

    if fp_qsize > 0 or scanners_qsize > 0:
        if not prompt_for_resume(config):
            remove_queues()

    if fp_qsize == 0 and scanners_qsize == 0:
        # Clear the found queue if there's no fingerprints or scanners in the queues
        try:
            logger.debug('Clearing found_q')
            found_q = RedisQueue('found_q')
            found_q.delete()
        except Exception as e:
            logger.debug('Exception: %s: %s' %
                         (type(e).__name__, e.__str__().replace('\n', '|')))
            pass
Пример #2
0
def remove_queues():
    logger = logging.getLogger('changeme')
    try:
        os.remove(PERSISTENT_QUEUE)
        logger.debug("%s removed" % PERSISTENT_QUEUE)
    except OSError:
        logger.debug("%s didn't exist" % PERSISTENT_QUEUE)
        pass

    # Clear Redis
    queues = ['fingerprint', 'scanners', 'found_q']
    for q in queues:
        logger.debug('Removing %s RedisQueue' % q)
        r = RedisQueue(q)
        try:
            r.delete()
            logger.debug("%s Redis queue removed" % q)
        except:
            logger.debug("%s Redis queue exception" % q)
            pass
Пример #3
0
def remove_queues():
    logger = logging.getLogger('changeme')
    try:
        os.remove(PERSISTENT_QUEUE)
        logger.debug("%s removed" % PERSISTENT_QUEUE)
    except OSError:
        logger.debug("%s didn't exist" % PERSISTENT_QUEUE)
        pass

    # Clear Redis
    queues = ['fingerprint', 'scanners', 'found_q']
    for q in queues:
        logger.debug('Removing %s RedisQueue' % q)
        r = RedisQueue(q)
        try:
            r.delete()
            logger.debug("%s Redis queue removed" % q)
        except:
            logger.debug("%s Redis queue exception" % q)
            pass
Пример #4
0
def check_for_interrupted_scan(config):
    logger = logging.getLogger('changeme')
    if config.fresh:
        logger.debug("Forcing a fresh scan")
        remove_queues()
    elif config.resume:
        logger.debug("Resuming previous scan")
        return

    fp = RedisQueue('fingerprint')
    scanners = RedisQueue('scanners')
    fp_qsize = 0
    scanners_qsize = 0
    logger.debug('scanners: %s, fp: %s' % (scanners_qsize, fp_qsize))
    try:
        fp_qsize = fp.qsize()
    except redis.exceptions.ConnectionError:
        pass
    try:
        scanners_qsize = scanners.qsize()
    except redis.exceptions.ConnectionError:
        pass

    if fp_qsize > 0 or scanners_qsize > 0:
        if not prompt_for_resume(config):
            remove_queues()

    if fp_qsize == 0 and scanners_qsize == 0:
        # Clear the found queue if there's no fingerprints or scanners in the queues
        try:
            logger.debug('Clearing found_q')
            found_q = RedisQueue('found_q')
            found_q.delete()
        except Exception as e:
            logger.debug('Exception: %s: %s' %
                         (type(e).__name__, e.__str__().replace('\n', '|')))
            pass
Пример #5
0
def check_for_interrupted_scan(config):
    logger = logging.getLogger('changeme')
    if config.fresh:
        logger.debug("Forcing a fresh scan")
        remove_queues()
    elif config.resume:
        logger.debug("Resuming previous scan")
        return

    fp = RedisQueue('fingerprint')
    scanners = RedisQueue('scanners')
    fp_qsize = 0
    scanners_qsize = 0
    logger.debug('scanners: %s, fp: %s' % (scanners_qsize, fp_qsize))
    try:
        fp_qsize = fp.qsize()
    except redis.exceptions.ConnectionError:
        pass
    try:
        scanners_qsize = scanners.qsize()
    except redis.exceptions.ConnectionError:
        pass

    if fp_qsize > 0 or scanners_qsize > 0:
        if not prompt_for_resume(config):
            remove_queues()

    if fp_qsize == 0 and scanners_qsize == 0:
        # Clear the found queue if there's no fingerprints or scanners in the queues
        try:
            logger.debug('Clearing found_q')
            found_q = RedisQueue('found_q')
            found_q.delete()
        except Exception as e:
            logger.debug('Exception: %s: %s' % (type(e).__name__, e.__str__().replace('\n', '|')))
            pass