def getSocksVersion(proxy, port, uniquehash): newprox = str(proxy) + ":" + str(port) host = proxy sch = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sch.settimeout(2) try: sch.connect((host, port)) if(isSocks4(host, port, sch)): sch.close() update_ban("socks", port, "4", None, None, uniquehash) config.confproto.gline_socks(ip, int(time.time()), int(time.time()) + config.DURATION, port, "4") return elif(isSocks5(host, port, sch)): sch.close() update_ban("socks", port, "5", None, None, uniquehash) config.confproto.gline_socks(ip, int(time.time()), int(time.time()) + config.DURATION, port, "5") return else: sch.close() return 0 except socket.timeout: sch.close() return 0 except socket.error: sch.close() return 0
def DNSBL(ip, nick, DNSTRUE, HTTPTRUE, SOCKSTRUE, uniquehash): bll = ["tor.dan.me.uk", "rbl.efnetrbl.org", "dnsbl.proxybl.org", "dnsbl.dronebl.org", "tor.efnet.org"] if DNSTRUE == 0 or isIPv6(ip): http_connect(ip, HTTPTRUE, SOCKSTRUE, uniquehash) else: config.main.logger(2, "[SCANNING]: DNSBL scan on " + str(ip)) newip = ip.split(".") newip = newip[::-1] newip = '.'.join(newip) contrue = 0 for blacklist in bll: newstring = newip + "." + blacklist try: answers = dns.resolver.query(newstring,'A') if answers: update_ban("dnsbl", None, None, None, blacklist, uniquehash) config.confproto.gline_dnsbl(ip, int(time.time()), int(time.time()) + config.DURATION, blacklist) contrue = 0 break except dns.resolver.NXDOMAIN: contrue += 1 continue except dns.resolver.NoNameservers: contrue += 1 continue if contrue == 5: http_connect(ip, HTTPTRUE, SOCKSTRUE, uniquehash)
def http_connect_threads(ip, port, uniquehash): tcp=socket.socket() tcp.settimeout(2) portbuf = "" try: tcp.connect((ip, port)) tcp.send("CONNECT %s HTTP/1.0\r\n\r\n" % (ip)) inttime1 = int(time.time()) inttime2 = int(time.time()) while inttime2 - inttime1 < 2: inttime2 = int(time.time()) data = tcp.recv(1024) if data is not False and "HTTP/1.0 200 OK" in data: update_ban("http", port, None, "Non-SSL", None, uniquehash) config.confproto.gline_http(ip, int(time.time()), int(time.time()) + config.DURATION, port) tcp.close() break except socket.error, v: pass
def https_connect_threads(ip, port, uniquehash): tcps=socket.socket(socket.AF_INET, socket.SOCK_STREAM) ssl_sock = ssl.wrap_socket(tcps) ssl_sock.settimeout(2) portbuf = "" try: ssl_sock.connect((ip, port)) ssl_sock.send("CONNECT %s HTTP/1.0\r\n\r\n" % (ip)) inttime1 = int(time.time()) inttime2 = int(time.time()) while inttime2 - inttime1 < 2: inttime2 = int(time.time()) data = ssl_sock.recv(1024) if data is not False and "HTTP/1.0 200 OK" in data: update_ban("http", port, None, "SSL", None, uniquehash) config.confproto.gline_http(ip, int(time.time()), int(time.time()) + config.DURATION, port) ssl_sock.close() break except socket.error, v: pass