mirror of
https://github.com/codingo/Interlace.git
synced 2026-02-01 13:14:33 +01:00
Merge pull request #175 from codingo/safe-flag
Safe-target variable implementation
This commit is contained in:
@@ -1 +1 @@
|
||||
__version__ = '1.9.7'
|
||||
__version__ = '1.9.8'
|
||||
|
||||
@@ -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 @@ class InputHelper(object):
|
||||
|
||||
@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 @@ class InputHelper(object):
|
||||
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):
|
||||
|
||||
21
README.md
21
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:<name>_`. 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.
|
||||
|
||||
Reference in New Issue
Block a user