All Projects → sethmlarson → Socksio

sethmlarson / Socksio

Licence: mit
Sans-I/O implementation of SOCKS4, SOCKS4A, and SOCKS5

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Socksio

nimSocks
A filtering SOCKS proxy server and client library written in nim.
Stars: ✭ 51 (+88.89%)
Mutual labels:  socks, socks5, socks-proxy
socks5 list
Auto-updated SOCKS5 proxy list + proxies for Telegram
Stars: ✭ 210 (+677.78%)
Mutual labels:  socks, socks5, socks-proxy
3proxy
3proxy - tiny free proxy server
Stars: ✭ 2,493 (+9133.33%)
Mutual labels:  socks, socks5, socks-proxy
Flynet
A powerful TCP/UDP tool, which support socks5 proxy by tcp and udp, http proxy and NAT traversal. This tool can help you bypass gfw easily
Stars: ✭ 124 (+359.26%)
Mutual labels:  socks5, socks, socks-proxy
Socks
Fully featured SOCKS proxy client supporting SOCKSv4, SOCKSv4a, and SOCKSv5. Includes Bind and Associate functionality.
Stars: ✭ 200 (+640.74%)
Mutual labels:  socks5, socks, socks-proxy
3proxy
3proxy - tiny free proxy server
Stars: ✭ 2,263 (+8281.48%)
Mutual labels:  socks5, socks, socks-proxy
microsocks11
A cross-platform SOCKS5 library and server based on the microsocks project.
Stars: ✭ 22 (-18.52%)
Mutual labels:  socks, socks5, socks-proxy
Tor Socks Proxy
🐳 Tiny Docker(🤏 10MB) image as 🧅 Tor SOCKS5 proxy 🛡
Stars: ✭ 218 (+707.41%)
Mutual labels:  socks5, socks, socks-proxy
rsp
Rapid SSH Proxy
Stars: ✭ 223 (+725.93%)
Mutual labels:  socks, socks5, socks-proxy
arch-privoxyvpn
Docker build script for Arch Linux base with Privoxy and OpenVPN
Stars: ✭ 55 (+103.7%)
Mutual labels:  socks, socks5
asyncio-socks-server
A SOCKS proxy server implemented with the powerful python cooperative concurrency framework asyncio.
Stars: ✭ 154 (+470.37%)
Mutual labels:  socks, socks5
Pummel
Socks5 Proxy HTTP/HTTPS-Flooding (cc) attack
Stars: ✭ 53 (+96.3%)
Mutual labels:  socks, socks5
Socks5
A full-fledged high-performance socks5 proxy server written in C#. Plugin support included.
Stars: ✭ 331 (+1125.93%)
Mutual labels:  socks, socks5
shadowrocket
A socks5 proxy to build your own shadowsocks private network. PHP based & Composer supported.
Stars: ✭ 23 (-14.81%)
Mutual labels:  socks5, socks-proxy
python-socks
Core proxy client (SOCKS4, SOCKS5, HTTP) functionality for Python
Stars: ✭ 40 (+48.15%)
Mutual labels:  socks, socks5
Prox5
🧮 SOCKS5/4/4a 🌾 validating proxy pool and upstream SOCKS5 server for 🤽 LOLXDsoRANDum connections 🎋
Stars: ✭ 39 (+44.44%)
Mutual labels:  socks, socks5
Nps
一款轻量级、高性能、功能强大的内网穿透代理服务器。支持tcp、udp、socks5、http等几乎所有流量转发,可用来访问内网网站、本地支付接口调试、ssh访问、远程桌面,内网dns解析、内网socks5代理等等……,并带有功能强大的web管理端。a lightweight, high-performance, powerful intranet penetration proxy server, with a powerful web management terminal.
Stars: ✭ 19,537 (+72259.26%)
Mutual labels:  socks5, socks
Docker Dante Telegram
dante config builder for Telegram SOCKS-proxy & Dockerfile for building image with such proxy
Stars: ✭ 16 (-40.74%)
Mutual labels:  socks5, socks
Proxy List
Get PROXY List that gets updated everyday
Stars: ✭ 347 (+1185.19%)
Mutual labels:  socks, socks-proxy
Socks5
SOCKS Protocol Version 5 Library in Go. Full TCP/UDP and IPv4/IPv6 support
Stars: ✭ 321 (+1088.89%)
Mutual labels:  socks5, socks

SOCKSIO

Build Status codecov Supported Python Versions PyPI

Client-side sans-I/O SOCKS proxy implementation. Supports SOCKS4, SOCKS4A, and SOCKS5.

socksio is a sans-I/O library similar to h11 or h2, this means the library itself does not handle the actual sending of the bytes through the network, it only deals with the implementation details of the SOCKS protocols so you can use it in any I/O library you want.

Current status: stable

Features not yet implemented:

  • SOCKS5 GSS-API authentication.
  • SOCKS5 UDP associate requests.

Usage

TL;DR check the examples directory.

Being sans-I/O means that in order to test socksio you need an I/O library. And the most basic I/O is, of course, the standard library's socket module.

You'll need to know ahead of time the type of SOCKS proxy you want to connect to. Assuming we have a SOCKS4 proxy running in our machine on port 8080, we will first create a connection to it:

import socket

sock = socket.create_connection(("localhost", 8080))

socksio exposes modules for SOCKS4, SOCKS4A and SOCKS5, each of them includes a Connection class:

from socksio import socks4

# The SOCKS4 protocol requires a `user_id` to be supplied.
conn = socks4.SOCKS4Connection(user_id=b"socksio")

Since socksio is a sans-I/O library, we will use the socket to send and receive data to our SOCKS4 proxy. The raw data, however, will be created and parsed by our SOCKS4Connection.

We need to tell our connection we want to make a request to the proxy. We do that by first creating a request object.

In SOCKS4 we only need to send a command along with an IP address and port. socksio exposes the different types of commands as enumerables and a convenience from_address class method in the request classes to create a valid request object:

# SOCKS4 does not allow domain names, below is an IP for google.com
request = socks4.SOCKS4Request.from_address(
    socks4.SOCKS4Command.CONNECT, ("216.58.204.78", 80))

from_address methods are available on all request classes in socksio, they accept addresses as tuples of (address, port) as well as string address:port.

Now we ask the connection to send our request:

conn.send(request)

The SOCKS4Connection will then compose the necessary bytes in the proper format for us to send to our proxy:

data = conn.data_to_send()
sock.sendall(data)

If all goes well the proxy will have sent reply, we just need to read from the socket and pass the data to the SOCKS4Connection:

data = sock.recv(1024)
event = conn.receive_data(data)

The connection will parse the data and return an event from it, in this case, a SOCKS4Reply that includes attributes for the fields in the SOCKS reply:

if event.reply_code != socks4.SOCKS4ReplyCode.REQUEST_GRANTED:
    raise Exception(
        "Server could not connect to remote host: {}".format(event.reply_code)
    )

If all went well the connection has been established correctly and we can start sending our request directly to the proxy:

sock.sendall(b"GET / HTTP/1.1\r\nhost: google.com\r\n\r\n")
data = receive_data(sock)
print(data)
# b'HTTP/1.1 301 Moved Permanently\r\nLocation: http://www.google.com/...`

The same methodology is used for all protocols, check out the examples directory for more information.

Development

Install the test requirements with pip install -r test-requirements.txt.

Install the project in pseudo-editable mode with flit install -s.

Tests can be ran directly invoking pytest.

This project uses nox to automate testing and linting tasks. nox is installed as part of the test requirements. Invoking nox will run all sessions, but you may also run only some them, for example nox -s lint will only run the linting session.

In order to test against a live proxy server a Docker setup is provided based on the Dante SOCKS server.

A container will start danted listening on port 1080. The docker-compose.yml will start the container and map the ports appropriately. To start the container in the background:

docker-compose -f docker/docker-compose.yml up -d

To stop it:

docker-compose -f docker/docker-compose.yml down

Alternatively, remove the -d flag to run the containers in the foreground.

Reference documents

Each implementation follows the documents as listed below:

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].