Skip to content

Commit c27843c

Browse files
committed
加入终端颜色
1 parent eb36618 commit c27843c

File tree

8 files changed

+33
-20
lines changed

8 files changed

+33
-20
lines changed

config.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,4 @@
4545

4646
# DEBUG
4747
DEBUG = True
48-
# EXCLUDE_PLUGINS = ['subdomain_found.py', 'jsonp.py', 'js_sensitive_content.py'
49-
# ]
50-
# INCLUDE_PLUGINS = ['sql_inject_bool.py']
51-
# THREAD_NUM = 1
48+
# EXCLUDE_PLUGINS = ['subdomain_found.py', 'jsonp.py', 'js_sensitive_content.py']

lib/data.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
# @Time : 2019/6/28 12:47 PM
44
# @Author : w8ay
55
# @File : data.py
6-
import logging
76

87
from lib.datatype import _ThreaData
8+
from lib.log import LOGGER
99

10-
logging.basicConfig(level=logging.INFO,
11-
format='[%(asctime)s] %(levelname)s %(message)s',
12-
datefmt='%Y-%m-%d %H:%M:%S')
1310

14-
logger = logging
11+
logger = LOGGER
1512
PATH = dict() # 全局路径
1613
KB = dict()
1714
Share = _ThreaData()

lib/datatype.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@
33
# @Time : 2019/6/29 12:27 AM
44
# @Author : w8ay
55
# @File : datatype.py
6-
import threading
76
import logging
8-
from urllib.parse import urlparse
7+
import threading
98

109
from lib.common import dataToStdout
1110

12-
logging.basicConfig(level=logging.INFO,
13-
format='[%(asctime)s] %(levelname)s %(message)s',
14-
datefmt='%Y-%m-%d %H:%M:%S')
15-
1611

1712
class _ThreaData(object):
1813

lib/log.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
# @Time : 2019/7/25 10:08 PM
4+
# @Author : w8ay
5+
# @File : log.py
6+
import logging
7+
8+
FORMATTER = logging.Formatter("\r[%(asctime)s] [%(levelname)s] %(message)s", "%H:%M:%S")
9+
LOGGER = logging.getLogger('w13scan')
10+
LOGGER.setLevel(logging.INFO)
11+
LOGGER_HANDLER = logging.StreamHandler()
12+
LOGGER_HANDLER.setFormatter(FORMATTER)
13+
LOGGER.addHandler(LOGGER_HANDLER)

lib/option.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import time
1010
from queue import Queue
1111

12+
from colorama import Fore
13+
1214
from config import EXCLUDE_PLUGINS, INCLUDE_PLUGINS, SERVER_ADDR, DEBUG, INCLUDES, EXCLUDES, THREAD_NUM, LEVEL, TIMEOUT, \
1315
RETRY, PROXY_CONFIG, ACTIVE_SCAN, PROXY_CONFIG_BOOL
1416
from lib.common import dataToStdout
@@ -168,4 +170,5 @@ def banner():
168170
  \  /\  /
169171
   ︶  ︶
170172
'''
171-
dataToStdout(_.format(version=VERSION, git=REPOSITORY))
173+
174+
dataToStdout(Fore.GREEN + _.format(version=VERSION, git=REPOSITORY))

lib/output.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
from threading import Lock
88

9+
from colorama import Fore
10+
911
from lib.data import Share, KB
1012

1113

@@ -41,7 +43,7 @@ def success(self, url, plugin='unknown', **kw):
4143
report.update(kw)
4244
self.lock.acquire()
4345
self.collect.append(report)
44-
self.log("[{}] ".format(report["plugin"]))
46+
self.log("[{}] ".format(report["plugin"]), Fore.RED)
4547
del report["plugin"]
4648
raw = None
4749
if "raw" in report:
@@ -67,7 +69,7 @@ def success(self, url, plugin='unknown', **kw):
6769
index += 1
6870
self.lock.release()
6971

70-
def log(self, msg):
72+
def log(self, msg, color=Fore.YELLOW):
7173
width = KB["console_width"][0]
7274
outputs = []
7375
msgs = msg.split('\n')
@@ -80,7 +82,7 @@ def log(self, msg):
8082
line = line[width:]
8183
outputs.append(line)
8284
for i in outputs:
83-
Share.dataToStdout('\r' + i + ' ' * (width - len(i)) + '\n\r')
85+
Share.dataToStdout('\r' + color + i + ' ' * (width - len(i)) + '\n\r')
8486

8587
def output(self):
8688
'''

main.py

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import signal
33
import threading
44

5+
from colorama import deinit, init as cinit, Style, Fore, Back
6+
57
from lib.baseproxy import AsyncMitmProxy
68
from lib.cmdparse import cmd_line_parser
79
from lib.controller import start
@@ -12,7 +14,9 @@
1214
def main():
1315
# init
1416
root = os.path.dirname(os.path.abspath(__file__))
17+
cinit(autoreset=True)
1518
banner()
19+
1620
cmdline = cmd_line_parser().__dict__
1721
init(root, cmdline)
1822
if conf["show_version"]:
@@ -30,6 +34,7 @@ def main():
3034
baseproxy.serve_forever()
3135
except KeyboardInterrupt:
3236
print("\n[*] User quit")
37+
deinit()
3338
if not KB["is_win"]:
3439
os.kill(os.getpid(), signal.SIGHUP)
3540

requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ asn1crypto==0.24.0
22
certifi==2019.6.16
33
cffi==1.12.3
44
chardet==3.0.4
5+
colorama==0.4.1
56
cryptography==2.7
67
idna==2.8
78
pycparser==2.19
89
pyOpenSSL==18.0.0
910
requests==2.22.0
1011
six==1.12.0
12+
tld==0.9.3
1113
urllib3==1.25.3
12-
tld==0.9.3

0 commit comments

Comments
 (0)