• 灌水小程序(aspx)


    远程提交表单,进行灌水,程序简单,如果留言板有验证码,哪就over了

    核心代码块
     string URL = "http://localhost:3359/Web/Message.aspx";

            #region  //接受返回的页面
            //方法一
            
    //HttpWebRequest request = WebRequest.Create(URL) as HttpWebRequest;
            
    //request.Method = "GET";
            
    //request.KeepAlive = false;
            
    //HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            
    //Stream stream = response.GetResponseStream();
            
    //StreamReader reader = new StreamReader(stream, Encoding.UTF8);
            
    // string srcString = reader.ReadToEnd();

            
    //方法二
            WebClient webClient = new WebClient();
            byte[] responseBytes = webClient.DownloadData(URL);
            string srcString = Encoding.UTF8.GetString(responseBytes);

            #endregion

            // 获取页面的 VeiwState   
            string regViewState = "<input type=\"hidden\" name=\"__VIEWSTATE\" id=\"__VIEWSTATE\" value=\"(?<viewState>[^\\s\t\r\n\"\"'<>]*)\" />";
            Match mathView = Regex.Match(srcString, regViewState, RegexOptions.IgnoreCase | RegexOptions.Multiline);
            string viewState = mathView.Groups[1].Value;

            // 获取页面的 EventValidation      
            string regEvent = "<input type=\"hidden\" name=\"__EVENTVALIDATION\" id=\"__EVENTVALIDATION\" value=\"(?<viewState>[^\\s\t\r\n\"\"'<>]*)\" />";
            Match matchEvent = Regex.Match(srcString, regEvent, RegexOptions.IgnoreCase | RegexOptions.Multiline);
            string eventValidation = matchEvent.Groups[1].Value;
                         

            //自动提交
            string submitButton = "留言";
            string txtTitle = this.txtContent.Text; //标题
            string txtContent = this.txtTitle.Text; //留言内容

            
    // 将文本转换成 URL 编码字符串
            viewState = System.Web.HttpUtility.UrlEncode(viewState);
            eventValidation = System.Web.HttpUtility.UrlEncode(eventValidation);
            submitButton = System.Web.HttpUtility.UrlEncode(submitButton);

            // 要提交的字符串数据。格式形如:user=uesr1&password=123
            string postString = string.Format("txtTitle={0}&txtContent={1}" + "&btnSave=" + submitButton + "&__VIEWSTATE=" + viewState + "&__EVENTVALIDATION=" + eventValidation, txtTitle, txtContent);
            byte[] postData = Encoding.UTF8.GetBytes(postString);  // 将字符串转换成字节数组

            
    //循环提交
            int num = Convert.ToInt32(txtNum.Text);
            for (int i = 0; i <= num; i++)
            {
                webClient = new WebClient();
                webClient.Headers.Add("Content-Type""application/x-www-form-urlencoded");
                webClient.UploadData(URL, "POST", postData); // 上传数据,返回页面的字节数组    
            }
            ClientScriptManager cs=Page.ClientScript;
            cs.RegisterClientScriptBlock(typeof(Page),"","<script>alert('执行完成');</script>");      
    下载源文件
  • 相关阅读:
    回车符和换行符
    UDP ECHO server
    启动LINUX下的TFTP服务器
    WPF版的Dock控件第二版完成
    最近写的一个WPF版的Dock控件
    搜狗开始耍流氓了
    对WebBrowser控件设置代理
    删除Jumplist中的历史记录
    C#中Undo/Redo的一个简易实现
    如何向枚举中添加新值
  • 原文地址:https://www.cnblogs.com/clc2008/p/2244610.html
Copyright © 2020-2023  润新知