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
0783f8af
Commit
0783f8af
authored
Jul 21, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'add-test-from-template'
parents
e09b224e
cea89787
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
127 additions
and
1 deletions
+127
-1
__init__.py
routersploit/templates/__init__.py
+0
-0
exploit.py
routersploit/templates/exploit.py
+33
-0
utils.py
routersploit/utils.py
+76
-0
rsf.py
rsf.py
+18
-1
No files found.
routersploit/templates/__init__.py
0 → 100644
View file @
0783f8af
routersploit/templates/exploit.py
0 → 100644
View file @
0783f8af
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 @
0783f8af
...
@@ -11,6 +11,7 @@ import string
...
@@ -11,6 +11,7 @@ import string
import
importlib
import
importlib
import
select
import
select
import
socket
import
socket
import
errno
from
functools
import
wraps
from
functools
import
wraps
from
distutils.util
import
strtobool
from
distutils.util
import
strtobool
from
abc
import
ABCMeta
,
abstractmethod
from
abc
import
ABCMeta
,
abstractmethod
...
@@ -34,6 +35,8 @@ colors = {
...
@@ -34,6 +35,8 @@ colors = {
# Disable certificate verification warnings
# Disable certificate verification warnings
requests
.
packages
.
urllib3
.
disable_warnings
(
requests
.
packages
.
urllib3
.
exceptions
.
InsecureRequestWarning
)
requests
.
packages
.
urllib3
.
disable_warnings
(
requests
.
packages
.
urllib3
.
exceptions
.
InsecureRequestWarning
)
Resource
=
collections
.
namedtuple
(
"Resource"
,
[
"name"
,
"template_path"
,
"context"
])
def
index_modules
(
modules_directory
=
MODULES_DIR
):
def
index_modules
(
modules_directory
=
MODULES_DIR
):
""" Return list of all exploits modules """
""" Return list of all exploits modules """
...
@@ -528,3 +531,76 @@ def tokenize(token_specification, text):
...
@@ -528,3 +531,76 @@ def tokenize(token_specification, text):
else
:
else
:
column
=
mo
.
start
()
-
line_start
column
=
mo
.
start
()
-
line_start
yield
Token
(
kind
,
value
,
line_num
,
column
,
mo
)
yield
Token
(
kind
,
value
,
line_num
,
column
,
mo
)
def
create_exploit
(
path
):
# TODO: cover with tests
from
.templates
import
exploit
parts
=
path
.
split
(
os
.
sep
)
module_type
,
name
=
parts
[
0
],
parts
[
-
1
]
if
not
name
:
print_error
(
"Invalid exploit name. ;("
)
return
if
module_type
not
in
[
'creds'
,
'exploits'
,
'scanners'
]:
print_error
(
"Invalid module type. ;("
)
return
create_resource
(
name
=
os
.
path
.
join
(
*
parts
[:
-
1
]),
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
):
# TODO: cover with tests
""" 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
()
for
name
,
template_path
,
context
in
content
:
if
os
.
path
.
splitext
(
name
)[
-
1
]
==
""
:
# Checking if resource has extension if not it's directory
mkdir_p
(
os
.
path
.
join
(
root_path
,
name
))
else
:
try
:
with
open
(
template_path
,
"rb"
)
as
template_file
:
template
=
string
.
Template
(
template_file
.
read
())
except
(
IOError
,
TypeError
):
template
=
string
.
Template
(
""
)
try
:
file_handle
=
os
.
open
(
os
.
path
.
join
(
root_path
,
name
),
os
.
O_CREAT
|
os
.
O_EXCL
|
os
.
O_WRONLY
)
except
OSError
as
e
:
if
e
.
errno
==
errno
.
EEXIST
:
print_status
(
"{} already exist."
.
format
(
name
))
else
:
raise
else
:
with
os
.
fdopen
(
file_handle
,
'w'
)
as
target_file
:
target_file
.
write
(
template
.
substitute
(
**
context
))
print_success
(
"{} successfully created."
.
format
(
name
))
def
mkdir_p
(
path
):
# TODO: cover with tests
"""
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} successfully 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
rsf.py
View file @
0783f8af
#!/usr/bin/env python2
#!/usr/bin/env python2
from
__future__
import
print_function
import
argparse
from
routersploit.interpreter
import
RoutersploitInterpreter
from
routersploit.interpreter
import
RoutersploitInterpreter
from
routersploit.utils
import
create_exploit
parser
=
argparse
.
ArgumentParser
(
description
=
'RouterSploit - Router Exploitation Framework'
)
parser
.
add_argument
(
'-a'
,
'--add-exploit'
,
metavar
=
'exploit_path'
,
help
=
'Add exploit using default template.'
)
def
routersploit
():
def
routersploit
():
...
@@ -8,4 +20,9 @@ def routersploit():
...
@@ -8,4 +20,9 @@ def routersploit():
rsf
.
start
()
rsf
.
start
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
routersploit
()
args
=
parser
.
parse_args
()
if
args
.
add_exploit
:
create_exploit
(
args
.
add_exploit
)
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