def __init__(self, baseURL, notFoundPattern=None): baseURL = URL.getURI(baseURL) self.baseURL = baseURL.rstrip("/") self.notFoundPattern = notFoundPattern self.fp = YamlConf(self._fingerprintFile) self.log = Log("cmsidentify")
def __init__(self, baseURL, notFoundPattern=None): ''' @params: baseURL: 待识别的站点的URL notFoundPattern: 指定notFoundPattern,有时候website只返回301或200,这时候需要该字段来识别‘404’ ''' baseURL = URL.getURI(baseURL) self.baseURL = baseURL.rstrip("/") self.notFoundPattern = notFoundPattern self.fp = YamlConf(self._fingerprintFile) self.log = Log("cmsidentify")
def bruteforce(self, baseURL, notFoundPattern=None, safeURL=None, timeout=10, delay=0): ''' 爆破 ''' baseURL = URL.getURI(baseURL) keyword = self._getKeywordFromURL(baseURL) if keyword: self.keywords.append(keyword) matchs = [] baseURL = baseURL.rstrip("/") for line in self._dictIter(): time.sleep(delay) self._safeRequest(safeURL) url = baseURL.rstrip("/") + line try: self.log.debug(u"request url '{0}'".format(url)) #response = http.get(url, timeout=timeout) response = http.get(url, timeout=timeout, allow_redirects=False) except http.ConnectionError: continue if response.status_code == 200: if notFoundPattern: if notFoundPattern in response.content: continue #if response.history: # if notFoundPattern in response.history[0].content: # continue else: self.log.debug(u"find available url '{0}'".format(url)) matchs.append(url) else: continue return matchs