当前位置: 首页>>代码示例>>Python>>正文


Python URL.getHost方法代码示例

本文整理汇总了Python中java.net.URL.getHost方法的典型用法代码示例。如果您正苦于以下问题:Python URL.getHost方法的具体用法?Python URL.getHost怎么用?Python URL.getHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.URL的用法示例。


在下文中一共展示了URL.getHost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: googleSiteIndex

# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import getHost [as 别名]
	def googleSiteIndex(self, url, mCallBacks, startIndex):
		#print 'Starting Google Site: Index for URL: ' + str(url)
		data = 'Starting Google Site: Index for URL: ' + str(url) + '\n'
		self.parent.printLogTab(str(data))
		googleRequest = self.buildGoogleRequest(url, startIndex)
		googleResponse = mCallBacks.makeHttpRequest('www.google.com', int('80'), False, googleRequest)
		googleStringResponse = googleResponse.tostring()
		for urlInSearch in re.findall(r'''<a href="([^<]+)" class=l''', googleStringResponse):
			uUrl = URL(urlInSearch)
			port = 80
			if str(uUrl.getProtocol()) == "https":
				port = 443
			if mCallBacks.isInScope(uUrl):
				newRequest = self.buildGenericRequest(uUrl)
				newResponse = mCallBacks.makeHttpRequest(str(uUrl.getHost()), port, (str(uUrl.getProtocol()) == "https"), newRequest)
				newResponseString = newResponse.tostring()
				firstWord, statusCode, restResponse = newResponseString.split(" ", 2)
				requestResponse = HttpRequestResponse.HttpRequestResponse(None, uUrl.getHost(), port, uUrl.getProtocol(), newRequest, newResponse, int(statusCode), uUrl)
				mCallBacks.addToSiteMap(requestResponse)
				#print "Adding: " + urlInSearch
				data = "Adding: " + urlInSearch + "\n"
				self.parent.printLogTab(str(data))
			else:
				data = "\n" + urlInSearch + " was not in scope.\n\n"
				self.parent.printLogTab(str(data))

		data = "End of Google Site Indexing for URL " + str(url) + "\n"
		self.parent.printLogTab(str(data))
开发者ID:droogie,项目名称:burp_extended,代码行数:30,代码来源:GoogleSiteIndex.py

示例2: nukeAndPave

# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import getHost [as 别名]
def nukeAndPave(islandID, wipeMasters=False, wipeSlaves=False):
    if not wipeMasters and not wipeSlaves:
        return

    clusterMgr = mc.getClusterManager()
    clusters = clusterMgr.enumClusters(islandID)

    slaves = []
    masters = []

    for cluster in clusters:
        locs = clusterMgr.enumClusterLocations(cluster.getID())
        for loc in locs:
            slaveURL = URL(loc.getClusterLocationProperty(SolrClusterAdapter.SOLR_SLAVE_HOST_URL_PROP))
            slaveHost = slaveURL.getHost()
            masterURL = URL(loc.getClusterLocationProperty(SolrClusterAdapter.SOLR_MASTER_HOST_URL_PROP))
            masterHost = masterURL.getHost()
            slaves.append(slaveHost)
            masters.append(masterHost)

    rc = 0
    if wipeSlaves:
        print "Removing Solr from slaves to prepare for upgrade", slaves
        failures = runJob(["/usr/local/bin/ender", "remote-action", "upgrade-support", "remove-solr-install"], slaves)

        if failures.isEmpty():
            print "INFO: nuke and pave of slaves succeeded"
        else:
            print "WARN: check logs for errors before upgrading slaves. Host(s) reporting falilure:", failures
            rc = 1

    return rc
开发者ID:piyush76,项目名称:EMS,代码行数:34,代码来源:upgrade-solr.py

示例3: DiscoveryMain

# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import getHost [as 别名]
def DiscoveryMain(Framework):
	OSHVResult = ObjectStateHolderVector()
	
	urlString = Framework.getParameter(PARAM_URL)
	
	reportPoweredOffVms = 0
	reportPoweredOffVmsValue = Framework.getParameter(PARAM_REPORT_POWERED_OFF_VMS)
	if reportPoweredOffVmsValue and reportPoweredOffVmsValue.lower() =='true':
		reportPoweredOffVms = 1

	
	ipAddress = None
	try:
		urlObject = URL(urlString)
		hostname = urlObject.getHost()
		
		if not hostname:
			logger.debug("Hostname is not defined in URL '%s'" % urlString)
			raise MalformedURLException()
		
		ipAddress = vcloud_discover.getIpFromUrlObject(urlObject)
		if not ipAddress or not netutils.isValidIp(ipAddress) or netutils.isLocalIp(ipAddress):
			msg = "Failed to resolve the IP address of server from specified URL"
			errormessages.resolveAndReport(msg, vcloud_discover.VcloudProtocol.DISPLAY, Framework)
			return OSHVResult
		
	except MalformedURLException:
		msg = "Specified URL '%s' is malformed" % urlString
		errormessages.resolveAndReport(msg, vcloud_discover.VcloudProtocol.DISPLAY, Framework)
	except:
		msg = logger.prepareJythonStackTrace("")
		errormessages.resolveAndReport(msg, vcloud_discover.VcloudProtocol.DISPLAY, Framework)
	else:
		
		#configure how connections should be discovered/established
		connectionDiscoverer = vcloud_discover.ConnectionDiscoverer(Framework)
		urlGenerator = vcloud_discover.ConstantUrlGenerator(urlString)
		connectionDiscoverer.setUrlGenerator(urlGenerator)
		connectionDiscoverer.addIp(ipAddress)
		
		#configure how established/failed connection should be used
		connectionHandler = vcloud_discover.BaseDiscoveryConnectionHandler(Framework)
		topologyDiscoverer = vcloud_discover.createVcloudDiscoverer(Framework)
		topologyReporter = vcloud_report.createVcloudReporter(Framework, None, reportPoweredOffVms)
		connectionHandler.setDiscoverer(topologyDiscoverer)
		connectionHandler.setReporter(topologyReporter)
		
		connectionDiscoverer.setConnectionHandler(connectionHandler)
		
		connectionDiscoverer.initConnectionConfigurations()
		
		connectionDiscoverer.discover(firstSuccessful=0)
		
		if not connectionHandler.connected:
			for errorMsg in connectionHandler.connectionErrors:
				Framework.reportError(errorMsg)
			for warningMsg in connectionHandler.connectionWarnings:
				Framework.reportWarning(warningMsg)

	return OSHVResult
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:62,代码来源:vcloud_director_url_by_vcloud_api.py

示例4: getUrl

# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import getHost [as 别名]
def getUrl(WSDLUrl, containerOSH):

    res = ObjectStateHolderVector()
    urlIP = None
    try:
        url = URL(WSDLUrl)
        hostName = url.getHost()
        urlIP = netutils.getHostAddress(hostName, None)

        if (not netutils.isValidIp(urlIP)) or netutils.isLocalIp(urlIP):
            urlIP = None
    except:
        urlIP = None
    
    urlOSH = modeling.createUrlOsh(containerOSH, WSDLUrl, 'wsdl')

    urlIpOSH = None
    if urlIP != None:
        try:
            urlIpOSH = modeling.createIpOSH(urlIP)
        except:
            urlIpOSH = None

    res.add(urlOSH)

    if urlIpOSH:
        res.add(urlIpOSH)
        urlToIpOSH = modeling.createLinkOSH('depend', urlOSH, urlIpOSH)
        res.add(urlToIpOSH)

    return res
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:33,代码来源:OracleAplicationServer.py

示例5: __init__

# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import getHost [as 别名]
 def __init__(self, queryString):
     self.args = queryString
     # We would like content_type to be a class property but this is
     # not supported in Python 2.1
     self.content_type = "text/plain"
     reqURL = URL("http://myhost/mywms/")
     self.server = FakeModPythonServerObject("%s:%d" % (reqURL.getHost(), reqURL.getPort()))
     self.unparsed_uri = str(reqURL.getPath())
开发者ID:,项目名称:,代码行数:10,代码来源:

示例6: createURLOSHV

# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import getHost [as 别名]
def createURLOSHV(urlString, framework = None):
    OSHVResult = ObjectStateHolderVector()    
    
    #urlOSH2 = modeling.createOshByCmdbIdString('uri_endpoint', urlId)       
    logger.debug("Starting URL discovery on '%s'" % urlString)
    #urlString = urlString[1:len(urlString)-1]
    if not urlString:
        return OSHVResult
    
    try:
    
        urlString = str(urlString).replace("\\", "//")
        
        urlObject = URL(urlString)
        hostname = urlObject.getHost()
    
        if not hostname:
            raise MalformedURLException("Hostname is not defined in URL '%s'" % urlString)
    
        urlObjectResolver = URLObjectResolver(urlObject)
        protocol = urlObjectResolver.getProtocolFromUrlObject()
        
        if not protocol:
            raise Exception("Failed to resolve the http/https protocol from specified URL")
    
        port = urlObjectResolver.getPortFromUrlObject()
        
        if not port:
            raise Exception("Failed to resolve the port number from specified URL")
    
        # get topology
        # create business element CI and attach the url as configuration document CI to it 
    
        ips = urlObjectResolver.getIpFromUrlObject()
        
        for ipAddress in ips:
            logger.debug('%s: Reporting ip address: %s' % (urlString, ipAddress))
            if not ipAddress or not netutils.isValidIp(ipAddress) or netutils.isLocalIp(ipAddress):
                raise Exception("Failed to resolve the IP address of server from specified URL")
    
            
            hostOSH, ipOSH, OSHVResult2 = createIPEndpointOSHV(framework, ipAddress, port, protocol, hostname)     
            OSHVResult.addAll(OSHVResult2)
            # create UriEndpoint and relations between business element and UriEndpoint
            urlOSH = modeling.createUrlOsh(hostOSH, urlString, None)
            #urlOSH.setCmdbObjectId(urlOSH2.getCmdbObjectId())            
            OSHVResult.add(urlOSH)
            OSHVResult.add(modeling.createLinkOSH('dependency', urlOSH, ipOSH)) 
           
                        
            #create Web Server
    except:
        logger.warnException("Error creating URL OSH for %s" % urlString)


    return OSHVResult
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:58,代码来源:pi_utils.py

