Skip to content

Commit 9648101

Browse files
committed
Python library style fixes
1 parent 0f0b116 commit 9648101

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

lib/msf/core/modules/external/python/metasploit/module.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import sys, os, json
1+
import json
2+
import os
3+
import sys
24

35

46
def log(message, level='info'):
@@ -11,25 +13,19 @@ def log(message, level='info'):
1113
def report_host(ip, **opts):
1214
host = opts.copy()
1315
host.update({'host': ip})
14-
rpc_send({'jsonrpc': '2.0', 'method': 'report', 'params': {
15-
'type': 'host', 'data': host
16-
}})
16+
report('host', host)
1717

1818

1919
def report_service(ip, **opts):
2020
service = opts.copy()
2121
service.update({'host': ip})
22-
rpc_send({'jsonrpc': '2.0', 'method': 'report', 'params': {
23-
'type': 'service', 'data': service
24-
}})
22+
report('service', service)
2523

2624

2725
def report_vuln(ip, name, **opts):
2826
vuln = opts.copy()
2927
vuln.update({'host': ip, 'name': name})
30-
rpc_send({'jsonrpc': '2.0', 'method': 'report', 'params': {
31-
'type': 'vuln', 'data': vuln
32-
}})
28+
report('vuln', vuln)
3329

3430

3531
def run(metadata, module_callback):
@@ -44,6 +40,12 @@ def run(metadata, module_callback):
4440
}})
4541

4642

43+
def report(kind, data):
44+
rpc_send({'jsonrpc': '2.0', 'method': 'report', 'params': {
45+
'type': kind, 'data': data
46+
}})
47+
48+
4749
def rpc_send(req):
4850
print(json.dumps(req))
4951
sys.stdout.flush()

lib/msf/core/modules/external/python/metasploit/probe_scanner.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import socket, re, functools
21
import asyncio
2+
import functools
3+
import re
34

4-
from metasploit import module
55
from async_timeout import timeout
6+
from metasploit import module
67

78

89
def make_scanner(payload='', pattern='', onmatch=None, connect_timeout=3, read_timeout=10):
@@ -40,7 +41,6 @@ def __init__(self, runs):
4041
target = (args['host'], args['port'])
4142
f.add_done_callback(functools.partial(self.__queue_result, target))
4243

43-
4444
def __queue_result(self, target, f):
4545
res = None
4646

@@ -51,11 +51,9 @@ def __queue_result(self, target, f):
5151

5252
self.queue.put_nowait((target, res))
5353

54-
5554
async def __aiter__(self):
5655
return self
5756

58-
5957
async def __anext__(self):
6058
if self.done == self.total:
6159
raise StopAsyncIteration
@@ -66,8 +64,6 @@ async def __anext__(self):
6664

6765

6866
async def probe_host(host, port, payload, connect_timeout, read_timeout):
69-
r = None
70-
w = None
7167
buf = bytearray()
7268

7369
async with timeout(connect_timeout):

0 commit comments

Comments
 (0)