Ejemplo n.º 1
0
        private void crozzleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Check if the crozzle is valid.
            SIT323Crozzle.Validate();

            // Update GUI - display crozzle data (whether valid or invalid),
            // crozle file errors, config file errors, word list file errors and crozzle errors.
            crozzleWebBrowser.DocumentText          = SIT323Crozzle.ToStringHTML();
            ErrorListViewer.WebBrowser.DocumentText =
                SIT323Crozzle.FileErrorsHTML +
                SIT323Crozzle.Configuration.FileErrorsHTML +
                SIT323Crozzle.WordList.FileErrorsHTML +
                SIT323Crozzle.ErrorsHTML;

            // Log crozzle errors.
            SIT323Crozzle.LogFileErrors(SIT323Crozzle.ErrorsTXT);
        }
Ejemplo n.º 2
0
        private void openCrozzleFile()
        {
            DialogResult result;

            // As we are opening a crozzle file,
            // indicate crozzle file, and crozzle are not valid, and clear GUI.
            crozzleToolStripMenuItem.Enabled        = false;
            crozzleWebBrowser.DocumentText          = "";
            ErrorListViewer.WebBrowser.DocumentText = "";

            // Process crozzle file.
            result = openFileDialog1.ShowDialog();
            if (result == DialogResult.OK)
            {
                // Get configuration filename.
                String configurationFileName = GetConfigurationFileName(openFileDialog1.FileName);
                if (configurationFileName == null)
                {
                    MessageBox.Show("configuration filename is missing from the crozzle file", ApplicationAboutBox.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // Add root to the path
                else
                {
                    String filename = configurationFileName.Trim();
                    if (Validator.IsDelimited(filename, Crozzle.StringDelimiters))
                    {
                        filename = filename.Trim(Crozzle.StringDelimiters);
                    }
                    configurationFileName = filename;

                    if (!Path.IsPathRooted(configurationFileName))
                    {
                        configurationFileName = Path.GetDirectoryName(openFileDialog1.FileName) + @"\" + configurationFileName;
                    }
                }

                // Parse configuration file.
                Configuration aConfiguration = null;
                Configuration.TryParse(configurationFileName, out aConfiguration);

                // Get wordlist filename.
                String wordListFileName = GetWordlistFileName(openFileDialog1.FileName);
                if (wordListFileName == null)
                {
                    MessageBox.Show("wordlist filename is missing from the crozzle file", ApplicationAboutBox.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    String filename = wordListFileName.Trim();
                    if (Validator.IsDelimited(filename, Crozzle.StringDelimiters))
                    {
                        filename = filename.Trim(Crozzle.StringDelimiters);
                    }
                    wordListFileName = filename;

                    if (!Path.IsPathRooted(wordListFileName))
                    {
                        wordListFileName = Path.GetDirectoryName(openFileDialog1.FileName) + @"\" + wordListFileName;
                    }
                }

                // Parse wordlist file.
                WordList wordList = null;
                WordList.TryParse(wordListFileName, aConfiguration, out wordList);

                // Parse crozzle file.
                Crozzle aCrozzle;
                Crozzle.TryParse(openFileDialog1.FileName, aConfiguration, wordList, out aCrozzle);
                SIT323Crozzle = aCrozzle;

                // Update GUI - menu enabled, display crozzle data (whether valid or invalid), and crozzle file errors.
                if (SIT323Crozzle.FileValid && SIT323Crozzle.Configuration.Valid && SIT323Crozzle.WordList.Valid)
                {
                    crozzleToolStripMenuItem.Enabled = true;
                }

                crozzleWebBrowser.DocumentText          = SIT323Crozzle.ToStringHTML();
                ErrorListViewer.WebBrowser.DocumentText =
                    SIT323Crozzle.FileErrorsHTML +
                    SIT323Crozzle.Configuration.FileErrorsHTML +
                    SIT323Crozzle.WordList.FileErrorsHTML;

                // Log errors.
                SIT323Crozzle.LogFileErrors(SIT323Crozzle.FileErrorsTXT);
                SIT323Crozzle.LogFileErrors(SIT323Crozzle.Configuration.FileErrorsTXT);
                SIT323Crozzle.LogFileErrors(SIT323Crozzle.WordList.FileErrors);
            }
        }
Ejemplo n.º 3
0
        private void saveAndOpenWebCrozzleFile()
        {
            string tempCrozzlePath       = @"..\..\..\TempCrozzleFile\TempCrozzle.txt";
            string tempWordlistPath      = @"..\..\..\TempCrozzleFile\TempWordlist.txt";
            string tempConfigurationPath = @"..\..\..\TempCrozzleFile\TempConfiguration.txt";

            this.downloadFile(this.comboBox1.Text, tempCrozzlePath);

            // As we are opening a crozzle file,
            // indicate crozzle file, and crozzle are not valid, and clear GUI.
            crozzleToolStripMenuItem.Enabled        = false;
            crozzleWebBrowser.DocumentText          = "";
            ErrorListViewer.WebBrowser.DocumentText = "";

            // Process crozzle file.
            // Get configuration filename.
            String configurationFileName = GetConfigurationFileName(tempCrozzlePath);

            if (configurationFileName == null)
            {
                MessageBox.Show("configuration filename is missing from the crozzle file", ApplicationAboutBox.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                String filename = configurationFileName.Trim().Replace("\"", string.Empty);
                this.downloadFile(filename, tempConfigurationPath);
            }

            // Parse configuration file.
            Configuration aConfiguration = null;

            Configuration.TryParse(tempConfigurationPath, out aConfiguration);

            // Get wordlist filename.
            String wordListFileName = GetWordlistFileName(tempCrozzlePath);

            if (wordListFileName == null)
            {
                MessageBox.Show("wordlist filename is missing from the crozzle file", ApplicationAboutBox.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                String filename = wordListFileName.Trim().Replace("\"", string.Empty);
                this.downloadFile(filename, tempWordlistPath);
            }

            // Parse wordlist file.
            WordList wordList = null;

            WordList.TryParse(tempWordlistPath, aConfiguration, out wordList);

            // Parse crozzle file.
            Crozzle aCrozzle;

            Crozzle.TryParse(tempCrozzlePath, aConfiguration, wordList, out aCrozzle);
            SIT323Crozzle = aCrozzle;

            // Update GUI - menu enabled, display crozzle data (whether valid or invalid), and crozzle file errors.
            if (SIT323Crozzle.FileValid && SIT323Crozzle.Configuration.Valid && SIT323Crozzle.WordList.Valid)
            {
                crozzleToolStripMenuItem.Enabled = true;
            }

            crozzleWebBrowser.DocumentText          = SIT323Crozzle.ToStringHTML();
            ErrorListViewer.WebBrowser.DocumentText =
                SIT323Crozzle.FileErrorsHTML +
                SIT323Crozzle.Configuration.FileErrorsHTML +
                SIT323Crozzle.WordList.FileErrorsHTML;

            // Log errors.
            SIT323Crozzle.LogFileErrors(SIT323Crozzle.FileErrorsTXT);
            SIT323Crozzle.LogFileErrors(SIT323Crozzle.Configuration.FileErrorsTXT);
            SIT323Crozzle.LogFileErrors(SIT323Crozzle.WordList.FileErrors);
        }
Ejemplo n.º 4
0
        private void openCrozzleFileRemotely()
        {
            crozzleToolStripMenuItem.Enabled = false;

            // Process crozzle file to get configuration filename
            String configurationFileName = GetConfigurationFileNameRemotely(crozzleComboBox.Text);

            if (configurationFileName == null)
            {
                MessageBox.Show("configuration filename is missing from the crozzle file", ApplicationAboutBox.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                String filename = configurationFileName.Trim();
                if (Validator.IsDelimited(filename, Crozzle.StringDelimiters))
                {
                    filename = filename.Trim(Crozzle.StringDelimiters);
                }
                configurationFileName = filename;
            }

            // Parse configuration file.
            Configuration aConfiguration = null;

            Configuration.TryParse(configurationFileName, out aConfiguration, true);

            // Get wordlist filename.
            String wordListFileName = GetWordlistFileNameRemotely(crozzleComboBox.Text);

            if (wordListFileName == null)
            {
                MessageBox.Show("wordlist filename is missing from the crozzle file", ApplicationAboutBox.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                String filename = wordListFileName.Trim();
                if (Validator.IsDelimited(filename, Crozzle.StringDelimiters))
                {
                    filename = filename.Trim(Crozzle.StringDelimiters);
                }
                wordListFileName = filename;
            }

            // Parse wordlist file.
            WordList wordList = null;

            WordList.TryParse(wordListFileName, aConfiguration, out wordList, true);

            // Parse crozzle file.
            Crozzle aCrozzle;

            Crozzle.TryParse(crozzleComboBox.Text, aConfiguration, wordList, out aCrozzle, true);
            SIT323Crozzle = aCrozzle;

            // Update GUI - menu enabled, display crozzle data (whether valid or invalid), and crozzle file errors.
            if (SIT323Crozzle.FileValid && SIT323Crozzle.Configuration.Valid && SIT323Crozzle.WordList.Valid)
            {
                crozzleToolStripMenuItem.Enabled = true;
            }

            crozzleWebBrowser.DocumentText          = SIT323Crozzle.ToStringHTML();
            ErrorListViewer.WebBrowser.DocumentText =
                SIT323Crozzle.FileErrorsHTML +
                SIT323Crozzle.Configuration.FileErrorsHTML +
                SIT323Crozzle.WordList.FileErrorsHTML;

            // Log errors.
            SIT323Crozzle.LogFileErrors(SIT323Crozzle.FileErrorsTXT, true);
            SIT323Crozzle.LogFileErrors(SIT323Crozzle.Configuration.FileErrorsTXT, true);
            SIT323Crozzle.LogFileErrors(SIT323Crozzle.WordList.FileErrors, true);
        }
Ejemplo n.º 5
0
        /* This section is added for Assessment 2 */
        private void button1_Click(object sender, EventArgs e)
        {
            // Crozzle generataion start
            label1.Text = "Generating crozzle...";
            // Get URL address
            crozzleName = URL.Text;

            String configurationFileName = GetConfigurationFileName(crozzleName);

            if (configurationFileName == null)
            {
                MessageBox.Show("configuration filename is missing from the crozzle file", ApplicationAboutBox.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                String filename = configurationFileName.Trim();
                if (Validator.IsDelimited(filename, Crozzle.StringDelimiters))
                {
                    filename = filename.Trim(Crozzle.StringDelimiters);
                }
                configurationFileName = filename;

                if (!Path.IsPathRooted(configurationFileName) && !crozzleName.Contains("http"))
                {
                    configurationFileName = Path.GetDirectoryName(crozzleName) + @"\" + configurationFileName;
                }
            }

            // Parse configuration file.
            Configuration aConfiguration = null;

            Configuration.TryParse(configurationFileName, out aConfiguration);

            // Get wordlist filename.
            String wordListFileName = GetWordlistFileName(crozzleName);

            if (wordListFileName == null)
            {
                MessageBox.Show("wordlist filename is missing from the crozzle file", ApplicationAboutBox.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                String filename = wordListFileName.Trim();
                if (Validator.IsDelimited(filename, Crozzle.StringDelimiters))
                {
                    filename = filename.Trim(Crozzle.StringDelimiters);
                }
                wordListFileName = filename;

                if (!Path.IsPathRooted(wordListFileName) && !crozzleName.Contains("http"))
                {
                    wordListFileName = Path.GetDirectoryName(crozzleName) + @"\" + wordListFileName;
                }
            }

            // Parse wordlist file.
            WordList wordList = null;

            WordList.TryParse(wordListFileName, aConfiguration, out wordList);

            // Parse crozzle file.
            Crozzle aCrozzle;

            Crozzle.TryParse(crozzleName, aConfiguration, wordList, out aCrozzle);
            SIT323Crozzle = aCrozzle;

            // Update GUI - menu enabled, display crozzle data (whether valid or invalid), and crozzle file errors.
            if (SIT323Crozzle.FileValid && SIT323Crozzle.Configuration.Valid && SIT323Crozzle.WordList.Valid)
            {
                crozzleToolStripMenuItem.Enabled = true;
            }

            crozzleWebBrowser.DocumentText          = SIT323Crozzle.ToStringHTML();
            ErrorListViewer.WebBrowser.DocumentText =
                SIT323Crozzle.FileErrorsHTML +
                SIT323Crozzle.Configuration.FileErrorsHTML +
                SIT323Crozzle.WordList.FileErrorsHTML;

            // Crozzle generataion complete
            label1.Text = "Crozzle generation succeed";

            // Log errors.
            SIT323Crozzle.LogFileErrors(SIT323Crozzle.FileErrorsTXT);
            SIT323Crozzle.LogFileErrors(SIT323Crozzle.Configuration.FileErrorsTXT);
            SIT323Crozzle.LogFileErrors(SIT323Crozzle.WordList.FileErrors);
        }