private void TCheckingData(JObject data, ref string url, ref string title, ref string message, ref string username)
        {
            Converts conv = new Converts();


            ////////////////////////////////////////////
            url = (data["url"] == null) ? "" : HIOStaticValues.getDomainName(data["url"].Value <string>().ToLower());
            var urlByteArray = url.GetUTF8Bytes(256);

            url = UnicodeEncoding.UTF8.GetString(urlByteArray);

            //proccess unicode character and get len of string
            title = (data["title"] == null) ? "" : (data["title"].Value <string>().Length < 65) ? data["title"].Value <string>() : data["title"].Value <string>().Substring(0, 64);
            var titleByteArray = title.GetUTF8Bytes(64);

            title = UnicodeEncoding.UTF8.GetString(titleByteArray);
            //////////////////////
            message = (data["CMD"] == null) ? "" : data["CMD"].Value <string>();
            ////////////////////////////////////////
            username = (data["username"] == null) ? "" : (data["username"].Value <string>().Length < 65) ? data["username"].Value <string>() : data["username"].Value <string>().Substring(0, 64);
            if (username != "")
            {
                HIOStaticValues.username = username;//check username(if user want just fill password element and username element filled already by self)
            }
            var usernameByteArray = username.GetUTF8Bytes(64);

            username = UnicodeEncoding.UTF8.GetString(usernameByteArray);
            ////////////////////////////////////////////
        }
예제 #2
0
        public static void CheckingData(TAccountItem account)
        {
            Converts conv = new Converts();

            ////////////////////////////////////////////
            account.Url = (account.Url == null || account.Url == "") ? "" : HIOStaticValues.getDomainName(account.Url.ToLower());
            var urlByteArray = account.Url.GetUTF8Bytes(256);

            account.Url = UnicodeEncoding.UTF8.GetString(urlByteArray);
            //proccess unicode character and get len of string
            account.Name = (account.Name == null || account.Name == "") ? "" : (account.Name.Length < 65) ? account.Name : account.Name.Substring(0, 64);
            var titleByteArray = account.Name.GetUTF8Bytes(256);

            account.Name = UnicodeEncoding.UTF8.GetString(titleByteArray);
            //////////////////////
            account.Password = (account.Password == null || account.Password == "") ? "" : (account.Password.Length < 65) ? account.Password : account.Password.Substring(0, 64);
            var passByteArray = account.Password.GetUTF8Bytes(256);

            account.Password = UnicodeEncoding.UTF8.GetString(passByteArray);
            ////////////////////////////////////////
            account.Username = (account.Username == null || account.Username == "") ? "" : (account.Username.Length < 65) ? account.Username : account.Username.Substring(0, 64);
            if (account.Username != "")
            {
                HIOStaticValues.username = account.Username;//check username(if user want just fill password element and username element filled already by self)
            }
            var userByteArray = account.Username.GetUTF8Bytes(256);

            account.Username = UnicodeEncoding.UTF8.GetString(userByteArray);
            ////////////////////////////////////////////
        }
예제 #3
0
        public bool UpdateUser(string ID, string url, string appID, string title, string username, string password, byte flagPass)
        {
            DataBase db        = new DataBase();
            string   urlFilter = HIOStaticValues.getDomainName(url);

            if (HIOStaticValues.BaS.UpdateSwitch(ID, urlFilter, appID, title, username, password, flagPass) == 0)
            {
                db.UpdateDBFromRowID(ID, urlFilter, appID, title, username);
                return(true);
            }
            return(false);
        }
예제 #4
0
        public async static void Disconnect_Click(object sender, EventArgs e)
        {
            if (HIOStaticValues.CheckSyncingData())
            {
                return;
            }
            CloseDuplicateWindows();
            if (BaS.dev is BLEDevice bleDevice)
            {
                await bleDevice.Unpair();
            }
            App.Current.Dispatcher.BeginInvoke((Action)(() => tmain.SettingManager.AddNewDevice()));

            // BaS.UnBondSwitch(HIOStaticValues.blea.mac);
        }
