private string SendRequest(string account, string cardNumber, string cardPass)
{
string targetUrl = https://xxx.com/;//要提交数据的目标网站 //提交的数据
string postData = string.Format("ursName={0}&userName2={0}&cardNo={1}&cardPass={2}", account, cardNumber, cardPass); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(targetUrl);
request.Method = "POST";
request.Referer = http://www.xxx.com/jsp/xxx.jsp;
byte[] bytes = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = bytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(bytes, , bytes.Length); HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.Default);
string responseText = reader.ReadToEnd(); string res = "成功!";
if (responseText.Contains("errorID"))
{
string errorDetailPage = new System.Text.RegularExpressions.Regex(@"URL=(?<url>.*?)"">",
System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Multiline
).Match(responseText).Groups["url"].Value; HttpWebRequest requestErrorInfo = (HttpWebRequest)WebRequest.Create(errorDetailPage);
requestErrorInfo.Method = "GET";
requestErrorInfo.Proxy = request.Proxy;
HttpWebResponse responseErrorInfo = (HttpWebResponse)requestErrorInfo.GetResponse();
StreamReader readerErrorInfo = new StreamReader(responseErrorInfo.GetResponseStream(), Encoding.Default);
string responseTextErrorInfo = readerErrorInfo.ReadToEnd();
string errorDetailMessage = new System.Text.RegularExpressions.Regex(@"<h3>(?<info>.*?)<.*?</h3>",
System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Multiline
).Match(responseTextErrorInfo).Groups["info"].Value.Replace("&nbsp;", ""); res = string.Format(@"失败!<br />错误信息:{0}<br /><a href=""{1}"" target=""_blank"">查看错误详情</a>", errorDetailMessage, errorDetailPage);
} return res;
}

C# 伪造 referer 提交数据的更多相关文章

  1. JavaScript 伪造 Referer 来路方法

    Javascript 是一种由Netscape的LiveScript发展而来的原型化继承的基于对象的动态类型的区分大小写的客户端脚本语言,主要目的是为了解决服务器端语言,比如Perl,遗留的速度问题, ...

  2. php用fsockopen实现post提交数据并获得返回数据

    /** * 函数介绍: 用于post方式提交数据 * 输入参数: 完整url, 数据 * 返回值 : 接口返回值 */ function post_it($url, $data = '', $time ...

  3. php模拟POST请求提交数据

    php模拟POST请求提交数据 1.基于fsockopen function phppost00($jsonString){ $URL='https://www.jy.com/phppostok.ph ...

  4. iframe 加form提交数据

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. Django中Ajax提交数据的CSRF问题

    错误信息: Forbidden (CSRF token missing or incorrect.): 什么是CSRF: django为用户实现防止跨站请求伪造的功能,通过中间件 django.mid ...

  6. pos提交提交数据时碰到Django csrf

    我的github(PS:希望star):https://github.com/thWinterSun/v-admin 最近在用Vue写前端代码,再用vue-resource向后台提交数据.项目后台是用 ...

  7. delphi 模拟POST提交数据

    unit GetHttpInfo; interface uses Classes, WinINet, Sysutils, windows, IDURI, IdSSLOpenSSL , IdBaseCo ...

  8. C#中使用 HttpWebRequest 向网站提交数据

    HttpWebRequest 是 .NET 基类库中的一个类,在命名空间 System.Net 里,用来使用户通过 HTTP 协议和服务器交互. HttpWebRequest 对 HTTP 协议进行了 ...

  9. php CURL 模拟 POST 提交数据

    <?php function liansuo_post($url,$data){ // 模拟提交数据函数 $curl = curl_init(); // 启动一个CURL会话 curl_seto ...

随机推荐

  1. hdu 3832 Earth Hour

    http://acm.hdu.edu.cn/showproblem.php?pid=3832 #include <cstdio> #include <iostream> #in ...

  2. 通用Makefile

    本文推荐了一个用于对 C/C++ 程序进行编译和连接以产生可执行程序的通用 Makefile. 在使用 Makefile 之前,只需对它进行一些简单的设置即可:而且一经设置,即使以后对源程序文件有所增 ...

  3. VC++ 2013 开发windows窗体程序

    开发工具版本:Visual Studio Express 2013 for Windows Desktop 1. 新建Visual C++下面的"Win32 Project" 2. ...

  4. chrome无法使用非官方商店扩展解决办法

        自己开发的工具性插件不想放在官方商店(当然也有可能是工作相关的工具不能放在官方商店),由于新版本的chrome不允许非官方商店的插件进行安装使用,所以出现一个头疼的问题:每次开启chrome都 ...

  5. Unity 白猫操作小实例

    最近师兄找我说白猫的操作如何做,  0.0 结果白猫没有android的客户端玩不了,看了下视频介绍就简单做了下 效果图:   核心代码: using UnityEngine; using Syste ...

  6. ios delegate 和 block

    //委托的协议定义 @protocol UpdateDelegate <NSObject> - (void)update; @end @interface Test : NSObject ...

  7. struts2——简单登陆实例

    从今天开始,一起跟 各位聊聊java的三大框架——SSH.先从Struts开始说起,Struts对MVC进行了很好的封装,使用Struts的目的是为了帮助我们减少在 运用MVC设计模型来开发Web应用 ...

  8. [Hapi.js] Serving static files

    hapi does not support serving static files out of the box. Instead it relies on a module called Iner ...

  9. iOS开发CoreAnimation解读之一——初识CoreAnimation核心动画编程

    iOS开发CoreAnimation解读之一——初识CoreAnimation核心动画编程 一.引言 二.初识CoreAnimation 三.锚点对几何属性的影响 四.Layer与View之间的关系 ...

  10. 【问题备注】VS2012不能输入代码,文字…

    第一次遇到,非常奇怪,一个项目,VS2012能正常打开,但是不能输入代码. 对比分析发现,其他项目能正常work.在于一个问题就是,VS2012 右下角有个INS一直在转一直analyzing,而正常 ...