def doCrack(address, username, password): host = h.getPath(address) port = h.getPort(address) if h.getPort(address) != None else 23 try: tn = telnetlib.Telnet(host, port, timeout=10) tn.set_debuglevel(0) #2是为了看更多东西 # tn.read_until("login: "******"\r\n".encode('ascii')) # tn.read_until("password: "******"\r\n".encode('ascii')) tn.read_until("login:"******"\r\n") tn.read_until("assword:") tn.write(password + "\r\n") res = tn.read_some() res = tn.read_some() res = tn.read_some() tn.write("exit\r\n") tn.close() # Windows下登录失败关键字为Login Failed,Linux下登录失败关键字为Login incorrect。 rex = r'Login\s+(Failed|incorrect)' tmp = re.search(rex, res) if tmp == None: return True, u'Crack success!' else: return False, u'Crack fail!' except Exception as e: return False, str(e)
def crack_in_linux(address, username, password): ''' 中文提示:用户 'sa' 登录失败。 英文提示:Login failed for user 经过测试在linux下成功 window7下报错:struct.error: ('unpack requires a string argument of length 1', "When unpacking field 'Type | <B | ''[:1]'") ''' host = h.getPath(address) port = h.getPort(address) if h.getPort(address) != None else 1433 fp = tds.MSSQL(host, int(port)) fp.connect() r = fp.login(None, username, password, None, None, False) # 第二种登录方式:r = fp.login(None, username, password, domain, password_hash, True) if not r: key = fp.replies[TDS_ERROR_TOKEN][0] code = key['Number'] mesg = key['MsgText'].decode('utf-16le') else: key = fp.replies[TDS_LOGINACK_TOKEN][0] code = '0' mesg = '%s (%d%d %d%d)' % (key['ProgName'].decode('utf-16le'), key['MajorVer'], key['MinorVer'], key['BuildNumHi'], key['BuildNumLow']) fp.disconnect() code = int(code) if code == 0: return True, mesg elif code == 18456: return False, mesg else: return False, mesg
def doCrack(address, username, password): ''' # ORA-28000 代表账号被锁 # ORA-01017 代表账号或密码不正确 # ORA-12505 代表sid不正确 ''' host = h.getPath(address) port = h.getPort(address) if h.getPort(address) != None else 1521 ## 该处存在问题,如果没有传入参数,也没有报错。 sid = h.getParameters(address).get('sid') service_name = h.getParameters(address).get('service_name') if sid and sid != None: dsn = cx_Oracle.makedsn(host=host, port=port, sid=sid) elif service_name and service_name != None: dsn = cx_Oracle.makedsn(host=host, port=port, service_name=service_name) else: mesg = 'Options sid and service_name cannot be both empty' return False, mesg try: fp = cx_Oracle.connect(username, password, dsn, threaded=True) code, mesg = '0', fp.version return True, mesg except cx_Oracle.DatabaseError as e: code, mesg = e.args[0].message[:-1].split(': ', 1) return False, mesg
def crack_in_windows(address, username, password): host = h.getPath(address) port = h.getPort(address) if h.getPort(address) != None else 1433 try: db = pymssql.connect(server=host, port=port, user=username, password=password) return True, None except Exception, e: return False, str(e)
def doCrack(address,username,password): host = getPath(address) port = getPort(address) try: ftp = ftplib.FTP(host) ftp.connect(host, port, timeout = 10) ftp.login(username, password) ftp.quit() return True,u'Crack success!' except ftplib.all_errors: return False,u'Crack fail!'
def doCrack(address,username,password): ''' # ORA-28000 代表账号被锁 # ORA-01017 代表账号或密码不正确 # ORA-12505 代表sid不正确 ''' host = h.getPath(address) port = h.getPort(address) if h.getPort(address) !=None else 1521 dsn = cx_Oracle.makedsn(host=host, port=port, sid=password) try: fp = cx_Oracle.connect('SYS', '', dsn, threaded=True) code, mesg = '0',fp.version return True,mesg except cx_Oracle.DatabaseError as e: code,mesg = e.args[0].message[:-1].split(': ', 1) #print code,mesg if code == 'ORA-12505': return False,u'Crack fail!' else: return True,u'Crack success!'
def doCrack(address, username, password): host = getPath(address) port = getPort(address) db = None try: db = MySQLdb.connect(host=host, user=username, passwd=password, db='mysql', port=int(port)) return True, u'Crack success!' except: return False, u'Crack fail!' finally: if db: db.close()
def doCrack(address,username,password=None): v = VNC() host = h.getPath(address) port = h.getPort(address) timeout='10' try: with Timing() as timing: code, mesg = 0, v.connect(host, int(port or 5900), int(timeout)) with Timing() as timing: code, mesg = v.login(password) except VNC_Error as e: #print 'VNC_Error: %s' % e code, mesg = 2, str(e) print code,mesg if code == 0: return True,u'Crack success!' elif code == 1: return False,u'Crack fail!' else: return False,u'Crack fail!'