예제 #5
0
        public int Insert(string website, string username, string title, string password)
        {
            DataBase db  = new DataBase();
            int      res = -1;

            if (db.getInfoFromDB(website, username, title).Count == 0)
            {
                while (true)
                {
                    res = HIOStaticValues.BaS.AmISyncedSwitch();
                    if (res == 1)
                    {
                        break;
                    }
                    else if (res == -2)
                    {
                        HIOStaticValues.popUp("HIO is not connected");
                        return(0);
                    }
                    else
                    {
                        HIOStaticValues.SyncOpration();
                    }
                }
                res = HIOStaticValues.BaS.InsertToSwitch(new LoginFieldS {
                    url = website, userName = username, title = title, password = password, appID = ""
                });
                if (res > 0)
                {
                    db.insertToDatabase(res.ToString(), website, username, "", title);
                    HIOStaticValues.username = username;
                    return(1);
                }

                else
                {
                    return(0);
                }
            }
            else
            {
                System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    HIOStaticValues.popUp("This user already exists,You can modify it in the Edit Form.");
                }));
                return(-4);
            }
        }
예제 #6
0
 public bool EraseAll()
 {
     try
     {
         if (HIOStaticValues.BaS.EraseAllDataSwitch())
         {
             HIOStaticValues.DirectBluetooth = false;
             HIOStaticValues.Disconnect_Click(null, null);
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
예제 #7
0
        public bool Delete(string rowid)
        {
            DataBase db = new DataBase();

            int rowidInt = Int32.Parse(rowid);

            byte[] rowidByteArray = BitConverter.GetBytes(rowidInt).ToArray();
            string result         = HIOStaticValues.BaS.DeleteFromSwitch(rowidByteArray);

            if (result == StatusWord.SW_NO_ERROR)
            {
                db.deleteFromDatabase(rowid);
                return(true);
            }
            else
            {
                System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    HIOStaticValues.popUp("Something was wrong!\nPlease check log file.");
                }));
            }
            return(false);
        }
예제 #8
0
        private List <LoginFieldS> ParsJson(string filename)
        {
            string tempLine;

            List <LoginFieldS> lp = new List <LoginFieldS>();
            var json_serializer   = new JavaScriptSerializer();

            using (StreamReader file = new System.IO.StreamReader(filename))
            {
                while ((tempLine = file.ReadLine()) != null)
                {
                    try
                    {
                        if (tempLine == "")
                        {
                            continue;
                        }
                        var    dataValue = (IDictionary <string, object>)json_serializer.DeserializeObject(tempLine);
                        string url       = HIOStaticValues.getTitleNameURI(dataValue["url"].ToString()).GetUTF8String(256);
                        string username  = dataValue["username"].ToString().GetUTF8String(64);
                        string password  = dataValue["password"].ToString().GetUTF8String(64);
                        string title     = HIOStaticValues.getTitleNameURI(dataValue["title"].ToString()).GetUTF8String(64);
                        string appid     = dataValue["appid"].ToString().GetUTF8String(64);
                        string last_used = dataValue["last_used"].ToString().GetUTF8String(64);
                        int    counter   = int.Parse(dataValue["counter"].ToString());

                        lp.Add(new LoginFieldS {
                            url = url, userName = username, password = password, title = title, appID = title, last_used = last_used, popularity = counter
                        });
                    }
                    catch {
                        continue;
                    }
                }
            }
            return(lp);
        }
