diff --git a/Interlace/lib/core/__version__.py b/Interlace/lib/core/__version__.py index 71e0d8e..2015c15 100644 --- a/Interlace/lib/core/__version__.py +++ b/Interlace/lib/core/__version__.py @@ -1 +1 @@ -__version__ = '1.9.7' +__version__ = '1.9.8' diff --git a/Interlace/lib/core/input.py b/Interlace/lib/core/input.py index f8bef43..a3b1efc 100644 --- a/Interlace/lib/core/input.py +++ b/Interlace/lib/core/input.py @@ -1,8 +1,6 @@ import functools import itertools import os.path -import socket -import struct import sys from argparse import ArgumentParser from io import TextIOWrapper @@ -113,12 +111,15 @@ def _pre_process_commands(command_list, task_name=None, is_global_task=True, sil @staticmethod def _replace_target_variables_in_commands(tasks, str_targets, ipset_targets): + def starts_and_ends_with(string, character): + return string[0] == character and string[-1] == character TARGET_VAR = "_target_" HOST_VAR = "_host_" CLEANTARGET_VAR = "_cleantarget_" + SAFE_TARGET = "_safe-target_" for task in tasks: command = task.name() - if TARGET_VAR in command or HOST_VAR in command: + if TARGET_VAR in command or HOST_VAR in command or SAFE_TARGET in command: for dirty_target in itertools.chain(str_targets, ipset_targets): yielded_task = task.clone() dirty_target = str(dirty_target) @@ -129,6 +130,13 @@ def _replace_target_variables_in_commands(tasks, str_targets, ipset_targets): dirty_target.replace("http://", "").replace( "https://", "").rstrip("/").replace("/", "-"), ) + + if SAFE_TARGET in command: + if (starts_and_ends_with(dirty_target, "'")) or (starts_and_ends_with(dirty_target, '"')): + pass + else: + dirty_target = f"'{dirty_target}'" + yielded_task.replace(SAFE_TARGET, dirty_target) yield yielded_task elif CLEANTARGET_VAR in command: for dirty_target in itertools.chain(str_targets, ipset_targets): diff --git a/README.md b/README.md index 77a995f..cb5be1d 100644 --- a/README.md +++ b/README.md @@ -73,16 +73,17 @@ Alternatively, you can pass targets in via STDIN and neither -t or -tL will be r # Variable Replacements The following variables will be replaced in commands at runtime: -| Variable | Replacement | -|-----------|-------------------------------------------------------------------------| -| \_target\_ | Replaced with the expanded target list that the current thread is running against | -| \_cleantarget\_ | Replaced with target cleanded from http:// or https:// | -| \_host\_ | Works the same as \_target\_, and can be used interchangeably | -| \_output\_ | Replaced with the output folder variable from Interlace | -| \_port\_ | Replaced with the expanded port variable from Interlace | -| \_realport\_ | Replaced with the real port variable from Interlace | -| \_proxy\_ | Replaced with the proxy list from Interlace | -| \_random\_ | Replaced with the randomly chosen file from Interlace | +| Variable | Replacement | +|-----------------|---------------------------------------------------------------------------------------| +| \_target\_ | Replaced with the expanded target list that the current thread is running against | +| \_cleantarget\_ | Replaced with target cleaned from http:// or https:// | +| \_safe-target\_ | Replaced with target automatically quoting for commands, stopping subcommands running | +| \_host\_ | Works the same as \_target\_, and can be used interchangeably | +| \_output\_ | Replaced with the output folder variable from Interlace | +| \_port\_ | Replaced with the expanded port variable from Interlace | +| \_realport\_ | Replaced with the real port variable from Interlace | +| \_proxy\_ | Replaced with the proxy list from Interlace | +| \_random\_ | Replaced with the randomly chosen file from Interlace | # Advanced Command File Usage Interlace also makes the use of two additional features for controlling execution flow within a command file: `_blocker_` and `_block:_`. Blockers prevent execution of commands listed after them, until all commands before them have completed, and blocks can be used to force sequential execution of commands listed within a block, for a target.