mirror of
https://github.com/codingo/Interlace.git
synced 2025-12-17 06:44:23 +01:00
Added libs
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,7 +15,6 @@ dist/
|
|||||||
downloads/
|
downloads/
|
||||||
eggs/
|
eggs/
|
||||||
.eggs/
|
.eggs/
|
||||||
lib/
|
|
||||||
lib64/
|
lib64/
|
||||||
parts/
|
parts/
|
||||||
sdist/
|
sdist/
|
||||||
|
|||||||
0
Interlace/lib/__init__.py
Normal file
0
Interlace/lib/__init__.py
Normal file
0
Interlace/lib/core/__init__.py
Normal file
0
Interlace/lib/core/__init__.py
Normal file
2
Interlace/lib/core/__version__.py
Normal file
2
Interlace/lib/core/__version__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
__version__ = '0.01'
|
||||||
|
|
||||||
112
Interlace/lib/core/input.py
Normal file
112
Interlace/lib/core/input.py
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
from argparse import ArgumentParser
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
|
||||||
|
class InputHelper(object):
|
||||||
|
@staticmethod
|
||||||
|
def readable_file(parser, arg):
|
||||||
|
if not os.path.exists(arg):
|
||||||
|
parser.error("The file %s does not exist!" % arg)
|
||||||
|
else:
|
||||||
|
return open(arg, 'r') # return an open file handle
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def process_targets(arguments):
|
||||||
|
targets = set()
|
||||||
|
|
||||||
|
if arguments.target:
|
||||||
|
targets.add(arguments.target)
|
||||||
|
else:
|
||||||
|
for target in arguments.target_list:
|
||||||
|
targets.add(target.strip())
|
||||||
|
|
||||||
|
return targets
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def process_commands(arguments):
|
||||||
|
commands = set()
|
||||||
|
|
||||||
|
if arguments.command:
|
||||||
|
commands.add(arguments.target)
|
||||||
|
else:
|
||||||
|
for command in arguments.command_list:
|
||||||
|
commands.add(command.strip())
|
||||||
|
|
||||||
|
return commands
|
||||||
|
|
||||||
|
class InputParser(object):
|
||||||
|
def __init__(self):
|
||||||
|
self._parser = self.setup_parser()
|
||||||
|
|
||||||
|
def parse(self, argv):
|
||||||
|
return self._parser.parse_args(argv)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def setup_parser():
|
||||||
|
parser = ArgumentParser()
|
||||||
|
|
||||||
|
targets = parser.add_mutually_exclusive_group(required=True)
|
||||||
|
|
||||||
|
targets.add_argument(
|
||||||
|
'-t', dest='target', required=False,
|
||||||
|
help='Specify a target or domain name.'
|
||||||
|
)
|
||||||
|
|
||||||
|
targets.add_argument(
|
||||||
|
'-tL', dest='target_list', required=False,
|
||||||
|
help='Specify a list of targets or domain names.',
|
||||||
|
metavar="FILE",
|
||||||
|
type=lambda x: InputHelper.readable_file(parser, x)
|
||||||
|
)
|
||||||
|
|
||||||
|
commands = parser.add_mutually_exclusive_group(required=True)
|
||||||
|
commands.add_argument(
|
||||||
|
'-c', dest='command',
|
||||||
|
help='Specify a single command to execute.'
|
||||||
|
)
|
||||||
|
|
||||||
|
commands.add_argument(
|
||||||
|
'-cL', dest='command_list', required=False,
|
||||||
|
help='Specify a list of commands to execute',
|
||||||
|
metavar="FILE",
|
||||||
|
type=lambda x: InputHelper.readable_file(parser, x)
|
||||||
|
)
|
||||||
|
|
||||||
|
output = parser.add_mutually_exclusive_group()
|
||||||
|
output.add_argument(
|
||||||
|
'-oN', dest='output_normal',
|
||||||
|
help='Normal output printed to a file when the -oN option is '
|
||||||
|
'specified with a filename argument.'
|
||||||
|
)
|
||||||
|
|
||||||
|
output.add_argument(
|
||||||
|
'-oJ', dest='output_json',
|
||||||
|
help='JSON output printed to a file when the -oJ option is '
|
||||||
|
'specified with a filename argument.'
|
||||||
|
)
|
||||||
|
|
||||||
|
output.add_argument(
|
||||||
|
'-oG', dest='output_grepable',
|
||||||
|
help='Grepable output printed to a file when the -oG option is '
|
||||||
|
'specified with a filename argument.'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--no-color', dest='nocolor', action='store_true', default=False,
|
||||||
|
help='If set then any foreground or background colours will be '
|
||||||
|
'stripped out.'
|
||||||
|
)
|
||||||
|
|
||||||
|
output_types = parser.add_mutually_exclusive_group()
|
||||||
|
output_types.add_argument(
|
||||||
|
'-v', '--verbose', dest='verbose', action='store_true', default=False,
|
||||||
|
help='If set then verbose output will be displayed in the terminal.'
|
||||||
|
)
|
||||||
|
output_types.add_argument(
|
||||||
|
'--silent', dest='silent', action='store_true', default=False,
|
||||||
|
help='If set only findings will be displayed and banners '
|
||||||
|
'and other information will be redacted.'
|
||||||
|
)
|
||||||
|
|
||||||
|
return parser
|
||||||
54
Interlace/lib/core/output.py
Normal file
54
Interlace/lib/core/output.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
from colorclass import Color
|
||||||
|
from colorclass import disable_all_colors, enable_all_colors, is_enabled
|
||||||
|
from time import localtime, strftime
|
||||||
|
from lib.core.__version__ import __version__
|
||||||
|
from enum import IntEnum
|
||||||
|
|
||||||
|
class OutputHelper(object):
|
||||||
|
def __init__(self, arguments):
|
||||||
|
if arguments.nocolor:
|
||||||
|
disable_all_colors()
|
||||||
|
|
||||||
|
self.verbose = arguments.verbose
|
||||||
|
self.silent = arguments.silent
|
||||||
|
self.seperator = "=============================================="
|
||||||
|
|
||||||
|
def print_banner(self):
|
||||||
|
if self.silent:
|
||||||
|
return
|
||||||
|
|
||||||
|
print(self.seperator)
|
||||||
|
print("Interlace v%s\tby Michael Skelton (@codingo_)" % __version__)
|
||||||
|
print(self.seperator)
|
||||||
|
|
||||||
|
def terminal(self, level, target, command, message=""):
|
||||||
|
if level == 0 and not self.verbose:
|
||||||
|
return
|
||||||
|
|
||||||
|
formatting = {
|
||||||
|
0: Color('{autoblue}[VERBOSE]{/autoblue}'),
|
||||||
|
1: Color('{autogreen}[THREAD]{/autogreen}'),
|
||||||
|
3: Color('{autobgyellow}{autored}[ERROR]{/autobgyellow}{/autored}')
|
||||||
|
}
|
||||||
|
|
||||||
|
leader = formatting.get(level, '[#]')
|
||||||
|
|
||||||
|
format_args = {
|
||||||
|
'time': strftime("%H:%M:%S", localtime()),
|
||||||
|
'target': target,
|
||||||
|
'command': command,
|
||||||
|
'message': message,
|
||||||
|
'leader':leader
|
||||||
|
}
|
||||||
|
|
||||||
|
if level == 1:
|
||||||
|
template = '[{time}] {leader} [{target}] {command} {message}'
|
||||||
|
else:
|
||||||
|
template = '[{time}] {leader} [{target}] {command} {message}'
|
||||||
|
|
||||||
|
print(template.format(**format_args))
|
||||||
|
|
||||||
|
class Level(IntEnum):
|
||||||
|
VERBOSE = 0
|
||||||
|
THREAD = 1
|
||||||
|
ERROR = 3
|
||||||
Reference in New Issue
Block a user