예제 #9
0
        /// <summary>
        /// Fetching user passwords from browser
        /// </summary>
        /// <param name="bas">using for get handle hid device</param>
        /// <returns>List of users</returns>
        public List <LoginFieldS> getDataFromChrome()
        {
            List <LoginFieldS> userlist = new List <LoginFieldS>();

            try
            {
                string path     = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                var    profiles = FindProfileName(path);
                foreach (var profile in profiles)
                {
                    string db_way  = path + "\\Google\\Chrome\\User Data\\" + profile + "\\Login Data";
                    string db_way2 = path + "\\Google\\Chrome\\User Data\\" + profile + "\\Login Data.hio";
                    File.Copy(db_way, db_way2, true);
                    string db_field = "logins";
                    string sql;
                    byte[] entropy = null;
                    string description;


                    DataBase  dbLocal          = new DataBase();
                    string    ConnectionString = "data source=" + db_way2 + ";New=True;UseUTF16Encoding=True";
                    DataTable DB = new DataTable();
                    sql = string.Format("SELECT  DISTINCT  * FROM {0}", db_field);
                    using (SQLiteConnection connect = new SQLiteConnection(ConnectionString))
                    {
                        SQLiteCommand     command = new SQLiteCommand(sql, connect);
                        SQLiteDataAdapter adapter = new SQLiteDataAdapter(command);
                        adapter.Fill(DB);
                        int rows = DB.Rows.Count;

                        for (int i = 0; i < rows; i++)
                        {
                            Trace.WriteLine("DB.Rows.Count: " + rows);



                            byte[] byteArray = (byte[])DB.Rows[i][5];
                            byte[] decrypted = DPAPI.Decrypt(byteArray, entropy, out description);
                            if (((string)DB.Rows[i][7]).Split(':')[0] == "android")
                            {
                                continue;
                            }

                            string username = DB.Rows[i][3].ToString().GetUTF8String(64);
                            string password = (new UTF8Encoding(true).GetString(decrypted)).ToString().GetUTF8String(64);
                            string title    = HIOStaticValues.getTitleNameURI(DB.Rows[i][7].ToString()).GetUTF8String(64);
                            string url      = HIOStaticValues.getDomainNameURI(DB.Rows[i][7].ToString()).GetUTF8String(256);

                            if (password != "" && (string)DB.Rows[i][3] != "")
                            {
                                if (dbLocal.getInfoFromDB(url, username, "").Count == 0)
                                {
                                    userlist.Add(new LoginFieldS {
                                        password = new UTF8Encoding(true).GetString(decrypted), userName = (string)DB.Rows[i][3], title = title, url = url
                                    });
                                }
                            }
                        }


                        adapter.Dispose();
                        connect.Close();
                    }
                }
                return(userlist);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// For Extensions
        /// </summary>
        /// <param name="data">recieve data from browser</param>
        /// <param name="source">check refrence of data</param>
        /// <param name="tMain">parent handler</param>

        public void ProcessRecieveMessage(JObject data, Source source)
        {
            try
            {
                if (data == null)
                {
                    return;
                }
                Converts conv = new Converts();
                Dictionary <string, string> dicData = new Dictionary <string, string> ();
                string url = "", title = "", message = "", username = "";
                TCheckingData(data, ref url, ref title, ref message, ref username);

                DataBase db = new DataBase();
                if (HIOStaticValues.CONNECTIONBHIO == false)
                {
                    dicData.Add("CMD", "CONNCETION");
                    dicData.Add("DATA", "false");


                    HIOStaticValues.BaS.Write(dicData, source);
                    if (message != "INIT" && message != "SUBMIT")
                    {
                        HIOStaticValues.popUp("HIO is not connected!");
                    }
                    return;
                }
                if (message != "INIT" && !HIOStaticValues.TPinStatus())
                {
                    return;
                }


                if (HIOStaticValues.CheckSyncingData())
                {
                    return;
                }

                switch (message)
                {
                case "exit":
                    //Environment.Exit(0);
                    break;

                case "MENUCHROME":
                    List <LoginFieldS> listUsers = db.getInfoFromDB("*", "", "");
                    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        HIOStaticValues.AdminExtention.CloseAll();
                        HIOStaticValues.AdminExtention.ExtentionMenu.Initialize(url, title);
                        HIOStaticValues.AdminExtention.ExtentionMenu.Show();
                    }));

                    break;


                //case "DASHBOARD":
                //    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                //    {
                //        TMain.Instance.Show();
                //    }));
                //    break;
                //case "MANAGEALLUSER":
                //    List<LoginFieldS> lnFields = db.getInfoFromDB("*", "", "");
                //    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                //    {


                //        HIOStaticValues.AdminExtention.CloseAll();
                //        HIOStaticValues.AdminExtention.Extention08.Initialize(lnFields);
                //        HIOStaticValues.AdminExtention.Extention08.Show();

                //    }));

                //    break;
                //case "ADDUSER":

                //    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                //    {
                //        HIOStaticValues.AdminExtention.CloseAll();
                //        HIOStaticValues.AdminExtention.Extention02.Show(new TAccountItem { Url = url, Name = title });
                //    }));
                //    break;
                case "READYDATA":
                    //ready for fill username
                    dicData.Add("CMD", "USER");
                    dicData.Add("USER", HIOStaticValues.username);
                    HIOStaticValues.BaS.Write(dicData, source, true);
                    break;

                case "READYDATAPASS":
                    //ready for fill password
                    //  Dictionary<string, string> dicData = new Dictionary<string, string> { { "CMD", "USER" }, { "USER", HIOStaticValues.username } };
                    dicData.Add("CMD", "PASS");
                    dicData.Add("DATA", HIOStaticValues.password);
                    HIOStaticValues.BaS.Write(dicData, source, true);
                    break;

                case "INIT":
                    dicData.Add("CMD", "CONNCETION");
                    dicData.Add("DATA", HIOStaticValues.CONNECTIONBHIO.ToString().ToLower());
                    HIOStaticValues.BaS.Write(dicData, source);
                    break;

                case "MANAGEUSER":
                    break;

                case "CANNOTFIND":
                    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => {
                        HIOStaticValues.popUp("HIO could not find the login form." +
                                              "\nMove the cursor inside the Username or Password field.");
                    }));
                    break;
                //case "GENERATEPASSWORDNOFILL":


                //    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                //    {

                //        try
                //        {
                //            HIOStaticValues.AdminExtention.CloseAll();
                //            HIOStaticValues.AdminExtention.Extentiongp.Show(false,false);

                //        }
                //        catch (Exception ex)
                //        {

                //            ;
                //        }
                //    }));

                //    break;
                case "GENERATEPASSWORD":
                    TGeneratePasswordForm();

                    break;

                case "JUSTMENU":

                    url = (url.Length < 257) ? url : url.Substring(0, 256);
                    // action = data["action"].Value<string>().ToLower();
                    title = (data["title"].Value <string>().Length < 65) ? data["title"].Value <string>() : data["title"].Value <string>().Substring(0, 64);
                    List <LoginFieldS> lgnpack = db.getInfoFromDB(url, "", "");

                    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        HIOStaticValues.AdminExtention.CloseAll();
                        HIOStaticValues.AdminExtention.ExtentionManage.Initialize(lgnpack, false, source, url);
                        HIOStaticValues.AdminExtention.ExtentionManage.Show();
                    }));

                    break;

                case "SUBMIT":
                    url = (url.Length < 257) ? url : url.Substring(0, 256);
                    string passwd = (data["password"].Value <string>().Length < 64) ? data["password"].Value <string>() : data["password"].Value <string>().Substring(0, 64);

                    List <LoginFieldS> listlgnpck = db.getInfoFromDB(url, username, "");
                    if (listlgnpck.Count == 0)
                    {
                        System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            HIOStaticValues.AdminExtention.CloseAll();
                            HIOStaticValues.AdminExtention.Extention10.Initialize(new LoginFieldS {
                                url = url, title = title, userName = username, password = passwd
                            });
                            HIOStaticValues.AdminExtention.Extention10.Show();
                        }));
                    }

                    break;

                case "CHECKPASS":
                    dicData.Add("CMD", "CHECKPASS");

                    HIOStaticValues.BaS.Write(dicData, source);
                    break;

                case "GETUSER":
                    HIOStaticValues.username = "";
                    url = (url.Length < 257) ? url : url.Substring(0, 256);

                    TGetUsername(url, title, source, db);

                    break;

                case "GETPASS":

                    url = (url.Length < 257) ? url : url.Substring(0, 256);
                    TGetPassword(url, title, db, source);


                    break;
                }
            }
            catch (Exception ex)
            {
            }
        }