Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import time
- import logging
- import threading
- logging.basicConfig(filename='data.log', level=logging.DEBUG)
- def is_open_port(ip, port):
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.settimeout(4)
- try:
- result = sock.connect_ex((ip, port))
- sock.close()
- return not result
- except Exception, b:
- logging.debug(str(b) + ip)
- return False
- def check(domain, c, ip):
- logging.info(domain + "," + c + "," + ip + "," + " 80: " + str(is_open_port(domain, 80)) + "," + " 443: " + str(is_open_port(domain, 443)) )
- threads = []
- with open('vng-records.txt') as f:
- lines = f.readlines()
- for line in lines:
- while threading.activeCount() > 500:
- time.sleep(1)
- domain = line.split(",")[0].replace("\"", "")
- c = line.split(",")[1].replace("\"", "")
- ip = line.split(",")[2].replace("\"", "").strip()
- p = threading.Thread(target=check, args=[domain, c, ip])
- p.daemon = True
- threads.append(p)
- p.start()
- for _ in threads:
- _.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement