SOCKS5协议

1. NEGO.
client---->ss-local start a connection
negotiate with sock5 protocal
+-----+---------------+-----------------+
| VER |    NMETHODS   |     METHODS     |
+-----+---------------+-----------------+
| 1   |      1        |    1 to 255     |
+-----+---------------+-----------------+
version is  x05
nmethods is x01 : methods's length is 1
methods is  x00 : no authentication required
            x01 : gssapi
            x02 : username/password
            x03 : to x7f IANA assigned
            x04 : to xfe reserved for private methods
            xff : no acceptable methods
eg:b'\x05\x02\x00\02'  b'\x05\x01\x00'

the ss-local as server receives the req, selects one of the methods,
then send the message as response to client. The method here is x00.
+-----+---------------+
| VER |     METHOD    |
+-----+---------------+
| 1   |      1        |
+-----+---------------+
version is  x05
methods is  x00

2.client send request
After Nego, the client sends the request detail. The req as follows:
+-----+-----+-----+------+----------+----------+
| VER | CMD | RSV | ATYP | DST.ADDR | DST.PORT |
+-----+-----+-----+------+----------+----------+
|  1  |  1  | X00 |   1  |   Var    |     2    |
+-----+-----+-----+------+----------+----------+
VER:  protocol version:x05

CMD
    1.CONNECT       x01
    2.BIND          x02
    3.UDP ASSOCIATE x03
    
RSV:  reserved

ATYP: address type of following address
    1.IPV4 addr     x01   (4bytes)
    2.domainname    x03   (variable len)
    3.IPV6 addr     x04   (16bytes)
    
DST.ADDR: desired destination address.(client request dest addr)
    1.ATYP=x01-->ipv4 addr  with a length of 4 octets(4 bytes)
    2.ATYP=x03-->domainname DST.ADDR: len(1 byte) + domain
    +--------------+
    |  DST.ADDR    |
    +--------------+
    | len  |domain |
    +--------------+
    3.ATYP=x04-->ipv6 addr  with a length of 16 octets(16 bytes)
    
DST.PORT: desired destination port in network octet order. (2bytes)

3.ss-local(as server) send reply
when ss-local as server of socks5 receive the request of client,
it returns a reply formed as follows:
+-----+-----+-----+------+----------+----------+
| VER | REP | RSV | ATYP | BND.ADDR | BND.PORT |
+-----+-----+-----+------+----------+----------+
|  1  |  1  | X00 |   1  |   Var    |     2    |
+-----+-----+-----+------+----------+----------+

VER:  protocol version: x05

REP:
    1.x00: succeeded
    2.x01: general SOCKS server failure
    3.x02: connection not allowed by ruleset
    4.x03: network unreachable
    5.x04: host unreachable
    6.x05: connection refused
    7.x06: TTL expired
    8.x07: command not supported
    9.x08: address type not supported
    10.x09:to xff unassigned
    
RSV:  reserved

ATYP: address type of following address
    1.IPV4 addr     x01   (4bytes)
    2.domainname    x03   (variable len)
    3.IPV6 addr     x04   (16bytes)
    
BND.ADDR: server bound address
BND.PORT: server bound port in network octet order.it contains
          the port that socks server assigned to connect to the
          target host.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值