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
f0fce106
Commit
f0fce106
authored
Aug 03, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using custom threads in scanner
parent
8631b17b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
33 deletions
+53
-33
autopwn.py
routersploit/modules/scanners/autopwn.py
+39
-25
threads.py
routersploit/threads.py
+14
-8
No files found.
routersploit/modules/scanners/autopwn.py
View file @
f0fce106
import
threading
import
time
from
routersploit
import
(
exploits
,
print_error
,
...
...
@@ -6,7 +7,7 @@ from routersploit import (
print_status
,
print_info
,
utils
,
LockedIterator
,
threads
,
)
...
...
@@ -33,9 +34,31 @@ class Exploit(exploits.Exploit):
threads
=
exploits
.
Option
(
8
,
"Number of threads"
)
def
run
(
self
):
data
=
LockedIterator
(
utils
.
iter_modules
(
utils
.
EXPLOITS_DIR
))
self
.
vulnerabilities
=
[]
self
.
run_threads
(
self
.
threads
,
self
.
target_function
,
data
)
data_producer
=
threads
.
DataProducerThread
(
utils
.
iter_modules
(
utils
.
EXPLOITS_DIR
))
data_producer
.
start
()
time
.
sleep
(
1
)
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
:
print_info
()
...
...
@@ -48,26 +71,17 @@ class Exploit(exploits.Exploit):
def
check
(
self
):
raise
NotImplementedError
(
"Check method is not available"
)
def
target_function
(
self
,
running
,
data
):
name
=
threading
.
current_thread
()
.
name
print_status
(
name
,
'process is starting...'
)
while
running
.
is_set
():
try
:
exploit
=
data
.
next
()
except
StopIteration
:
break
else
:
exploit
=
exploit
()
exploit
.
target
=
self
.
target
exploit
.
port
=
self
.
port
def
target_function
(
self
,
exploit
):
exploit
=
exploit
()
exploit
.
target
=
self
.
target
exploit
.
port
=
self
.
port
response
=
exploit
.
check
()
response
=
exploit
.
check
()
if
response
is
True
:
print_success
(
"{} {} is vulnerable"
.
format
(
name
,
exploit
))
self
.
vulnerabilities
.
append
(
exploit
)
elif
response
is
False
:
print_error
(
"{} {} is not vulnerable"
.
format
(
name
,
exploit
))
else
:
print_status
(
"{} {} could not be verified"
.
format
(
name
,
exploit
))
if
response
is
True
:
print_success
(
"{} is vulnerable"
.
format
(
exploit
))
self
.
vulnerabilities
.
append
(
exploit
)
elif
response
is
False
:
print_error
(
"{} is not vulnerable"
.
format
(
exploit
))
else
:
print_status
(
"{} could not be verified"
.
format
(
exploit
))
routersploit/threads.py
View file @
f0fce106
from
__future__
import
print_function
from
__future__
import
absolute_import
import
threading
from
weakref
import
WeakKeyDictionary
...
...
@@ -25,19 +24,26 @@ class DataProducerThread(threading.Thread):
for
record
in
self
.
data
:
data_queue
.
put
(
record
)
def
stop
(
self
):
data_queue
.
queue
.
clear
()
def
join_queue
(
self
):
data_queue
.
join
()
class
WorkerThread
(
threading
.
Thread
):
def
__init__
(
self
):
super
(
WorkerThread
,
self
)
.
__init__
()
def
__init__
(
self
,
target
,
name
):
super
(
WorkerThread
,
self
)
.
__init__
(
target
=
target
,
name
=
name
)
self
.
target
=
target
self
.
name
=
name
def
run
(
self
):
while
not
data_queue
.
empty
():
record
=
data_queue
.
get
()
self
.
target
(
record
)
data_queue
.
task_done
()
def
target
(
self
,
record
):
pass
try
:
self
.
target
(
record
)
finally
:
data_queue
.
task_done
()
class
PrinterThread
(
threading
.
Thread
):
...
...
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