Python socket.setdefaulttimeout() Examples

The following are 30 code examples for showing how to use socket.setdefaulttimeout(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may want to check out the right sidebar which shows the related API usage.

You may also want to check out all available functions/classes of the module socket , or try the search function .

Example 1
Project: dynamic-training-with-apache-mxnet-on-aws   Author: awslabs   File: diagnose.py    License: Apache License 2.0 6 votes vote down vote up
def check_network(args):
    print('----------Network Test----------')
    if args.timeout > 0:
        print('Setting timeout: {}'.format(args.timeout))
        socket.setdefaulttimeout(10)
    for region in args.region.strip().split(','):
        r = region.strip().lower()
        if not r:
            continue
        if r in REGIONAL_URLS:
            URLS.update(REGIONAL_URLS[r])
        else:
            import warnings
            warnings.warn('Region {} do not need specific test, please refer to global sites.'.format(r))
    for name, url in URLS.items():
        test_connection(name, url, args.timeout) 
Example 2
Project: Vxscan   Author: al0ne   File: memcached_unauthorized_access.py    License: Apache License 2.0 6 votes vote down vote up
def check(url, ip, ports, apps):
    if verify(vuln, ports, apps):
        socket.setdefaulttimeout(2)
        port = 11211
        payload = b'\x73\x74\x61\x74\x73\x0a'  # command:stats
        s = socket.socket()
        socket.setdefaulttimeout(5)
        try:
            s.connect((ip, port))
            s.send(payload)
            recvdata = s.recv(2048)  # response larger than 1024
            s.close()
            if recvdata and (b'STAT version' in recvdata):
                return '11211 Memcache Unauthorized Access'
        except Exception as e:
            print(e) 
Example 3
Project: Vxscan   Author: al0ne   File: rsync_unauthorized_access.py    License: Apache License 2.0 6 votes vote down vote up
def check(url, ip, ports, apps):
    if verify(vuln, ports, apps):
        try:
            socket.setdefaulttimeout(1.5)
            payload = b"\x40\x52\x53\x59\x4e\x43\x44\x3a\x20\x33\x31\x2e\x30\x0a"
            socket.setdefaulttimeout(timeout)
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            server_address = (ip, 873)
            sock.connect(server_address)
            sock.sendall(payload)
            initinfo = sock.recv(400)
            if b"RSYNCD" in initinfo:
                sock.sendall(b"\x0a")
            modulelist = sock.recv(200)
            sock.close()
            if len(modulelist) > 0:
                return '873 Rsync Unauthorized Access'
        except Exception as e:
            pass 
Example 4
def check(ip, port, timeout):
    try:
        socket.setdefaulttimeout(timeout)
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect((ip, port))
        flag = "GET /?order[updatexml(1,concat(0x3a,user()),1)]=1 HTTP/1.1"
        s.send(flag)
        time.sleep(1)
        data = s.recv(1024)
        s.close()
        if 'GET' in data:
            url = 'http://' + ip + ":" + str(port) + '/?order[updatexml(1,concat(0x3a,user()),1)]=1'
            request = urllib2.Request(url)
            res_html = urllib2.urlopen(request, timeout=timeout).read(204800)
            if 'root' in res_html:
                return u"ThinkPHP 3.X order by注入漏洞"


    except Exception, e:
        pass 
Example 5
Project: vulscan   Author: vulscanteam   File: 30-rsync-unauthorized.py    License: MIT License 6 votes vote down vote up
def _verify(self):
        import socket

        #调用指纹方法
        result={}
        output = Output(self)
        message = ''

        try:
            s = socket.socket()
            socket.setdefaulttimeout(1)#两秒超时
            port = 873
            ip = self.url.split(':')[1].replace('/','')
            s.connect((ip, port))
            print('Rsync未授权访问')
            message = 'Rsync 873端口 未授权访问'
            result['VerifyInfo'] = {}
            result['VerifyInfo']['url'] = ip
            result['VerifyInfo']['Payload'] = message
        except Exception as e:
            print(e)
        s.close()
        print '[+]30 poc done'
        return self.save_output(result) 
Example 6
Project: vulscan   Author: vulscanteam   File: option.py    License: MIT License 6 votes vote down vote up
def _setHTTPTimeout():
    """
    Set the HTTP timeout
    """

    if conf.timeout:
        infoMsg = "setting the HTTP timeout"
        logger.log(CUSTOM_LOGGING.SYSINFO, infoMsg)

        conf.timeout = float(conf.timeout)

        if conf.timeout < 3.0:
            warnMsg = "the minimum HTTP timeout is 3 seconds, pocsuite will going to reset it"
            logger.log(CUSTOM_LOGGING.WARNING, warnMsg)

            conf.timeout = 3.0
    else:
        conf.timeout = 30.0

    socket.setdefaulttimeout(conf.timeout) 
Example 7
Project: codimension   Author: SergeySatskiy   File: qpartwrap.py    License: GNU General Public License v3.0 6 votes vote down vote up
def downloadAndShow(self):
        """Triggered when the user wants to download and see the file"""
        url = self.selectedText.strip()
        if url.lower().startswith("www."):
            url = "http://" + url

        oldTimeout = socket.getdefaulttimeout()
        newTimeout = 5      # Otherwise the pause is too long
        socket.setdefaulttimeout(newTimeout)
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))

        try:
            response = urllib.request.urlopen(url)
            content = decodeURLContent(response.read())

            # The content has been read sucessfully
            mainWindow = GlobalData().mainWindow
            mainWindow.editorsManager().newTabClicked(content,
                                                      os.path.basename(url))
        except Exception as exc:
            logging.error("Error downloading '" + url + "'\n" + str(exc))

        QApplication.restoreOverrideCursor()
        socket.setdefaulttimeout(oldTimeout) 
Example 8
Project: pythonpentest   Author: funkandwagnalls   File: banner_grabber.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def main():
    ports = [21,23,22]
    ips = "192.168.195."
    for octet in range(0,255):
        for port in ports:
            ip = ips + str(octet)
            #print("[*] Testing port %s at IP %s") % (port, ip)
            try:
                socket.setdefaulttimeout(1)
                s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
                s.connect((ip,port))
                output = s.recv(1024)
                print("[+] The banner: %s for IP: %s at Port: %s") % (output,ip,port)
            except:
                print("[-] Failed to Connect to %s:%s") % (ip, port)
            finally:
                s.close() 
Example 9
Project: gitfollow   Author: sepandhaghighi   File: gitfollow.py    License: MIT License 6 votes vote down vote up
def internet(host="8.8.8.8", port=53, timeout=10):
    """
    Check Internet Connections.
    :param  host: the host that check connection to
    :param  port: port that check connection with
    :param  timeout: times that check the connnection
    :type host:str
    :type port:int
    :type timeout:int
    :return bool: True if Connection is Stable
    >>> internet() # if there is stable internet connection
    True
    >>> internet() # if there is no stable internet connection
    False
    """
    try:
        socket.setdefaulttimeout(timeout)
        socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
        return True
    except Exception as ex:
        return False 
Example 10
Project: 12306   Author: testerSunshine   File: agency_tools.py    License: MIT License 6 votes vote down vote up
def filter_proxy(self):
        """
        将不可用IP剔除
        :return: 
        """
        socket.setdefaulttimeout(1)
        path = os.path.join(os.path.dirname(__file__), './proxy_list')
        f = open(path, "w")
        head = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36',
            'Connection': 'keep-alive'}
        url = "http://icanhazip.com"
        proxy_num = 0
        for proxy in self.proxy_list:
            proxy_temp = {"https": "https://{}".format(proxy)}
            try:
                req = requests.get(url, proxies=proxy_temp, timeout=2, headers=head).content
                print(req)
                write_proxy = proxy + "\n"
                f.write(write_proxy)
                proxy_num += 1
            except Exception:
                print ("代理链接超时,去除此IP:{0}".format(proxy))
                continue
        print("总共可使用ip量为{}个".format(proxy_num)) 
Example 11
Project: aerospike-admin   Author: aerospike   File: common.py    License: Apache License 2.0 6 votes vote down vote up
def _collect_aws_data(cmd=''):
    aws_rsp = ''
    aws_timeout = 1
    socket.setdefaulttimeout(aws_timeout)
    aws_metadata_base_url = 'http://169.254.169.254/latest/meta-data'
    out = "['AWS']"
    try:
        req = urllib.request.Request(aws_metadata_base_url)
        r = urllib.request.urlopen(req)
        # r = requests.get(aws_metadata_base_url,timeout=aws_timeout)
        if r.code == 200:
            rsp = r.read()
            aws_rsp += _get_aws_metadata(rsp, '/')
            out += "\n" + "Requesting... {0} \n{1}  \t Successful".format(aws_metadata_base_url, aws_rsp)
        else:
            aws_rsp = " Not likely in AWS"
            out += "\n" + "Requesting... {0} \t FAILED {1} ".format(aws_metadata_base_url, aws_rsp)

    except Exception as e:
        out += "\n" + "Requesting... {0} \t  {1} ".format(aws_metadata_base_url, e)
        out += "\n" + "FAILED! Node Is Not likely In AWS"

    return out, None 
Example 12
Project: aerospike-admin   Author: aerospike   File: common.py    License: Apache License 2.0 6 votes vote down vote up
def _collect_gce_data(cmd=''):
    gce_timeout = 1
    socket.setdefaulttimeout(gce_timeout)
    gce_metadata_base_url = 'http://metadata.google.internal/computeMetadata/v1/instance/'
    out = "['GCE']"

    fields_to_ignore = ['attributes/']

    try:
        req = urllib.request.Request(gce_metadata_base_url, headers={"Metadata-Flavor" : "Google"})
        r = urllib.request.urlopen(req)

        if r.code == 200:
            rsp = r.read()
            gce_rsp = _get_gce_metadata(rsp, fields_to_ignore=fields_to_ignore)
            out += "\n" + "Requesting... {0} \n{1}  \t Successful".format(gce_metadata_base_url, gce_rsp)
        else:
            gce_rsp = " Not likely in GCE"
            out += "\n" + "Requesting... {0} \t FAILED {1} ".format(gce_metadata_base_url, gce_rsp)

    except Exception as e:
        out += "\n" + "Requesting... {0} \t  {1} ".format(gce_metadata_base_url, e)
        out += "\n" + "FAILED! Node Is Not likely In GCE"

    return out, None 
Example 13
Project: aerospike-admin   Author: aerospike   File: common.py    License: Apache License 2.0 6 votes vote down vote up
def _collect_azure_data(cmd=''):
    azure_timeout = 1
    socket.setdefaulttimeout(azure_timeout)
    azure_metadata_base_url = 'http://169.254.169.254/metadata/instance?api-version=2017-04-02'
    out = "['Azure']"

    try:
        req = urllib.request.Request(azure_metadata_base_url, headers={"Metadata" : "true"})
        r = urllib.request.urlopen(req)

        if r.code == 200:
            rsp = r.read()
            rsp = rsp.decode("utf-8")
            jsonObj = json.loads(rsp)
            out += "\n" + "Requesting... {0} \n{1}  \t Successful".format(azure_metadata_base_url,
                                                                          json.dumps(jsonObj, sort_keys=True, indent=4, separators=(',', ': ')))
        else:
            rsp = " Not likely in Azure"
            out += "\n" + "Requesting... {0} \t FAILED {1} ".format(azure_metadata_base_url, rsp)

    except Exception as e:
        out += "\n" + "Requesting... {0} \t  {1} ".format(azure_metadata_base_url, e)
        out += "\n" + "FAILED! Node Is Not likely In Azure"

    return out, None 
Example 14
Project: ironpython2   Author: IronLanguages   File: test_multiprocessing.py    License: Apache License 2.0 6 votes vote down vote up
def test_timeout(self):
        old_timeout = socket.getdefaulttimeout()
        try:
            socket.setdefaulttimeout(0.1)
            parent, child = multiprocessing.Pipe(duplex=True)
            l = multiprocessing.connection.Listener(family='AF_INET')
            p = multiprocessing.Process(target=self._test_timeout,
                                        args=(child, l.address))
            p.start()
            child.close()
            self.assertEqual(parent.recv(), 123)
            parent.close()
            conn = l.accept()
            self.assertEqual(conn.recv(), 456)
            conn.close()
            l.close()
            p.join(10)
        finally:
            socket.setdefaulttimeout(old_timeout)

#
# Test what happens with no "if __name__ == '__main__'"
# 
Example 15
Project: recon-ng   Author: lanmaster53   File: browser.py    License: GNU General Public License v3.0 6 votes vote down vote up
def get_browser(self):
        '''Returns a mechanize.Browser object configured with the framework's global options.'''
        br = mechanize.Browser()
        # set the user-agent header
        br.addheaders = [('User-agent', self._global_options['user-agent'])]
        # set debug options
        if self._global_options['verbosity'] >= 2:
            br.set_debug_http(True)
            br.set_debug_redirects(True)
            br.set_debug_responses(True)
        # set proxy
        if self._global_options['proxy']:
            br.set_proxies({'http': self._global_options['proxy'], 'https': self._global_options['proxy']})
        # additional settings
        br.set_handle_robots(False)
        # set timeout
        socket.setdefaulttimeout(self._global_options['timeout'])
        return br 
Example 16
Project: CGIShell   Author: cj1324   File: cgishell.py    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
def main(url):
    # set default timeout 10s
    socket.setdefaulttimeout(10)

    f = Fetch(url.strip())
    print ':) URL: {0}'.format(f.fullurl)
    try:
        msg = f.injection('id')
    except InjectionFailed:
        print '*_* Injection Code Failed.'
        return 1
    except InjectionNetError:
        print '*_* Check the target server connection'
        return 1
    idinfo = msg.split(' ')[0].split('=')
    if len(idinfo) == 2:
        f.user = idinfo[1]
    else:
        f.user = idinfo[0]
    csc = CgiShellConsole()
    csc.set_fetch(f)
    sys.ps1 = '{0}@{1} >>'.format(f.host, f.user)
    csc.interact(':) Injection Code Success! Shell it.')
    return 0 
Example 17
Project: fuzzdb-collect   Author: euphrat1ca   File: win_weblogic_rce_exp.py    License: GNU General Public License v3.0 6 votes vote down vote up
def commandtool(self, host):
        try:
            socket.setdefaulttimeout(6)
            tempsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            server_address = (host, int(65500))
            tempsock.connect(server_address)
            # socket连接没有报错的话,说明socket服务器端口正常监听起来了.
            # bye 关闭socket,socket利用方式只在具有交互式条件下才能使用,这里用socket连接只为增强验证漏洞存在的准确性.
            tempsock.sendall("cmd:::whoami")
            time.sleep(1)
            data = tempsock.recv(2048).encode('gbk')
            print data.replace("\n", "")
            tempsock.close()
            time.sleep(1)
            tempsock.sendall('bye')
            time.sleep(2)
            data = tempsock.recv(1048).encode('gbk')
            if "success" == data:
                tempsock.close()
                return True
            else:
                tempsock.close()
            return True
        except Exception, e:
            return False 
Example 18
Project: fuzzdb-collect   Author: euphrat1ca   File: linux_weblogic_rce_exp.py    License: GNU General Public License v3.0 6 votes vote down vote up
def commandtool(self, host):
        try:
            socket.setdefaulttimeout(6)
            tempsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            server_address = (host, int(65500))
            tempsock.connect(server_address)
            # socket连接没有报错的话,说明socket服务器端口正常监听起来了.
            # bye 关闭socket,socket利用方式只在具有交互式条件下才能使用,这里用socket连接只为增强验证漏洞存在的准确性.
            tempsock.sendall("cmd:::whoami")
            time.sleep(1)
            data = tempsock.recv(2048).encode('gbk')
            print data.replace("\n", "")
            tempsock.close()
            time.sleep(1)
            tempsock.sendall('bye')
            time.sleep(2)
            data = tempsock.recv(1048).encode('gbk')
            if "success" == data:
                tempsock.close()
                return True
            else:
                tempsock.close()
            return True
        except Exception, e:
            return False 
Example 19
def pfind(plugin):
	try:
		socket.setdefaulttimeout(3)
		s = socket.socket()
		s.connect((host,port))
		s.send("GET /_plugin/%s/ HTTP/1.0\n"
			"Host: %s\n\n" % (plugin, host))
		file = s.recv(16)
		print "[*] Trying to find plugin %s:" % plugin
		if ("HTTP/1.0 200 OK" in file):
			print "[+] Plugin found!"
			grab(plugin)
			sys.exit()
		else:
		    print "[-]  Not Found "
	except Exception, e:
		print "[-] Error connecting to %s: %s" % (host, e)
		sys.exit()

