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
b9248c7a
Commit
b9248c7a
authored
Aug 04, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding custom ThreadPoolExecutor.
parent
46fc9ad1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
26 deletions
+39
-26
autopwn.py
routersploit/modules/scanners/autopwn.py
+3
-26
threads.py
routersploit/threads.py
+36
-0
No files found.
routersploit/modules/scanners/autopwn.py
View file @
b9248c7a
import
time
from
routersploit
import
(
from
routersploit
import
(
exploits
,
exploits
,
print_error
,
print_error
,
...
@@ -35,30 +33,9 @@ class Exploit(exploits.Exploit):
...
@@ -35,30 +33,9 @@ class Exploit(exploits.Exploit):
def
run
(
self
):
def
run
(
self
):
self
.
vulnerabilities
=
[]
self
.
vulnerabilities
=
[]
data_producer
=
threads
.
DataProducerThread
(
utils
.
iter_modules
(
utils
.
EXPLOITS_DIR
))
executor
=
threads
.
ThreadPoolExecutor
(
self
.
threads
)
data_producer
.
start
()
executor
.
feed
(
utils
.
iter_modules
(
utils
.
EXPLOITS_DIR
))
time
.
sleep
(
1
)
executor
.
run
(
self
.
target_function
)
workers
=
[]
for
worker_id
in
xrange
(
int
(
self
.
threads
)):
worker
=
threads
.
WorkerThread
(
target
=
self
.
target_function
,
name
=
'worker-{}'
.
format
(
worker_id
),
)
workers
.
append
(
worker
)
worker
.
start
()
try
:
while
worker
.
isAlive
():
worker
.
join
(
1
)
except
KeyboardInterrupt
:
print_info
()
print_status
(
"Waiting for already scheduled jobs to finish..."
)
data_producer
.
stop
()
for
worker
in
workers
:
worker
.
join
()
else
:
data_producer
.
join_queue
()
if
self
.
vulnerabilities
:
if
self
.
vulnerabilities
:
print_info
()
print_info
()
...
...
routersploit/threads.py
View file @
b9248c7a
...
@@ -44,3 +44,39 @@ class WorkerThread(threading.Thread):
...
@@ -44,3 +44,39 @@ class WorkerThread(threading.Thread):
self
.
target
(
record
)
self
.
target
(
record
)
finally
:
finally
:
data_queue
.
task_done
()
data_queue
.
task_done
()
class
ThreadPoolExecutor
(
object
):
def
__init__
(
self
,
threads
):
self
.
threads
=
threads
self
.
data_producer
=
None
def
feed
(
self
,
dataset
):
self
.
data_producer
=
DataProducerThread
(
dataset
)
self
.
data_producer
.
start
()
time
.
sleep
(
0.1
)
def
run
(
self
,
target
):
workers
=
[]
for
worker_id
in
xrange
(
int
(
self
.
threads
)):
worker
=
WorkerThread
(
target
=
target
,
name
=
'worker-{}'
.
format
(
worker_id
),
)
workers
.
append
(
worker
)
worker
.
start
()
start
=
time
.
time
()
try
:
while
worker
.
isAlive
():
worker
.
join
(
1
)
except
KeyboardInterrupt
:
utils
.
print_info
()
utils
.
print_status
(
"Waiting for already scheduled jobs to finish..."
)
self
.
data_producer
.
stop
()
for
worker
in
workers
:
worker
.
join
()
else
:
self
.
data_producer
.
join_queue
()
utils
.
print_status
(
'Elapsed time: '
,
time
.
time
()
-
start
,
'seconds'
)
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