我试图在python中创建子域的暴力破解工具,但是我的代码无法正常工作,可能有更好的方法,我只需要在正确的方向上进行指导即可。
import sys
import socket
import requests
host = "paypal.com"
sublist = ["cpanel.", "admin.", "manager.", "secure."]
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
status = s.connect_ex((host, 80))
if status == 0:
print (host + " is up!")
else:
print (host + " is down!")
s.close()
except socket.error:
print (host + " is not reachable")
def checklist():
try:
for lines in sublist:
check = requests.get("http://" + lines + host).status_code
if check == 200:
print "Found: " + lines + host
except Exception:
print "Error"
checklist()
它只是在终端中打印出“错误”,我不知道它是否与主机一起检查子域。
如何浏览列表并检查网站的每个子域是否可用,然后将其显示在终端上?
没有其他代码的错误:
引发ConnectionError(例如,request = request) requests.exceptions.ConnectionError:HTTPSConnectionPool(host ='cpanel.paypal.com',端口= 443):URL超过了最大重试次数:/(由NewConnectionError(':导致:无法建立新连接:[Errno -2]名称或服务未知”,))
答案 0 :(得分:0)
问题是您的发送请求太快,您也可以尝试使用标头来覆盖python请求
import time
try:
time.sleep(1.5)
check = requests.get("http://" + lines + host).status_code
except requests.exceptions.ConnectionError:
r.status_code = "Connection Refused by Host"