예제 #1
0
        private bool ValidateUser(string username, string password)
        {
            var check = false;
            //Get the user and validate the password matches the DB
            var user = _conn.GetUserByName(username);

            if (user != null)
            {
                var pass = _secure.DecryptData(user.Password);
                if (pass == password)
                {
                    check   = true;
                    _userId = user.UserId;
                }
            }

            return(check);
        }
예제 #2
0
 private void cmdEncode_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtString.Text.Trim()))
     {
         string CryptKey    = txtKey.Text.Trim();
         string CryptString = txtString.Text.Trim();
         using (Simple3Des wrapper = new Simple3Des(CryptKey))
         {
             txtResult.Text = wrapper.EncryptData(CryptString);
         }
     }
     else if (!string.IsNullOrEmpty(txtResult.Text.Trim()))
     {
         using (Simple3Des wrapper = new Simple3Des(txtKey.Text.Trim()))
         {
             txtString.Text = wrapper.DecryptData(txtResult.Text.Trim());
         }
     }
 }
예제 #3
0
        private void LoginForm_Load(object sender, EventArgs e)
        {
            //Program.connectstring = "Hello Deny...";
            Mydataconn mc = Mydataconn.Load();

            if (null != mc)
            {
                Simple3Des jm = new Simple3Des("deny01.12345678901234567890zb");

                this.textBoxSQLSERVER.Text = mc.Sqlser;
                this.textDatabaseName.Text = mc.Databs;
                this.textBoxSQLuser.Text   = mc.SqlserUser;
                this.textBoxSQLPW.Text     = jm.DecryptData(mc.ServerKey);

                this.textBoxuserID.Text = mc.UserID;

                //this.textBoxuserID.Select(0, 0);

                this.textBoxuserPW.Focus();
                //this.textBoxuserPW.Text = jm.DecryptData(mc.Passwd);
            }
        }
예제 #4
0
        private static void OtherMaps(bool quiet, Args CommandLine)
        {
            Simple3Des dec = new Simple3Des("A$hbySchool1");

            if (CommandLine["m"] != null)
            {
                //String username = System.DirectoryServices.AccountManagement.UserPrincipal.Current.UserPrincipalName;
                String username = Environment.UserName;  //+ "@ashbyschool.org.uk";
                String password = dec.DecryptData(CommandLine["p"]);

                //if (username != null) { if (CommandLine["d"] != null) username = username.Split('@')[0] + "@" + CommandLine["d"]; }
                String   line      = CommandLine["m"];
                String[] parts     = line.Split(',');
                String[] baseparts = parts[0].Split('~');
                Uri      tempuri   = new Uri(baseparts[1]);
                if (CommandLine["u"] != null)
                {
                    RunAsync(tempuri, username, password, false, false, false).Wait();
                }



                CookieCollection cookies = SpoAuthUtility.Current.cookieContainer.GetCookies(tempuri);
                String           baseUrl = tempuri.Scheme + "://" + tempuri.Host;
                InternetSetCookie(baseUrl, null, cookies["FedAuth"].ToString() + "; Expires = " + cookies["FedAuth"].Expires.AddMinutes(0).ToString("R"));
                InternetSetCookie(baseUrl, null, cookies["rtFA"].ToString() + "; Expires = " + cookies["rtFA"].Expires.AddMinutes(0).ToString("R"));


                foreach (String part in parts)
                {
                    String[] drivepaths    = part.Split('~');
                    String   drive         = drivepaths[0] + ":";
                    String   path          = drivepaths[1];
                    Uri      sharepointUri = new Uri(path);
                    DoMap(quiet, sharepointUri, drive, "");
                }
            }
        }
예제 #5
0
        static void Main(string[] args)
        {
            // Set Default Argument values
            bool       quiet             = false;
            bool       debug             = false;
            string     sharepointUrl     = null;
            Uri        sharepointUri     = null;
            string     username          = null;
            string     password          = null;
            bool       useIntegratedAuth = true;
            string     disk    = null;
            bool       mount   = false;
            double     expire  = 0;
            string     homedir = "";
            Simple3Des dec     = new Simple3Des("A$hbySchool1");

            //Parse args
            Args CommandLine = new Args(args);

            if (CommandLine["m"] != null)
            {
                OtherMaps(false, CommandLine);
            }
            else
            {
                if (CommandLine["s"] == null)
                {
                    Console.WriteLine("Error: SharePoint URL not specified !\n\nUsage: Cookie365 -s URL [-u [email protected] | -d domain.com] [-p {password}] [-quiet] [-mount [disk] [-homedir]]");
                }
                else
                {
                    try
                    {
                        // Retrieve SharePoint URL and Create URI
                        sharepointUrl = CommandLine["s"];
                        sharepointUri = new Uri(sharepointUrl);

                        // If username is specified use it, otherwise get the user UPN from AD
                        if (CommandLine["u"] != null)
                        {
                            username = CommandLine["u"];
                        }
                        else
                        {
                            username = System.DirectoryServices.AccountManagement.UserPrincipal.Current.UserPrincipalName;
                            if (username != null)
                            {
                                if (CommandLine["d"] != null)
                                {
                                    username = username.Split('@')[0] + "@" + CommandLine["d"];
                                }
                            }
                            else
                            {
                                Console.WriteLine("Username cannot be empty");
                                return;
                            }
                        }

                        // If password is specified, use it, otherwise try integrated authentication

                        if (CommandLine["p"] != null)
                        {
                            password = dec.DecryptData(CommandLine["p"]); useIntegratedAuth = false;
                        }

                        // Set the flag for quiet mode
                        if (CommandLine["quiet"] != null)
                        {
                            quiet = true;
                        }
                        else if (CommandLine["debug"] != null)
                        {
                            debug = true;
                        }

                        // If asked to mount sharepoint as a share
                        disk = CommandLine["mount"];
                        if (disk != null)
                        {
                            mount = true;
                            if (disk == "true")
                            {
                                disk = "*";
                            }
                        }

                        if (CommandLine["expire"] != null)
                        {
                            expire = Convert.ToDouble(CommandLine["expire"]);
                        }

                        if (CommandLine["homedir"] != null)
                        {
                            String user   = username.Split('@')[0];
                            String domain = username.Split('@')[1];
                            homedir = "DavWWWRoot\\personal\\" + user + "_" + domain.Split('.')[0] + "_" + domain.Split('.')[1] + "_" + domain.Split('.')[2] + "\\Documents";
                        }

                        // if not quiet, display parameters
                        if (!quiet)
                        {
                            // Message
                            Console.WriteLine("============= Cookie365 v0.7 - (C)opyright 2014-2017 Fabio Cuneaz =============\n");
                            Console.WriteLine("SharePoint URL: " + sharepointUrl);
                            Console.WriteLine("User: "******"Use Windows Integrated Authentication: " + useIntegratedAuth.ToString());
                            if (homedir != "")
                            {
                                Console.WriteLine("HomeDir: " + homedir);
                            }
                            if (mount)
                            {
                                Console.WriteLine("Mount as disk: " + disk);
                            }
                        }

                        // Run Asynchronously and wait for cookie retrieval
                        RunAsync(sharepointUri, username, password, useIntegratedAuth, !quiet, debug).Wait();

                        // If
                        if (SpoAuthUtility.Current != null)
                        {
                            if (!quiet)
                            {
                                Console.Write("Setting Cookies in OS...");
                            }
                            try
                            {
                                // Create the cookie collection object for sharepoint URI
                                CookieCollection cookies = SpoAuthUtility.Current.cookieContainer.GetCookies(sharepointUri);

                                // Extract the base URL in case the URL provided contains nested paths (e.g. https://contoso.sharepoint.com/abc/ddd/eed)
                                // The cookie has to be set for the domain (contoso.sharepoint.com), otherwise it will not work
                                String baseUrl = sharepointUri.Scheme + "://" + sharepointUri.Host;

                                if (InternetSetCookie(baseUrl, null, cookies["FedAuth"].ToString() + "; Expires = " + cookies["FedAuth"].Expires.AddMinutes(expire).ToString("R")))
                                {
                                    if (InternetSetCookie(baseUrl, null, cookies["rtFA"].ToString() + "; Expires = " + cookies["rtFA"].Expires.AddMinutes(expire).ToString("R")))
                                    {
                                        if (!quiet)
                                        {
                                            Console.WriteLine("[OK]. Expiry = " + cookies["FedAuth"].Expires.AddMinutes(expire).ToString("R"));
                                        }
                                        if (mount)
                                        {
                                            try
                                            {
                                                String cmdArgs = "/c net use " + disk + " \\\\" + sharepointUri.Host + "@ssl" + sharepointUri.PathAndQuery.Replace("/", "\\") + homedir;
                                                if (!quiet)
                                                {
                                                    Console.Write("Mounting Share..." + cmdArgs);
                                                }
                                                System.Diagnostics.Process Process = new System.Diagnostics.Process();
                                                Process.StartInfo = new System.Diagnostics.ProcessStartInfo("cmd", cmdArgs);
                                                Process.StartInfo.RedirectStandardOutput = true;
                                                Process.StartInfo.UseShellExecute        = false;
                                                //Process.StartInfo.CreateNoWindow = true;
                                                Process.Start();
                                                Process.WaitForExit();
                                                String output = Process.StandardOutput.ReadToEnd();
                                                if (!quiet)
                                                {
                                                    Console.WriteLine("[OK]");
                                                    Console.WriteLine(output);
                                                }
                                            }
                                            catch (Exception e)
                                            { Console.WriteLine("[ERROR Mounting Share]:" + e.Message); }
                                        }
                                    }
                                }
                            }
                            catch (Exception e)
                            { Console.WriteLine("[ERROR setting Cookies]:" + e.Message); }
                        }
                    }
                    catch (Exception e)
                    { Console.WriteLine("[ERROR]:" + e.Message); }
                }
            }
        }