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. Digit Stack

    Digit Stack In computer science, a stack is a particular kind of data type or collection in which th ...

  2. adb链接手机调试android应用

    adb链接手机调试android应用 hulk@hulk-Lenovo:~$ adb devices List of devices attached  ???????????? no permiss ...

  3. HDU 1074 Doing Homework (状态压缩 DP)

    题目大意: 有 n 项作业需要完成,每项作业有上交的期限和需完成的天数,若某项作业晚交一天则扣一分.输入每项作业时包括三部分,作业名称,上交期限,完成所需要的天数.求出完成所有作业时所扣掉的分数最少, ...

  4. Largest Rectangle in Histogram 解答

    Question Given n non-negative integers representing the histogram's bar height where the width of ea ...

  5. C#模拟网站用户登录

    我们在写灌水机器人.抓资源机器人和Web网游辅助工具的时候第一步要实现的就是用户登录.那么怎么用C#来模拟一个用户的登录拉?要实现用户的登录,那么首先就必须要了解一般网站中是怎么判断用户是否登录的. ...

  6. [Regex Expression] Tagline --- {0, } {1,10}

    Using a character set repeated 1 or more times, make a pattern to search for strings that do not con ...

  7. Android项目svn代码管理问题

    用svn控制版本,svn本身是不会识别哪些该传,哪些不该传,这就导致有些关于路径的东西(比如拓展jar的路径)也被上传了,而当别人下载后,那个路径对于这个人可能完全不存在,项目编译就会出问题.用ecl ...

  8. 纯css实现下拉菜单

    今天给大家分享一个纯html+css实现的下拉菜单.在此声明一点,源码并非出自本人之手,是同项目组一兄弟PLUTO写的.好东西嘛,所以果断拿出来和大家分享.如果有更好的想法或者建议,一定记得留言哦!好 ...

  9. HDU 5618 Jam's problem again

    题意: 三维坐标,对于1个点,找出有多少个点,3个坐标都比该点小! Sample Input 1 4 10 4 7 10 6 6 8 2 5 7 3 10   Sample Output 1 1 0 ...

  10. myeclipse8.6 for spring环境配置