Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
routersploit
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
czos-dpend
routersploit
Commits
bf5a036e
Commit
bf5a036e
authored
May 17, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding command-line utility for adding modules.
parent
2a73e612
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
0 deletions
+106
-0
__init__.py
routersploit/templates/__init__.py
+0
-0
exploit.py
routersploit/templates/exploit.py
+33
-0
utils.py
routersploit/utils.py
+46
-0
rsf.py
rsf.py
+27
-0
No files found.
routersploit/templates/__init__.py
0 → 100644
View file @
bf5a036e
routersploit/templates/exploit.py
0 → 100644
View file @
bf5a036e
from
routersploit
import
(
exploits
,
mute
,
validators
,
)
class
Exploit
(
exploits
.
Exploit
):
""" Exploit template. """
__info__
=
{
'name'
:
''
,
'authors'
:
[
''
,
# vulnerability discovery
''
,
# routersploit module
],
'description'
:
''
,
'references'
:
[
''
,
],
'devices'
:
[
''
,
],
}
target
=
exploits
.
Option
(
''
,
'Target address e.g. http://192.168.1.1'
,
validators
=
validators
.
url
)
port
=
exploits
.
Option
(
80
,
'Target Port'
)
def
run
(
self
):
pass
@mute
def
check
(
self
):
pass
routersploit/utils.py
View file @
bf5a036e
...
...
@@ -8,6 +8,8 @@ import random
import
string
import
socket
import
importlib
import
errno
from
collections
import
namedtuple
from
functools
import
wraps
from
distutils.util
import
strtobool
from
abc
import
ABCMeta
,
abstractmethod
...
...
@@ -31,6 +33,8 @@ colors = {
# Disable certificate verification warnings
requests
.
packages
.
urllib3
.
disable_warnings
(
requests
.
packages
.
urllib3
.
exceptions
.
InsecureRequestWarning
)
Resource
=
namedtuple
(
"Resource"
,
[
"name"
,
"template_path"
,
"context"
])
def
index_modules
(
modules_directory
=
MODULES_DIR
):
""" Return list of all exploits modules """
...
...
@@ -435,3 +439,44 @@ def boolify(value):
return
False
else
:
return
bool
(
value
)
def
create_resource
(
name
,
content
=
(),
python_package
=
False
):
""" Creates resource directory in current working directory. """
root_path
=
os
.
path
.
join
(
MODULES_DIR
,
name
)
mkdir_p
(
root_path
)
if
python_package
:
open
(
os
.
path
.
join
(
root_path
,
"__init__.py"
),
"a"
)
.
close
()
print_success
(
"__init__.py successfully created."
)
for
name
,
template_path
,
context
in
content
:
if
os
.
path
.
splitext
(
name
)[
-
1
]
==
""
:
# Checking if resource has extension if not it's directory
os
.
mkdir
(
os
.
path
.
join
(
root_path
,
name
))
print_success
(
"Sub-directory /{name} successfully created."
.
format
(
name
=
name
))
else
:
try
:
with
open
(
template_path
,
"rb"
)
as
template_file
:
template
=
string
.
Template
(
template_file
.
read
())
except
(
IOError
,
TypeError
):
template
=
string
.
Template
(
""
)
finally
:
with
open
(
os
.
path
.
join
(
root_path
,
name
),
"wb"
)
as
target_file
:
target_file
.
write
(
template
.
substitute
(
**
context
))
print_success
(
"{file} successfully created."
.
format
(
file
=
name
))
def
mkdir_p
(
path
):
"""
Simulate mkdir -p shell command. Creates directory with all needed parents.
:param path: Directory path that may include non existing parent directories
:return:
"""
try
:
os
.
makedirs
(
path
)
print_success
(
"Directory {path} sucessfully created."
.
format
(
path
=
path
))
except
OSError
as
exc
:
if
exc
.
errno
==
errno
.
EEXIST
and
os
.
path
.
isdir
(
path
):
print_success
(
"Directory {path}"
.
format
(
path
=
path
))
else
:
raise
\ No newline at end of file
rsf.py
View file @
bf5a036e
#!/usr/bin/env python2
from
__future__
import
print_function
import
os
import
argparse
from
routersploit.interpreter
import
RoutersploitInterpreter
from
routersploit.utils
import
create_resource
,
Resource
from
routersploit.templates
import
exploit
parser
=
argparse
.
ArgumentParser
(
description
=
'RouterSploit - Router Exploitation Framework'
)
parser
.
add_argument
(
'--add-exploit'
,
metavar
=
'exploit_path'
,
help
=
'Add exploit using default template.'
)
def
routersploit
():
...
...
@@ -8,4 +20,19 @@ def routersploit():
rsf
.
start
()
if
__name__
==
"__main__"
:
args
=
parser
.
parse_args
()
if
args
.
add_exploit
:
base
,
_
,
name
=
args
.
add_exploit
.
rpartition
(
os
.
sep
)
create_resource
(
name
=
base
,
content
=
(
Resource
(
name
=
"{}.py"
.
format
(
name
),
template_path
=
os
.
path
.
abspath
(
exploit
.
__file__
.
rstrip
(
"c"
)),
context
=
{}),
),
python_package
=
True
)
else
:
routersploit
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment