Commit a9087776 by fwkz

Flexible exploit creation

parent 8f50b7c4
...@@ -441,21 +441,18 @@ def boolify(value): ...@@ -441,21 +441,18 @@ def boolify(value):
return bool(value) return bool(value)
def create_exploit(path): def create_exploit(path): # TODO: cover with tests
from .templates import exploit from .templates import exploit
try: parts = path.split(os.sep)
module_type, vendor, name = path.split(os.sep) module_type, name = parts[0], parts[-1]
except ValueError:
print_error("Invalid path. ;(")
return
if module_type not in ['creds', 'exploits', 'scanners']: if module_type not in ['creds', 'exploits', 'scanners']:
print_error("Invalid module type. ;(") print_error("Invalid module type. ;(")
return return
create_resource( create_resource(
name=os.path.join(module_type, vendor), name=os.path.join(*parts[:-1]),
content=( content=(
Resource( Resource(
name="{}.py".format(name), name="{}.py".format(name),
...@@ -466,7 +463,7 @@ def create_exploit(path): ...@@ -466,7 +463,7 @@ def create_exploit(path):
) )
def create_resource(name, content=(), python_package=False): def create_resource(name, content=(), python_package=False): # TODO: cover with tests
""" Creates resource directory in current working directory. """ """ Creates resource directory in current working directory. """
root_path = os.path.join(MODULES_DIR, name) root_path = os.path.join(MODULES_DIR, name)
mkdir_p(root_path) mkdir_p(root_path)
...@@ -497,7 +494,7 @@ def create_resource(name, content=(), python_package=False): ...@@ -497,7 +494,7 @@ def create_resource(name, content=(), python_package=False):
print_success("{} successfully created.".format(name)) print_success("{} successfully created.".format(name))
def mkdir_p(path): def mkdir_p(path): # TODO: cover with tests
""" """
Simulate mkdir -p shell command. Creates directory with all needed parents. Simulate mkdir -p shell command. Creates directory with all needed parents.
:param path: Directory path that may include non existing parent directories :param path: Directory path that may include non existing parent directories
......
...@@ -9,7 +9,8 @@ from routersploit.utils import create_exploit ...@@ -9,7 +9,8 @@ from routersploit.utils import create_exploit
parser = argparse.ArgumentParser(description='RouterSploit - Router Exploitation Framework') parser = argparse.ArgumentParser(description='RouterSploit - Router Exploitation Framework')
parser.add_argument('--add-exploit', parser.add_argument('-a',
'--add-exploit',
metavar='exploit_path', metavar='exploit_path',
help='Add exploit using default template.') help='Add exploit using default template.')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment