A windows DLL which hook the connect()
std call to redirect sockets to SOCKS5 proxy server. Includes support for authentication with username/password.
Follow the Vcpkg Quick Start and install the following packages:
.\vcpkg install spdlog:x86-windows-static spdlog:x64-windows-static detours:x86-windows-static detours:x64-windows-static
This project use the NMAKE version of makefile. To build the DLL, simply open your Developper Command Prompt for Visual Studio
and use:
nmake
to buildnmake clean
to clean
To enable the redirection you just have to inject the DLL in your target process.
By default, socksfier redirect sockets to localhost:1080
but these values can be set by using the exported functions set_proxy_address()
and set_proxy_port()
. You can also set authentication username and password with set_proxy_username()
and set_proxy_password()
.
To call these functions and use your own configuration you need a DLL injector which allow you to calls these functions. For example with this one, I can change the default port to 9050
. Full example below.
from injector import Injector
import socket
import struct
injector = Injector()
# Variables
proxy_addr = socket.inet_aton("127.0.0.1")
proxy_port = struct.pack("!H", 9050)
proxy_username = 'your_username'
proxy_password = 'your_password'
path_exe = 'path/to/your/exe/to/be/hooked'
path_dll = 'path/to/socksfier/dll/with/same/architeture/as/exe'
# Create the given process
pid = injector.create_process(path_exe)
# Load it.
injector.load_from_pid(pid)
# Inject the DLL.
dll_addr = injector.inject_dll(path_dll)
# Set variables on DLL
injector.call_from_injected(path_dll, dll_addr, "set_proxy_address", proxy_addr)
injector.call_from_injected(path_dll, dll_addr, "set_proxy_port", proxy_port)
# If your SOCKS 5 proxy does not need authentication, comment these 2 lines:
injector.call_from_injected(path_dll, dll_addr, "set_proxy_username", bytes(proxy_username, 'ascii'))
injector.call_from_injected(path_dll, dll_addr, "set_proxy_password", bytes(proxy_password, 'ascii'))
injector.unload()