MCPcopy
hub / github.com/Threekiii/Awesome-Redteam / color

Function color

scripts/ShellcodeWrapper/shellcode_encoder_py3.py:141–174  ·  view source on GitHub ↗

Author: HarmJ0y, borrowed from Empire Change text color for the Linux terminal.

(string, color=None)

Source from the content-addressed store, hash-verified

139
140#------------------------------------------------------------------------
141def color(string, color=None):
142 """
143 Author: HarmJ0y, borrowed from Empire
144 Change text color for the Linux terminal.
145 """
146
147 attr = []
148 # bold
149 attr.append('1')
150
151 if color:
152 if color.lower() == "red":
153 attr.append('31')
154 elif color.lower() == "green":
155 attr.append('32')
156 elif color.lower() == "blue":
157 attr.append('34')
158 return '\x1b[%sm%s\x1b[0m' % (';'.join(attr), string)
159
160 else:
161 if string.strip().startswith("[!]"):
162 attr.append('31')
163 return '\x1b[%sm%s\x1b[0m' % (';'.join(attr), string)
164 elif string.strip().startswith("[+]"):
165 attr.append('32')
166 return '\x1b[%sm%s\x1b[0m' % (';'.join(attr), string)
167 elif string.strip().startswith("[?]"):
168 attr.append('33')
169 return '\x1b[%sm%s\x1b[0m' % (';'.join(attr), string)
170 elif string.strip().startswith("[*]"):
171 attr.append('34')
172 return '\x1b[%sm%s\x1b[0m' % (';'.join(attr), string)
173 else:
174 return string
175
176#======================================================================================================
177# MAIN FUNCTION

Callers 5

convertFromTemplateFunction · 0.85
formatCPPFunction · 0.85
formatCSharpFunction · 0.85
formatPyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected