mirror of
https://github.com/codingo/Interlace.git
synced 2025-12-17 23:04:24 +01:00
Merge branch 'master' into flat
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
from argparse import ArgumentParser
|
|
||||||
from math import ceil
|
|
||||||
from random import sample
|
|
||||||
|
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
from re import compile
|
||||||
|
from random import sample, choice
|
||||||
|
from math import ceil
|
||||||
from netaddr import IPNetwork, IPRange, IPGlob
|
from netaddr import IPNetwork, IPRange, IPGlob
|
||||||
|
|
||||||
from Interlace.lib.threader import Task
|
from Interlace.lib.threader import Task
|
||||||
@@ -11,12 +12,17 @@ from Interlace.lib.threader import Task
|
|||||||
|
|
||||||
class InputHelper(object):
|
class InputHelper(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def readable_file(parser, arg):
|
def check_path(parser, arg):
|
||||||
if not os.path.exists(arg):
|
if not os.path.exists(arg):
|
||||||
parser.error("The file %s does not exist!" % arg)
|
parser.error("The path %s does not exist!" % arg)
|
||||||
else:
|
else:
|
||||||
return open(arg, 'r') # return an open file handle
|
return arg
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def readable_file(parser, arg):
|
||||||
|
if InputHelper.check_path(parser, arg):
|
||||||
|
return open(arg, 'r') # return an open file handle
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_positive(parser, arg):
|
def check_positive(parser, arg):
|
||||||
ivalue = int(arg)
|
ivalue = int(arg)
|
||||||
@@ -25,6 +31,17 @@ class InputHelper(object):
|
|||||||
|
|
||||||
return arg
|
return arg
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_files_from_directory(arg):
|
||||||
|
files = list()
|
||||||
|
|
||||||
|
for file in os.listdir(arg):
|
||||||
|
location = os.path.join(arg, file)
|
||||||
|
if os.path.isfile(location):
|
||||||
|
files.append(location)
|
||||||
|
|
||||||
|
return files
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_ips_from_range(ip_range):
|
def _get_ips_from_range(ip_range):
|
||||||
ips = set()
|
ips = set()
|
||||||
@@ -80,7 +97,7 @@ class InputHelper(object):
|
|||||||
:param command_list:
|
:param command_list:
|
||||||
:param task_name: all tasks have 'scope' and all scopes have unique names, global scope defaults ''
|
:param task_name: all tasks have 'scope' and all scopes have unique names, global scope defaults ''
|
||||||
:param is_global_task: when True, signifies that all global tasks are meant to be run concurrently
|
:param is_global_task: when True, signifies that all global tasks are meant to be run concurrently
|
||||||
:return:
|
:return: list of possibly re-adjusted commands
|
||||||
"""
|
"""
|
||||||
task_block = []
|
task_block = []
|
||||||
sibling = None
|
sibling = None
|
||||||
@@ -172,6 +189,7 @@ class InputHelper(object):
|
|||||||
exclusions_ranges = set()
|
exclusions_ranges = set()
|
||||||
exclusions = set()
|
exclusions = set()
|
||||||
|
|
||||||
|
# removing the trailing slash if any
|
||||||
if arguments.output and arguments.output[-1] == "/":
|
if arguments.output and arguments.output[-1] == "/":
|
||||||
arguments.output = arguments.output[:-1]
|
arguments.output = arguments.output[:-1]
|
||||||
|
|
||||||
@@ -210,6 +228,10 @@ class InputHelper(object):
|
|||||||
if len(targets) == 0:
|
if len(targets) == 0:
|
||||||
raise Exception("No target provided, or empty target list")
|
raise Exception("No target provided, or empty target list")
|
||||||
|
|
||||||
|
if arguments.random:
|
||||||
|
files = InputHelper._get_files_from_directory(arguments.random)
|
||||||
|
random_file = choice(files)
|
||||||
|
|
||||||
if arguments.command:
|
if arguments.command:
|
||||||
commands.append(arguments.command.rstrip('\n'))
|
commands.append(arguments.command.rstrip('\n'))
|
||||||
else:
|
else:
|
||||||
@@ -223,6 +245,9 @@ class InputHelper(object):
|
|||||||
|
|
||||||
if arguments.realport:
|
if arguments.realport:
|
||||||
commands = InputHelper._replace_variable_with_commands(commands, "_realport_", real_ports)
|
commands = InputHelper._replace_variable_with_commands(commands, "_realport_", real_ports)
|
||||||
|
|
||||||
|
if arguments.random:
|
||||||
|
commands = InputHelper._replace_variable_for_commands(commands, "_random_", [random_file])
|
||||||
|
|
||||||
if arguments.output:
|
if arguments.output:
|
||||||
commands = InputHelper._replace_variable_with_commands(commands, "_output_", [arguments.output])
|
commands = InputHelper._replace_variable_with_commands(commands, "_output_", [arguments.output])
|
||||||
@@ -345,6 +370,12 @@ class InputParser(object):
|
|||||||
help='Specify a real port variable that can be used in commands as _realport_'
|
help='Specify a real port variable that can be used in commands as _realport_'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'-random', dest='random',
|
||||||
|
help='Specify a directory of files that can be randomly used in commands as _random_',
|
||||||
|
type=lambda x: InputHelper.check_path(parser, x)
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--no-cidr', dest='nocidr', action='store_true', default=False,
|
'--no-cidr', dest='nocidr', action='store_true', default=False,
|
||||||
help='If set then CIDR notation in a target file will not be automatically '
|
help='If set then CIDR notation in a target file will not be automatically '
|
||||||
|
|||||||
@@ -30,12 +30,13 @@ Dependencies will then be installed and Interlace will be added to your path as
|
|||||||
| -o | Specify an output folder variable that can be used in commands as \_output\_ |
|
| -o | Specify an output folder variable that can be used in commands as \_output\_ |
|
||||||
| -p | Specify a list of port variable that can be used in commands as \_port\_. This can be a single port, a comma delimited list, or use dash notation |
|
| -p | Specify a list of port variable that can be used in commands as \_port\_. This can be a single port, a comma delimited list, or use dash notation |
|
||||||
| -pL | Specify a list of proxies |
|
| -pL | Specify a list of proxies |
|
||||||
| --proto | Specify protocols that can be used in commands as \_proto\_ |
|
| --proto | Specify protocols that can be used in commands as \_proto\_ |
|
||||||
| -rp | Specify a real port variable that can be used in commands as \_realport\_ |
|
| -rp | Specify a real port variable that can be used in commands as \_realport\_ |
|
||||||
| --no-bar / --sober | If set then progress bar be stripped out |
|
| -random | Specify a directory of files that can be randomly used in commands as \_random\_ |
|
||||||
|
| --no-bar / --sober | If set then progress bar be stripped out |
|
||||||
| --no-cidr | If set then CIDR notation in a target file will not be automatically be expanded into individual hosts |
|
| --no-cidr | If set then CIDR notation in a target file will not be automatically be expanded into individual hosts |
|
||||||
| --no-color | If set then any foreground or background colours will be stripped out |
|
| --no-color | If set then any foreground or background colours will be stripped out |
|
||||||
| --silent | If set then only important information will be displayed and banners and other information will be redacted |
|
| --silent | If set then only important information will be displayed and banners and other information will be redacted |
|
||||||
| -v | If set then verbose output will be displayed in the terminal |
|
| -v | If set then verbose output will be displayed in the terminal |
|
||||||
|
|
||||||
## Further information regarding ports (-p)
|
## Further information regarding ports (-p)
|
||||||
@@ -62,6 +63,7 @@ The following variables will be replaced in commands at runtime:
|
|||||||
| \_port\_ | Replaced with the expanded port variable from interlace |
|
| \_port\_ | Replaced with the expanded port variable from interlace |
|
||||||
| \_realport\_ | Replaced with the real port variable from interlace |
|
| \_realport\_ | Replaced with the real port variable from interlace |
|
||||||
| \_proxy\_ | Replaced with the proxy list from interlace |
|
| \_proxy\_ | Replaced with the proxy list from interlace |
|
||||||
|
| \_random\_ | Replaced with the randomly-chosen file from interlace |
|
||||||
|
|
||||||
# Usage Examples
|
# Usage Examples
|
||||||
## Run Nikto Over Multiple Sites
|
## Run Nikto Over Multiple Sites
|
||||||
|
|||||||
Reference in New Issue
Block a user