private void checktime(int count) { Thread.Sleep(1000); string now = DateTime.Now.ToString("yyyy-MM-dd"); MyConfig con = new MyConfig(); string oldtime = con.GetValue("time"); if(oldtime.Equals("")) { con.SetValue("time", now); return; } DateTime told = DateTime.Parse(oldtime); DateTime tnow = DateTime.Parse(now); System.TimeSpan t3 =tnow - told ; if (t3.TotalDays > 30 ) { con.SetValue("time", now); Pyworks pw = new Pyworks(); string pass = pw.work("..\\pyscript\\makepass " + count.ToString()); MessageBox.Show("Passwd Timeout" + pass, "WARNING", MessageBoxButton.OK); } }
private void checkconfig2() { MyConfig con = new MyConfig(); if (con.GetValue("islogin").Equals("False")) { if (con.GetValue("auto").Equals("false")) { if (con.GetValue("savepass").Equals("True")) { user.Text = con.GetValue("username"); } return; } } }
private void checkconfig() { MyConfig con = new MyConfig(); if (con.GetValue("islogin").Equals("False")) { if (con.GetValue("auto").Equals("false")) { if (con.GetValue("savepass").Equals("True")) { user.Text = con.GetValue("username"); } return; } else { Main main = new Main(); main.Show(); this.Close(); } } }
private void creatersakey() { con = new MyConfig(); RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); if (con.GetValue("RSAP") == null) { con.SetValue("RSAP", rsa.ToXmlString(true)); con.SetValue("RSAPR", rsa.ToXmlString(false)); pubkey = con.GetValue("RSAP"); } else { pubkey = con.GetValue("RSAP"); } }
public Main() { notifyIcon.Icon = ico; notifyIcon.MouseDoubleClick += dclick; con = new MyConfig() ; this.username = con.GetValue("username") ; InitializeComponent(); this.Closing += MyExit; Thread aa = new Thread(getCombobox); aa.Start(); }
private void getComboboxtag() { int COUNT = 0; MyConfig con = new MyConfig(); if (!File.Exists("message.xml")) { if (con.GetValue("querytimes") != "0") { MessageBox.Show(myerror[1], "WARNING", MessageBoxButton.OK, MessageBoxImage.Error); return; } return; } Aworks aw = new Aworks(); if (con.GetValue("sig").Equals("true")) { if (!aw.Verify("message.xml")) { this.Close(); } } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("message.xml"); XmlNode root = xmlDoc.SelectSingleNode("ALLUSER"); XmlNodeList nodeList = xmlDoc.SelectSingleNode("ALLUSER").ChildNodes; foreach (XmlNode xn in nodeList) { XmlElement xe = (XmlElement)xn; if (xe.GetAttribute("Name") == username) { foreach (XmlNode xn2 in xe.ChildNodes) { XmlElement xe2 = (XmlElement)xn2; if (xe2.GetAttribute("tag") !="") { COMBOBOX.Items.Add(xe2.GetAttribute("tag")); COUNT++; } } } } runpy ru = new runpy(COUNT); Thread bb = new Thread(ru.run); bb.Start(); foreach(var astring in WAY2ENC) { Way2Enc.Items.Add(astring); } string a = con.GetValue("querytimes") ; int b = Int32.Parse(a) + 1 ; con.SetValue("querytime", b.ToString()); }
private void getkey() { MyConfig con = new MyConfig(); if (con.GetValue("RSAPR") == null) { MessageBox.Show("There is no KEY"); prikey = null; return; } else { prikey = con.GetValue("RSAPR"); } }
private int checkall(string usernum, string passwdnum) { MyConfig con = new MyConfig(); XmlDocument xmlDoc = new XmlDocument(); try { FileInfo fi = new FileInfo("hehe.xml"); string modifytime = fi.LastWriteTime.ToString(); int times = int.Parse(con.GetValue("querytimes")); if (times != 0) { string lasttime = con.GetValue("file"); if (!lasttime.Equals(modifytime)) { MessageBox.Show("FIlE HAS BEEN MODIFY!!!!"); return 0xFFBB; } times++; con.SetValue("querytime", times.ToString()); con.SetValue("file", modifytime); } con.SetValue("file", modifytime); xmlDoc.Load("hehe.xml"); } catch(Exception) { return (int)ERROR.FILE_MISSING ; } XmlNode root = xmlDoc.SelectSingleNode("ALLUSER"); // lookup the id XmlNodeList nodeList = xmlDoc.SelectSingleNode("ALLUSER").ChildNodes; foreach (XmlNode xn in nodeList) { XmlElement xe = (XmlElement)xn; XmlNode usernode = xe.ChildNodes[0]; XmlNode passnode = xe.ChildNodes[1]; XmlElement subuse = (XmlElement)usernode; XmlElement subpass = (XmlElement)passnode; if(subuse.InnerText.Equals(usernum)) { if(subpass.InnerText.Equals(passwdnum)) { return 0 ; } } } return (int)ERROR.PASSWD_WRONG; }
private void LOGIN_Click(object sender, RoutedEventArgs e) { if(user.Text == "" || pwd.Text == "" ) { MessageBox.Show(error[1], "Waring", MessageBoxButton.OK,MessageBoxImage.Warning); } // use MD5 and DES encrypt user // use SHA and AES encrypt passwd // and check local user if not online check //TODO String passwdnum; String usernum = makeuser(user.Text ,pwd.Text); MyConfig con = new MyConfig(); if (con.GetValue("savepass").Equals("True")) { passwdnum = getPasswdString(usernum); } else { passwdnum = makepwd(pwd.Text); } int i = checkall(usernum , passwdnum) ; if(i == 0) { Eenclass enc =new Eenclass(); byte[] crcword = Encoding.UTF8.GetBytes(passwdnum); byte[] crcword2=CRC.crc.CRC16(crcword); int times = int.Parse(con.GetValue("querytimes")); if (times == 0 ) { con.SetValue("crc", enc.hex2str(crcword2)); } else { byte[] getcrc = enc.str2hex(con.GetValue("crc")); if(!getcrc.Equals(crcword2)) { MessageBox.Show("FILE has been modify!!!!"); return; } } String issave = saveall.IsChecked == true ? "True" : "False"; con.SetValue("savepass", issave); string isauto = checkauto.IsChecked == true ? "True" : "False"; con.SetValue("auto", isauto); Main main = new Main(usernum); main.Show(); this.Close(); } else if(i ==(int)ERROR.FILE_MISSING) { //online check MessageBox.Show(error[i], "wrong", MessageBoxButton.OK, MessageBoxImage.Error) ; } else if(i == 0xFFBB) { return; } else { MessageBox.Show(error[i], "wrong", MessageBoxButton.OK, MessageBoxImage.Error); } }