Skip to content

Commit

Permalink
add console
Browse files Browse the repository at this point in the history
  • Loading branch information
LoRexxar committed Sep 9, 2020
1 parent 86095f4 commit cb7bfde
Show file tree
Hide file tree
Showing 8 changed files with 1,593 additions and 10 deletions.
9 changes: 8 additions & 1 deletion Kunlun_M/settings.py.bak
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,11 @@ EXAMPLES_PATH = os.path.join(TESTS_PATH, 'examples')
RULES_PATH = os.path.join(PROJECT_DIRECTORY, 'rules')
CONFIG_PATH = os.path.join(PROJECT_DIRECTORY, 'config')


# check platform
PLATFORM = "Linux"
if "Windows" in platform.system():
PLATFORM = "windows"
elif "Linux" in platform.system():
PLATFORM = "linux"
elif "Darwin" in platform.system():
PLATFORM = "mac"
23 changes: 22 additions & 1 deletion core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from .__version__ import __copyright__, __epilog__, __scan_epilog__

from core.rule import RuleCheck, TamperCheck
from core.console import KunlunInterpreter
from web.index.models import ScanTask

try:
Expand Down Expand Up @@ -71,7 +72,14 @@ def main():
help='show all rules & tanmpers')

parser_group_show.add_argument('-k', '--key', dest='listkey', action='store', default="all",
help='key for show rule & tamper')
help='key for show rule & tamper. eg: 1001/wordpress')

parser_group_console = subparsers.add_parser('console', help='enter console mode',
description=__introduction__.format(detail='enter console mode'),
formatter_class=argparse.RawDescriptionHelpFormatter,
usage=argparse.SUPPRESS, add_help=True)
parser_group_console.add_argument('console', action='store_true', default=True,
help='enter console mode')

args = parser.parse_args()

Expand Down Expand Up @@ -114,10 +122,23 @@ def main():
logger.info("[INIT] TamperRecover finished.")
exit()

else:
parser_group_core.print_help()
exit()

if hasattr(args, "list"):
if args.list:
logger.info("Show {}:\n{}".format(args.list, show_info(args.list, args.listkey.strip(""))))
exit()
else:
parser_group_show.print_help()
exit()

if hasattr(args, "console"):
logger.info("[INIT] Enter KunLun-M console mode.")
shell = KunlunInterpreter()
shell.start()
exit()

if not hasattr(args, "target") or args.target == '':
parser.print_help()
Expand Down
7 changes: 4 additions & 3 deletions core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import os
import codecs
import pprint
from prettytable import PrettyTable

from .detection import Detection
Expand Down Expand Up @@ -332,11 +333,11 @@ def list_parse(rules_path, istamp=False):
{}
Filter Func:
{}
{}
Input Control:
{}
""".format(tampname, filter_func, input_control)
{}
""".format(tampname, pprint.pformat(filter_func, indent=4), pprint.pformat(input_control, indent=4))
else:
logger.error("[Info] no tamper name {]".format(key))

Expand Down
Loading

0 comments on commit cb7bfde

Please sign in to comment.