Added in proxy feature

This commit is contained in:
prodigysml
2019-05-27 19:46:36 -07:00
parent be8b423560
commit 26d37d4c23

View File

@@ -6,6 +6,7 @@ from os import access, W_OK
import sys import sys
from re import compile from re import compile
from random import sample from random import sample
from math import ceil
class InputHelper(object): class InputHelper(object):
@@ -76,6 +77,23 @@ class InputHelper(object):
tmp_commands.update(test) tmp_commands.update(test)
return tmp_commands return tmp_commands
@staticmethod
def _replace_variable_array(commands, variable, replacement):
tmp_commands = set()
counter = 0
test = list()
if not variable in sample(commands, 1)[0]:
return commands
for command in commands:
test.append(str(command).replace(variable, str(replacement[counter])))
counter += 1
tmp_commands.update(test)
return tmp_commands
@staticmethod @staticmethod
def process_commands(arguments): def process_commands(arguments):
@@ -208,6 +226,20 @@ class InputHelper(object):
protocols = arguments.proto protocols = arguments.proto
final_commands = InputHelper._replace_variable_for_commands(final_commands, "_proto_", protocols) final_commands = InputHelper._replace_variable_for_commands(final_commands, "_proto_", protocols)
# process proxies
if arguments.proxy_list:
proxy_list = list()
for proxy in arguments.proxy_list:
if proxy.strip():
proxy_list.append(proxy.strip())
if len(proxy_list) < len(final_commands):
proxy_list = ceil(len(final_commands) / len(proxy_list)) * proxy_list
final_commands = InputHelper._replace_variable_array(final_commands, "_proxy_", proxy_list)
print(final_commands)
return final_commands return final_commands
@@ -272,6 +304,13 @@ class InputParser(object):
type=lambda x: InputHelper.check_positive(parser, x) type=lambda x: InputHelper.check_positive(parser, x)
) )
parser.add_argument(
'-pL', dest='proxy_list', required=False,
help='Specify a list of proxies.',
metavar="FILE",
type=lambda x: InputHelper.readable_file(parser, x)
)
commands = parser.add_mutually_exclusive_group(required=True) commands = parser.add_mutually_exclusive_group(required=True)
commands.add_argument( commands.add_argument(
'-c', dest='command', '-c', dest='command',