-
Notifications
You must be signed in to change notification settings - Fork 139
/
Output.py
81 lines (72 loc) · 2.13 KB
/
Output.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/python
# -*- coding: utf-8 -*-
#PYTHON_TERMCOLOR_OK
try:
from termcolor import colored
TERMCOLOR_AVAILABLE = True
except ImportError:
TERMCOLOR_AVAILABLE = False
class Output ():
'''
All output except log used this object
'''
def __init__(self, args):
'''
CONSTRUCTOR
'''
self.args = args
self.noColor = args['no-color']
self.titlePos = 0
self.subTitlePos = 0
def bigTitle (self, m):
'''
print a title
'''
self.titlePos = 0
self.subTitlePos = 0
formatMesg = '\n[+] {1}: {2}'.format(self.titlePos,'({0}:{1})'.format(self.args['host'],self.args['port']),m)
if self.noColor == True or TERMCOLOR_AVAILABLE == False: print (formatMesg)
else : print (colored(formatMesg, 'white',attrs=['bold']))
def title (self, m):
'''
print a title
'''
self.titlePos += 1
self.subTitlePos = 0
formatMesg = '\n\n[{0}] {1}: {2}'.format(self.titlePos,'({0}:{1})'.format(self.args['host'],self.args['port']),m)
if self.noColor == True or TERMCOLOR_AVAILABLE == False: print (formatMesg)
else : print (colored(formatMesg, 'white',attrs=['bold']))
def subtitle (self, m):
'''
print a subtitle
'''
self.subTitlePos += 1
formatMesg = '[{0}.{1}] {2}'.format(self.titlePos, self.subTitlePos, m)
if self.noColor == True or TERMCOLOR_AVAILABLE == False: print (formatMesg)
else : print (colored(formatMesg, 'white',attrs=['bold']))
def badNews (self, m):
'''
print a stop message
'''
formatMesg = '[-] {0}'.format(m)
if self.noColor == True or TERMCOLOR_AVAILABLE == False: print (formatMesg)
else : print (colored(formatMesg, 'red',attrs=['bold']))
def goodNews(self,m):
'''
print good news
'''
formatMesg = '[+] {0}'.format(m)
if self.noColor == True or TERMCOLOR_AVAILABLE == False: print (formatMesg)
else : print (colored(formatMesg, 'green',attrs=['bold']))
def unknownNews(self,m):
'''
print unknow news
'''
formatMesg = '[+] {0}'.format(m)
if self.noColor == True or TERMCOLOR_AVAILABLE == False: print (formatMesg)
else : print (colored(formatMesg, 'yellow',attrs=['bold']))
def printOSCmdOutput(self,m):
'''
print the output of a OS command
'''
print (m)