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
(
from
routersploit
import
(
exploits
,
exploits
,
print_error
,
print_error
,
...
@@ -6,7 +7,7 @@ from routersploit import (
...
@@ -6,7 +7,7 @@ from routersploit import (
print_status
,
print_status
,
print_info
,
print_info
,
utils
,
utils
,
LockedIterator
,
threads
,
)
)
...
@@ -33,9 +34,31 @@ class Exploit(exploits.Exploit):
...
@@ -33,9 +34,31 @@ class Exploit(exploits.Exploit):
threads
=
exploits
.
Option
(
8
,
"Number of threads"
)
threads
=
exploits
.
Option
(
8
,
"Number of threads"
)
def
run
(
self
):
def
run
(
self
):
data
=
LockedIterator
(
utils
.
iter_modules
(
utils
.
EXPLOITS_DIR
))
self
.
vulnerabilities
=
[]
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
:
if
self
.
vulnerabilities
:
print_info
()
print_info
()
...
@@ -48,26 +71,17 @@ class Exploit(exploits.Exploit):
...
@@ -48,26 +71,17 @@ class Exploit(exploits.Exploit):
def
check
(
self
):
def
check
(
self
):
raise
NotImplementedError
(
"Check method is not available"
)
raise
NotImplementedError
(
"Check method is not available"
)
def
target_function
(
self
,
running
,
data
):
def
target_function
(
self
,
exploit
):
name
=
threading
.
current_thread
()
.
name
exploit
=
exploit
()
print_status
(
name
,
'process is starting...'
)
exploit
.
target
=
self
.
target
exploit
.
port
=
self
.
port
while
running
.
is_set
():
try
:
exploit
=
data
.
next
()
except
StopIteration
:
break
else
:
exploit
=
exploit
()
exploit
.
target
=
self
.
target
exploit
.
port
=
self
.
port
response
=
exploit
.
check
()
response
=
exploit
.
check
()
if
response
is
True
:
if
response
is
True
:
print_success
(
"{} {} is vulnerable"
.
format
(
name
,
exploit
))
print_success
(
"{} is vulnerable"
.
format
(
exploit
))
self
.
vulnerabilities
.
append
(
exploit
)
self
.
vulnerabilities
.
append
(
exploit
)
elif
response
is
False
:
elif
response
is
False
:
print_error
(
"{} {} is not vulnerable"
.
format
(
name
,
exploit
))
print_error
(
"{} is not vulnerable"
.
format
(
exploit
))
else
:
else
:
print_status
(
"{} {} could not be verified"
.
format
(
name
,
exploit
))
print_status
(
"{} could not be verified"
.
format
(
exploit
))
routersploit/threads.py
View file @
f0fce106
from
__future__
import
print_function
from
__future__
import
print_function
from
__future__
import
absolute_import
import
threading
import
threading
from
weakref
import
WeakKeyDictionary
from
weakref
import
WeakKeyDictionary
...
@@ -25,19 +24,26 @@ class DataProducerThread(threading.Thread):
...
@@ -25,19 +24,26 @@ class DataProducerThread(threading.Thread):
for
record
in
self
.
data
:
for
record
in
self
.
data
:
data_queue
.
put
(
record
)
data_queue
.
put
(
record
)
def
stop
(
self
):
data_queue
.
queue
.
clear
()
def
join_queue
(
self
):
data_queue
.
join
()
class
WorkerThread
(
threading
.
Thread
):
class
WorkerThread
(
threading
.
Thread
):
def
__init__
(
self
):
def
__init__
(
self
,
target
,
name
):
super
(
WorkerThread
,
self
)
.
__init__
()
super
(
WorkerThread
,
self
)
.
__init__
(
target
=
target
,
name
=
name
)
self
.
target
=
target
self
.
name
=
name
def
run
(
self
):
def
run
(
self
):
while
not
data_queue
.
empty
():
while
not
data_queue
.
empty
():
record
=
data_queue
.
get
()
record
=
data_queue
.
get
()
self
.
target
(
record
)
try
:
data_queue
.
task_done
()
self
.
target
(
record
)
finally
:
def
target
(
self
,
record
):
data_queue
.
task_done
()
pass
class
PrinterThread
(
threading
.
Thread
):
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