5
5
from async_timeout import timeout
6
6
7
7
8
- def make_study (payload = '' , pattern = '' , onmatch = None , connect_timeout = 3 , read_timeout = 10 ):
9
- return lambda args : start_study (payload , pattern , args , onmatch , connect_timeout = connect_timeout , read_timeout = read_timeout )
8
+ def make_scanner (payload = '' , pattern = '' , onmatch = None , connect_timeout = 3 , read_timeout = 10 ):
9
+ return lambda args : start_scanner (payload , pattern , args , onmatch , connect_timeout = connect_timeout , read_timeout = read_timeout )
10
10
11
11
12
- def start_study (payload , pattern , args , onmatch , ** timeouts ):
12
+ def start_scanner (payload , pattern , args , onmatch , ** timeouts ):
13
13
loop = asyncio .get_event_loop ()
14
- loop .run_until_complete (run_study (payload , pattern , args , onmatch , ** timeouts ))
14
+ loop .run_until_complete (run_scanner (payload , pattern , args , onmatch , ** timeouts ))
15
15
16
16
17
- async def run_study (payload , pattern , args , onmatch , ** timeouts ):
18
- runs = [study_host (host , int (args ['rport' ]), payload , ** timeouts ) for host in args ['rhosts' ]]
19
- async for (target , res ) in Study ( runs ):
17
+ async def run_scanner (payload , pattern , args , onmatch , ** timeouts ):
18
+ probes = [probe_host (host , int (args ['rport' ]), payload , ** timeouts ) for host in args ['rhosts' ]]
19
+ async for (target , res ) in Scan ( probes ):
20
20
if isinstance (res , Exception ):
21
21
module .log ('{}:{} - Error connecting: {}' .format (* target , res ), level = 'error' )
22
22
elif res and re .search (pattern , res ):
@@ -28,7 +28,7 @@ async def run_study(payload, pattern, args, onmatch, **timeouts):
28
28
module .log ('{}:{} - Does not match with: {}' .format (* target , res ), level = 'debug' )
29
29
30
30
31
- class Study :
31
+ class Scan :
32
32
def __init__ (self , runs ):
33
33
self .queue = asyncio .queues .Queue ()
34
34
self .total = len (runs )
@@ -65,7 +65,7 @@ async def __anext__(self):
65
65
return res
66
66
67
67
68
- async def study_host (host , port , payload , connect_timeout , read_timeout ):
68
+ async def probe_host (host , port , payload , connect_timeout , read_timeout ):
69
69
r = None
70
70
w = None
71
71
buf = bytearray ()
0 commit comments