问题描述
我有一个python脚本,它使用Telnet扫描IP地址并向每个地址发送命令,但是它不起作用,我不知道为什么,我只是得到Error occurred
# !/usr/bin/env python
import getpass
import sys
import telnetlib
def h4ck_th3_w0rld(HOST):
user = 'admin'
password = 'admin'
tn = None
try:
tn = telnetlib.Telnet(HOST,23,5)
tn.read_until("Username: ",5)
tn.write(user + "\n")
if password:
tn.read_until("Password: ",5)
tn.write(password + "\n")
tn.write("ls\n")
tn.write("sendcmd\n")
tn.write("exit\n")
print(tn.read_all())
except Exception as e:
print 'Error occurred'
finally:
if tn:
tn.close()
for i in range(1,256):
for j in range(0,21):
ip_address = '192.168.%d.%d' % (j,i)
h4ck_th3_w0rld(ip_address)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)