def test_server_type(ssl_sock, ip): request_data = "HEAD / HTTP/1.1\r\nAccept: */*\r\nHost: %s\r\n\r\n" % ip time_start = time.time() ssl_sock.send(request_data.encode()) response = httplib.HTTPResponse(ssl_sock, buffering=True) try: response.begin() server_type = response.msg.dict["server"] time_stop = time.time() time_cost = (time_stop - time_start)*1000 server_type = server_type.replace(" ", "_") # gvs 1.0 if server_type == 'HTTP_server_(unknown)': res_url = response.msg.dict["location"] if "google.com/sorry/IndexRedirect?" in res_url: scan_sleep() if server_type == '': # for avoid csv split server_type = '_' xlog.info("server_type:%s time:%d", server_type, time_cost) return server_type finally: response.close()
def test_server_type(ssl_sock, ip): request_data = "HEAD / HTTP/1.1\r\nAccept: */*\r\nHost: %s\r\n\r\n" % ip time_start = time.time() ssl_sock.send(request_data.encode()) response = httplib.HTTPResponse(ssl_sock, buffering=True) try: response.begin() server_type = response.msg.dict["server"] time_stop = time.time() time_cost = (time_stop - time_start) * 1000 server_type = server_type.replace(" ", "_") # gvs 1.0 if server_type == 'HTTP_server_(unknown)': res_url = response.msg.dict["location"] if "google.com/sorry/IndexRedirect?" in res_url: scan_sleep() if server_type == '': # for avoid csv split server_type = '_' xlog.info("server_type:%s time:%d", server_type, time_cost) return server_type finally: response.close()