Python library style fixes

MS-2855/keylogger-mettle-extension
Adam Cammack 2018-01-22 22:10:32 -06:00
parent 0f0b116751
commit 964810146a
No known key found for this signature in database
GPG Key ID: C9378BA088092D66
2 changed files with 15 additions and 17 deletions

View File

@ -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()

View File

@ -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):