⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmain.cs

📁 自动投票工具
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using Microsoft.Win32;
using System.IO;
using System.Net;

namespace Destroy_Vote
{
    public partial class frmMain : Form
    {
        public static DateTime end_Time;
        public static DateTime start_Time;
        public static TimeSpan pass_Time;
        public static string vote_status;
        public static int voted_num;
        public static string vote_Method;
        public static StreamReader txtReader;
        public static string voteString;
        public static Thread voteThread1;
        public static string http_Accept;
        public static string http_AcceptEncoding;
        public static string http_ContentType;
        public static string http_Cookie;
        public static string http_Language;
        public static string http_Referer;
        public static string myBoundary;
        public static bool proxy_Status;
        public static string proxyip;
        public static int proxyport;
        public static bool ras_Status;
        public static string urlString;
        public static int perproxy;

        public frmMain()
        {
            InitializeComponent();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            //InternetSetOption  
            comHttpContentType.Items.Add("application/x-www-form-urlencoded");
            comHttpContentType.Items.Add("multipart/form-data");
            comHttpContentType.Text = "application/x-www-form-urlencoded";

            if (File.Exists("vote.ini"))
            {
                IniFile getinfo = new IniFile(Path.GetFullPath("vote.ini"));
                txtUrl.Text = getinfo.IniReadValue("VoteInfo", txtUrl.Name);
                txtData.Text = getinfo.IniReadValue("VoteInfo", txtData.Name);
                if (getinfo.IniReadValue("VoteInfo", "Method") == "0")
                {
                    raGet.Checked = false;
                    raPost.Checked = true;
                }
                else
                {
                    raGet.Checked = true;
                    raPost.Checked = false;
                }

                string type = getinfo.IniReadValue("VoteInfo", "Type");
                if (type == "0")
                {
                    unuseProxy.Checked = true;
                }
                else if (type == "1")
                {
                    useProxy.Checked = true;
                }
                else
                {
                    useRas.Checked = true;
                }
                txtHttp_AcceptEncoding.Text = getinfo.IniReadValue("VoteInfo", txtHttp_AcceptEncoding.Name);
                txtHttpAccept.Text = getinfo.IniReadValue("VoteInfo", txtHttpAccept.Name);
                txtHttpCookie.Text = getinfo.IniReadValue("VoteInfo", txtHttpCookie.Name);
                txtHttpLanguage.Text = getinfo.IniReadValue("VoteInfo", txtHttpLanguage.Name);
                txtHttpReferer.Text = getinfo.IniReadValue("VoteInfo", txtHttpReferer.Name);
                txtPerProxy.Text = getinfo.IniReadValue("VoteInfo", txtPerProxy.Name);
                txtRasPervoted.Text = getinfo.IniReadValue("VoteInfo", txtRasPervoted.Name);
                txtRasSleep.Text = getinfo.IniReadValue("VoteInfo", txtRasSleep.Name);
                txtVoteSleep.Text = getinfo.IniReadValue("VoteInfo", txtVoteSleep.Name);
                comHttpContentType.Text = getinfo.IniReadValue("VoteInfo", comHttpContentType.Name);
            }
           
            try
            {
                string[] textArray1 = Registry.CurrentUser.OpenSubKey(@"RemoteAccess\Profile").GetSubKeyNames();
                for (int num1 = 0; num1 < textArray1.Length; num1++)
                {
                    myrasList.Items.Add(textArray1[num1]);
                }
                myrasList.Text = textArray1[0];
            }
            catch (Exception exception1)
            {
                txtOutputBox.Text = "您的计算机没有拨号连接,不能使用自动循环拨号/断开功能。\r\n错误信息:" + exception1.Message;
                useRas.Enabled = false;
                txtRasPervoted.Enabled = false;
                myrasList.Enabled = false;
                txtRasSleep.Enabled = false;
            }

        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            txtStatus.Text = "正在投票...";
            voted_num = 0;
            urlString = txtUrl.Text;
            voteString = txtData.Text;
            if (urlString.Length <= 7)
            {
                txtOutputBox.Text = "请输入您投票提交的网址.";
                txtStatus.Text = "准备投票....";
            }
            else
            {
                if (raGet.Checked)
                {
                    vote_Method = raGet.Text;
                }
                else
                {
                    vote_Method = raPost.Text;
                }
                http_Accept = txtHttpAccept.Text;
                http_AcceptEncoding = txtHttp_AcceptEncoding.Text;
                http_Language = txtHttpLanguage.Text;
                http_Cookie = txtHttpCookie.Text;
                http_Referer = txtHttpReferer.Text;
                if (http_Referer.Length == 0)
                {
                    http_Referer = urlString;
                }
                http_ContentType = comHttpContentType.Text;
                if (http_ContentType == "multipart/form-data")
                {
                    myBoundary = "---------------------------7d61b53610077c";
                    http_ContentType = "multipart/form-data; boundary=" + myBoundary;
                    string text1 = "";
                    if (voteString.Length <= 0)
                    {
                        txtOutputBox.Text = "请输入您投票提交的数据.";
                        txtStatus.Text = "准备投票....";
                        return;
                    }
                    string[] textArray1 = voteString.Split(new string[] { "#" }, StringSplitOptions.None);
                    for (int num1 = 0; num1 < textArray1.Length; num1++)
                    {
                        string[] textArray2 = textArray1[num1].Split(new string[] { "=" }, StringSplitOptions.None);
                        text1 = text1 + "--" + myBoundary + "\r\nContent-Disposition: form-data; name=\"" + textArray2[0] + "\"\r\n\r\n";
                        text1 = text1 + textArray2[1] + "\r\n";
                    }
                    text1 = text1 + "--" + myBoundary + "--\r\n";
                    voteString = text1;
                }
                start_Time = DateTime.Now;
                if (unuseProxy.Checked)
                {
                    btnOk.Enabled = false;
                    btnCel.Enabled = true;
                    vote_status = "正在投票...";
                    count_timer.Interval = 0x3e8;
                    count_timer.Start();
                    int num2 = (int)(float.Parse(txtVoteSleep.Text) * 1000f);
                    if (num2 < 1)
                    {
                        num2 = 1;
                    }
                    vote_Timer.Interval = num2;
                    vote_Timer.Start();
                }
                else if (useProxy.Checked)
                {
                    txtOutputBox.Text = "正在使用代理服务器投票...\r\n1、从proxy.txt文件中读取一行数据;\r\n2、将读出的数据分离出代理服务器的IP地址和端口; \r\n3、通过该IP地址和端口进行投票; \r\n4、如果数据有错误或代理服务器不可用,将自动读取文件中的下一行; \r\n5、点击[停止投票]按钮来结束本轮投票。 \r\n通过代理服务器投票会比较慢,请耐心等候。";
                    btnOk.Enabled = false;
                    btnCel.Enabled = true;
                    vote_status = "已使用完代理服务器地址。";
                    count_timer.Interval = 0x3e8;
                    count_timer.Start();
                    perproxy = int.Parse(txtPerProxy.Text);
                    voteThread1 = new Thread(new ThreadStart(voteThreadProc));
                    voteThread1.Start();
                }
                else if (useRas.Checked)
                {
                    vote_status = "\u4f7f\u7528ADSL\u81ea\u52a8\u62e8\u53f7\u6765\u6295\u7968...";
                    btnOk.Enabled = false;
                    btnCel.Enabled = true;
                    count_timer.Interval = 0x3e8;
                    count_timer.Start();
                    ras_Status = true;
                    while (ras_Status)
                    {
                        try
                        {
                            new RASDisplay().Connect(myrasList.Text);
                        }
                        catch (Exception exception1)
                        {
                            txtOutputBox.Text = "\n" + exception1.Message + "\n\u62e8\u53f7\u65f6\u53d1\u751f\u5f02\u5e38\u3002\n";
                            txtStatus.Text = "\u62e8\u53f7\u51fa\u73b0\u9519\u8bef\u3002";
                            return;
                        }
                        for (int num3 = 0; num3 < int.Parse(txtRasPervoted.Text); num3++)
                        {
                            if (vote_Method == "GET")
                            {
                                try
                                {
                                    byte[] buffer1 = new byte[0x9530];
                                    HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create(urlString);
                                    request1.Referer = http_Referer;
                                    Stream stream1 = ((HttpWebResponse)request1.GetResponse()).GetResponseStream();
                                    int num4 = stream1.Read(buffer1, 0, buffer1.Length);
                                    txtOutputBox.Text = Encoding.Default.GetString(buffer1, 0, num4);
                                    stream1.Close();
                                    goto Label_06F3;
                                }
                                catch (Exception exception2)
                                {
                                    txtOutputBox.Text = "\n" + exception2.Message + "\n\u63d0\u4ea4\u6570\u636e\u65f6\u51fa\u73b0\u5f02\u5e38\uff0c\u53ef\u80fd\u662f\u60a8\u8f93\u5165\u7684\u7f51\u5740\u4e0d\u5bf9\u6216\u7f51\u7edc\u672a\u8fde\u901a\u3002\n";
                                    txtStatus.Text = "\u63d0\u4ea4\u6570\u636e\u51fa\u73b0\u9519\u8bef\u3002";
                                    return;
                                }
                            }
                            if (vote_Method == "POST")
                            {
                                byte[] buffer3;
                                WebClient client1 = new WebClient();
                                client1.Headers.Add("Accept", http_Accept);
                                client1.Headers.Add("Accept-Language", http_Language);
                                client1.Headers.Add("Accept-Encoding", http_AcceptEncoding);
                                client1.Headers.Add("Cookie", http_Cookie);
                                client1.Headers.Add("Referer", http_Referer);
                                client1.Headers.Add("Content-Type", http_ContentType);
                                WebHeaderCollection collection1 = client1.Headers;
                                txtOutputBox.Text = "发送的HTTP头信息\r\n";
                                for (int num5 = 0; num5 < collection1.Count; num5++)
                                {
                                    txtOutputBox.Text = txtOutputBox.Text + collection1.GetKey(num5) + " : " + collection1.Get(num5) + "\n";
                                }
                                byte[] buffer2 = Encoding.Default.GetBytes(voteString);
                                try
                                {
                                    buffer3 = client1.UploadData(urlString, vote_Method, buffer2);
                                }
                                catch (Exception exception3)
                                {
                                    txtOutputBox.Text = "\n" + exception3.Message + "\n\u63d0\u4ea4\u6570\u636e\u65f6\u51fa\u73b0\u5f02\u5e38\uff0c\u53ef\u80fd\u662f\u60a8\u8f93\u5165\u7684\u7f51\u5740\u4e0d\u5bf9\u6216\u7f51\u7edc\u672a\u8fde\u901a\u3002\n";
                                    txtStatus.Text = "\u63d0\u4ea4\u6570\u636e\u51fa\u73b0\u9519\u8bef\u3002";
                                    client1.Dispose();
                                    return;
                                }
                                txtOutputBox.Text = txtOutputBox.Text + "\r\n接收的HTTP头信息\r\n";
                                collection1 = client1.ResponseHeaders;
                                for (int num6 = 0; num6 < collection1.Count; num6++)
                                {
                                    txtOutputBox.Text = txtOutputBox.Text + collection1.GetKey(num6) + " : " + collection1.Get(num6) + "\n";
                                }
                                txtOutputBox.Text = txtOutputBox.Text + "\r\n接收的正文信息\r\n";
                                txtOutputBox.Text = txtOutputBox.Text + Encoding.Default.GetString(buffer3);
                                client1.Dispose();
                            }
                            else
                            {
                                txtOutputBox.Text = "\u53c2\u6570\u9519\u8bef\uff01";
                            }
                        Label_06F3:
                            voted_num++;
                        }
                        try
                        {
                            new RASDisplay().Disconnect();
                        }
                        catch (Exception exception4)
                        {
                            txtOutputBox.Text = "\n" + exception4.Message + "\n提交数据时出现异常,可能是您输入的网址不对或网络未连通。";
                            txtStatus.Text = "\u6302\u65ad\u65f6\u51fa\u73b0\u9519\u8bef\u3002";
                            return;
                        }
                        Thread.Sleep((int)(int.Parse(txtRasSleep.Text) * 0x3e8));
                    }
                }
                else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -