Example #1
0
def main():
    from server.queue_manager import QueueClient

    c = QueueClient()
    qm = c.queue_manager()

    while True:
        status = qm.status()

        print('#'*15 + ' Scan Status ' + '#'*15)

        print('{0:<32}{1:.2f} m'.format('scan time:', status.get('scantime')/60))
        print('{0:<32}{1:.2f} s'.format('average scan time:', status.get('avgtime')))

        print('{0:<32}{1}'.format('scans completed:', status.get('completed')))
        print('{0:<32}{1}'.format('fully scanned:', status.get('fully_scanned')))

        print('{0:<32}{1}'.format('host queue position:', status.get('counter')))
        print('{0:<32}{1}'.format('host queue is filling:', status.get('is_filling')))

        print('{0:<32}{1}'.format('host queue size:', status.get('host_queue_size')))
        print('{0:<32}{1}'.format('user queue size:', status.get('user_queue_size')))
        print('{0:<32}{1}'.format('result queue size:', status.get('result_queue_size')))

        # print('{0:<32}{1}'.format('dump threshold:', status.get('dump_limit')))
        # print('{0:<32}{1}'.format('result queue threshold:', status.get('result_queue_limit')))

        print('#'*43)

        time.sleep(10)
Example #2
0
def main():
    """
    Starts as many sslyze worker processes as specified in :mod:`settings`.
    """

    signal.signal(signal.SIGINT, _sigint_handler)

    # PLUGINS INITIALIZATION
    sslyze_plugins = PluginsFinder()
    available_commands = sslyze_plugins.get_commands()

    # QUEUE INITIALIZATION
    c = QueueClient()
    qm = c.queue_manager()

    # PROCESS INITIALIZATION
    while True:

        p = WorkerProcess(qm, available_commands)
        p.start()
        process_list.append(p)

        # Wait for processes to terminate
        p.join()
Example #3
0
def main():
    # get instance of QueueClient
    c = QueueClient()
    # get appropriate queue from QueueClient
    qm = c.queue_manager()
    # get instance of Database
    mdb = Database()

    tls_ver = ['tlsv1_2', 'tlsv1_1', 'sslv3', 'sslv2', 'tlsv1']

    while True:
        try:
            result = qm.next_result()

            scan_error = False
            scan_date = datetime.datetime.now()
            domain = result.get("target")[0]
            ip = result.get("target")[1]
            if ip == domain:
                tld = None
            else:
                tld = get_tld('https://' + domain, as_object=True, fail_silently=True).suffix
            sources = result.get("source")
            ciphers = []
            certificate = {}

            if result.get("error"):
                # print(result.get("err_msg"))
                scan_error = True

            else:
                result_list = result.get('result')

                public_key_size = None

                #  move the result of certinfo to the front of the result_list
                for i, result in enumerate(result_list):
                    if result.get('command') == 'certinfo':
                        result_list.insert(0, result_list.pop(i))
                        break

                for command_result in result_list:
                    if command_result.get("error"):
                        # TODO handle error
                        continue

                    if command_result.get("command") in tls_ver:
                        ciphers.extend(_parse_ciphers(command_result, command_result.get("command"), public_key_size))
                    elif command_result["command"] == "certinfo":
                        public_key_size = command_result.get('subjectPublicKeyInfo').get('publicKeySize')
                        certificate = _parse_cert(command_result)

            db_item = dict(
                    scanError=scan_error,
                    scanDate=scan_date,
                    domain=domain,
                    tld=tld,
                    sources=sources,
                    ciphers=ciphers,
                    certificate=certificate,
            )

            mdb.insert_result(db_item)

        except Exception as e:
            print(e)
Example #4
0
def fetchInput(queue_manager):
    """
    Downloads top-1m.csv, parses top500 country lists, merges them and sends them to queue_manager.
    """
    top500ListOfLists = startTop500Parsing()
    print("joining top 500 lists")
    top500List = joinListOfLists(top500ListOfLists)
    top1MioList = datedAlexaCSV(alexa_splits)
    print("joining 'joined' top 500 list with alexa top1mio")
    queue_manager.put_new_list(joinLists(top1MioList,top500List))
    print("Finished building and sending list.")


if __name__ == "__main__":
    # get instance of QueueClient
    c = QueueClient()
    # get appropriate queue from QueueClient
    queue_manager = c.queue_manager()
    fetchInput(queue_manager)
    while(True):
        t = datetime.datetime.today()#converting datetime.datetime.today object into datetime.date object
        today = datetime.date(t.year,t.month,t.day)
        if today > nextDownloadDate:
            fetchInput(queue_manager)
        os.remove(csvPath)
        print("sleeping now")
        time.sleep(86400)#sleeps for 86400 seconds, ~1 day