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
a08ddfd2
Commit
a08ddfd2
authored
Apr 10, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring mechanism used by 'show info' command.
parent
b6ba0005
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
12 deletions
+45
-12
interpreter.py
routersploit/interpreter.py
+5
-11
utils.py
routersploit/utils.py
+40
-1
No files found.
routersploit/interpreter.py
View file @
a08ddfd2
...
...
@@ -329,17 +329,11 @@ class RoutersploitInterpreter(BaseInterpreter):
info
,
options
=
'info'
,
'options'
sub_command
=
args
[
0
]
if
sub_command
==
info
:
info
=
[
"name"
,
"description"
,
"targets"
,
"authors"
,
"references"
]
for
i
in
info
:
# TODO refactor this.
if
i
in
self
.
module_metadata
.
keys
():
print
(
"
\n
{}:"
.
format
(
i
.
capitalize
()))
if
type
(
self
.
module_metadata
[
i
])
is
list
:
for
item
in
self
.
module_metadata
[
i
]:
print
(
"- {}"
.
format
(
item
))
else
:
print
(
self
.
module_metadata
[
i
])
print
()
utils
.
pprint_dict_in_order
(
(
"name"
,
"description"
,
"targets"
,
"authors"
,
"references"
),
self
.
module_metadata
,
)
utils
.
print_info
()
elif
sub_command
==
options
:
target_opts
=
{
'port'
,
'target'
}
module_opts
=
set
(
self
.
current_module
.
options
)
-
target_opts
...
...
routersploit/utils.py
View file @
a08ddfd2
...
...
@@ -193,7 +193,6 @@ def sanitize_url(address):
Converts address to valid HTTP url.
"""
url
=
""
if
not
address
.
startswith
(
"http://"
)
and
not
address
.
startswith
(
"https://"
):
url
=
"http://"
+
address
else
:
...
...
@@ -201,3 +200,43 @@ def sanitize_url(address):
return
url
def
pprint_dict_in_order
(
order
,
dictionary
):
""" Pretty dict print.
Pretty printing dictionary in specific order. (as in 'show info' command)
Keys not mentioned in *order* parameter will be printed in random order.
ex. pprint_dict_in_order(('sex', 'name'), {'name': John, 'sex': 'male', "hobby": ["rugby", "golf"]})
Sex:
male
Name:
John
Hobby:
- rugby
- golf
"""
def
prettyprint
(
title
,
body
):
print_info
(
"
\n
{}:"
.
format
(
title
.
capitalize
()))
if
not
isinstance
(
body
,
str
):
for
value_element
in
value
:
print_info
(
'- '
,
value_element
)
else
:
print_info
(
value
)
keys
=
dictionary
.
keys
()
for
element
in
order
:
try
:
key
=
keys
.
pop
(
keys
.
index
(
element
))
value
=
dictionary
[
key
]
except
(
KeyError
,
ValueError
):
pass
else
:
prettyprint
(
element
,
value
)
for
rest_keys
in
keys
:
prettyprint
(
rest_keys
,
dictionary
[
rest_keys
])
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