# Path: lib/core/data.py

# 
# Path: lib/core/enums.py
# class TARGET_MODE_STATUS:
#     FILE = 9
#     SINGLE = 8
#     IPMASK = 7
#     RANGE = 6
#     API = 5
# 
# class ENGINE_MODE_STATUS:
#     THREAD = 9
#     GEVENT = 8
# 
# Path: lib/core/enums.py
# class API_MODE_NAME:
#     ZOOMEYE = 'ZoomEye'
#     BAIDU = 'Baidu'
# 
# Path: lib/core/register.py
# class Register:
#     def __init__(self, start=1, stop=1, mutex_errmsg=None, mutex=True):
#         self.targets = []
#         self.mutex = mutex
#         self.start = start
#         self.stop = stop
#         self.mutex_errmsg = mutex_errmsg
#         self.verified = []
# 
#     def enable_mutex(self):
#         self.mutex = True
# 
#     def set_mutex_errmsg(self, s):
#         self.mutex_errmsg = str(s)
# 
#     def add(self, perform, trigger, args=(), kwargs=None):
#         if kwargs is None:
#             kwargs = {}
#         d = {'perform': perform, 'args': args, 'kwargs': kwargs, 'trigger': trigger}
#         self.targets.append(d)
#         self.__args = args
#         self.__kwargs = kwargs
# 
#     def run(self):
#         self.__pretreat()
#         for target in self.verified:
#             if not target.get('perform'):
#                 msg = 'Register has no verified target'
#                 raise RegisterDataException(msg)
#             target.get('perform')(*target.get('args'), **target.get('kwargs'))
# 
#     def __pretreat(self):
#         self.__input_vector_check()
#         for __target in self.targets:
#             __trigger = __target.get('trigger')
#             if type(__trigger) is types.BooleanType or type(__trigger) is types.StringType:
#                 if __trigger:
#                     self.verified.append(__target)
#             else:
#                 msg = '[Trigger Type Error] Expected:boolean,found:' + str(type(__trigger))
#                 raise RegisterValueException(msg)
#         self.__mutex_check()
# 
#     def __mutex_check(self):
#         if self.mutex:
#             if len(self.verified) < self.start or len(self.verified) > self.stop:
#                 if self.mutex_errmsg is None:
#                     raise RegisterMutexException('mutex error,verified func count: ' + str(len(self.verified)))
#                 else:
#                     sys.exit(logger.error(self.mutex_errmsg))
# 
#     def __input_vector_check(self):
#         if type(self.stop) is types.IntType and type(self.start) is types.IntType and type(
#                 self.mutex) is types.BooleanType:
#             pass
#         else:
#             raise RegisterValueException('Register init func type error')
#         if len(self.targets) is 0:
#             msg = 'no target'
#             raise RegisterDataException(msg)
#         if self.start > self.stop:
#             msg = 'start > stop'
#             raise RegisterDataException(msg)
# 
# Path: lib/core/common.py
# def dataToStdout(data, bold=False):
#     """
#     Writes text to the stdout (console) stream
#     """
#     logging._acquireLock()
#     if isinstance(data, unicode):
#         message = stdoutencode(data)
#     else:
#         message = data
# 
#     sys.stdout.write(setColor(message, bold))
# 
#     try:
#         sys.stdout.flush()
#     except IOError:
#         pass
# 
#     logging._releaseLock()
#     return


import os
import re
import glob #文件路径查找
import sys
from lib.core.data import conf, paths, th, logger
from lib.core.enums import TARGET_MODE_STATUS, ENGINE_MODE_STATUS
from lib.core.enums import API_MODE_NAME
from lib.core.register import Register
from lib.core.common import dataToStdout
from thirdparty.prettytable.prettytable import PrettyTable
        sys.exit(logger.error(msg))
    def __file(): #配置批量扫描文件路径
        if not os.path.isfile(input_file):
            msg = 'TargetFile not found: %s' % input_file
            sys.exit(logger.error(msg))
        conf.TARGET_MODE = TARGET_MODE_STATUS.FILE #conf.TAGET_MODE=9 -iF模式
        conf.INPUT_FILE_PATH = input_file

    def __cidr():
        conf.TARGET_MODE = TARGET_MODE_STATUS.IPMASK #conf.TARGET_MODE=7 -iN模式
        conf.NETWORK_STR = input_cidr
        conf.INPUT_FILE_PATH = None

    def __single():
        conf.TARGET_MODE = TARGET_MODE_STATUS.SINGLE #conf.TARGET_MODE=8 -iS模式
        conf.SINGLE_TARGET_STR = input_single
        th.THREADS_NUM = conf.THREADS_NUM = 1
        conf.INPUT_FILE_PATH = None

    def __zoomeye():
        conf.TARGET_MODE = TARGET_MODE_STATUS.API #conf.TARGET_MODE=5 API模式
        conf.API_MODE = API_MODE_NAME.ZOOMEYE #使用Zoomeye
        conf.API_DORK = api_zoomeye

    def __baidu():
        conf.TARGET_MODE = TARGET_MODE_STATUS.API #conf.TARGET_MODE=5 API模式
        conf.API_MODE = API_MODE_NAME.BAIDU #使用Baidu
        conf.API_DORK = api_baidu

    msg = 'Please load targets with [-t|-f|-c] or use API with [-zoomeye|-baidu]'

# Path: lib/core/data.py