# Include more plugin names to check if they are installed 
Example 20
Project: Paradrop   Author: ParadropLabs   File: discover.py    License: Apache License 2.0 5 votes vote down vote up
def perform_ssdp_discovery(service, timeout=5, retries=5, mx=3):
    # Standard multicast IP address and port for SSDP.
    group = ("239.255.255.250", 1900)

    message = "\r\n".join([
        "M-SEARCH * HTTP/1.1",
        "HOST: {0}:{1}",
        'MAN: "ssdp:discover"',
        "ST: {st}",
        "MX: {mx}"
    ]).format(*group, st=service, mx=mx)

    socket.setdefaulttimeout(timeout)

    sources = set()
    for _ in range(retries):
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)
        sock.sendto(message.encode('utf-8'), group)
        while True:
            try:
                data, addr = sock.recvfrom(1024)
                response = SsdpResponse(data, addr)
                if addr[0] not in sources:
                    # We only want to return each node once.
                    sources.add(addr[0])
                    yield response
            except socket.timeout:
                break 
Example 21
Project: oscrypto   Author: wbond   File: test_tls.py    License: MIT License 5 votes vote down vote up
def test_tls_error_ftp(self):
        s = None
        try:
            def_timeout = socket.getdefaulttimeout()
            socket.setdefaulttimeout(5)
            s = make_socket_server(8021, lambda s, d: s.send(b'220 Welcome to FooFTP\n'))
            with assert_exception(self, errors.TLSError, 'remote end closed the connection|server responded using FTP'):
                tls.TLSSocket('localhost', 8021)
        finally:
            if s:
                s.close()
            socket.setdefaulttimeout(def_timeout) 
Example 22
Project: Vxscan   Author: al0ne   File: docker_unauthorized_access.py    License: Apache License 2.0 5 votes vote down vote up
def check(url, ip, ports, apps):
    socket.setdefaulttimeout(2)
    if verify(vuln, ports, apps):
        try:
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            s.connect((ip, 2375))
            payload = "GET /containers/json HTTP/1.1\r\nHost: %s:%s\r\n\r\n" % (ip, 2375)
            s.send(payload.encode())
            recv = s.recv(1024)
            if b"HTTP/1.1 200 OK" in recv and b'Docker' in recv and b'Api-Version' in recv:
                return '2375 Docker unauthorized success'
        except Exception as e:
            # return '2375 Docker  Failed'
            pass 
Example 23
Project: Vxscan   Author: al0ne   File: zookeeper_unauthorized_access.py    License: Apache License 2.0 5 votes vote down vote up
def check(url, ip, ports, apps):
    if verify(vuln, ports, apps):
        try:
            socket.setdefaulttimeout(2)
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            s.connect((ip, 2181))
            s.send(b'success')
            data = s.recv(1024)
            if b'Environment' in data:
                return '2181 Zookeeper Unauthorized access'
        except Exception as e:
            pass 
Example 24
Project: Vxscan   Author: al0ne   File: port_scan.py    License: Apache License 2.0 5 votes vote down vote up
def socket_scan(self, hosts):
        global PROBE
        response = ''
        socket.setdefaulttimeout(2)
        ip, port = hosts.split(':')
        try:
            # 这里是统计总共开放端口,有些服务器一扫描就全端口开放当大于某个端口数量时则不记录
            if len(self.port) < 30:
                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                result = sock.connect_ex((ip, int(port)))
                # 建立3次握手成功
                if result == 0:
                    try:
                        for i in PROBE:
                            sock.sendall(i.encode())
                            response = sock.recv(256)
                            sock.close()
                            # 发送payload 获取响应 来判断服务
                            if response:
                                self.regex(response, port)
                            else:
                                proto = {"server": get_server(port), "port": port, "banner": ''}
                                self.out.append(proto)
                            break
                    except socket.timeout:
                        proto = {"server": get_server(port), "port": port, "banner": ''}
                        self.out.append(proto)

                    self.port.append(port)

            else:
                self.num = 1

        except (socket.timeout, ConnectionResetError, OSError):
            pass
        except Exception as e:
            # traceback.print_exc(e)
            logging.exception(e) 
