当前位置: 网学 > 编程文档 > VB > 正文

VB6中使用Winsock穿越各种代理的实现

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/16
下载{$ArticleTitle}原创论文样式
CKS request is formed as follows:

  +----+-----+-------+------+----------+----------+

  |VER | CMD | RSV | ATYP | DST.ADDR | DST.PORT |

  +----+-----+-------+------+----------+----------+

  | 1 | 1 | X''00'' | 1 | Variable | 2 |

  +----+-----+-------+------+----------+----------+

  Where:

  o VER protocol version: X''05'' ------------- 固定 05

  o CMD

  o CONNECT X''01'' ------------- TCP方式 01

  o BIND X''02''

  o UDP ASSOCIATE X''03'' ------------- UDP方式 03

  o RSV RESERVED ------------- 固定 00

  o ATYP address type of following address

  o IP V4 address: X''01'' ------------- IPv4 01

  o DOMAINNAME: X''03''

  o IP V6 address: X''04''

  o DST.ADDR desired destination address

  o DST.PORT desired destination port in network octet

  order

  The SOCKS server will typically evaluate the request based on source

  and destination addresses, and return one or more reply messages, as

  appropriate for the request type.

  发送 05 01 00 01 + 目的地址(4字节) + 目的端口(2字节),目的地址和端口都是16进制码(不是字符串)。

  例202.103.190.27 - 7201

  则发送的信息为:05 01 00 01 CA 67 BE 1B 1C 21

  (CA=202 67=103 BE=190 1B=27 1C21=7201)

  关于我是怎么把16进制码换成10进制的,请自己看程序

  最后,接受服务器返回数据,看RFC:

  +----+-----+-------+------+----------+----------+

  |VER | REP | RSV | ATYP | BND.ADDR | BND.PORT |

  +----+-----+-------+------+----------+----------+

  | 1 | 1 | X''00'' | 1 | Variable | 2 |

  +----+-----+-------+------+----------+----------+

  Where:

  o VER protocol version: X''05'' ------------ 固定 05

  o REP Reply field:

  o X''00'' succeeded ------------ 若为 00 成功 其余可以都看成失败

  o X''01'' general SOCKS server failure

  o X''02'' connection not allowed by ruleset

  o X''03'' Network unreachable

  o X''04'' Host unreachable

  o X''05'' Connection refused

  o X''06'' TTL expired

  o X''07'' Command not supported

  o X''08'' Address type not supported

  o X''09'' to X''FF'' unassigned

  o RSV RESERVED

  o ATYP address type of following address

  o IP V4 address: X''01''

  o DOMAINNAME: X''03''

  o IP V6 address: X''04''

  o BND.ADDR server bound address

  o BND.PORT server bound port in network octet order

  Fields marked RESERVED (RSV) must be set to X''00''.

  可见,对于返回信息,只须判断第二字节是否为00.若为 00 连接成功,剩下的操作和直连一样,Winsock可直接用SendData 和 GetData 发送\接受数据.

  下面介绍需要验证用户名/密码的socks5穿透

  第一步还是发送三个字节,只是内容有变,展开来写为: 05 01 02

  服务器返回信息也有所不同,正确的返回为 05 02

  成功后发送用户/密码信息,请看RFC 说明:

  Once the SOCKS V5 server has started, and the client has selected the

  Username/Password Authentication protocol, the Username/Password

  subnegotiation begins. This begins with the client producing a

  Username/Password request:

  +----+------+----------+------+----------+

  |VER | ULEN | UNAME | PLEN | PASSWD |

  +----+------+----------+------+----------+

  | 1 | 1 | 1 to 255 | 1 | 1 to

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号