# 
# Path: lib/core/enums.py
# class TARGET_MODE_STATUS:
#     FILE = 9
#     SINGLE = 8
#     IPMASK = 7
#     RANGE = 6
#     API = 5
# 
# class ENGINE_MODE_STATUS:
#     THREAD = 9
#     GEVENT = 8
# 
# Path: lib/core/enums.py
# class API_MODE_NAME:
#     ZOOMEYE = 'ZoomEye'
#     BAIDU = 'Baidu'
# 
# Path: lib/core/register.py
# class Register:
#     def __init__(self, start=1, stop=1, mutex_errmsg=None, mutex=True):
#         self.targets = []
#         self.mutex = mutex
#         self.start = start
#         self.stop = stop
#         self.mutex_errmsg = mutex_errmsg
#         self.verified = []
# 
#     def enable_mutex(self):
#         self.mutex = True
# 
#     def set_mutex_errmsg(self, s):
#         self.mutex_errmsg = str(s)
# 
#     def add(self, perform, trigger, args=(), kwargs=None):
#         if kwargs is None:
#             kwargs = {}
#         d = {'perform': perform, 'args': args, 'kwargs': kwargs, 'trigger': trigger}
#         self.targets.append(d)
#         self.__args = args
#         self.__kwargs = kwargs
# 
#     def run(self):
#         self.__pretreat()
#         for target in self.verified:
#             if not target.get('perform'):
#                 msg = 'Register has no verified target'
#                 raise RegisterDataException(msg)
#             target.get('perform')(*target.get('args'), **target.get('kwargs'))
# 
#     def __pretreat(self):
#         self.__input_vector_check()
#         for __target in self.targets:
#             __trigger = __target.get('trigger')
#             if type(__trigger) is types.BooleanType or type(__trigger) is types.StringType:
#                 if __trigger:
#                     self.verified.append(__target)
#             else:
#                 msg = '[Trigger Type Error] Expected:boolean,found:' + str(type(__trigger))
#                 raise RegisterValueException(msg)
#         self.__mutex_check()
# 
#     def __mutex_check(self):
#         if self.mutex:
#             if len(self.verified) < self.start or len(self.verified) > self.stop:
#                 if self.mutex_errmsg is None:
#                     raise RegisterMutexException('mutex error,verified func count: ' + str(len(self.verified)))
#                 else:
#                     sys.exit(logger.error(self.mutex_errmsg))
# 
#     def __input_vector_check(self):
#         if type(self.stop) is types.IntType and type(self.start) is types.IntType and type(
#                 self.mutex) is types.BooleanType:
#             pass
#         else:
#             raise RegisterValueException('Register init func type error')
#         if len(self.targets) is 0:
#             msg = 'no target'
#             raise RegisterDataException(msg)
#         if self.start > self.stop:
#             msg = 'start > stop'
#             raise RegisterDataException(msg)
# 
# Path: lib/core/common.py
# def dataToStdout(data, bold=False):
#     """
#     Writes text to the stdout (console) stream
#     """
#     logging._acquireLock()
#     if isinstance(data, unicode):
#         message = stdoutencode(data)
#     else:
#         message = data
# 
#     sys.stdout.write(setColor(message, bold))
# 
#     try:
#         sys.stdout.flush()
#     except IOError:
#         pass
# 
#     logging._releaseLock()
#     return


# Path: lib/core/option.py
import os
import re
import glob #文件路径查找
import sys
from lib.core.data import conf, paths, th, logger
from lib.core.enums import TARGET_MODE_STATUS, ENGINE_MODE_STATUS
from lib.core.enums import API_MODE_NAME
from lib.core.register import Register
from lib.core.common import dataToStdout
from thirdparty.prettytable.prettytable import PrettyTable

        sys.exit(logger.error(msg))
    def __file(): #配置批量扫描文件路径
        if not os.path.isfile(input_file):
            msg = 'TargetFile not found: %s' % input_file
            sys.exit(logger.error(msg))
        conf.TARGET_MODE = TARGET_MODE_STATUS.FILE #conf.TAGET_MODE=9 -iF模式
        conf.INPUT_FILE_PATH = input_file

    def __cidr():
        conf.TARGET_MODE = TARGET_MODE_STATUS.IPMASK #conf.TARGET_MODE=7 -iN模式
        conf.NETWORK_STR = input_cidr
        conf.INPUT_FILE_PATH = None

    def __single():
        conf.TARGET_MODE = TARGET_MODE_STATUS.SINGLE #conf.TARGET_MODE=8 -iS模式
        conf.SINGLE_TARGET_STR = input_single
        th.THREADS_NUM = conf.THREADS_NUM = 1
        conf.INPUT_FILE_PATH = None

    def __zoomeye():
        conf.TARGET_MODE = TARGET_MODE_STATUS.API #conf.TARGET_MODE=5 API模式
        conf.API_MODE = API_MODE_NAME.ZOOMEYE #使用Zoomeye
        conf.API_DORK = api_zoomeye

    def __baidu():
        conf.TARGET_MODE = TARGET_MODE_STATUS.API #conf.TARGET_MODE=5 API模式
        conf.API_MODE = API_MODE_NAME.BAIDU #使用Baidu
        conf.API_DORK = api_baidu

    msg = 'Please load targets with [-t|-f|-c] or use API with [-zoomeye|-baidu]'

    r = Register(mutex=True, mutex_errmsg=msg)