示例7: getIpFromUrlString

# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import getHost [as 别名]
def getIpFromUrlString(urlString):
    try:
        urlObject = URL(urlString)
        hostname = urlObject.getHost()
        if not hostname:
            logger.debug("Hostname is not defined in URL '%s'" % urlString)
            raise MalformedURLException()
        
        ipAddress = getIpFromUrlObject(urlObject)
        if not ipAddress or not netutils.isValidIp(ipAddress) or netutils.isLocalIp(ipAddress):
            raise ValueError("Failed determining the IP address of server")
        
        return ipAddress
    except:
        logger.warnException("Invalid URL")
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:17,代码来源:vmware_vim.py

示例8: upgradeMaster

# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import getHost [as 别名]
def upgradeMaster(islandID):

    clusterMgr = mc.getClusterManager()
    clusters = clusterMgr.enumClusters(islandID)
    for cluster in clusters:
        locs = clusterMgr.enumClusterLocations(cluster.getID())
        hosts = []
        for loc in locs:
            masterURL = URL(loc.getClusterLocationProperty(SolrClusterAdapter.SOLR_MASTER_HOST_URL_PROP))
            masterHost = masterURL.getHost()
            hosts.append(masterHost)

        service = Service("ems-solr")
        service.setThreadCount(1)
        service.invoke("stop", hosts)

        failures = runJob(["/usr/local/bin/ender", "remote-action", "upgrade-support", "save-index"], hosts)
        if not failures.isEmpty():
            print "WARN: Failed to backup the index on all hosts. Check logs.", failures

        failures = runJob(["/usr/local/bin/ender", "remote-action", "upgrade-support", "upgrade-index"], hosts)
        if not failures.isEmpty():
            print "Failed to start the backup job running on all hosts. Check logs.", failures
            return 1

        failures = runJob(
            ["/usr/local/bin/ender", "remote-action", "upgrade-support", "upgrade-status"],
            hosts,
            sleepTime=120,
            maxWaits=43200,
            interimResult=3,
        )
        if not failures.isEmpty():
            print "ERROR: upgrade job failed. Upgrade aborted", failures
            return 1

        failures = runJob(["/usr/local/bin/ender", "remote-action", "upgrade-support", "remove-solr-service"], hosts)
        if not failures.isEmpty():
            print "ERROR: unable to remove solr service from all hosts", failures
            return 1

    print "Please check for any errors in the output before proceeding"
    print "If it appears the Solr index has been upgraded successfully. Please proceed to install the new version of Solr and then run the validate-master step"

    return 0
开发者ID:piyush76,项目名称:EMS,代码行数:47,代码来源:upgrade-solr.py

示例9: fullStatus

# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import getHost [as 别名]
def fullStatus(islandID):
    islandMgr = mc.getIslandManager()
    island = islandMgr.getIsland(int(islandID))
    print "INFO: island status for island", islandID
    print "INFO: search URL", islandID, island.getSearchURL()
    print "INFO: search Parmeters", islandID, island.getSearchParms()

    print "INFO: cluster and shard status for island", islandID
    clusterMgr = mc.getClusterManager()
    clusters = clusterMgr.enumClusters(islandID)
    masters = []
    slaves = []
    masterURLs = []
    slaveURLs = []
    for cluster in clusters:
        print "INFO: cluster", cluster.getID(), "F:", cluster.isFeedEnabled(), "U:", cluster.isUpdateEnabled(), "P:", cluster.isPurgeEnabled()
        locs = clusterMgr.enumClusterLocations(cluster.getID())
        for loc in locs:
            print "INFO: location", loc.getId(), "F:", loc.isFeedEnabled(), "U:", loc.isUpdateEnabled(), "P:", loc.isPurgeEnabled(), "M:", loc.isManagementEnabled()
            slaveURL = URL(loc.getClusterLocationProperty(SolrClusterAdapter.SOLR_SLAVE_HOST_URL_PROP))
            slaveHost = slaveURL.getHost()
            slaves.append(slaveHost)
            masterURL = URL(loc.getClusterLocationProperty(SolrClusterAdapter.SOLR_MASTER_HOST_URL_PROP))
            masterHost = masterURL.getHost()
            masters.append(masterHost)
            masterURL = masterURL.toString() + "/admin/system"
            masterURLs.append(masterURL)
            slaveURL = slaveURL.toString() + "/admin/system"
            slaveURLs.append(slaveURL)

    print "INFO: Service Status for island", islandID
    service = Service("ems-solr")
    service.setThreadCount(1)
    responses = service.invoke("status", masters)
    for key in responses.keySet():
        sr = responses.get(key)
        print "INFO: Master", key, sr.getStdout()
    responses = service.invoke("status", slaves)
    for key in responses.keySet():
        sr = responses.get(key)
        print "INFO: Slave", key, sr.getStdout()

    print "INFO: Version Info for island", islandID
    for masterURL in masterURLs:
        masterF = None
        try:
            masterF = urllib.urlopen(masterURL)
        except:
            print "WARN: Solr not running on", masterURL
            continue
        try:
            masterData = masterF.read()
            look = '<str name="solr-spec-version">'
            idx = masterData.find(look)
            idx = idx + len(look)
            end = masterData.find("</str>", idx)
            print "INFO:", masterURL, masterData[idx:end]
        finally:
            masterF.close()

    for slaveURL in slaveURLs:
        slaveF = None
        try:
            slaveF = urllib.urlopen(slaveURL)
        except:
            print "WARN: Solr not running on", slaveURL
            continue
        try:
            slaveData = slaveF.read()
            look = '<str name="solr-spec-version">'
            idx = slaveData.find(look)
            idx = idx + len(look)
            end = slaveData.find("</str>", idx)
            print "INFO:", slaveURL, slaveData[idx:end]
        finally:
            slaveF.close()

    print "INFO: Upgrade activities"
    ulog = "/tmp/.solr_upgrade_log_" + str(islandID)
    if os.path.exists(ulog):
        for line in open(ulog):
            print "INFO:", line.strip()
    else:
        print "INFO: No activity log found:", ulog
开发者ID:piyush76,项目名称:EMS,代码行数:86,代码来源:upgrade-solr.py

示例10: connect

# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import getHost [as 别名]
    def connect(self, url):
        if re.findall('(?:\:\d{2,5})', url) and self.urlRegex.match(url):
            try:
                javaURL = URL(url)
                newRequest = self._helpers.buildHttpRequest(javaURL)
                requestResponse = self._callbacks.makeHttpRequest(self._helpers.buildHttpService(str(javaURL.getHost()), javaURL.getPort(), str(javaURL.getProtocol())), newRequest)

                # Follow redirects if a 301 or 302 response is received. As of Oct 9 2014 the API is not capable of this: http://forum.portswigger.net/thread/1504/ask-burp-follow-redirections-extension
                response = requestResponse.getResponse()
                if response:
                    requestInfo = self._helpers.analyzeResponse(response)
                    responseHeader = requestInfo.getHeaders()
                    
                    if ('301' in responseHeader[0] or '302' in responseHeader[0]) and self.redirectsCheckbox.isSelected():
                        self.redirectCounter += 1
                        for headerLine in responseHeader:
                            if 'Location: ' in headerLine or 'location: ' in headerLine:
                                url = self.locationHeaderConvert(str(headerLine.split(' ')[1]), str(javaURL.getPort()), str(javaURL.getHost()), '')
                                self.connect(url)
                    
                    self.goodUrlList.append(url)
                    self._callbacks.addToSiteMap(requestResponse)
                else:
                    self.badUrlList.append(url)
            except:
                self.badUrlList.append(url)
        else:
            if 'http://' in url:
                fixedUrl = self.addPort(url, '80')
                self.connect(fixedUrl)
            elif 'https://' in url:
                fixedUrl = self.addPort(url, '443')
                self.connect(fixedUrl)
            else:
                self.badUrlList.append(url)
开发者ID:SmeegeSec,项目名称:Burp-Importer,代码行数:37,代码来源:BurpImporter.py

示例11: testRequest

# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import getHost [as 别名]
    def testRequest(self, url, messageInfo):
        ########### CONFIGURATION START ###########
        #Host name for which you want to perform CSRF check and other attacks
        host_name = "localhost"
        #File extensions that you don't want to test (lowercase only)
        skip_extensions = ["jpg","jpeg","png","gif","svg","css","js"]
        #Which HTTP methods should be tested? Example: ["GET", "POST", "PUT"]
        allowed_http_methods = ["POST"]
        #Do you want to test for CSRF? True/False
        csrf_check = True
        #Name of the Anti-CSRF parameter in your application
        anti_csrf_param = '_wpnonce'
        #Message shown when the CSRF parameter is not sent in the request
        csrf_fail_message = 'Are you sure you want to do this'
        #Do you want to print original request? True/False
        print_original_request = True
        #Do you want to print modified request? True/False
        print_modified_request = True
        #Do you want to print response for modified request? True/False
        print_modified_request_response = False
        #Write to HTML file configuration
        save_to_html = True
        save_filepath = "c:\\temp\\report_test.html"
        ########### CONFIGURATION END ###########
        
        #Check if the host is in scope for testing
        if host_name != URL(str(url)).getHost():
            return
        
        #Check if the HTTP method is allowed for testing
        if ((self._helpers.analyzeRequest(messageInfo)).getMethod()).upper() not in allowed_http_methods:
            return
        
        #Check if the file name is in scope for testing
        if not self.isAllowedFileName(str(url), skip_extensions):
            return
        
        #Get the url and data to create the new URL request
        urlString = str(url)#cast to cast to stop the TYPEerror on URL()

        #Java URL to be used with Burp API
        url = URL(urlString)
        #print "UrlString: "+urlString

        #Build the new request    
        newRequest = None
        requestInfo = self._helpers.analyzeRequest(messageInfo)
        #Get current request
        currentRequest = self._helpers.bytesToString(messageInfo.getRequest());
        #Get the request body
        messageBody = currentRequest[requestInfo.getBodyOffset():];
        list_messageBody = messageBody.split('&')
        final_messageBody = ""
        final_list_messageBody = list_messageBody
        #Get headers in original request
        headers = requestInfo.getHeaders()
        #Data variables
        data_original_request = ""
        data_modified_request = ""
        data_modified_request_response = ""
        
        ########### [Start] ADD/REMOVE Content ###########
        #Add new headers
        #Syntax: headers = self.addHeader(headers, 'header_name', 'header_value')
        #headers = self.addHeader(headers, 'newheader', 'newheaderval')
        
        #Remove header from request
        #Syntax: headers = self.removeHeader(headers, 'header_name')
        headers = self.removeHeader(headers, 'Referer') # Do not remove. This is important for CSRF testing
        
        #Add a parameter to message body
        #Syntax: final_messageBody = self.addParameter(final_messageBody, 'new_param_name', 'new_param_value')
        #final_messageBody = self.addParameter(final_messageBody, 'newparam', 'newparamvalue')
        
        #Remove a parameter from message body
        #Syntax: final_messageBody = self.removeParameter(final_messageBody, 'existing_param_name')
        #list_messageBody = self.removeParameter(list_messageBody, 'asd')
        ########### [End] ADD/REMOVE Content ###########
        
        #Check if CSRF check is to be performed or not
        if csrf_check:
            #Remove anti-csrf token from request
            final_list_messageBody = filter(lambda x: not x.startswith(anti_csrf_param+'='), list_messageBody)
        #Add all params to message body string
        for param in final_list_messageBody:
            final_messageBody = final_messageBody + param + '&'
        
        #Remove trailing "&" from the POST message body
        final_messageBody = final_messageBody[:-1] if final_messageBody.endswith('&') else final_messageBody
        
        #Prepare the final POST request message body
        final_messageBody = bytearray(final_messageBody.encode('ascii', 'ignore'))
        
        #VERIFICATION: when port isn't define in the URL it is equals to -1, so we set it back to http
        if url.getPort() <= 0:
            if url.getProtocol() == "https":
                port = 443
            else:
                port = 80
        else:
#.........这里部分代码省略.........
开发者ID:xujun10110,项目名称:Request-Buster,代码行数:103,代码来源:Request_Buster.py

示例12: doUddiExplore

# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import getHost [as 别名]
def doUddiExplore(uddiAgent, registryOSH, OSHVResult):
    table = uddiAgent.doTableCommand("")
    Empty = ''

    rows = table.getRowCount()
    logger.debug('XXXXXXXXXXXXXXX  There are Business entity:', rows)


    for row in range(rows):
        properties  = table.getCell(row, 0)
        #businessEntity
        entityName = properties.getProperty(UDDIUtil.BUSINESS_ENTITY_NAME, Empty)
        entityDescription = properties.getProperty(UDDIUtil.BUSINESS_ENTITY_DESC, Empty)

        bsOSH = ObjectStateHolder('organization')
        bsOSH.setAttribute('name', entityName)
        bsOSH.setAttribute('description', entityDescription)
        bsOSH.setAttribute('organization_type', 'department')

        logger.debug('XXXXXXXXXXXXXXX add Business entity:', entityName)
        contacts = properties.get(UDDIUtil.BUSINESS_ENTITY_CONTACTS)
        contactinfo = []
        if contacts != None:
            itc = contacts.iterator()
            while itc.hasNext():
                contact = itc.next()
                contactName = contact.getProperty(UDDIUtil.CONTACT_NAME, Empty)
                contactPhon = contact.getProperty(UDDIUtil.CONTACT_PHONE, Empty)
                contactEmail = contact.getProperty(UDDIUtil.CONTACT_EMAIL, Empty)
                contactUse = contact.getProperty(UDDIUtil.CONTACT_USE_TYPE, Empty)
                contactinfo.append("[")
                contactinfo.append(contactName)
                contactinfo.append(" Phone:")
                contactinfo.append(contactPhon)
                contactinfo.append(" Email:")
                contactinfo.append(contactEmail)
                contactinfo.append(" Use type:")
                contactinfo.append(contactUse)
                contactinfo.append("] ")
            contactInfoData = ''.join(contactinfo)
            bsOSH.setAttribute('contact_info', contactInfoData)

        OSHVResult.add(bsOSH)
        link2Reg = modeling.createLinkOSH('containment', registryOSH, bsOSH)
        OSHVResult.add(link2Reg)

        services = properties.get(UDDIUtil.BUSINESS_ENTITY_SERVICES)
        if services != None:
            logger.debug('XXXXXXXXXXXXXXX services:', services.size())
            its = services.iterator()
            while its.hasNext():
                service = its.next();
                name        = service.getProperty(UDDIUtil.NAME, Empty)
                description = service.getProperty(UDDIUtil.DESCRIPTION, Empty)
                key	    = service.getProperty(UDDIUtil.KEY, Empty)
                wsdlUrl	    = service.getProperty(UDDIUtil.WSDL_URL, Empty)
                url	    = service.getProperty(UDDIUtil.URL, Empty)
                namespace = service.getProperty(UDDIUtil.TARGET_NAME_SPACE, Empty)

                if not wsdlUrl and url:
                    wsdlUrl = url

                urlIP = None
                try:
                    url = URL(wsdlUrl)
                except:
                    logger.warn("Incorrect URL \"%s\" found. Skipped." % wsdlUrl)
                    continue

                try:
                    hostName = url.getHost()
                    urlIP = netutils.getHostAddress(hostName, None);
                    if (not netutils.isValidIp(urlIP)) or netutils.isLocalIp(urlIP):
                        urlIP = None
                except:
                    urlIP = None

                urlOSH = modeling.createUrlOsh(registryOSH, wsdlUrl, 'wsdl')
                urlIpOSH = None
                if urlIP != None:
                    try:
                        urlIpOSH = modeling.createIpOSH(urlIP)
                    except:
                        urlIpOSH = None

                OSHVResult.add(urlOSH)
                if urlIpOSH:
                    OSHVResult.add(urlIpOSH)
                    urlToIpOSH = modeling.createLinkOSH('dependency', urlOSH, urlIpOSH)
                    OSHVResult.add(urlToIpOSH)

                wsOSH = ObjectStateHolder('webservice')
                wsOSH.setAttribute('name', namespace)
                wsOSH.setAttribute('description', description)
                wsOSH.setAttribute('service_name', name)
                wsOSH.setAttribute('wsdl_url', wsdlUrl)
                OSHVResult.add(wsOSH)

                urlToWsOSH = modeling.createLinkOSH('dependency', wsOSH , urlOSH )
                OSHVResult.add(urlToWsOSH)
#.........这里部分代码省略.........
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:103,代码来源:UDDI_Registry.py

示例13: nmapParse_run

# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import getHost [as 别名]
        def nmapParse_run(nmapFile, portField, serviceField, checkbox, hostName):

            try:  # Attempt to open XML file
                source = open(nmapFile)
            except:
                self.appendToResults("Nmap File not found (Check if Path and Filename is Correct)\n")
                return
            resultList = []
            try:  # Attempt to get list of ports to parse
                portList = portField.split(",")
                for i in portList:
                    i.strip()
                    i.lstrip()
            except:
                self.appendToResults("Error with Port List\n")
                return
            try:  # Attempt to get list of service names to parse
                serviceList = serviceField.split(",")
                for i in serviceList:
                    i.strip()
                    i.lstrip()
            except:
                self.appendToResults("Error with Service List")
                return
            self.appendToResults("Attempting to Parse XML File\n")
            try:  # Attempt to parse XML
                Handler = NMAPContentHandler()
                if hostName.isSelected():
                    Handler._useHostname = True
                xml.sax.parse(source, Handler)
                source.close()
                self.appendToResults("Finished Parsing File\n")
                for result in Handler._list:
                    for portCheck in portList:
                        if portCheck == result[1]:
                            if [result[0], result[1], result[2]] not in resultList:
                                resultList.append([result[0], result[1], result[2]])
                    for serviceCheck in serviceList:
                        if serviceCheck in result[2]:
                            if [result[0], result[1], result[2]] not in resultList:
                                resultList.append([result[0], result[1], result[2]])
            except:
                self.appendToResults("Error Parsing Nmap File\n")
                return
            # Take parsed results and attempt to make request to host and port using HTTP/HTTPS, adding successful request/response to scope
            for list in resultList:
                uUrl = URL("http", list[0], int(list[1]), "/")
                newRequest = self._helpers.buildHttpRequest(uUrl)
                try:
                    requestResponse = self._callbacks.makeHttpRequest(
                        self._helpers.buildHttpService(
                            str(uUrl.getHost()), int(list[1]), str(uUrl.getProtocol()) == "https"
                        ),
                        newRequest,
                    )
                    if not requestResponse.getResponse() == None:
                        if not self._callbacks.isInScope(uUrl):
                            self.appendToResults(
                                "Adding http://" + (str(uUrl.getHost())) + " port " + str(list[1]) + " to the sitemap\n"
                            )
                            self._callbacks.includeInScope(uUrl)
                        self._callbacks.addToSiteMap(requestResponse)
                        if checkbox.isSelected():
                            self.appendToResults(
                                "Spidering http://" + (str(uUrl.getHost())) + " Port " + str(list[1]) + "\n"
                            )
                            self._callbacks.sendToSpider(uUrl)

                    else:
                        uUrl = URL("https", list[0], int(list[1]), "/")

                        newRequest = self._helpers.buildHttpRequest(uUrl)
                        try:
                            requestResponse = self._callbacks.makeHttpRequest(
                                self._helpers.buildHttpService(
                                    str(uUrl.getHost()), int(list[1]), str(uUrl.getProtocol()) == "https"
                                ),
                                newRequest,
                            )
                            if not requestResponse.getResponse() == None:
                                if not self._callbacks.isInScope(uUrl):
                                    self.appendToResults(
                                        "Adding https://"
                                        + (str(uUrl.getHost()))
                                        + " port "
                                        + str(list[1])
                                        + " to the sitemap\n"
                                    )
                                    self._callbacks.includeInScope(uUrl)
                                self._callbacks.addToSiteMap(requestResponse)
                                if checkbox.isSelected():
                                    self.appendToResults(
                                        "Spidering https://" + (str(uUrl.getHost())) + " Port " + str(list[1]) + "\n"
                                    )
                                    self._callbacks.sendToSpider(uUrl)
                            else:
                                self.appendToResults(
                                    "Host "
                                    + list[0]
                                    + " with Port "
#.........这里部分代码省略.........
开发者ID:Xephoxx,项目名称:BurpSuite,代码行数:103,代码来源:NmapParser.py

示例14: DiscoveryMain

# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import getHost [as 别名]
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    businessElementId = Framework.getDestinationAttribute('id') 
    urlString = Framework.getDestinationAttribute('url')
    jobId = Framework.getDiscoveryJobId()
    dnsServers = Framework.getParameter('dnsServers') or None
    localShell = None

    if dnsServers:
        dnsServers = [dnsServer for dnsServer in dnsServers.split(',') if dnsServer and dnsServer.strip()] or None
    if dnsServers:
        logger.debug('Using dns servers: ', dnsServers)
        localShell = shellutils.ShellUtils(Framework.createClient(ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME))

    if not urlString:
        msg = "There is no specified URL in the input BusinessElement CI"
        errormessages.resolveAndReport(msg, jobId, Framework)
        return OSHVResult

    try:
        urlString = urlString[1:len(urlString)-1]

        if netutils.isValidIp(urlString):
            createHostOSHwithIP(OSHVResult, urlString)
            return OSHVResult

        urlObject = URL(urlString)
        hostname = urlObject.getHost()

        if not hostname:
            logger.debug("Hostname is not defined in URL '%s'" % urlString)
            raise MalformedURLException()

        urlObjectResolver = URLObjectResolver(urlObject)
        protocol = urlObjectResolver.getProtocolFromUrlObject()
        if not protocol:
            msg = "Failed to resolve the http/https protocol from specified URL"
            errormessages.resolveAndReport(msg, jobId, Framework)
            return OSHVResult

        port = urlObjectResolver.getPortFromUrlObject()
        if not port:
            msg = "Failed to resolve the port number from specified URL"
            errormessages.resolveAndReport(msg, jobId, Framework)
            return OSHVResult


        # get topology
        # create business element CI and attach the url as configuration document CI to it
        bizOSH = modeling.createOshByCmdbIdString('business_element', businessElementId)
        urlConfigOSH = modeling.createConfigurationDocumentOSH('url.txt', '', urlString, bizOSH)
        linkBizUrlConifg = modeling.createLinkOSH('composition', bizOSH, urlConfigOSH)
        OSHVResult.add(bizOSH)
        OSHVResult.add(urlConfigOSH)
        OSHVResult.add(linkBizUrlConifg)

        hostDNSName = None
        if not netutils.isValidIp(hostname):
            # Treat the host name as its DNS name if it is not a valid ip address
            hostDNSName = hostname

        ipAddresses = []
        if dnsServers:
            ipAddresses = urlObjectResolver.getIpFromUrlObjectWithDnsList(dnsServers, localShell)
        else:
            ipAddresses = urlObjectResolver.getIpFromUrlObject()
        for ipAddress in ipAddresses:
            logger.debug('Reporting ip address: ', ipAddresses)
            if not ipAddress or not netutils.isValidIp(ipAddress) or netutils.isLocalIp(ipAddress):
                msg = "Failed to resolve the IP address of server from specified URL"
                errormessages.resolveAndReport(msg, jobId, Framework)
                return OSHVResult

            hostOSH, ipOSH = createHostOSHwithIP(OSHVResult, ipAddress)
            if hostDNSName:
                ipOSH.setAttribute('authoritative_dns_name', hostDNSName)

            # create UriEndpoint and relations between business element and UriEndpoint
            urlOSH = modeling.createServiceURLAddressOsh(hostOSH, urlString)
            linkBizUrl = modeling.createLinkOSH('usage', bizOSH, urlOSH)
            OSHVResult.add(urlOSH)
            OSHVResult.add(linkBizUrl)

            # create ipServiceEndpoint and relations between UriEndpoint and ipServiceEndpoint
            ipPort = modeling.createServiceAddressOsh(hostOSH, ipAddress, port, modeling.SERVICEADDRESS_TYPE_TCP)
            linkUrlIP = modeling.createLinkOSH('dependency', urlOSH, ipOSH)
            OSHVResult.add(ipPort)
            OSHVResult.add(linkUrlIP)

    except MalformedURLException:
        msg = "Specified URL '%s' is malformed" % urlString
        errormessages.resolveAndReport(msg, jobId, Framework)
    except:
        msg = logger.prepareJythonStackTrace("")
        errormessages.resolveAndReport(msg, jobId, Framework)

    return OSHVResult
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:99,代码来源:URL_Resolver.py

示例15: importList

# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import getHost [as 别名]
 def importList(self):
     if self.parsedList:
         urlsAdded = 0
         # Loop through each URL and check the response.  If the response code is less than 404, add to site map
         for item in self.parsedList:
             # Pass exception if urlopen returns an http error if the URL is not reachable
             try:
                 code = urlopen(item).code
                 if code < 404:
                     javaURL = URL(item)
                     newRequest = self._helpers.buildHttpRequest(javaURL)
                     stringNewRequest = self._helpers.bytesToString(newRequest).rstrip()
                     if self.cookie:
                         stringNewRequest += '\nCookie: ' + self.cookie.rstrip('; ') + '\r\n\r\n'
                         requestResponse = self._callbacks.makeHttpRequest(self._helpers.buildHttpService(str(javaURL.getHost()), int(javaURL.getPort()), javaURL.getProtocol() == "https"), stringNewRequest)
                     else:
                         requestResponse = self._callbacks.makeHttpRequest(self._helpers.buildHttpService(str(javaURL.getHost()), int(javaURL.getPort()), javaURL.getProtocol() == "https"), newRequest)
                     self._callbacks.addToSiteMap(requestResponse)
                     urlsAdded += 1
             except Exception, e:
                 print e
                 pass
         JOptionPane.showMessageDialog(None, str(urlsAdded) + " URL(s) added to Burp site map.")
开发者ID:LucaBongiorni,项目名称:Directory-File-Listing-Parser-Importer,代码行数:25,代码来源:Directory-File-Listing-Parser-Importer.py


注:本文中的java.net.URL.getHost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。