cryptosploit.cprint
View Source
0class SGR: 1 """Styling class with constants.""" 2 TEMPLATE = "\x1b[{}m" 3 CLEAR = TEMPLATE.format("0") 4 5 @staticmethod 6 def format(s): 7 return SGR.TEMPLATE.format(s) 8 9 class STYLES: 10 NORMAL = "0" 11 BOLD = "1" 12 LIGHT = "2" 13 ITALIC = "3" 14 UNDERLINE = "4" 15 BLINK = "5" 16 17 class COLOR: 18 class FOREGROUND: 19 BLACK = "30" 20 RED = "31" 21 GREEN = "32" 22 YELLOW = "33" 23 BLUE = "34" 24 PURPLE = "35" 25 CYAN = "36" 26 WHITE = "37" 27 28 class BACKGROUND: 29 BLACK = "40" 30 RED = "41" 31 GREEN = "42" 32 YELLOW = "43" 33 BLUE = "44" 34 PURPLE = "45" 35 CYAN = "46" 36 WHITE = "47" 37 38 39def colorize_strings(*strings, styles=[], fg="", bg="", sep=" "): 40 """ 41 With colorize_strings you can change 42 strings style, color (fg), color of background (bg). 43 Use SGR class for styling. 44 """ 45 template = "" 46 if styles: 47 template += SGR.format(";".join(styles)) 48 if fg: 49 template += SGR.format(fg) 50 if bg: 51 template += SGR.format(bg) 52 template += "{}" + SGR.CLEAR 53 return template.format(sep.join(map(template.format, strings))) 54 55 56class Printer: 57 """ 58 Class for printing of any information. 59 Use it to colorize the output of your module. 60 """ 61 @staticmethod 62 def info(*strings, sep=" "): 63 """Print cyan string with '[>]' prefix.""" 64 prefix = colorize_strings("[>]", sep.join(strings), fg=SGR.COLOR.FOREGROUND.CYAN) 65 print(prefix) 66 67 @staticmethod 68 def error(*strings, sep=" "): 69 """Print red string with '[!]' prefix.""" 70 s = colorize_strings( 71 colorize_strings("[!]", styles=[SGR.STYLES.BLINK]), 72 sep.join(strings), 73 fg=SGR.COLOR.FOREGROUND.RED, 74 ) 75 print(s) 76 77 @staticmethod 78 def exec(*strings, sep=" "): 79 """Print yellow string with '[*]' prefix.""" 80 prefix = colorize_strings("[*]", sep.join(strings), fg=SGR.COLOR.FOREGROUND.YELLOW) 81 print(prefix) 82 83 @staticmethod 84 def positive(*strings, sep=" "): 85 """Print green string with '[+]' prefix.""" 86 prefix = colorize_strings("[+]", sep.join(strings), fg=SGR.COLOR.FOREGROUND.GREEN) 87 print(prefix) 88 89 @staticmethod 90 def negative(*strings, sep=" "): 91 """Print red string with '[-]' prefix.""" 92 prefix = colorize_strings("[-]", sep.join(strings), fg=SGR.COLOR.FOREGROUND.RED) 93 print(prefix)
View Source
1class SGR: 2 """Styling class with constants.""" 3 TEMPLATE = "\x1b[{}m" 4 CLEAR = TEMPLATE.format("0") 5 6 @staticmethod 7 def format(s): 8 return SGR.TEMPLATE.format(s) 9 10 class STYLES: 11 NORMAL = "0" 12 BOLD = "1" 13 LIGHT = "2" 14 ITALIC = "3" 15 UNDERLINE = "4" 16 BLINK = "5" 17 18 class COLOR: 19 class FOREGROUND: 20 BLACK = "30" 21 RED = "31" 22 GREEN = "32" 23 YELLOW = "33" 24 BLUE = "34" 25 PURPLE = "35" 26 CYAN = "36" 27 WHITE = "37" 28 29 class BACKGROUND: 30 BLACK = "40" 31 RED = "41" 32 GREEN = "42" 33 YELLOW = "43" 34 BLUE = "44" 35 PURPLE = "45" 36 CYAN = "46" 37 WHITE = "47"
Styling class with constants.
View Source
View Source
18 class COLOR: 19 class FOREGROUND: 20 BLACK = "30" 21 RED = "31" 22 GREEN = "32" 23 YELLOW = "33" 24 BLUE = "34" 25 PURPLE = "35" 26 CYAN = "36" 27 WHITE = "37" 28 29 class BACKGROUND: 30 BLACK = "40" 31 RED = "41" 32 GREEN = "42" 33 YELLOW = "43" 34 BLUE = "44" 35 PURPLE = "45" 36 CYAN = "46" 37 WHITE = "47"
View Source
View Source
View Source
40def colorize_strings(*strings, styles=[], fg="", bg="", sep=" "): 41 """ 42 With colorize_strings you can change 43 strings style, color (fg), color of background (bg). 44 Use SGR class for styling. 45 """ 46 template = "" 47 if styles: 48 template += SGR.format(";".join(styles)) 49 if fg: 50 template += SGR.format(fg) 51 if bg: 52 template += SGR.format(bg) 53 template += "{}" + SGR.CLEAR 54 return template.format(sep.join(map(template.format, strings)))
With colorize_strings you can change strings style, color (fg), color of background (bg). Use SGR class for styling.
View Source
57class Printer: 58 """ 59 Class for printing of any information. 60 Use it to colorize the output of your module. 61 """ 62 @staticmethod 63 def info(*strings, sep=" "): 64 """Print cyan string with '[>]' prefix.""" 65 prefix = colorize_strings("[>]", sep.join(strings), fg=SGR.COLOR.FOREGROUND.CYAN) 66 print(prefix) 67 68 @staticmethod 69 def error(*strings, sep=" "): 70 """Print red string with '[!]' prefix.""" 71 s = colorize_strings( 72 colorize_strings("[!]", styles=[SGR.STYLES.BLINK]), 73 sep.join(strings), 74 fg=SGR.COLOR.FOREGROUND.RED, 75 ) 76 print(s) 77 78 @staticmethod 79 def exec(*strings, sep=" "): 80 """Print yellow string with '[*]' prefix.""" 81 prefix = colorize_strings("[*]", sep.join(strings), fg=SGR.COLOR.FOREGROUND.YELLOW) 82 print(prefix) 83 84 @staticmethod 85 def positive(*strings, sep=" "): 86 """Print green string with '[+]' prefix.""" 87 prefix = colorize_strings("[+]", sep.join(strings), fg=SGR.COLOR.FOREGROUND.GREEN) 88 print(prefix) 89 90 @staticmethod 91 def negative(*strings, sep=" "): 92 """Print red string with '[-]' prefix.""" 93 prefix = colorize_strings("[-]", sep.join(strings), fg=SGR.COLOR.FOREGROUND.RED) 94 print(prefix)
Class for printing of any information. Use it to colorize the output of your module.
View Source
Print cyan string with '[>]' prefix.
View Source
Print red string with '[!]' prefix.
View Source
Print yellow string with '[*]' prefix.
View Source
Print green string with '[+]' prefix.
View Source
Print red string with '[-]' prefix.