免责声明:本文仅做技术交流与学习...
目录
IP端口爆破
域名解析爆破
IP端口爆破
#端口扫描:
#获取扫描的 IP和端口
#连接 IP和端口(socket)
#判断连接状态-开放和关闭# import socket
# # 加入参数模式
# import os
# s=socket.socket()
# s.connect(('127.0.0.1',1))
#通过报错判断端口是否占用import socket,sys,threading,queue# 多线程?def port_scan(ip):while not q.empty():port=q.get()s=socket.socket()try:s.connect((ip,port))print(ip+":"+str(port)+':open')except Exception as e:pass#print(str(port)+':close')finally:s.close()if __name__ == '__main__':#自定义端口扫描#ports=input('please input scan ports(eg:135,80,445):')#ip=input('please input scan ip:')# 程序是第0个参数,ip=sys.argv[1]th_nums = sys.argv[2]print(th_nums)#ports = sys.argv[2]# for port in ports.split(','):# port_scan(ip,int(port))#全端口扫描q=queue.Queue()for port in range(1,65536):q.put(port)for th_num in range(int(th_nums)):t = threading.Thread(target=port_scan,args=(ip,)) # 传参t.start()
域名解析爆破
先准备一个域名前缀的文件.(dic.txt)
import socket
# 输入域名---进行子域名搜索and ip解析
# 未做多线程# import socket
# ip=socket.gethostbyname('www.baidu.com')
# print(ip)
# 通过域名解析IP
# 域名存在 IP就有 不存在就没有 报错def zym_baopo(url):for u in open('dic.txt'):urls = (u + '.' + url).replace('\n', '')# print(urls)try:ip = socket.gethostbyname(urls)print(urls + "|" + ip)except Exception as e:passif __name__ == '__main__':url = input('please input scan url:')zym_baopo(url)