Example 25
Project: watchdog   Author: flipkart-incubator   File: lswww.py    License: Apache License 2.0 5 votes vote down vote up
def browse(self, web_resource):
        """Extract urls from a webpage and add them to the list of urls
        to browse if they aren't in the exclusion list"""
        url = web_resource.url

        # We don't need destination anchors
        current_full_url = url.split("#")[0]
        # Url without query string
        current = current_full_url.split("?")[0]
        # Get the dirname of the file
        currentdir = "/".join(current.split("/")[:-1]) + "/"

        # Timeout must not be too long to block big documents
        # (for exemple a download script)
        # and not too short to give good results
        socket.setdefaulttimeout(self.timeout)

        headers = {}
        headers["user-agent"] = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
        try:
            resp = self.h.send(web_resource, headers=headers)
        except socket.timeout:
            self.excluded.append(url)
            return False
        except requests.exceptions.Timeout:
            self.excluded.append(url)
            return False
        except socket.error, msg:
            if msg.errno == 111:
                print(_("Connection refused!"))
            self.excluded.append(url)
            return False 
Example 26
Project: watchdog   Author: flipkart-incubator   File: HTTP.py    License: Apache License 2.0 5 votes vote down vote up
def setTimeOut(self, timeout=6.0):
        "Set the time to wait for a response from the server."
        self.timeout = timeout
        socket.setdefaulttimeout(self.timeout) 
Example 27
Project: watchdog   Author: flipkart-incubator   File: lswww.py    License: Apache License 2.0 5 votes vote down vote up
def browse(self, web_resource):
        """Extract urls from a webpage and add them to the list of urls
        to browse if they aren't in the exclusion list"""
        url = web_resource.url

        # We don't need destination anchors
        current_full_url = url.split("#")[0]
        # Url without query string
        current = current_full_url.split("?")[0]
        # Get the dirname of the file
        currentdir = "/".join(current.split("/")[:-1]) + "/"

        # Timeout must not be too long to block big documents
        # (for exemple a download script)
        # and not too short to give good results
        socket.setdefaulttimeout(self.timeout)

        headers = {}
        headers["user-agent"] = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
        try:
            resp = self.h.send(web_resource, headers=headers)
        except socket.timeout:
            self.excluded.append(url)
            return False
        except requests.exceptions.Timeout:
            self.excluded.append(url)
            return False
        except socket.error, msg:
            if msg.errno == 111:
                print(_("Connection refused!"))
            self.excluded.append(url)
            return False 
Example 28
Project: watchdog   Author: flipkart-incubator   File: HTTP.py    License: Apache License 2.0 5 votes vote down vote up
def setTimeOut(self, timeout=6.0):
        "Set the time to wait for a response from the server."
        self.timeout = timeout
        socket.setdefaulttimeout(self.timeout) 
Example 29
Project: Windows-Agent   Author: AutohomeRadar   File: agent.py    License: Apache License 2.0 5 votes vote down vote up
def __init__(self, args):
        win32serviceutil.ServiceFramework.__init__(self, args)
        self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
        socket.setdefaulttimeout(60)
        self.isAlive = True 
Example 30
Project: vulscan   Author: vulscanteam   File: 20-openssl-access.py    License: MIT License 5 votes vote down vote up
def _verify(self):
        #定义返回结果
        result = {}
        #获取漏洞url
        vul_url = '%s' % self.url
 
        #如果设置端口则取端口,没有设置则为默认端口
        import re
        from pocsuite.lib.utils.funs import url2ip
        _port = re.findall(':(\d+)\s*', vul_url)
        if len(_port) != 0:
            _host = url2ip(vul_url)[0]
            _port = url2ip(vul_url)[1]
        else :
            _host = url2ip(vul_url)
            _port = 443
 
        #s = socket.socket()
        #socket.setdefaulttimeout(1)
        #检测漏洞
        try:
            ret = ssltest(_host,_port)
            # print ret
            if ret == "check":
                result['VerifyInfo'] = {}
                result['VerifyInfo']['URL'] = host
                result['VerifyInfo']['Payload'] = payload
            else:
                pass
        except:
            pass
        print '[+]20 poc done'
        return self.save_output(result)
 
    #漏洞攻击