예제 #1
0
        public bool autossl()
        {
            Scan_Test.BackColor = Color.Chocolate;
            bool             setssl = true;
            string           strCmdText;
            SSLResults       sslresform = new SSLResults();
            ProcessStartInfo startinfo  = new ProcessStartInfo();
            Process          cmd        = new Process();

            strCmdText = "/C" + " " + "TestSSLServer2.exe -json " + " \"" + Directory.GetCurrentDirectory() + "\\aresult.json" + "\" " + G_callingip + " " + G_callingport;

            cmd.StartInfo.WorkingDirectory = @"C:\Windows\System32";

            cmd.StartInfo.FileName = "cmd.exe";

            cmd.StartInfo.Arguments              = strCmdText.ToString();
            cmd.StartInfo.UseShellExecute        = false;
            cmd.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            cmd.StartInfo.RedirectStandardOutput = true;
            cmd.Start();
            cmd.WaitForExit();

            string jsonfile = Directory.GetCurrentDirectory() + "\\aresult.json" + " ";

            using (StreamReader jfile = File.OpenText(jsonfile))
                using (JsonTextReader reader = new JsonTextReader(jfile))
                {
                    JObject        o2   = (JObject)JToken.ReadFrom(reader);
                    IList <string> keys = o2.Properties().Select(p => p.Name).ToList();
                    //string rem= o2.SelectToken("TLSv1.2[1]").ToString();
                    //Console.WriteLine(o2.SelectToken("TLSv1.2"));
                    // string test= o2.SelectToken("TLSv1.2.suites[0].name").ToString();
                    if ((keys.Any(l => l.Contains("TLS"))) || (keys.Any(l => l.Contains("SSL"))))
                    {
                        sslcheckstatus = true;
                    }
                    else
                    {
                        sslcheckstatus = false;
                    }
                    if (sslcheckstatus == false)
                    {
                        setssl = false;
                    }
                    string foundkeys = keys[3].ToString();// write code to check if TLS1.0/etc is upported exit
                    if (foundkeys.Contains("TLSv1.0") || foundkeys.Contains("TLSv1.1") || foundkeys.Contains("SSLv3.0") || foundkeys.Contains("SSLv2.0"))
                    {
                        setssl = false;
                    }
                    if (supportlowerver == false)
                    {
                        foreach (var st in o2.SelectTokens("['TLSv1.2'].suites[0].name"))
                        {
                            atciphers.Add(st.ToString());
                        }
                        atciphers.ToArray();

                        foreach (string cp in atciphers)
                        {
                            atciphercontained.Add(supportedciphers.Contains(cp));
                        }
                        atciphercontained.ToArray();



                        // code to match cipher suites with dicom standards
                        if (!(atciphercontained.Contains(false)))
                        {
                            setssl = true;
                        }
                        else
                        {
                            string todisplay        = string.Join(Environment.NewLine, supportedciphers);
                            string todisplayciphers = string.Join(Environment.NewLine, atciphers);

                            setssl = false;
                        }
                    }
                }
            return(setssl);

            Scan_Test.BackColor = default(Color);
        }
예제 #2
0
        private void SSL_Click_1(object sender, EventArgs e)
        {
            SSL_button.Enabled   = false;
            SSL_button.BackColor = Color.Chocolate;
            label3.Text          = "SSL Scan initiated";
            if (sysdetset == true)
            {
                string     strCmdText;
                SSLResults sslresform = new SSLResults();
//                sslresform.ShowDialog();
                ProcessStartInfo startinfo = new ProcessStartInfo();
                Process          cmd       = new Process();

                strCmdText = "/C" + " " + "TestSSLServer2.exe -json " + " \"" + Directory.GetCurrentDirectory() + "\\aresult.json" + "\" " + G_callingip + " " + G_callingport;

                cmd.StartInfo.WorkingDirectory = @"C:\Windows\System32";

                cmd.StartInfo.FileName = "cmd.exe";

                cmd.StartInfo.Arguments              = strCmdText.ToString();
                cmd.StartInfo.UseShellExecute        = false;
                cmd.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
                cmd.StartInfo.RedirectStandardOutput = true;
                cmd.Start();
                cmd.WaitForExit();
                // parsing json output of test ssl server
                string jsonfile = Directory.GetCurrentDirectory() + "\\aresult.json";


                // read JSON directly from a file
                using (StreamReader jfile = File.OpenText(jsonfile))
                    using (JsonTextReader reader = new JsonTextReader(jfile))
                    {
                        JObject        o2   = (JObject)JToken.ReadFrom(reader);
                        IList <string> keys = o2.Properties().Select(p => p.Name).ToList();

                        if ((keys.Any(l => l.Contains("TLS"))) || (keys.Any(l => l.Contains("SSL"))))
                        {
                            sslcheckstatus = true;
                        }
                        else
                        {
                            sslcheckstatus = false;
                        }
                        if (sslcheckstatus == false)
                        {
                            MessageBox.Show("Could not detect cipher suites, please re run");
                            this.Close();
                        }
                        string foundkeys = keys[3].ToString();// write code to check if TLS1.0/etc is upported exit
                        if (foundkeys.Contains("TLSv1.0") || foundkeys.Contains("TLSv1.1") || foundkeys.Contains("SSLv3.0") || foundkeys.Contains("SSLv2.0"))
                        {
                            supportlowerver = true;
                            MessageBox.Show(String.Format("The SSL/TLS version is unsupported use only TLSv1.2 or above, the version detected is {0}", foundkeys));
                            this.Close();
                        }
                        if (supportlowerver == false)
                        {
                            MessageBox.Show(String.Format("The SSL/TLS version detected is supported , the version is {0}", foundkeys));
                            //loop for ciphers



                            foreach (var st in o2.SelectTokens("['TLSv1.2'].suites[0].name"))
                            {
                                ciphers.Add(st.ToString());
                            }
                            ciphers.ToArray();

                            foreach (string cp in ciphers)
                            {
                                ciphercontained.Add(supportedciphers.Contains(cp));
                            }
                            ciphercontained.ToArray();



                            // code to match cipher suites with dicom standards
                            if (!(ciphercontained.Contains(false)))
                            {
                                MessageBox.Show(String.Format("The ciphersuite detected matches as per DICOM standards and cipher suite is {0}", ciphers));
                            }
                            else
                            {
                                string todisplay        = string.Join(Environment.NewLine, supportedciphers);
                                string todisplayciphers = string.Join(Environment.NewLine, ciphers);

                                MessageBox.Show(String.Format("The ciphersuite detected does not matche as per DICOM standards and dicom supported cipher suites are {0}", todisplay));
                                MessageBox.Show(String.Format("The cipher suite detected is {0}", todisplayciphers));
                            }
                        }
                    }
            }
            else
            {
                MessageBox.Show("Please enter the details in config");
            }
            SSL_button.BackColor = default(Color);
            SSL_button.Enabled   = true;
        }