2
kojines is an application that accepts connections forwarded to it by
3
the iptables REDIRECT target, and forwards them to a remote SOCKS5
4
proxy, using the original destination address of the REDIRECTed
5
connection as the destination address in the SOCKS5 proxy request.
9
1. Set up a SOCKS5 proxy. For example, using ssh, run ssh with the
10
"-D 1080" argument (or add 'DynamicForward 0.0.0.0:1080' in the
11
config file for the host you are ssh'ing to).
15
3. Forward connections to kojines by adding an iptables rule to
16
REDIRECT those connections to localhost port 63636 (which is the
17
default address:port combination that kojines listens on).
19
For example, to forward all connections to 1.2.3.4 port 80 (TCP)
20
over the SOCKS5 proxy, do:
22
iptables -t nat -A OUTPUT -d 1.2.3.4 -p tcp --dport 80 -j REDIRECT --to-ports 63636
24
Now if a connection is made to 1.2.3.4:80, it will be redirected to
25
localhost:63636, where kojines will pick it up, issue a SO_ORIGINAL_DST
26
ioctl on it to find the original destination address, get 1.2.3.4:80
27
back from that ioctl, connect to 127.0.0.1:1080 (the ssh process you
28
started earlier), send a SOCKS5 open request for the remote address
29
1.2.3.4:80 to 127.0.0.1:1080, and once the SOCKS5 connection establishes,
30
splice the two TCP connections together.
32
There is currently no run-time (config file or command line option)
33
method to change the listening address and SOCKS5 proxy address -- you'll
34
have to edit main.c for now.