示例#1
0
def client_check():
    # Setup hidden or not messages.
    ShellMessage.view = (False if any(
        i in ['STDOUT', 'FILESTDOUT']
        for i in clt_config['logfile']) else True)
    # Create log.
    logger_create(loggerclt, clt_config, mode='a')

    # Check cmid.
    if clt_config['cmid'] is not None:
        try:
            uuid.UUID(clt_config['cmid'])
        except ValueError:
            loggerclt.error("Bad CMID. Exiting...")
            sys.exit()

    # Check machineName.
    if clt_config['machineName'] is not None:
        if len(clt_config['machineName']) < 2 or len(
                clt_config['machineName']) > 63:
            loggerclt.error(
                "machineName must be between 2 and 63 characters in length.")
            sys.exit()

    clt_config['call_id'] = 1
示例#2
0
def server_check():
        # Check logfile.
        srv_config['logfile'] = check_logfile(srv_config['logfile'], srv_options['lfile']['def'], where = "srv")

        # Setup hidden or not messages.
        ShellMessage.view = ( False if any(i in ['STDOUT', 'FILESTDOUT'] for i in srv_config['logfile']) else True )

        # Create log.        
        logger_create(loggersrv, srv_config, mode = 'a')

        # Random HWID.
        if srv_config['hwid'] == "RANDOM":
                randomhwid = uuid.uuid4().hex
                srv_config['hwid'] = randomhwid[:16]
           
        # Sanitize HWID.
        hexstr = srv_config['hwid'].strip('0x')
        hexsub = re.sub(r'[^0-9a-fA-F]', '', hexstr)
        diff = set(hexstr).symmetric_difference(set(hexsub))

        if len(diff) != 0:
                diff = str(diff).replace('{', '').replace('}', '')
                pretty_printer(log_obj = loggersrv.error, to_exit = True,
                               put_text = "{reverse}{red}{bold}HWID '%s' is invalid. Digit %s non hexadecimal. Exiting...{end}" %(hexstr.upper(), diff))
        else:
                lh = len(hexsub)
                if lh % 2 != 0:
                        pretty_printer(log_obj = loggersrv.error, to_exit = True,
                                       put_text = "{reverse}{red}{bold}HWID '%s' is invalid. Hex string is odd length. Exiting...{end}" %hexsub.upper())
                elif lh < 16:
                        pretty_printer(log_obj = loggersrv.error, to_exit = True,
                                       put_text = "{reverse}{red}{bold}HWID '%s' is invalid. Hex string is too short. Exiting...{end}" %hexsub.upper())
                elif lh > 16:
                        pretty_printer(log_obj = loggersrv.error, to_exit = True,
                                       put_text = "{reverse}{red}{bold}HWID '%s' is invalid. Hex string is too long. Exiting...{end}" %hexsub.upper())
                else:
                        srv_config['hwid'] = binascii.a2b_hex(hexsub)

        # Check LCID.
        srv_config['lcid'] = check_lcid(srv_config['lcid'], loggersrv.warning)
                                
        # Check sqlite.
        try:
                import sqlite3            
        except:
                pretty_printer(log_obj = loggersrv.warning,
                               put_text = "{reverse}{yellow}{bold}Module 'sqlite3' is not installed, database support disabled.{end}")
                srv_config['dbSupport'] = False
        else:
                srv_config['dbSupport'] = True

        # Check port.
        if not 1 <= srv_config['port'] <= 65535:
                pretty_printer(log_obj = loggersrv.error, to_exit = True,
                               put_text = "{red}{bold}Port number '%s' is invalid. Enter between 1 - 65535. Exiting...{end}" %srv_config['port'])
示例#3
0
def server_check():
    # Setup hidden or not messages.
    ShellMessage.view = (False if any(
        i in ['STDOUT', 'FILESTDOUT']
        for i in srv_config['logfile']) else True)
    # Create log.
    logger_create(loggersrv, srv_config, mode='a')

    # Random HWID.
    if srv_config['hwid'] == "RANDOM":
        randomhwid = uuid.uuid4().hex
        srv_config['hwid'] = randomhwid[:16]

    # Sanitize HWID.
    hexstr = srv_config['hwid'].strip('0x')
    hexsub = re.sub(r'[^0-9a-fA-F]', '', hexstr)
    diff = set(hexstr).symmetric_difference(set(hexsub))

    if len(diff) != 0:
        pretty_errors(41, loggersrv, put_text=[hexstr.upper(), diff])
    else:
        lh = len(hexsub)
        if lh % 2 != 0:
            pretty_errors(42, loggersrv, put_text=hexsub.upper())
        elif lh < 16:
            pretty_errors(43, loggersrv, put_text=hexsub.upper())
        elif lh > 16:
            pretty_errors(44, loggersrv, put_text=hexsub.upper())
        else:
            srv_config['hwid'] = binascii.a2b_hex(hexsub)

    # Check LCID.
    srv_config['lcid'] = check_lcid(srv_config['lcid'], loggersrv)

    # Check sqlite.
    try:
        import sqlite3
    except:
        loggersrv.warning(
            "Module \"sqlite3\" is not installed, database support disabled.")
        srv_config['dbSupport'] = False
    else:
        srv_config['dbSupport'] = True

    # Check port.
    if not 1 <= srv_config['port'] <= 65535:
        pretty_errors(45, loggersrv, put_text=srv_config['port'])
