C# 伪造 referer 提交数据
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(" ", ""); res = string.Format(@"失败!<br />错误信息:{0}<br /><a href=""{1}"" target=""_blank"">查看错误详情</a>", errorDetailMessage, errorDetailPage);
} return res;
}
C# 伪造 referer 提交数据的更多相关文章
- JavaScript 伪造 Referer 来路方法
Javascript 是一种由Netscape的LiveScript发展而来的原型化继承的基于对象的动态类型的区分大小写的客户端脚本语言,主要目的是为了解决服务器端语言,比如Perl,遗留的速度问题, ...
- php用fsockopen实现post提交数据并获得返回数据
/** * 函数介绍: 用于post方式提交数据 * 输入参数: 完整url, 数据 * 返回值 : 接口返回值 */ function post_it($url, $data = '', $time ...
- php模拟POST请求提交数据
php模拟POST请求提交数据 1.基于fsockopen function phppost00($jsonString){ $URL='https://www.jy.com/phppostok.ph ...
- iframe 加form提交数据
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Django中Ajax提交数据的CSRF问题
错误信息: Forbidden (CSRF token missing or incorrect.): 什么是CSRF: django为用户实现防止跨站请求伪造的功能,通过中间件 django.mid ...
- pos提交提交数据时碰到Django csrf
我的github(PS:希望star):https://github.com/thWinterSun/v-admin 最近在用Vue写前端代码,再用vue-resource向后台提交数据.项目后台是用 ...
- delphi 模拟POST提交数据
unit GetHttpInfo; interface uses Classes, WinINet, Sysutils, windows, IDURI, IdSSLOpenSSL , IdBaseCo ...
- C#中使用 HttpWebRequest 向网站提交数据
HttpWebRequest 是 .NET 基类库中的一个类,在命名空间 System.Net 里,用来使用户通过 HTTP 协议和服务器交互. HttpWebRequest 对 HTTP 协议进行了 ...
- php CURL 模拟 POST 提交数据
<?php function liansuo_post($url,$data){ // 模拟提交数据函数 $curl = curl_init(); // 启动一个CURL会话 curl_seto ...
随机推荐
- linux下制作共享库.a和 .so
接触linux时间不长,总是感觉底气不足,很多东西总是感到迷迷糊糊,其实是因为没找拿到linux C的两把钥匙: makefile和动态库.共享库.linux C中几乎所有的程序都是以库的形式给出,如 ...
- c# list exists(contains) delegate 委托判断 元素是否在LIST中存在
static void Main(string[] args) { List<GoodsInfo> list = new List<GoodsIn ...
- CF 578A A Problem about Polyline
题意: There is a polyline going through points (0, 0) – (x, x) – (2x, 0) – (3x, x) – (4x, 0) – ... - ( ...
- hdu2059 龟兔赛跑
hdu2059 龟兔赛跑 动态规划 题目描述: Problem Description 据说在很久很久以前,可怜的兔子经历了人生中最大的打击——赛跑输给乌龟后,心中郁闷,发誓要报仇雪恨,于是躲进了杭州 ...
- hdu 5288 OO’s Sequence(计数)
Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number o ...
- yii2学习的论坛
http://www.yiifans.com/forum.php http://www.yiichina.com/ http://www.yiichina.com/
- ZOJ Goldbach 2013年长沙赛区网络赛
迟到了一天的AC.... 思路: 先把单个素数 或着 两个素数能组成的情况预处理一下,然后对于给出的 n,拿第三个素数去和两个素数的情况匹配,最后要注意去重. 详情见代码. 因为手残少敲了一个 els ...
- 安卓Menu键的问题
近期开发中有须要Menu键,结果发现了一个非常尴尬的问题.我的測试机上有Menu键.可是測试平板上没有,队友的測试机上竟然也没有Menu键.这着实有些尴尬... 上网谷歌之后才发现问题所在: 仅仅有在 ...
- 关于mybatis插入数据库返回主键id
关于Sequence主键的数据库来说,如: <insert id="add" parameterType="vo.Category"> <se ...
- linq和lamda表达式中添加时间判断时解决方案
在工作中遇到个问题,在使用lamda查询数据的时候,需要添加一个时间判断, DateTime.AddDays(3) > e.ExpirationDate 例如:list = Context.Vo ...