def heads(self, rulesRegex, cms): webTitle = "" webServer = "" for key in list(WebInfos): if 'server' in WebInfos[key][0]: webServer = WebInfos[key][0]['server'] else: webServer = "None" webTitles = re.findall(self.rex, WebInfos[key][1]) if webTitles: webTitle = webTitles[0] else: webTitle = "None" for head in WebInfos[key][0]: resHeads = re.findall(rulesRegex, WebInfos[key][0][head]) if resHeads: print( mkPut.fuchsia("[{0}]".format( time.strftime("%H:%M:%S", time.localtime()))), mkPut.red(cms), mkPut.green(webServer), mkPut.yellow(WebInfos[key][2]), key, mkPut.blue(webTitle)) OutInfos[key] = cms, webServer, WebInfos[key][2], webTitle WebInfos.pop(key) break
def run(self): keywordsBs = base64.b64encode(self.ip.encode('utf-8')) keywordsBs = keywordsBs.decode('utf-8') url = "https://fofa.so/api/v1/search/all?email={0}&key={1}&qbase64={2}&full=false&fields=ip,title,port,domain,protocol,host&size={3}".format( self.email, self.key, keywordsBs, fofaSize) try: req = requests.Session() req.keep_alive = False req.headers = self.headers req.mount("https://", HTTPAdapter(max_retries=10)) target = req.get(url, timeout=10) lock.acquire() print( mkPut.fuchsia('\n[{0}]'.format( time.strftime("%H:%M:%S", time.localtime()))), mkPut.green('[INFO]'), '正在检测IP:', self.ip) print( mkPut.fuchsia('[{0}]'.format( time.strftime("%H:%M:%S", time.localtime()))), mkPut.green('[INFO]'), '正在通过API获取信息...') datas = json.loads(target.text) self.ipInfo(datas['results']) req.close() lock.release() except requests.exceptions.ReadTimeout: print( mkPut.fuchsia('[{0}]'.format( time.strftime("%H:%M:%S", time.localtime()))), mkPut.red('[ERROR]'), '请求超时') except requests.exceptions.ConnectionError: print( mkPut.fuchsia('[{0}]'.format( time.strftime("%H:%M:%S", time.localtime()))), mkPut.red('[ERROR]'), '网络超时') except json.decoder.JSONDecodeError: print( mkPut.fuchsia('[{0}]'.format( time.strftime("%H:%M:%S", time.localtime()))), mkPut.red('[ERROR]'), '获取失败,请重试') lock.release() self.sem.release()
def bodys(self, rulesRegex, cms): webTitle = "" webServer = "" for key in list(WebInfos): if 'server' in WebInfos[key][0]: webServer = WebInfos[key][0]['server'] else: webServer = "None" webTitles = re.findall(self.rex, WebInfos[key][1]) if webTitles: webTitle = webTitles[0] else: webTitle = "None" resCodes = re.findall(rulesRegex, WebInfos[key][1]) if resCodes: logger.success("{} {} {} {} {}".format(mkPut.red(cms), mkPut.green( webServer), mkPut.yellow(WebInfos[key][2]), key, mkPut.blue(webTitle))) OutInfos[key] = cms, webServer, WebInfos[key][2], webTitle WebInfos.pop(key)
from config.colors import mkPut from colorama import init class LoggingLevel: SUCCESS = 9 SYSINFO = 8 ERROR = 7 WARNING = 6 init(autoreset=True) logging.addLevelName(LoggingLevel.SUCCESS, mkPut.cyan("[+]")) logging.addLevelName(LoggingLevel.SYSINFO, mkPut.green("[INFO]")) logging.addLevelName(LoggingLevel.ERROR, mkPut.red("[ERROR]")) logging.addLevelName(LoggingLevel.WARNING, mkPut.yellow("[WARNING]")) LOGGER = logging.getLogger("GlassLog") formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s", datefmt=mkPut.fuchsia("[%H:%M:%S]")) LOGGER_HANDLER = logging.StreamHandler(sys.stdout) LOGGER_HANDLER.setFormatter(formatter) LOGGER.addHandler(LOGGER_HANDLER) LOGGER.setLevel(LoggingLevel.WARNING) class MY_LOGGER: def info(msg): return LOGGER.log(LoggingLevel.SYSINFO, msg)