示例#4
0
def client_check():
    # Check logfile.
    clt_config['logfile'] = check_logfile(clt_config['logfile'],
                                          clt_options['lfile']['def'],
                                          where="clt")

    # Setup hidden or not messages.
    ShellMessage.view = (False if any(
        i in ['STDOUT', 'FILESTDOUT']
        for i in clt_config['logfile']) else True)

    # Create log.
    logger_create(loggerclt, clt_config, mode='a')

    # Check cmid.
    if clt_config['cmid'] is not None:
        try:
            uuid.UUID(clt_config['cmid'])
        except ValueError:
            pretty_printer(
                log_obj=loggerclt.error,
                to_exit=True,
                where="clt",
                put_text="{reverse}{red}{bold}Bad CMID. Exiting...{end}")
    # Check machineName.
    if clt_config['machineName'] is not None:
        if len(clt_config['machineName']) < 2 or len(
                clt_config['machineName']) > 63:
            pretty_printer(
                log_obj=loggerclt.error,
                to_exit=True,
                where="clt",
                put_text=
                "{reverse}{red}{bold}machineName must be between 2 and 63 characters in length. Exiting...{end}"
            )

    clt_config['call_id'] = 1
示例#5
0
def server_check():
    # Setup hidden or not messages.
    ShellMessage.view = (False if srv_config['logfile'] == 'STDOUT' else True)
    # Create log.
    logger_create(loggersrv, srv_config, mode='a')

    # Random HWID.
    if srv_config['hwid'] == "RANDOM":
        randomhwid = uuid.uuid4().hex
        srv_config['hwid'] = randomhwid[:16]

    # Sanitize HWID.
    try:
        srv_config['hwid'] = binascii.a2b_hex(
            re.sub(r'[^0-9a-fA-F]', '', srv_config['hwid'].strip('0x')))
        if len(binascii.b2a_hex(srv_config['hwid'])) < 16:
            loggersrv.error(
                "HWID \"%s\" is invalid. Hex string is too short." %
                deco(binascii.b2a_hex(srv_config['hwid']), 'utf-8').upper())
            return
        elif len(binascii.b2a_hex(srv_config['hwid'])) > 16:
            loggersrv.error(
                "HWID \"%s\" is invalid. Hex string is too long." %
                deco(binascii.b2a_hex(srv_config['hwid']), 'utf-8').upper())
            return
    except TypeError:
        loggersrv.error(
            "HWID \"%s\" is invalid. Odd-length hex string." %
            deco(binascii.b2a_hex(srv_config['hwid']), 'utf-8').upper())
        return

    # Check LCID.
    # http://stackoverflow.com/questions/3425294/how-to-detect-the-os-default-language-in-python
    if not srv_config['lcid'] or (srv_config['lcid'] not in ValidLcid):
        if hasattr(sys,
                   'implementation') and sys.implementation.name == 'cpython':
            srv_config['lcid'] = 1033
        elif os.name == 'nt':
            import ctypes

            srv_config[
                'lcid'] = ctypes.windll.kernel32.GetUserDefaultUILanguage()
        else:
            import locale

            try:
                srv_config['lcid'] = next(
                    k for k, v in locale.windows_locale.items()
                    if v == locale.getdefaultlocale()[0])
            except StopIteration:
                srv_config['lcid'] = 1033

    # Check sqlite.
    try:
        import sqlite3
    except:
        loggersrv.warning(
            "Module \"sqlite3\" is not installed, database support disabled.")
        srv_config['dbSupport'] = False
    else:
        srv_config['dbSupport'] = True

    # Check port.
    try:
        p = srv_config['port']
        if p > 65535:
            loggersrv.error(
                'Please enter a valid port number between 1 - 65535')
            return
    except Exception as e:
        loggersrv.error('%s' % e)
        return