コード例 #1
0
ファイル: prober.py プロジェクト: tomato42/tls_prober
def main():
    options = OptionParser(usage='%prog server [options]',
                           description='A tool to fingerprint SSL/TLS servers')
    options.add_option('-p',
                       '--port',
                       type='int',
                       default=443,
                       help='TCP port to test (default: 443)')
    options.add_option('-m',
                       '--matches',
                       dest='matches',
                       type='int',
                       default=0,
                       help=('Only display the first N matching scores'
                             '(default: 0 which displays them all)'))
    options.add_option('-d',
                       '--debug',
                       action='store_true',
                       dest='debug',
                       default=False,
                       help='Print debugging messages')
    options.add_option(
        '-s',
        '--starttls',
        dest='starttls',
        type='choice',
        action='store',
        default='auto',
        choices=['auto', 'smtp', 'ftp', 'pop3', 'imap', 'none'],
        help=('Enable a starttls mode. '
              'The available modes are: auto, smtp, ftp, pop3, imap, none'))
    options.add_option('-t',
                       '--probe',
                       dest='probe',
                       type='string',
                       help='Run the specified probe')
    options.add_option('-a',
                       '--add',
                       dest='add',
                       type='string',
                       help='Add the specified fingerprint to the database')
    options.add_option('-l',
                       '--list',
                       dest='list',
                       action='store_true',
                       help='List the fingerprints of the target')
    options.add_option('--list-probes',
                       dest='list_probes',
                       action='store_true',
                       help='List the available probes')
    options.add_option('-n',
                       '--thorough',
                       dest='thorough',
                       action='store_true',
                       help="Run all probes against target, don't perform a "
                       "quick scan")
    options.add_option('-v',
                       '--version',
                       dest='version',
                       action='store_true',
                       help='Display the version information')

    opts, args = options.parse_args()

    if opts.version:
        print 'TLS Prober version %s, %s <%s>' % (__version__, __author__,
                                                  __email__)
        return

    if opts.list_probes:
        list_probes()
        return

    if len(args) < 1:
        options.print_help()
        return

    if opts.debug:
        logging.basicConfig(level=logging.DEBUG)

    # Probe the server
    if opts.probe:
        results = run_one_probe(args[0], opts.port, opts.starttls, opts.probe)
    elif opts.add or opts.thorough:
        results = probe(args[0], opts.port, opts.starttls)
    else:
        print 'Running quick scan, results may be unreliable...'
        db = probe_db.read_database()
        results = quick_probe(args[0], opts.port, opts.starttls, db)

    # Add a fingerprint to the db
    if opts.add:
        filename = probe_db.add_fingerprint(opts.add, results)
        print 'Added %s to the database' % opts.add
        print 'The fingerprint is located at:', filename
        print 'Please submit your new fingerprint for inclusion in the next release!'
        return

    # Print the results of the probe
    if opts.list:
        for key, val in sorted(results.items()):
            print '%24s:\t%s' % (key, val)
        return

    # Print the matches
    matches = probe_db.find_matches(results)
    count = 0
    prev_score = None
    for server, score in matches:
        if opts.matches:
            if score != prev_score:
                prev_score = score
                count += 1
            if count > opts.matches:
                break

        print("{0:>65}: {1:6.2f}%".format(server, score * 100))
コード例 #2
0
ファイル: prober.py プロジェクト: hypn0s/tls_prober
def main():
    options = OptionParser(usage='%prog server [options]',
                           description='A tool to fingerprint SSL/TLS servers')
    options.add_option('-p', '--port',
                       type='int', default=443,
                       help='TCP port to test (default: 443)')
    options.add_option('-m', '--matches', dest='matches',
                       type='int', default=0,
                       help=('Only display the first N matching scores'
                             '(default: 0 which displays them all)') )
    options.add_option('-d', '--debug', action='store_true', dest='debug',
                       default=False,
                       help='Print debugging messages')
    options.add_option( '-s', '--starttls', dest='starttls',
                       type='choice', action='store', default='auto',
                       choices=['auto','smtp','ftp','pop3','imap','none'],
                       help=('Enable a starttls mode. '
                             'The available modes are: auto, smtp, ftp, pop3, imap, none') )
    options.add_option('-t', '--probe', dest='probe',
                       type='string',
                       help='Run the specified probe')
    options.add_option('-a', '--add', dest='add', type='string',
                       help='Add the specified fingerprint to the database')
    options.add_option('-l', '--list', dest='list', action='store_true',
                       help='List the fingerprints of the target')
    options.add_option('--list-probes', dest='list_probes', action='store_true',
                       help='List the available probes')
    options.add_option('-v', '--version', dest='version', action='store_true',
                       help='Display the version information')
    options.add_option('-o', '--output', dest='output',
                       help='Store output as XML')

    opts, args = options.parse_args()

    if opts.version:
        print 'TLS Prober version %s, %s <%s>' % (__version__, __author__, __email__)
        return

    if opts.list_probes:
        list_probes()
        return

    if len(args) < 1:
        options.print_help()
        return

    if opts.debug:
        logging.basicConfig(level=logging.DEBUG)

    # Probe the server
    results = probe(args[0], opts.port, opts.starttls, opts.probe)

    # Add a fingerprint to the db
    if opts.add:
        filename = probe_db.add_fingerprint(opts.add, results)
        print 'Added %s to the database' % opts.add
        print 'The fingerprint is located at:', filename
        print 'Please submit your new fingerprint for inclusion in the next release!'
        return
    
    if opts.list:
        for key, val in sorted(results.items()):
            print '%24s:\t%s' % (key, val)
        return
    
    # Print the matches
    matches = probe_db.find_matches(results)
    count = 0
    prev_score = None
    # Print the results of the probe
    if opts.output:
        with open(opts.output, 'w') as f:
            f.write('<?xml version="1.0"?>\n')
            f.write('<host hostname="%s" port="%d">\n' % (args[0], opts.port))
            for server, score in matches:
                if opts.matches:
                    if score != prev_score:
                        prev_score = score
                        count += 1
                    if count > opts.matches:
                        break

                f.write('<item engine="{0}">{1:.2f}%</item>\n'.format(server, score*100))
            f.write('</host>\n')

    for server, score in matches:
        if opts.matches:
            if score != prev_score:
                prev_score = score
                count += 1
            if count > opts.matches:
                break

        print("{0:>65}: {1:6.2f}%".format(server, score*100))
コード例 #3
0
ファイル: prober.py プロジェクト: PeterMosmans/tls_prober
def main():
    options = OptionParser(usage='%prog server [options]',
                           description='A tool to fingerprint SSL/TLS servers')
    options.add_option('-p', '--port',
                       type='int', default=443,
                       help='TCP port to test (default: 443)')
    options.add_option('-m', '--matches', dest='matches',
                       type='int', default=0,
                       help=('Only display the first N matching scores'
                             '(default: 0 which displays them all)') )
    options.add_option('-d', '--debug', action='store_true', dest='debug',
                       default=False,
                       help='Print debugging messages')
    options.add_option( '-s', '--starttls', dest='starttls',
                       type='choice', action='store', default='auto',
                       choices=['auto','smtp','ftp','pop3','imap','none'],
                       help=('Enable a starttls mode. '
                             'The available modes are: auto, smtp, ftp, pop3, imap, none') )
    options.add_option('-t', '--probe', dest='probe',
                       type='string',
                       help='Run the specified probe')
    options.add_option('-a', '--add', dest='add', type='string',
                       help='Add the specified fingerprint to the database')
    options.add_option('-l', '--list', dest='list', action='store_true',
                       help='List the fingerprints of the target')
    options.add_option('--list-probes', dest='list_probes', action='store_true',
                       help='List the available probes')
    options.add_option('-v', '--version', dest='version', action='store_true',
                       help='Display the version information')

    opts, args = options.parse_args()

    if opts.version:
        print 'TLS Prober version %s, %s <%s>' % (__version__, __author__, __email__)
        return

    if opts.list_probes:
        list_probes()
        return

    if len(args) < 1:
        options.print_help()
        return

    if opts.debug:
        logging.basicConfig(level=logging.DEBUG)

    # Probe the server
    results = probe(args[0], opts.port, opts.starttls, opts.probe)

    # Add a fingerprint to the db
    if opts.add:
        filename = probe_db.add_fingerprint(opts.add, results)
        print 'Added %s to the database' % opts.add
        print 'The fingerprint is located at:', filename
        print 'Please submit your new fingerprint for inclusion in the next release!'
        return
    
    # Print the results of the probe
    if opts.list:
        for key in results.keys():
            print '%20s:\t%s' % (key, results[key])
        return
    
    # Print the matches
    matches = probe_db.find_matches(results)
    count = 0
    prev_score = None
    for server, score in matches:
        if opts.matches:
            if score != prev_score:
                prev_score = score
                count += 1
            if count > opts.matches:
                break

        print '%20s\t%s' % (server, score)
コード例 #4
0
def main():
    options = OptionParser(usage='%prog server [options]',
                           description='A tool to fingerprint SSL/TLS servers')
    options.add_option('-p',
                       '--port',
                       type='int',
                       default=443,
                       help='TCP port to test (default: 443)')
    options.add_option('-d',
                       '--debug',
                       action='store_true',
                       dest='debug',
                       default=False,
                       help='Print debugging messages')
    options.add_option(
        '-s',
        '--starttls',
        dest='starttls',
        type='choice',
        action='store',
        default='auto',
        choices=['auto', 'smtp', 'ftp', 'pop3', 'imap', 'none'],
        help=('Enable a starttls mode. '
              'The available modes are: auto, smtp, ftp, pop3, imap, none'))
    options.add_option('-t',
                       '--probe',
                       dest='probe',
                       type='string',
                       help='Run the specified probe')
    options.add_option('-a',
                       '--add',
                       dest='add',
                       type='string',
                       help='Add the specified fingerprint to the database')
    options.add_option('-l',
                       '--list',
                       dest='list',
                       action='store_true',
                       help='List the fingerprints of the target')
    options.add_option('--list-probes',
                       dest='list_probes',
                       action='store_true',
                       help='List the available probes')
    options.add_option('-v',
                       '--version',
                       dest='version',
                       action='store_true',
                       help='Display the version information')

    opts, args = options.parse_args()

    if opts.version:
        print 'TLS Prober version %s, %s <%s>' % (__version__, __author__,
                                                  __email__)
        return

    if opts.list_probes:
        list_probes()
        return

    if len(args) < 1:
        options.print_help()
        return

    if opts.debug:
        logging.basicConfig(level=logging.DEBUG)

    # Probe the server
    results = probe(args[0], opts.port, opts.starttls, opts.probe)

    # Add a fingerprint to the db
    if opts.add:
        filename = probe_db.add_fingerprint(opts.add, results)
        print 'Added %s to the database' % opts.add
        print 'The fingerprint is located at:', filename
        print 'Please submit your new fingerprint for inclusion in the next release!'
        return

    # Print the results of the probe
    if opts.list:
        for key in results.keys():
            print '%20s\t%s' % (key, results[key])
        return

    # Print the matches
    matches = probe_db.find_matches(results)
    for server, score in matches:
        print '%20s\t%s' % (server, score)