Coder Social home page Coder Social logo

smous / xsocks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lparam/xsocks

0.0 1.0 0.0 255 KB

A secure and fast proxy for protect your network traffic

License: GNU General Public License v3.0

Python 0.96% Makefile 2.95% Shell 1.34% C 94.76%

xsocks's Introduction

xsocks

A secure and fast proxy for protect your network traffic

Introdution

  • xsocksd: Backend of xsocks, xtproxy, xforwarder
  • xsocks: A socks5 server
  • xtproxy: A Transparent Proxy
  • xforwarder: Forward data to a specific server
  • xtunnel: Like xforwarder, but standalone and specify target on server side

Features

  • Transparent Proxy for all tcp traffic and udp packet
  • Multithreading
  • Cross-platform, including PC (Linux, Windows), Mobile (Android) and Router (OpenWRT)

BUILD

Linux

make && sudo make install

OpenWRT

# At OpenWRT build root
git clone https://github.com/lparam/xsocks.git package/xsocks
make package/xsocks/openwrt/compile

Windows

# win32
make mingw32 HOST=i686-w64-mingw32
# win64
make mingw32 HOST=x86_64-w64-mingw32

Usage

Server

xsocksd -k PASSWORD
xtunnel -m server -k PASSWORD -t TARGET:PORT

Multithreading:

xsocksd -k PASSWORD -c THREADS

Stop:

xsocksd --signal stop

Client

xsocks -s SERVER:PORT -k PASSWORD
xforwarder -s SERVER:PORT -k PASSWORD -t TARGET:PORT
xtunnel -m client -k PASSWORD -t TARGET:PORT

Transparent Proxy

Proxy all tcp traffic and udp packet transparently on gateway.

root@OpenWrt:~# opkg install iptables-mod-tproxy
root@OpenWrt:~# opkg install xsocks_VER_ARCH.ipk

Modify your SERVER and PASSWORD in /etc/init.d/xsocks

#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2014 OpenWrt.org

START=72
STOP=30
FIREWALL_RELOAD=0
SERVER=IP:PORT
PASSWORD=PASSWORD

start() {
    tproxy
    mkdir -p /var/run/xsocks
    xsocks -s $SERVER -k $PASSWORD
    xtproxy -s $SERVER -k $PASSWORD
    xforwarder -l 0.0.0.0:5533 -t 8.8.8.8:53 -s $SERVER -k $PASSWORD
}

stop() {
    xsocks --signal stop
    xtproxy --signal stop
    xforwarder --signal stop
}

shutdown() {
    xsocks --signal quit
    xtproxy --signal quit
    xforwarder --signal quit
}

tproxy() {
    local LISTEN_PORT=1070
    local IP_ROUTE_TABLE_NUMBER=100
    local FWMARK="0x01/0x01"
    local SETNAME=wall

    iptables -t nat -D PREROUTING -p tcp -j XSOCKS
    iptables -t nat -F XSOCKS
    iptables -t nat -X XSOCKS

    iptables -t mangle -D PREROUTING -j XSOCKS
    iptables -t mangle -F XSOCKS
    iptables -t mangle -X XSOCKS

    iptables -t nat -N XSOCKS
    iptables -t mangle -N XSOCKS

    ipset -F $SETNAME
    ipset -X $SETNAME
    ipset -N $SETNAME iphash

    ### TCP
    iptables -t nat -A XSOCKS -p tcp -m set --match-set $SETNAME dst -j REDIRECT --to-port $LISTEN_PORT
    iptables -t nat -A PREROUTING -p tcp -j XSOCKS

    ### UDP
    ip rule del fwmark $FWMARK table $IP_ROUTE_TABLE_NUMBER
    ip route del local 0.0.0.0/0 dev lo table $IP_ROUTE_TABLE_NUMBER

    ip rule add fwmark $FWMARK table $IP_ROUTE_TABLE_NUMBER
    ip route add local 0.0.0.0/0 dev lo table $IP_ROUTE_TABLE_NUMBER

    iptables -t mangle -A XSOCKS -p udp -m set --match-set $SETNAME dst -j TPROXY \
        --on-port $LISTEN_PORT --tproxy-mark $FWMARK
    iptables -t mangle -A PREROUTING -j XSOCKS
}
root@OpenWrt:~# /etc/init.d/xsocks start
root@OpenWrt:~# ipset add SETNAME IP

License

Copyright (C) 2014 lparam

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

xsocks's People

Contributors

lparam avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.