Python library style fixes
parent
0f0b116751
commit
964810146a
|
@ -1,4 +1,6 @@
|
|||
import sys, os, json
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def log(message, level='info'):
|
||||
|
@ -11,25 +13,19 @@ def log(message, level='info'):
|
|||
def report_host(ip, **opts):
|
||||
host = opts.copy()
|
||||
host.update({'host': ip})
|
||||
rpc_send({'jsonrpc': '2.0', 'method': 'report', 'params': {
|
||||
'type': 'host', 'data': host
|
||||
}})
|
||||
report('host', host)
|
||||
|
||||
|
||||
def report_service(ip, **opts):
|
||||
service = opts.copy()
|
||||
service.update({'host': ip})
|
||||
rpc_send({'jsonrpc': '2.0', 'method': 'report', 'params': {
|
||||
'type': 'service', 'data': service
|
||||
}})
|
||||
report('service', service)
|
||||
|
||||
|
||||
def report_vuln(ip, name, **opts):
|
||||
vuln = opts.copy()
|
||||
vuln.update({'host': ip, 'name': name})
|
||||
rpc_send({'jsonrpc': '2.0', 'method': 'report', 'params': {
|
||||
'type': 'vuln', 'data': vuln
|
||||
}})
|
||||
report('vuln', vuln)
|
||||
|
||||
|
||||
def run(metadata, module_callback):
|
||||
|
@ -44,6 +40,12 @@ def run(metadata, module_callback):
|
|||
}})
|
||||
|
||||
|
||||
def report(kind, data):
|
||||
rpc_send({'jsonrpc': '2.0', 'method': 'report', 'params': {
|
||||
'type': kind, 'data': data
|
||||
}})
|
||||
|
||||
|
||||
def rpc_send(req):
|
||||
print(json.dumps(req))
|
||||
sys.stdout.flush()
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import socket, re, functools
|
||||
import asyncio
|
||||
import functools
|
||||
import re
|
||||
|
||||
from metasploit import module
|
||||
from async_timeout import timeout
|
||||
from metasploit import module
|
||||
|
||||
|
||||
def make_scanner(payload='', pattern='', onmatch=None, connect_timeout=3, read_timeout=10):
|
||||
|
@ -40,7 +41,6 @@ class Scan:
|
|||
target = (args['host'], args['port'])
|
||||
f.add_done_callback(functools.partial(self.__queue_result, target))
|
||||
|
||||
|
||||
def __queue_result(self, target, f):
|
||||
res = None
|
||||
|
||||
|
@ -51,11 +51,9 @@ class Scan:
|
|||
|
||||
self.queue.put_nowait((target, res))
|
||||
|
||||
|
||||
async def __aiter__(self):
|
||||
return self
|
||||
|
||||
|
||||
async def __anext__(self):
|
||||
if self.done == self.total:
|
||||
raise StopAsyncIteration
|
||||
|
@ -66,8 +64,6 @@ class Scan:
|
|||
|
||||
|
||||
async def probe_host(host, port, payload, connect_timeout, read_timeout):
|
||||
r = None
|
||||
w = None
|
||||
buf = bytearray()
|
||||
|
||||
async with timeout(connect_timeout):
|
||||
|
|
Loading…
Reference in New Issue