Author: HarmJ0y, borrowed from Empire Change text color for the Linux terminal.
(string, color=None)
| 139 | |
| 140 | #------------------------------------------------------------------------ |
| 141 | def 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 |
no outgoing calls
no test coverage detected