侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

Asp WinHttp.WinHttpRequest.5.1 对象使用详解 伪造 HTTP 头信息

Windows  /  管理员 发布于 5年前   373

由于微软封锁了 XmlHttp 对象,所以无法伪造部分 HTTP 头信息,但是 WinHttp.WinHttpRequest.5.1 对象,它居然用可以成功伪造所有 http 请求的 header 信息!

从msdn得知,WinHttp.WinHttpRequest.5.1 是 msxml 4.0 的底层对象,也就是说 XMLHTTP/ServerXMLHTTP 也是在它的基础上封装而来,WinHttpRequest 的用法与 XmlHttp 大致相同。

WaitForResponse 在使用异步方式发送请求时,可以用这个方法来控制请求的进程,指定的等待时间,以秒为一个异步传送方法来完成的值,SetTimeouts。

在服务端脚本中,不可以像客户端那样直接使用回调函数来控制异步请求,也没有相应的函数来使用程序休眠一定的时间,因此,为了等待请求返回,我们可以使用这个方法来等待一定时间。

复制代码 代码如下:

<%
Dim WinHttp
Set WinHttp = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
'设置参数
WinHttp.SetTimeouts 60000, 60000, 60000, 3000 '设置操作超时时间
'WinHttp.SetTimeouts resolveTimeout, connectTimeout, sendTimeout, receiveTimeout
'resolveTimeout = 10000 '解析 DNS 名字的超时时间,10000 毫秒。
'connectTimeout = 10000 '建立 Winsock 连接的超时时间,10000 毫秒。
'sendTimeout = 120000 '发送数据的超时时间,120000 毫秒。
'receiveTimeout = 60000 '接收 response 的超时时间,60000 毫秒。
WinHttp.Option(4) = 13056 '忽略错误标志
WinHttp.Option(6) = False '为 True 时,当请求页面重定向跳转时自动跳转,False 不自动跳转,截取服务端返回的302状态。
WinHttp.Open "GET", "http://www.baidu.com/", False 'GET 或 POST, Url, False 同步方式;True 异步方式
'组成 HTTP 头信息
WinHttp.SetRequestHeader "Accept", "*/*" '接受数据类型
WinHttp.SetRequestHeader "Accept-Language", "zh-cn,zh" '用户系统语言
WinHttp.SetRequestHeader "User-Agent", "Mozilla/6.0" '用户浏览器信息
WinHttp.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded" '编码方式
WinHttp.SetRequestHeader "Referer", "http://www.baidu.com/" '来路
WinHttp.SetRequestHeader "Connection", "Close" 'Close = 不保持连接,Keep-Alive = 保持连接(持久连接)
'WinHttp.SetRequestHeader "Accept-Encoding", "gzip, deflate" '如果发送,会返回 gzip, deflate 压缩过的编码
'WinHttp.SetRequestHeader "Content-Length", Len(Str) '内容长度,Post 方式用的。
WinHttp.SetRequestHeader "Cookie", "test cookie!" '设置 Cookie
'发送数据
WinHttp.Send 'Post 方式:WinHttp.Send (参数)
WinHttp.WaitForResponse '等待返回请求,XMLHTTP中也可以使用
'输出结果
Response.Write WinHttp.Status '当前 HTTP 状态
'Response.Write WinHttp.ResponseText '文本数据
Response.BinaryWrite WinHttp.ResponseBody '二进制数据流数据
%>

Option()相关:

WinHttpRequestOption_UserAgentString = 0;
WinHttpRequestOption_URL = 1;
WinHttpRequestOption_URLCodePage = 2;
WinHttpRequestOption_EscapePercentInURL = 3;
WinHttpRequestOption_SslErrorIgnoreFlags = 4;
WinHttpRequestOption_SelectCertificate = 5; '13056 = 忽略错误标志
WinHttpRequestOption_EnableRedirects = 6; '为True时,当请求的页面中有跳转时,抓取跳转页面信息.False相反不抓取
WinHttpRequestOption_UrlEscapeDisable = 7;
WinHttpRequestOption_UrlEscapeDisableQuery = 8;
WinHttpRequestOption_SecureProtocols = 9;
WinHttpRequestOption_EnableTracing = 10;
WinHttpRequestOption_RevertImpersonationOverSsl = 11;
WinHttpRequestOption_EnableHttpsToHttpRedirects = 12;
WinHttpRequestOption_EnablePassportAuthentication = 13;
WinHttpRequestOption_MaxAutomaticRedirects = 14;
WinHttpRequestOption_MaxResponseHeaderSize = 15;
WinHttpRequestOption_MaxResponseDrainSize = 16;
WinHttpRequestOption_EnableHttp1_1 = 17;
WinHttpRequestOption_EnableCertificateRevocationCheck = 18;

方法 Description 说明

Abort 中止一个WinHTTP的 发送方法。
GetAllResponseHeaders 检索所有的HTTP响应头。
GetResponseHeader 检索HTTP响应头。
Open 打开一个HTTP连接到HTTP资源。
Send 发送一个HTTP请求到HTTP服务器。
SetAutoLogonPolicy 设置当前自动登录策略。
SetClientCertificate 选择一个客户端证书发送到一个安全的超文本传输协议(HTTPS)服务器。
SetCredentials 设置要使用的凭据与HTTP服务器,要么是原籍国或代理服务器。
SetProxy 设置代理服务器信息。
SetRequestHeader 添加,更改或删除一个HTTP请求标头。
SetTimeouts 指定以毫秒为单位,个人的时间超过了一个组件发送/接收操作。
WaitForResponse 指定的等待时间,以秒为一个异步传送方法来完成的值,SetTimeouts。

该 WinHttpRequest 对象定义以下属性。

属性 访问类型 说明

Option 读/写 设置或检索一个WinHTTP的选项值。
ResponseBody 只读 检索作为无符号字节数组的响应实体机构。
ResponseStream 只读 检索机构作为响应实体的IStream。
ResponseText 只读 作为文本检索响应实体机构。
Status 只读 从上次检索响应的HTTP状态代码。
StatusText 只读 获取HTTP状态的文本。

Events 活动

The WinHttpRequest object defines the following events.
WinHttpRequest 对象定义的下列事件。

Event 事件 Description说明

OnError Occurs when there is a run-time error in the application.
当发生一个应用程序运行时错误时发生。
OnResponseDataAvailable Occurs when data is available from the response.
当响应数据可用时发生。
OnResponseFinished Occurs when the response data is complete.
响应数据完成时发生。
OnResponseStart Occurs when the response data starts to be received.
开始收到响应数据时发生。

Remarks 备注

The WinHttpRequest object uses the IErrorInfo interface to provide error data.
该 WinHttpRequest 对象使用 IErrorInfo 接口来提供错误数据。
A description and numerical error value can be obtained with the Err object in Microsoft Visual Basic Scripting Edition (VBScript),
and the Error object in Microsoft JScript.
The lower 16 bits of an error number correspond to the values found in Error Messages.
Note For Windows XP and Windows 2000, see Run-Time Requirements.
注意:对于 Windows XP 和 Windows 2000,请参阅运行时间要求。

Requirements 要求

最低支持的客户端 Windows XP, Windows 2000 Professional with SP3 Windows XP
最低支持的服务器 Windows Server 2003, Windows 2000 Server with SP3

可再发行 WinHTTP 5.0 and Internet Explorer 5.01 or later on Windows XP and Windows 2000.
WinHTTP的5.0和Internet Explorer 5.01或更高版本的Windows XP和Windows 2000。
IDL HttpRequest.idl HttpRequest.idl
Library Winhttp.lib Winhttp.lib
DLL Winhttp.dll Winhttp.dll


  • 上一条:
    Win7的IIS7中ASP获得的系统日期格式为斜杠的解决办法
    下一条:
    在Windows版的PHP中使用ADO
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • Windows 10的告别:2025年10月14日,一段时代的终结(0个评论)
    • windows 11激活_Win11 KMS激活流程步骤(1个评论)
    • 安装Windows 11系统的注意了,看看你的cpu是否在微软兼容列表排除中(1个评论)
    • 微软将于2022年9月20日推送Windows11 22H2新版本,推测2024发布windows 12(0个评论)
    • windows11系统中可以关闭禁止的服务及介绍(1个评论)
    • 近期文章
    • 智能合约Solidity学习CryptoZombie第三课:组建僵尸军队(高级Solidity理论)(0个评论)
    • 智能合约Solidity学习CryptoZombie第二课:让你的僵尸猎食(0个评论)
    • 智能合约Solidity学习CryptoZombie第一课:生成一只你的僵尸(0个评论)
    • 在go中实现一个常用的先进先出的缓存淘汰算法示例代码(0个评论)
    • 在go+gin中使用"github.com/skip2/go-qrcode"实现url转二维码功能(0个评论)
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(0个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 欧盟关于强迫劳动的规定的官方举报渠道及官方举报网站(0个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf文件功能(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2018-01
    • 2018-06
    • 2020-06
    • 2021-06
    • 2021-07
    • 2022-01
    • 2022-04
    • 2022-08
    • 2023-08
    • 2023-10
    • 2024-04
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客