WinHttp用法(WinHttp.WinHttpRequest.5.1方法,属性)

WinHttp用法(WinHttp.WinHttpRequest.5.1方法,属性)使用WinHttpRequest伪造HTTP头信息,伪造Referer等信息由于微软封锁了XmlHttp对象,所以无法伪造部分HTTP头信息,但是WinHttp.WinHttpRequest.5.1对象,它居然用可以成功伪造所有http请求的header信息!从msdn得知,WinHttp.WinHttpRequest.5.1是msxml4.0的底层对象,也就是说XML

大家好,又见面了,我是你们的朋友全栈君。使用WinHttpRequest伪造HTTP头信息,伪造Referer等信息

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

从msdn得知,WinHttp.WinHttpRequest.5.1是msxml4.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


版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/157272.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • python for跳过下一个循环_python循环三次跳出循环

    python for跳过下一个循环_python循环三次跳出循环python中如何退出for循环Python中的for循环与其它语言不大一样,但跳出循环还是与大多数语言一样,可以使用关键字continue跳出本次循环或者break跳出整个for循环。break语句:Python中的break语句,就像在C语言中,打破了最小封闭for或while循环。break语句用来终止循环语句,即循环条件没有False条件或者序列还没被完全递归完,也会停止执行循环语句。br…

    2022年8月12日
    9
  • 6421B Lab1 规划和配置IPv4

    6421B Lab1 规划和配置IPv4

    2021年8月20日
    54
  • 下载文件总结

    下载文件总结

    2021年9月20日
    73
  • springboot 配置JedisPool 简洁有效 复制即可运行「建议收藏」

    springboot 配置JedisPool 简洁有效 复制即可运行「建议收藏」吐槽一下,本来以为随便找个文章跟着配置一下,就可以了,后来发现好多例子无法运行。估计是环境的问题,后来把大神们的例子综合一下,终于配置出一个简洁有效的例子,个人太懒,技术太烂,复杂的代码不理解,所以能简就简。抛砖引玉,大家多指点。

    2025年9月14日
    7
  • 什么是多线程?如何实现多线程?[通俗易懂]

    什么是多线程?如何实现多线程?[通俗易懂]【转】什么是线程安全?怎么实现线程安全?什么是进程?什么是线程?什么是线程安全?添加一个状态呢?如何确保线程安全?synchronizedlock转自:https://blog.csdn.net/csdnnews/article/details/82321777什么是进程?电脑中时会有很多单独运行的程序,每个程序有一个独立的进程,而进程之间是相互独立存在的。比如下图中的QQ、酷狗播放器、电脑…

    2022年6月5日
    26
  • @JsonIgnore作用「建议收藏」

    @jsonignore的作用作用是json序列化时将javabean中的一些属性忽略掉,序列化和反序列化都受影响。如下:packagecom.hzboy.orm;importjava.util.List;importjavax.persistence.CascadeType;importjavax.persistence.Column;importj

    2022年4月11日
    119

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号