Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Text.RegularExpressions;
- using System.IO;
- using System.Diagnostics;
- using System.Threading;
- namespace TestProcessCaller
- {
- /// <summary>
- /// A simple form to launch a process using ProcessCaller
- /// and display all StdOut and StdErr in a RichTextBox.
- /// </summary>
- /// <remarks>
- /// Special thanks to Chad Christensen for suggestions
- /// on using the RichTextBox.
- /// Note there are a lot of issues with scrolling on a
- /// RichTextBox, depending upon if the cursor (selection point)
- /// is in the RichTextBox or not, and if it is hidden or not.
- /// I've disabled the RichTextBox tabstop so that the cursor isn't
- /// automatically placed in the text box.
- /// Now setting or unsetting:
- /// richTextBox1.HideSelection
- /// will affect if the textbox is always repositioned at the bottom
- /// when new text is entered.
- /// </remarks>
- public class ProgressForm : System.Windows.Forms.Form
- {
- private System.Windows.Forms.Button btnOk;
- private System.Windows.Forms.Button btnCancel;
- // Note: richtext box can hold much longer text than a plain textbox.
- private TextBox textBox1;
- private WebBrowser webBrowser1;
- private ComboBox comboBox1;
- private TextBox textBox2;
- private TextBox textBox3;
- private Label label1;
- private Label label2;
- private TextBox textBox4;
- private Label label3;
- private TextBox textBox5;
- private CheckBox checkBox1;
- private TextBox textBox6;
- private Button button1;
- private WebBrowser webBrowser2;
- private Button button2;
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.Container components = null;
- /// <summary>
- /// Default constructor
- /// </summary>
- public ProgressForm()
- {
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
- }
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ProgressForm));
- this.btnOk = new System.Windows.Forms.Button();
- this.btnCancel = new System.Windows.Forms.Button();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.webBrowser1 = new System.Windows.Forms.WebBrowser();
- this.comboBox1 = new System.Windows.Forms.ComboBox();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.textBox3 = new System.Windows.Forms.TextBox();
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.textBox4 = new System.Windows.Forms.TextBox();
- this.label3 = new System.Windows.Forms.Label();
- this.textBox5 = new System.Windows.Forms.TextBox();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
- this.textBox6 = new System.Windows.Forms.TextBox();
- this.button1 = new System.Windows.Forms.Button();
- this.webBrowser2 = new System.Windows.Forms.WebBrowser();
- this.button2 = new System.Windows.Forms.Button();
- this.SuspendLayout();
- //
- // btnOk
- //
- this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.btnOk.Location = new System.Drawing.Point(697, 526);
- this.btnOk.Name = "btnOk";
- this.btnOk.Size = new System.Drawing.Size(75, 23);
- this.btnOk.TabIndex = 2;
- this.btnOk.Text = "&START";
- this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
- //
- // btnCancel
- //
- this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.btnCancel.Location = new System.Drawing.Point(12, 526);
- this.btnCancel.Name = "btnCancel";
- this.btnCancel.Size = new System.Drawing.Size(75, 23);
- this.btnCancel.TabIndex = 1;
- this.btnCancel.Text = "&STOP";
- this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(69, 242);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(437, 20);
- this.textBox1.TabIndex = 3;
- //
- // webBrowser1
- //
- this.webBrowser1.Location = new System.Drawing.Point(12, -1);
- this.webBrowser1.Margin = new System.Windows.Forms.Padding(0);
- this.webBrowser1.Name = "webBrowser1";
- this.webBrowser1.ScriptErrorsSuppressed = true;
- this.webBrowser1.ScrollBarsEnabled = false;
- this.webBrowser1.Size = new System.Drawing.Size(747, 108);
- this.webBrowser1.TabIndex = 1;
- this.webBrowser1.Url = new System.Uri("http://mox5500.github.io/tools/ads/728x90.html", System.UriKind.Absolute);
- //
- // comboBox1
- //
- this.comboBox1.FormattingEnabled = true;
- this.comboBox1.Location = new System.Drawing.Point(592, 241);
- this.comboBox1.Name = "comboBox1";
- this.comboBox1.Size = new System.Drawing.Size(69, 21);
- this.comboBox1.TabIndex = 4;
- this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- //
- // textBox2
- //
- this.textBox2.Location = new System.Drawing.Point(629, 42);
- this.textBox2.Name = "textBox2";
- this.textBox2.Size = new System.Drawing.Size(100, 20);
- this.textBox2.TabIndex = 5;
- this.textBox2.Visible = false;
- //
- // textBox3
- //
- this.textBox3.BackColor = System.Drawing.SystemColors.InfoText;
- this.textBox3.ForeColor = System.Drawing.Color.Lime;
- this.textBox3.Location = new System.Drawing.Point(12, 268);
- this.textBox3.Multiline = true;
- this.textBox3.Name = "textBox3";
- this.textBox3.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
- this.textBox3.Size = new System.Drawing.Size(760, 247);
- this.textBox3.TabIndex = 6;
- this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged);
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(10, 245);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(53, 13);
- this.label1.TabIndex = 7;
- this.label1.Text = "TARGET :";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(512, 245);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(74, 13);
- this.label2.TabIndex = 8;
- this.label2.Text = "ENUMERATE :";
- //
- // textBox4
- //
- this.textBox4.Location = new System.Drawing.Point(69, 216);
- this.textBox4.Name = "textBox4";
- this.textBox4.Size = new System.Drawing.Size(100, 20);
- this.textBox4.TabIndex = 9;
- this.textBox4.TextChanged += new System.EventHandler(this.textBox4_TextChanged);
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(9, 219);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(53, 13);
- this.label3.TabIndex = 10;
- this.label3.Text = "PROXY :";
- //
- // textBox5
- //
- this.textBox5.Location = new System.Drawing.Point(510, 61);
- this.textBox5.Name = "textBox5";
- this.textBox5.Size = new System.Drawing.Size(91, 20);
- this.textBox5.TabIndex = 11;
- this.textBox5.Visible = false;
- //
- // checkBox1
- //
- this.checkBox1.AutoSize = true;
- this.checkBox1.Location = new System.Drawing.Point(667, 244);
- this.checkBox1.Name = "checkBox1";
- this.checkBox1.Size = new System.Drawing.Size(106, 17);
- this.checkBox1.TabIndex = 12;
- this.checkBox1.Text = "RANDOM AGENT";
- this.checkBox1.UseVisualStyleBackColor = true;
- this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
- //
- // textBox6
- //
- this.textBox6.Location = new System.Drawing.Point(514, 32);
- this.textBox6.Name = "textBox6";
- this.textBox6.Size = new System.Drawing.Size(72, 20);
- this.textBox6.TabIndex = 13;
- this.textBox6.Visible = false;
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(346, 526);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 14;
- this.button1.Text = "CLEAR";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // webBrowser2
- //
- this.webBrowser2.Location = new System.Drawing.Point(575, 115);
- this.webBrowser2.MinimumSize = new System.Drawing.Size(20, 20);
- this.webBrowser2.Name = "webBrowser2";
- this.webBrowser2.ScrollBarsEnabled = false;
- this.webBrowser2.Size = new System.Drawing.Size(183, 75);
- this.webBrowser2.TabIndex = 15;
- this.webBrowser2.Url = new System.Uri("http://mox5500.github.io/tools/ads/donate.html", System.UriKind.Absolute);
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(17, 125);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(81, 24);
- this.button2.TabIndex = 16;
- this.button2.Text = "UPDATE";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // ProgressForm
- //
- this.AcceptButton = this.btnOk;
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
- this.BackColor = System.Drawing.SystemColors.ButtonFace;
- this.CancelButton = this.btnCancel;
- this.ClientSize = new System.Drawing.Size(784, 561);
- this.Controls.Add(this.button2);
- this.Controls.Add(this.webBrowser2);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.textBox6);
- this.Controls.Add(this.checkBox1);
- this.Controls.Add(this.textBox5);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.textBox4);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.textBox3);
- this.Controls.Add(this.textBox2);
- this.Controls.Add(this.comboBox1);
- this.Controls.Add(this.webBrowser1);
- this.Controls.Add(this.textBox1);
- this.Controls.Add(this.btnCancel);
- this.Controls.Add(this.btnOk);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.MaximizeBox = false;
- this.Name = "ProgressForm";
- this.Text = "Wpscan For Windows";
- this.Load += new System.EventHandler(this.ProgressForm_Load);
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- #endregion
- private ProcessCaller processCaller;
- private void btnOk_Click(object sender, System.EventArgs e)
- {
- this.Cursor = Cursors.AppStarting;
- this.btnOk.Enabled = false;
- processCaller = new ProcessCaller(this);
- processCaller.FileName = @"cmd.exe";
- //processCaller.FileName = @"..\env\bin\ruby.exe";
- processCaller.Arguments = (@"/k chcp 1252 & %cd%\env\bin\ruby.exe %cd%\files\wpscan.rb --no-color -u " + textBox1.Text + textBox2.Text + textBox5.Text + textBox6.Text);
- processCaller.StdErrReceived += new DataReceivedHandler(writeStreamInfo);
- processCaller.StdOutReceived += new DataReceivedHandler(writeStreamInfo);
- processCaller.Completed += new EventHandler(processCompletedOrCanceled);
- processCaller.Cancelled += new EventHandler(processCompletedOrCanceled);
- //processCaller.Failed += no event handler for this one, yet;
- this.textBox3.Text = "Started function. Please stand by.." + Environment.NewLine;
- // the following function starts a process and returns immediately,
- // thus allowing the form to stay responsive.
- processCaller.Start();
- }
- private void btnCancel_Click(object sender, System.EventArgs e)
- {
- if (processCaller != null)
- {
- processCaller.Cancel();
- }
- }
- /// <summary>
- /// Handles the events of StdErrReceived and StdOutReceived.
- /// </summary>
- /// <remarks>
- /// If stderr were handled in a separate function, it could possibly
- /// be displayed in red in the richText box, but that is beyond
- /// the scope of this demo.
- /// </remarks>
- private void writeStreamInfo(object sender, DataReceivedEventArgs e)
- {
- this.textBox3.AppendText(e.Text + Environment.NewLine);
- }
- /// <summary>
- /// Handles the events of processCompleted & processCanceled
- /// </summary>
- private void processCompletedOrCanceled(object sender, EventArgs e)
- {
- this.Cursor = Cursors.Default;
- this.btnOk.Enabled = true;
- this.textBox3.AppendText(Environment.NewLine + "completed");
- }
- [STAThread]
- static void Main(string[] args)
- {
- Application.Run(new ProgressForm());
- }
- private void textBox3_TextChanged(object sender, EventArgs e)
- {
- }
- private void ProgressForm_Load(object sender, EventArgs e)
- {
- comboBox1.Items.Add("Users");
- comboBox1.Items.Add("Themes");
- comboBox1.Items.Add("Plugins");
- comboBox1.Items.Add("Timthumbs");
- }
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (comboBox1.SelectedItem.ToString() == "Users")
- {
- textBox2.Text = " --enumerate u";
- }
- else
- if (comboBox1.SelectedItem.ToString() == "Themes")
- {
- textBox2.Text = " --enumerate t";
- }
- else
- if (comboBox1.SelectedItem.ToString() == "Plugins")
- {
- textBox2.Text = " --enumerate p";
- }
- else
- if (comboBox1.SelectedItem.ToString() == "Timthumbs")
- {
- textBox2.Text = " --enumerate tt";
- }
- }
- private void textBox4_TextChanged(object sender, EventArgs e)
- {
- if (textBox4.Text.ToString() == "")
- {
- textBox5.Text = (textBox4.Text);
- }
- else
- textBox5.Text = (" --proxy " +textBox4.Text);
- }
- private void checkBox1_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBox1.Checked == true)
- {
- textBox6.Text = (" --random-agent");
- }
- else if (checkBox1.Checked == false)
- {
- textBox6.Text = ("");
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- textBox3.Text = String.Empty;
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.button2.Enabled = false;
- processCaller = new ProcessCaller(this);
- processCaller.FileName = @"cmd.exe";
- processCaller.Arguments = (@"/k chcp 1252 & %cd%\env\bin\ruby.exe %cd%\files\wpscan.rb --no-color --update");
- processCaller.StdErrReceived += new DataReceivedHandler(writeStreamInfo);
- processCaller.StdOutReceived += new DataReceivedHandler(writeStreamInfo);
- processCaller.Completed += new EventHandler(processCompletedOrCanceled);
- processCaller.Cancelled += new EventHandler(processCompletedOrCanceled);
- //processCaller.Failed += no event handler for this one, yet;
- this.textBox3.Text = "Started function. Please stand by.." + Environment.NewLine;
- // the following function starts a process and returns immediately,
- // thus allowing the form to stay responsive.
- processCaller.Start();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement