Commit 8f50b7c4 by fwkz

Validation of exploit creation

parent 39a69009
...@@ -441,6 +441,31 @@ def boolify(value): ...@@ -441,6 +441,31 @@ def boolify(value):
return bool(value) return bool(value)
def create_exploit(path):
from .templates import exploit
try:
module_type, vendor, name = path.split(os.sep)
except ValueError:
print_error("Invalid path. ;(")
return
if module_type not in ['creds', 'exploits', 'scanners']:
print_error("Invalid module type. ;(")
return
create_resource(
name=os.path.join(module_type, vendor),
content=(
Resource(
name="{}.py".format(name),
template_path=os.path.abspath(exploit.__file__.rstrip("c")),
context={}),
),
python_package=True
)
def create_resource(name, content=(), python_package=False): def create_resource(name, content=(), python_package=False):
""" 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)
......
#!/usr/bin/env python2 #!/usr/bin/env python2
from __future__ import print_function from __future__ import print_function
import os
import argparse import argparse
from routersploit.interpreter import RoutersploitInterpreter from routersploit.interpreter import RoutersploitInterpreter
from routersploit.utils import create_resource, Resource from routersploit.utils import create_exploit
from routersploit.templates import exploit
parser = argparse.ArgumentParser(description='RouterSploit - Router Exploitation Framework') parser = argparse.ArgumentParser(description='RouterSploit - Router Exploitation Framework')
...@@ -23,16 +22,6 @@ if __name__ == "__main__": ...@@ -23,16 +22,6 @@ if __name__ == "__main__":
args = parser.parse_args() args = parser.parse_args()
if args.add_exploit: if args.add_exploit:
base, _, name = args.add_exploit.rpartition(os.sep) create_exploit(args.add_exploit)
create_resource(
name=base,
content=(
Resource(
name="{}.py".format(name),
template_path=os.path.abspath(exploit.__file__.rstrip("c")),
context={}),
),
python_package=True
)
else: else:
routersploit() routersploit()
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