-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskid.py
172 lines (147 loc) · 11.2 KB
/
skid.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
"""
Usage:
skid.py --help
skid.py ir --source <path> [--doxyconf <conf.json> -wnv -q -d]
Arguments:
ir interface-recovery
Options (interface-recovery):
--source -s=<path>
--doxyconf=<path.json>
Misc Options:
--dont-validate -d
--help -h
--verbose -v
--no-color -n
--write-log -w
--quite -q
"""
import logging
import random
import os
from typing import Dict
import colorlog
from docopt import docopt
from skid.interface_recovery.entry import start_interface_recovery
def setup_logger(colour=True, verbose=False, write_location="/tmp/skid.log") -> logging.Logger:
""" Sets up the root logger and it's formatters """
if colour:
fmt = "%(log_color)s%(levelname)-8s%(reset)s : %(white)s%(message)s"
else:
fmt = "%(levelname)-8s%(reset)s : %(message)s"
if verbose:
lvl = logging.DEBUG
else:
lvl = logging.INFO
formatter = colorlog.ColoredFormatter(
fmt, datefmt=None, reset=True,
log_colors={
'DEBUG': 'cyan',
'INFO': 'green',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'red',
}
)
logger = logging.getLogger("")
logger.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(formatter)
stream_handler.setLevel(lvl)
file_handler = logging.FileHandler(write_location, 'w+')
file_handler_formatter = logging.Formatter('%(levelname)-8s [%(filename)s:%(lineno)d] %(message)s')
file_handler.setFormatter(file_handler_formatter)
file_handler.setLevel(logging.DEBUG)
logger.addHandler(file_handler)
logger.addHandler(stream_handler)
return logger
def print_ascii():
""" print ASCII logo """
print(" ████████████████████████████████████")
print(" ██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒████")
print(" ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██████")
print(" ██▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██████")
print(" ██▒▒▓▓████████████████████████████▒▒▓▓██████")
print(" ██▒▒▓▓████████████████████████████▒▒▓▓██████")
print(" ██▒▒▓▓████████████████████████████▒▒▓▓██████")
print(" ██▒▒▓▓xxxxxxxxxxxxxxxxxxxxxxxxxxxx▒▒▓▓██████")
print(" ██▒▒▓▓ ███████╗██╗ ██╗██╗██████╗ ▒▒▓▓██████")
print(" ██▒▒▓▓ ██╔════╝██║ ██╔╝██║██╔══██╗▒▒▓▓██████")
print(" ██▒▒▓▓ ███████╗█████╔╝ ██║██║ ██║▒▒▓▓██████")
print(" ██▒▒▓▓ ╚════██║██╔═██╗ ██║██║ ██║▒▒▓▓██████")
print(" ██▒▒▓▓ ███████║██║ ██╗██║██████╔╝▒▒▓▓██████")
print(" ██▒▒▓▓ ╚══════╝╚═╝ ╚═╝╚═╝╚═════╝ ▒▒▓▓██████")
print(" ██▒▒▓▓xxxxxxxxxxxxxxxxxxxxxxxxxxxx▒▒▓▓██████")
print(" ██▒▒▓▓████████████████████████████▒▒▓▓██████")
print(" ██▒▒▓▓████████████████████████████▒▒▓▓██████")
print(" ██▒▒▓▓████████████████████████████▒▒▓▓██████")
print(" ██▒▒▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓██████")
print(" ██▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██████████")
print(" ██████████████████████████████████████████████▓▓██")
print(" ████████████████████████████████████████████▓▓████")
print(" ██████████████████████████████████████████████▓▓██████")
print(" ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████████")
print(" ██▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████████")
print(" ██▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████████████████▓▓▓▓████████")
print(" ██▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████████████████▓▓▓▓████████")
print(" ██▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▓▓▓▓▓▓▓████████")
print(" ██▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████████")
print(" ████████▒▒████▒▒████▒▒████▒▒████▒▒████▒▒████▒▒▒▒██████")
print(" ██▒▒████▒▒████▒▒████▒▒████▒▒████▒▒████▒▒████▒▒████████")
print(" ██▒▒██████████████████████████████████████████████████")
print("██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓████")
print("██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████")
print(" ████████████████████████████████████████████████")
def print_ascii2():
""" print ASCII logo 2"""
print(" ▒▒ ▒▒")
print(" ▒▒░░▒▒▒▒ ▒▒▒▒░░▒▒")
print(" ▓▓░░ ░░░░▒▒▓▓▒▒░░░░ ░░▒▒")
print(" ▓▓░░ ░░░░░░░░░░░░░░ ░░▒▒")
print(" ▒▒░░ ░░░░░░░░░░ ░░▒▒")
print(" ▒▒░░ ░░░░░░░░░░░░░░ ░░▒▒")
print(" ▒▒░░░░ ░░░░░░ ░░░░▒▒")
print(" ▒▒░░░░ ░░ ░░░░▒▒▒▒░░ ▒▒")
print(" ▒▒░░ ██ ▓▓ ▒▒▓▓ ▒▒ ░░")
print(" ▒▒░░░░ ░░░░▒▒ ▒▒ ▒▒")
print(" ▒▒░░ ██████ ░░▒▒ ▒▒░░ ▒▒")
print(" ▒▒░░ ██ ▒▒▓▓ ▒▒░░░░ ░░")
print(" ▒▒░░▒▒░░ ░░▒▒░░▒▒▒▒░░░░░░▒▒")
print(" ▒▒ ░░ ▓▓░░░░▒▒▒▒▒▒▒▒░░")
print(" ▒▒░░ ░░░░░░░░░░░░▒▒")
print(" ▒▒▒▒▒▒ ░░░░▒▒▒▒▒▒░░░░▒▒")
print(" ▒▒░░░░▓▓ ▒▒ ░░░░▒▒░░░░░░░░▒▒")
print(" ▒▒░░░░▒▒ ▒▒ ░░░░▒▒ ░░░░░░▒▒")
print(" ▒▒░░ ▓▓ ▒▒ ░░▒▒ ▒▒")
print(" ▒▒ ▒▒ ▒▒ ▒▒ ▒▒")
print(" ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒▒▒▒▒▒▒▒▒")
print(" ▒▒▓▓▒▒▒▒ ▓▓▒▒▒▒▒▒")
print("██▒▒▓▓xxxxxxxxxxxxxxxxxxxxxxxxxxxx▒▒▓▓██████")
print("██▒▒▓▓ ███████╗██╗ ██╗██╗██████╗ ▒▒▓▓██████")
print("██▒▒▓▓ ██╔════╝██║ ██╔╝██║██╔══██╗▒▒▓▓██████")
print("██▒▒▓▓ ███████╗█████╔╝ ██║██║ ██║▒▒▓▓██████")
print("██▒▒▓▓ ╚════██║██╔═██╗ ██║██║ ██║▒▒▓▓██████")
print("██▒▒▓▓ ███████║██║ ██╗██║██████╔╝▒▒▓▓██████")
print("██▒▒▓▓ ╚══════╝╚═╝ ╚═╝╚═╝╚═════╝ ▒▒▓▓██████")
print("██▒▒▓▓xxxxxxxxxxxxxxxxxxxxxxxxxxxx▒▒▓▓██████")
def main(arguments: Dict):
asciiarts = [print_ascii, print_ascii2]
asciiarts[random.randint(0, len(asciiarts)-1)]()
# print_ascii()
log = setup_logger(colour=not arguments["--no-color"], verbose=arguments["--verbose"])
try:
if arguments["ir"]:
start_interface_recovery(arguments)
else:
log.critical("No command mode found!!")
except Exception as e:
log.exception(e)
log.critical("An unexpected programing error occured")
log.warning("You can check the log file at /tmp/skid.log")
log.warning("Please file a bug report to -> https://github.com/luke-goddard/skid/issues/new")
log.info("Finished")
if __name__ == "__main__":
arguments = docopt(__doc__)
try:
main(arguments)
except KeyboardInterrupt:
os.system("killall doxygen")