Skip to content

Update the SOCKS proxy to use the new RelayManager#21048

Open
zeroSteiner wants to merge 3 commits intorapid7:masterfrom
zeroSteiner:feat/mod/socks-proxy/fiber-update
Open

Update the SOCKS proxy to use the new RelayManager#21048
zeroSteiner wants to merge 3 commits intorapid7:masterfrom
zeroSteiner:feat/mod/socks-proxy/fiber-update

Conversation

@zeroSteiner
Copy link
Contributor

@zeroSteiner zeroSteiner commented Mar 3, 2026

This updates the SOCKS5 proxy module to use the newish RelayManager added in #20677 . The result is a net reduction in code and some performance improvements.

Requires rapid7/rex-core#45

Verification

List the steps needed to make sure this thing works

  • Start msfconsole
  • use auxiliary/server/socks_proxy
  • Use the proxy, make sure it's working correctly

Simple Benchmarking

This simple benchmark at least showed that when making repeated GET requests to a local server that is listening, the operation finished in about half the time.

smcintyre@fedora:~/Repositories/metasploit-framework$  for i in $(seq 1 100); do
    curl --socks5 127.0.0.1:1080 http://127.0.0.1:8000/ -o /dev/null -s -w "%{time_connect} %{time_total}\n"
  done | awk '{sum+=$2; n++} END {print "avg:", sum/n}'
avg: 0.0104874
smcintyre@fedora:~/Repositories/metasploit-framework$  for i in $(seq 1 100); do
    curl --socks5 127.0.0.1:1080 http://127.0.0.1:8000/ -o /dev/null -s -w "%{time_connect} %{time_total}\n"
  done | awk '{sum+=$2; n++} END {print "avg:", sum/n}'
avg: 0.014277
smcintyre@fedora:~/Repositories/metasploit-framework$  for i in $(seq 1 100); do
    curl --socks5 127.0.0.1:1080 http://127.0.0.1:8000/ -o /dev/null -s -w "%{time_connect} %{time_total}\n"
  done | awk '{sum+=$2; n++} END {print "avg:", sum/n}'
avg: 0.0125423

smcintyre@fedora:~/Repositories/metasploit-framework$ # new code tests start here

smcintyre@fedora:~/Repositories/metasploit-framework$  for i in $(seq 1 100); do
    curl --socks5 127.0.0.1:1080 http://127.0.0.1:8000/ -o /dev/null -s -w "%{time_connect} %{time_total}\n"
  done | awk '{sum+=$2; n++} END {print "avg:", sum/n}'
avg: 0.00496531
smcintyre@fedora:~/Repositories/metasploit-framework$ 
smcintyre@fedora:~/Repositories/metasploit-framework$  for i in $(seq 1 100); do
    curl --socks5 127.0.0.1:1080 http://127.0.0.1:8000/ -o /dev/null -s -w "%{time_connect} %{time_total}\n"
  done | awk '{sum+=$2; n++} END {print "avg:", sum/n}'
avg: 0.00502326
smcintyre@fedora:~/Repositories/metasploit-framework$  for i in $(seq 1 100); do
    curl --socks5 127.0.0.1:1080 http://127.0.0.1:8000/ -o /dev/null -s -w "%{time_connect} %{time_total}\n"
  done | awk '{sum+=$2; n++} END {print "avg:", sum/n}'
avg: 0.00545381
smcintyre@fedora:~/Repositories/metasploit-framework$ 

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the SOCKS5 proxy implementation to use Rex::IO::RelayManager for TCP relaying instead of the local per-socket relay mixin, and updates the rex-core dependency to a git-based version that provides the needed relay manager behavior.

Changes:

  • Replace the custom SOCKS5 TcpRelay implementation with Rex::IO::RelayManager-based relays.
  • Add a relay_manager to the SOCKS5 server and use it from ServerClient.
  • Switch rex-core dependency to a specific git branch/revision in Bundler.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
lib/rex/proto/proxy/socks5/server.rb Initializes and exposes a RelayManager instance for use by SOCKS5 clients.
lib/rex/proto/proxy/socks5/server_client.rb Removes bespoke relay threading and wires sockets through the shared RelayManager; updates error logging and stop behavior.
Gemfile Pins rex-core to a git branch to pick up RelayManager changes.
Gemfile.lock Locks Bundler to the git-sourced rex-core revision.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants