-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Open
Labels
suggestion-featureNew feature suggestionsNew feature suggestions
Description
Summary
Proposal to add an optional lightweight TCP redirector that allows local traffic multiplexing to a Metasploit handler.
Motivation
In enterprise-scale lab environments or multi-client testing scenarios, a single Metasploit handler can become overloaded if exposed directly to many simultaneous connections.
A local TCP proxy can accept multiple connections and forward them to the handler on a loopback interface, reducing stress on the listener and simplifying session management.
Example Implementation
A small Python TCP proxy can listen on a user-specified port, accept multiple local connections, and forward them to the Metasploit multi/handler:
python
import asyncio
MSF_HOST = "127.0.0.1" # Metasploit listener
MSF_PORT = 5555
LISTEN_HOST = "0.0.0.0"
LISTEN_PORT = 4444
async def handle_client(reader, writer):
try:
msf_reader, msf_writer = await asyncio.open_connection(MSF_HOST, MSF_PORT)
except Exception as e:
print(f"[!] Failed to connect to MSF: {e}")
writer.close()
return
async def pipe(src, dst):
try:
while True:
data = await src.read(4096)
if not data:
break
dst.write(data)
await dst.drain()
except:
pass
finally:
dst.close()
asyncio.create_task(pipe(reader, msf_writer))
asyncio.create_task(pipe(msf_reader, writer))
async def main():
server = await asyncio.start_server(handle_client, LISTEN_HOST, LISTEN_PORT)
print(f"[+] Proxy listening on {LISTEN_HOST}:{LISTEN_PORT} → MSF {MSF_HOST}:{MSF_PORT}")
async with server:
await server.serve_forever()
asyncio.run(main())
Metadata
Metadata
Assignees
Labels
suggestion-featureNew feature suggestionsNew feature suggestions