Python colorama.Back.WHITE Examples

The following are 14 code examples of colorama.Back.WHITE(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module colorama.Back , or try the search function .
Example #1
Source File: munin-host.py    From munin with Apache License 2.0 6 votes vote down vote up
def print_highlighted(line, hl_color=Back.WHITE):
    """
    Print a highlighted line
    """
    try:
        # Highlight positives
        colorer = re.compile(r'([^\s]+) POSITIVES: ([1-9]) ')
        line = colorer.sub(Fore.YELLOW + r'\1 ' + 'POSITIVES: ' + Fore.YELLOW + r'\2 ' + Style.RESET_ALL, line)
        colorer = re.compile(r'([^\s]+) POSITIVES: ([0-9]+) ')
        line = colorer.sub(Fore.RED + r'\1 ' + 'POSITIVES: ' + Fore.RED + r'\2 ' + Style.RESET_ALL, line)
        # Keyword highlight
        colorer = re.compile(r'([A-Z_]{2,}:)\s', re.VERBOSE)
        line = colorer.sub(Fore.BLACK + hl_color + r'\1' + Style.RESET_ALL + ' ', line)
        print(line)
    except Exception as e:
        pass 
Example #2
Source File: munin_stdout.py    From munin with Apache License 2.0 6 votes vote down vote up
def printHighlighted(line, hl_color=Back.WHITE, tag_color=False):
    """
    Print a highlighted line
    """
    if tag_color:
        # Tags
        colorer = re.compile('(HARMLESS|SIGNED|MS_SOFTWARE_CATALOGUE|MSSOFT|SUCCESSFULLY\sCOMMENTED)', re.VERBOSE)
        line = colorer.sub(Fore.BLACK + Back.GREEN + r'\1' + Style.RESET_ALL + '', line)
        colorer = re.compile('(REVOKED|EXPLOIT|CVE-[0-9\-]+|OBFUSCATED|RUN\-FILE)', re.VERBOSE)
        line = colorer.sub(Fore.BLACK + Back.RED + r'\1' + Style.RESET_ALL + '', line)
        colorer = re.compile('(EXPIRED|VIA\-TOR|OLE\-EMBEDDED|RTF|ATTACHMENT|ASPACK|UPX|AUTO\-OPEN|MACROS)', re.VERBOSE)
        line = colorer.sub(Fore.BLACK + Back.YELLOW + r'\1' + Style.RESET_ALL + '', line)
    # Extras
    colorer = re.compile('(\[!\])', re.VERBOSE)
    line = colorer.sub(Fore.BLACK + Back.LIGHTMAGENTA_EX + r'\1' + Style.RESET_ALL + '', line)
    # Add line breaks
    colorer = re.compile('(ORIGNAME:)', re.VERBOSE)
    line = colorer.sub(r'\n\1', line)
    # Standard
    colorer = re.compile('([A-Z_]{2,}:)\s', re.VERBOSE)
    line = colorer.sub(Fore.BLACK + hl_color + r'\1' + Style.RESET_ALL + ' ', line)
    print(line) 
Example #3
Source File: vt-checker.py    From Loki with GNU General Public License v3.0 6 votes vote down vote up
def print_highlighted(line, hl_color=Back.WHITE):
    """
    Print a highlighted line
    """
    # Tags
    colorer = re.compile('(HARMLESS|SIGNED|MS_SOFTWARE_CATALOGUE)', re.VERBOSE)
    line = colorer.sub(Fore.BLACK + Back.GREEN + r'\1' + Style.RESET_ALL + ' ', line)
    colorer = re.compile('(SIG_REVOKED)', re.VERBOSE)
    line = colorer.sub(Fore.BLACK + Back.RED + r'\1' + Style.RESET_ALL + ' ', line)
    colorer = re.compile('(SIG_EXPIRED)', re.VERBOSE)
    line = colorer.sub(Fore.BLACK + Back.YELLOW + r'\1' + Style.RESET_ALL + ' ', line)
    # Extras
    colorer = re.compile('(\[!\])', re.VERBOSE)
    line = colorer.sub(Fore.BLACK + Back.CYAN + r'\1' + Style.RESET_ALL + ' ', line)
    # Standard
    colorer = re.compile('([A-Z_]{2,}:)\s', re.VERBOSE)
    line = colorer.sub(Fore.BLACK + hl_color + r'\1' + Style.RESET_ALL + ' ', line)
    print line 
Example #4
Source File: vt-checker-hosts.py    From Loki with GNU General Public License v3.0 6 votes vote down vote up
def print_highlighted(line, hl_color=Back.WHITE):
    """
    Print a highlighted line
    """
    try:
        # Highlight positives
        colorer = re.compile(r'([^\s]+) POSITIVES: ([1-9]) ')
        line = colorer.sub(Fore.YELLOW + r'\1 ' + 'POSITIVES: ' + Fore.YELLOW + r'\2 ' + Style.RESET_ALL, line)
        colorer = re.compile(r'([^\s]+) POSITIVES: ([0-9]+) ')
        line = colorer.sub(Fore.RED + r'\1 ' + 'POSITIVES: ' + Fore.RED + r'\2 ' + Style.RESET_ALL, line)
        # Keyword highlight
        colorer = re.compile(r'([A-Z_]{2,}:)\s', re.VERBOSE)
        line = colorer.sub(Fore.BLACK + hl_color + r'\1' + Style.RESET_ALL + ' ', line)
        print line
    except Exception, e:
        pass 
Example #5
Source File: metaforge.py    From Metaforge with GNU General Public License v3.0 6 votes vote down vote up
def credits():
	print("")
	print("")
	print("███╗   ███╗███████╗████████╗ █████╗ ███████╗ ██████╗ ██████╗  ██████╗ ███████╗")
	print("████╗ ████║██╔════╝╚══██╔══╝██╔══██╗██╔════╝██╔═══██╗██╔══██╗██╔════╝ ██╔════╝")
	print("██╔████╔██║█████╗     ██║   ███████║█████╗  ██║   ██║██████╔╝██║  ███╗█████╗  ")
	print("██║╚██╔╝██║██╔══╝     ██║   ██╔══██║██╔══╝  ██║   ██║██╔══██╗██║   ██║██╔══╝ ")
	print("██║ ╚═╝ ██║███████╗   ██║   ██║  ██║██║     ╚██████╔╝██║  ██║╚██████╔╝███████╗")
	print("╚═╝     ╚═╝╚══════╝   ╚═╝   ╚═╝  ╚═╝╚═╝      ╚═════╝ ╚═╝  ╚═╝ ╚═════╝ ╚══════╝")
	print("")
	print("")
	print(Fore.WHITE + "An OSINT Metadata analyzing tool that filters through tags and creates reports")
	print("Version 1.3")
	print(Style.RESET_ALL)
	print(Fore.GREEN + "Authors: Chris Morris & Collin Mockbee")
	print("github.com/chriswmorris/Metaforge")
	print()
	print("=========================================================")
	print(Style.RESET_ALL)
	print(Fore.RED + "Remember to place the files you wish to analyze in this directory!")
	print(Style.BRIGHT +"-->  "+ ROOT_DIR + "/media  <--")
	print(Style.RESET_ALL)
	input("Press [ENTER] to continue")
	print() 
Example #6
Source File: munin_stdout.py    From munin with Apache License 2.0 5 votes vote down vote up
def printKeyLine(line):
    """
    Print a given string as a separator line
    :param line:
    :return:
    """
    print(Fore.BLACK + Back.WHITE)
    print("{0}".format(line).ljust(80) + Style.RESET_ALL)
    print("") 
Example #7
Source File: generate.py    From scrapple with MIT License 5 votes vote down vote up
def execute_command(self):
        """
        The generate command uses `Jinja2 <http://jinja.pocoo.org/>`_ templates \
        to create Python scripts, according to the specification in the configuration \
        file. The predefined templates use the extract_content() method of the \
        :ref:`selector classes <implementation-selectors>` to implement linear extractors \
        and use recursive for loops to implement multiple levels of link crawlers. This \
        implementation is effectively a representation of the traverse_next() \
        :ref:`utility function <implementation-utils>`, using the loop depth to \
        differentiate between levels of the crawler execution. 

        According to the --output_type argument in the CLI input, the results are \
        written into a JSON document or a CSV document. 

        The Python script is written into <output_filename>.py - running this file \
        is the equivalent of using the Scrapple :ref:`run command <command-run>`. 

        """
        print(Back.GREEN + Fore.BLACK + "Scrapple Generate")
        print(Back.RESET + Fore.RESET)
        directory = os.path.join(scrapple.__path__[0], 'templates', 'scripts')
        with open(os.path.join(directory, 'generate.txt'), 'r') as f:
            template_content = f.read()
        template = Template(template_content)
        try:
            with open(self.args['<projectname>'] + '.json', 'r') as f:
                config = json.load(f)
            if self.args['--output_type'] == 'csv':
                from scrapple.utils.config import extract_fieldnames
                config['fields'] = str(extract_fieldnames(config))
            config['output_file'] = self.args['<output_filename>']
            config['output_type'] = self.args['--output_type']
            rendered = template.render(config=config)
            with open(self.args['<output_filename>'] + '.py', 'w') as f:
                f.write(rendered)
            print(Back.WHITE + Fore.RED + self.args['<output_filename>'], \
                  ".py has been created" + Back.RESET + Fore.RESET, sep="")
        except IOError:
            print(Back.WHITE + Fore.RED + self.args['<projectname>'], ".json does not ", \
                  "exist. Use ``scrapple genconfig``." + Back.RESET + Fore.RESET, sep="") 
Example #8
Source File: genconfig.py    From scrapple with MIT License 5 votes vote down vote up
def execute_command(self):
        """
        The genconfig command depends on predefined `Jinja2 <http://jinja.pocoo.org/>`_ \
        templates for the skeleton configuration files. Taking the --type argument from the \
        CLI input, the corresponding template file is used. 

        Settings for the configuration file, like project name, selector type and URL \
        are taken from the CLI input and using these as parameters, the template is \
        rendered. This rendered JSON document is saved as <project_name>.json.
        
        """
        print(Back.GREEN + Fore.BLACK + "Scrapple Genconfig")
        print(Back.RESET + Fore.RESET)
        directory = os.path.join(scrapple.__path__[0], 'templates', 'configs')
        with open(os.path.join(directory, self.args['--type'] + '.txt'), 'r') as f:
            template_content = f.read()
        print("\n\nUsing the", self.args['--type'], "template\n\n")
        template = Template(template_content)
        settings = {
            'projectname': self.args['<projectname>'],
            'selector_type': self.args['--selector'],
            'url': self.args['<url>'],
            'levels': int(self.args['--levels'])
        }
        rendered = template.render(settings=settings)
        with open(self.args['<projectname>'] + '.json', 'w') as f:
            rendered_data = json.loads(rendered)
            json.dump(rendered_data, f, indent=3)
        print(Back.WHITE + Fore.RED + self.args['<projectname>'], ".json has been created" \
            + Back.RESET + Fore.RESET, sep="") 
Example #9
Source File: internal.py    From cheat.sh with MIT License 5 votes vote down vote up
def _back_color(code):
    if code == 0 or (isinstance(code, str) and code.lower() == "white"):
        return Back.WHITE
    if code == 1 or (isinstance(code, str) and code.lower() == "cyan"):
        return Back.CYAN
    if code == 2 or (isinstance(code, str) and code.lower() == "red"):
        return Back.RED

    return Back.WHITE 
Example #10
Source File: lokilogger.py    From Loki with GNU General Public License v3.0 5 votes vote down vote up
def print_welcome(self):

        if self.caller == 'main':
            print(Back.GREEN + " ".ljust(79) + Back.BLACK + Fore.GREEN)

            print("      __   ____  __ ______                            ")
            print ("     / /  / __ \/ //_/  _/                            ")
            print ("    / /__/ /_/ / ,< _/ /                              ")
            print ("   /____/\____/_/|_/___/                              ")
            print ("      ________  _____  ____                           ")
            print ("     /  _/ __ \/ ___/ / __/______ ____  ___  ___ ____ ")
            print ("    _/ // /_/ / /__  _\ \/ __/ _ `/ _ \/ _ \/ -_) __/ ")
            print ("   /___/\____/\___/ /___/\__/\_,_/_//_/_//_/\__/_/    ")

            print (Fore.WHITE)
            print ("   Copyright by Florian Roth, Released under the GNU General Public License")
            print ("   Version %s" % __version__)
            print ("  ")
            print ("   DISCLAIMER - USE AT YOUR OWN RISK")
            print ("   Please report false positives via https://github.com/Neo23x0/Loki/issues")
            print ("  ")
            print (Back.GREEN + " ".ljust(79) + Back.BLACK)
            print (Fore.WHITE+''+Back.BLACK)

        else:
            print ("  ")
            print (Back.GREEN + " ".ljust(79) + Back.BLACK + Fore.GREEN)

            print ("  ")
            print ("  LOKI UPGRADER ")

            print ("  ")
            print (Back.GREEN + " ".ljust(79) + Back.BLACK)
            print (Fore.WHITE + '' + Back.BLACK) 
Example #11
Source File: demo06.py    From colorama with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def main():
    colorama.init()
    pos = lambda y, x: Cursor.POS(x, y)
    # draw a white border.
    print(Back.WHITE, end='')
    print('%s%s' % (pos(MINY, MINX), ' '*MAXX), end='')
    for y in range(MINY, 1+MAXY):
        print('%s %s ' % (pos(y, MINX), pos(y, MAXX)), end='')
    print('%s%s' % (pos(MAXY, MINX), ' '*MAXX), end='')
    # draw some blinky lights for a while.
    for i in range(PASSES):
        print('%s%s%s%s%s' % (pos(randint(1+MINY,MAXY-1), randint(1+MINX,MAXX-1)), choice(FORES), choice(BACKS), choice(STYLES), choice(CHARS)), end='')
    # put cursor to top, left, and set color to white-on-black with normal brightness.
    print('%s%s%s%s' % (pos(MINY, MINX), Fore.WHITE, Back.BLACK, Style.NORMAL), end='') 
Example #12
Source File: cli.py    From tmessage with GNU General Public License v3.0 4 votes vote down vote up
def main():
    """ Register a new User or Authenticates the already registered User to send message """
    try:
        if auth.check_existed(CURRENT_USER):
            password = getpass(f"User {CURRENT_USER} found\nEnter password: ")
            payload = auth.authenticate(CURRENT_USER, password)
        else:
            print(f"Welcome {CURRENT_USER} to tmessage!\nPlease register...")
            displayed_name = input("Enter your name used for display: ")
            password = getpass("Enter password: ")
            password_confirm = getpass("Re-enter password: ")
            while password != password_confirm:
                print("Passwords do not match, please try again...")
                password = getpass("Enter password: ")
                password_confirm = getpass("Re-enter password: ")
            payload = auth.register(
                CURRENT_USER, displayed_name, password, password_confirm
            )
        print("User Authorized")
        user_name = payload["user_name"]
        displayed_name = payload["displayed_name"]

        MQTT_CLIENT.on_message = on_message
        MQTT_CLIENT.connect(BROKER_ENDPOINT, BROKER_PORT)
        MQTT_CLIENT.subscribe(MQTT_TOPIC)
        MQTT_CLIENT.loop_start()
        while True:
            raw_msg = MESSAGE_INPUT.get_input()
            formatted_msg = get_formatted_message(raw_msg)
            pub_msg = f"[{user_name}] {displayed_name}: {formatted_msg}"
            if raw_msg != "":
                MQTT_CLIENT.publish(MQTT_TOPIC, pub_msg)
                if IS_STORE:
                    store_messages(CURRENT_USER, formatted_msg)
            else:
                print(Back.WHITE + Fore.RED + "Can't send empty message", end="\n")
    except KeyboardInterrupt:
        # pylint: disable=pointless-statement
        MQTT_CLIENT.disconnect()
        Style.RESET_ALL
        deinit()
        print("\nGoodbye!")
    except ConnectionRefusedError:
        # pylint: disable=pointless-statement
        Style.RESET_ALL
        deinit()
        print("\nCan't connect please check your network connection")
    except Exception as err:  # pylint: disable=broad-except
        # pylint: disable=pointless-statement
        Style.RESET_ALL
        deinit()
        print(f"\n{err}") 
Example #13
Source File: hugin.py    From munin with Apache License 2.0 4 votes vote down vote up
def main():
    init(autoreset=False)

    print(Style.RESET_ALL)
    print(Fore.BLACK + Back.WHITE)
    print("   _    _   _    _   ______  _____  ______   ".ljust(80))
    print("  | |  | | | |  | | | | ____  | |  | |  \ \   (.\\ ".ljust(80))
    print("  | |--| | | |  | | | |  | |  | |  | |  | |   |/(\\ ".ljust(80))
    print("  |_|  |_| \_|__|_| |_|__|_| _|_|_ |_|  |_|    \\ \\\\".ljust(80))
    print("                                               \" \"'\\  ".ljust(80))
    print(" ".ljust(80))
    print("  Result Checker for Virustotal Retrohunts".ljust(80))
    print(("  " + __AUTHOR__ + " - " + __VERSION__ + "").ljust(80))
    print(" ".ljust(80) + Style.RESET_ALL)
    print(Style.RESET_ALL + " ")

    parser = argparse.ArgumentParser(description='Retrohunt Checker')
    parser.add_argument('-r', help='Name for the queried retrohunt', metavar='retrohunt-name', default='')
    parser.add_argument('-i', help='Name of the ini file that holds the VT API key', metavar='ini-file',
                        default=os.path.dirname(os.path.abspath(__file__)) + '/munin.ini')
    parser.add_argument('--csv-path', help='Write a CSV with the results', default='retrohunt_results.csv')
    parser.add_argument('--debug', action='store_true', default=False, help='Debug output')
    parser.add_argument('--no-comments', help='Skip VirusTotal comments', action='store_true', default=False)
    
    args = parser.parse_args()

    # PyMISP error handling > into Nirvana
    logger = logging.getLogger("pymisp")
    logger.setLevel(logging.CRITICAL)
    if args.debug:
        logger.setLevel(logging.DEBUG)

    # Read the config file
    config = configparser.ConfigParser()
    try:
        config.read(args.i)
        munin_vt.VT_PUBLIC_API_KEY = config['DEFAULT']['VT_PUBLIC_API_KEY']
        try:
            connections.setProxy(config['DEFAULT']['PROXY'])
        except KeyError as e:
            print("[E] Your config misses the PROXY field - check the new munin.ini template and add it to your "
                  "config to avoid this error.")
    except Exception as e:
        traceback.print_exc()
        print("[E] Config file '%s' not found or missing field - check the template munin.ini if fields have "
              "changed" % args.i)

    print("[+] Retrieving Retrohunt results ...")
    found_files = munin_vt.getRetrohuntResults(args.r, args.no_comments, args.debug)
    print("[+] Retrohunt results retrieved")

    csv_filename = args.csv_path

    writeCSVHeader(csv_filename)

    for i, file_info in enumerate(found_files):
        printResult(file_info, i, len(found_files))
        writeCSV(file_info, csv_filename) 
Example #14
Source File: run.py    From scrapple with MIT License 4 votes vote down vote up
def execute_command(self):
        """
        The run command implements the web content extractor corresponding to the given \
        configuration file. 

        The execute_command() validates the input project name and opens the JSON \
        configuration file. The run() method handles the execution of the extractor run.

        The extractor implementation follows these primary steps :

        1. Selects the appropriate :ref:`selector class <implementation-selectors>` through \
        a dynamic dispatch, with the selector_type argument from the CLI input. 

        #. Iterate through the data section in level-0 of the configuration file. \
        On each data item, call the extract_content() method from the selector class to \
        extract the content according to the specified extractor rule. 

        #. If there are multiple levels of the extractor, i.e, if there is a 'next' \
        attribute in the configuration file, call the traverse_next() \
        :ref:`utility function <implementation-utils>` and parse through successive levels \
        of the configuration file.

        #. According to the --output_type argument, the result data is saved in a JSON \
        document or a CSV document. 

        """
        try:
            self.args['--verbosity'] = int(self.args['--verbosity'])
            if self.args['--verbosity'] not in [0, 1, 2]:
                raise ValueError
            if self.args['--verbosity'] > 0:
                print(Back.GREEN + Fore.BLACK + "Scrapple Run")
                print(Back.RESET + Fore.RESET)
            import json
            with open(self.args['<projectname>'] + '.json', 'r') as f:
                self.config = json.load(f)
            validate_config(self.config)
            self.run()
        except ValueError:
            print(Back.WHITE + Fore.RED + "Use 0, 1 or 2 for verbosity." \
                + Back.RESET + Fore.RESET, sep="")
        except IOError:
            print(Back.WHITE + Fore.RED + self.args['<projectname>'], ".json does not ", \
                  "exist. Use ``scrapple genconfig``." + Back.RESET + Fore.RESET, sep="")
        except InvalidConfigException as e:
            print(Back.WHITE + Fore.RED + e + Back.RESET + Fore.RESET, sep="")