写一个简单的密码测试工具,一个 user 文件,一个 pwd 文件,然后迭代 user 里面嵌套迭代 pwd ,结果 user 只迭代了一行, pwd 迭代正常,这是为啥? 就是 user 那个只迭代了一次就完事了,字典文件都是多行的。 求指点一下 是不是指针问题??
![]() | 1 mhycy 2017-04-19 09:46:10 +08:00 你的代码呢? |
![]() | 2 raptium 2017-04-19 09:49:18 +08:00 因为执行完一次以后,里层的迭代器已经读完了 |
![]() | 6 UnixCRoot OP ```python def DictAttck(Host,UsernameFile,PasswordFile): UserHandle = open(UsernameFile) PwdHandle = open(PasswordFile) for user in UserHandle: for pwd in PwdHandle: print Fore.RED + "[***] " + Style.RESET_ALL + "Try to UserName:%s Password:%s"%(user,pwd) if chekpassword(Host,user,pwd) == 1: print Fore.GREEN + "[OK] " + Style.RESET_ALL + "Got password. Username:%s Password:%s" %(user,pwd) break ``` |
7 gdsing 2017-04-19 09:52:29 +08:00 break |
12 fds 2017-04-19 15:49:54 +08:00 PwdHandle.seek(0) |