科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道VB6中使用Winsock穿越各种代理的实现(五)

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

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

     根据RFC的说法,代理服务器返回8字节的数据,我们只要判断第二字节是否为90即可,若是90连接成功,否则失败.剩下的操作和直连一样,Winsock可直接用SendData 和 GetData 发送\接受数据.   HTTP1.1 代理的穿透

作者:中国IT实验室 来源:中国IT实验室 2007年9月13日

关键字: 使用 VB 编程

  • 评论
  • 分享微博
  • 分享邮件
  

  根据RFC的说法,代理服务器返回8字节的数据,我们只要判断第二字节是否为90即可,若是90连接成功,否则失败.剩下的操作和直连一样,Winsock可直接用SendData 和 GetData 发送\接受数据.

  HTTP1.1 代理的穿透

  由于RFC 2616过于冗长,加上HTTP代理穿透的步骤比socks简单,这里就不详细说明了,我只给出连接的步骤和发送数据格式.

  第一步仍然是用Winsock去连接代理服务器.第二步为发送请求字符,其格式为:

  无用户名/密码校验 格式:

  "CONNECT" + 空格 + 目标连接地址 + ":" + 目标连接端口 + 空格 + "HTTP/1.1" + Chr(13) + Chr(10) + "Host:" + 空格 + 目标连接地址 + ":" + 目标连接端口 + Chr(13) + Chr(10) + Chr(13) + Chr(10)

  用户名/密码验证格式:

  "CONNECT" + 空格 + 目标连接地址 + ":" + 目标连接端口 + 空格 + "HTTP/1.1" + Chr(13) + Chr(10) + "Host:" + 空格 + 目标连接地址 + ":" + 目标连接端口 + Chr(13) + Chr(10) + "Authorization: Basic" + 空格 + 经Base64加密过后的[用户名:密码] + Chr(13) + Chr(10) + Chr(13) + Chr(10) + "Proxy-Authorization: Basic" + 空格 + 经Base64加密过后的[用户名:密码] + Chr(13) + Chr(10) + Chr(13) + Chr(10)

发送请求完毕后,将收到代理的回应,根据RFC说明(注意 Status-Line 和 Status-Code):

  6 Response

  After receiving and interpreting a request message, a server responds

  with an HTTP response message.

  Response = Status-Line ; Section 6.1

  *(( general-header ; Section 4.5

  | response-header ; Section 6.2

  | entity-header ) CRLF) ; Section 7.1

  CRLF

  [ message-body ] ; Section 7.2

  6.1 Status-Line

  The first line of a Response message is the Status-Line, consisting

  of the protocol version followed by a numeric status code and its

  associated textual phrase, with each element separated by SP

  characters. No CR or LF is allowed except in the final CRLF sequence.

  Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF

  6.1.1 Status Code and Reason Phrase

  The Status-Code element is a 3-digit integer result code of the

  attempt to understand and satisfy the request. These codes are fully

  defined in section 10. The Reason-Phrase is intended to give a short

  textual description of the Status-Code. The Status-Code is intended

  for use by automata and the Reason-Phrase is intended for the human

  user. The client is not required to examine or display the Reason-

  Phrase.

  The first digit of the Status-Code defines the class of response. The

  last two digits do not have any categorization role. There are 5

  values for the first digit:

  - 1xx: Informational - Request received, continuing process

  - 2xx: Success - The action was successfully received,

  understood, and accepted

  - 3xx: Redirection - Further action must be taken in order to

  complete the request

  - 4xx: Client Error - The request contains bad syntax or cannot

  be fulfilled

  - 5xx: Server Error - The server failed to fulfill an apparently

  valid request

  The individual values of the numeric status codes defined for

  HTTP/1.1, and an example set of corresponding Reason-Phrase's, are

  presented below. The reason phrases listed here are only

  recommendations -- they MAY be replaced by local equivalents without

 

查看本文来源

    • 评论
    • 分享微博
    • 分享邮件
    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章