Advertisement
Guest User

Untitled

a guest
Jun 25th, 2015
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 18.88 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Text.RegularExpressions;
  7. using System.IO;
  8. using System.Diagnostics;
  9. using System.Threading;
  10.  
  11. namespace TestProcessCaller
  12. {
  13.     /// <summary>
  14.     /// A simple form to launch a process using ProcessCaller
  15.     /// and display all StdOut and StdErr in a RichTextBox.
  16.     /// </summary>
  17.     /// <remarks>
  18.     /// Special thanks to Chad Christensen for suggestions
  19.     /// on using the RichTextBox.
  20.     /// Note there are a lot of issues with scrolling on a
  21.     /// RichTextBox, depending upon if the cursor (selection point)
  22.     /// is in the RichTextBox or not, and if it is hidden or not.
  23.     /// I've disabled the RichTextBox tabstop so that the cursor isn't
  24.     /// automatically placed in the text box.
  25.     /// Now setting or unsetting:
  26.     ///    richTextBox1.HideSelection
  27.     /// will affect if the textbox is always repositioned at the bottom
  28.     ///   when new text is entered.
  29.     /// </remarks>
  30.     public class ProgressForm : System.Windows.Forms.Form
  31.     {
  32.         private System.Windows.Forms.Button btnOk;
  33.         private System.Windows.Forms.Button btnCancel;
  34.         // Note: richtext box can hold much longer text than a plain textbox.
  35.         private TextBox textBox1;
  36.         private WebBrowser webBrowser1;
  37.         private ComboBox comboBox1;
  38.         private TextBox textBox2;
  39.         private TextBox textBox3;
  40.         private Label label1;
  41.         private Label label2;
  42.         private TextBox textBox4;
  43.         private Label label3;
  44.         private TextBox textBox5;
  45.         private CheckBox checkBox1;
  46.         private TextBox textBox6;
  47.         private Button button1;
  48.         private WebBrowser webBrowser2;
  49.         private Button button2;
  50.         /// <summary>
  51.         /// Required designer variable.
  52.         /// </summary>
  53.         private System.ComponentModel.Container components = null;
  54.  
  55.         /// <summary>
  56.         /// Default constructor
  57.         /// </summary>
  58.         public ProgressForm()
  59.         {
  60.             //
  61.             // Required for Windows Form Designer support
  62.             //
  63.             InitializeComponent();
  64.  
  65.         }
  66.  
  67.         /// <summary>
  68.         /// Clean up any resources being used.
  69.         /// </summary>
  70.         protected override void Dispose( bool disposing )
  71.         {
  72.             if( disposing )
  73.             {
  74.                 if(components != null)
  75.                 {
  76.                     components.Dispose();
  77.                 }
  78.             }
  79.             base.Dispose( disposing );
  80.         }
  81.  
  82.         #region Windows Form Designer generated code
  83.         /// <summary>
  84.         /// Required method for Designer support - do not modify
  85.         /// the contents of this method with the code editor.
  86.         /// </summary>
  87.         private void InitializeComponent()
  88.         {
  89.             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ProgressForm));
  90.             this.btnOk = new System.Windows.Forms.Button();
  91.             this.btnCancel = new System.Windows.Forms.Button();
  92.             this.textBox1 = new System.Windows.Forms.TextBox();
  93.             this.webBrowser1 = new System.Windows.Forms.WebBrowser();
  94.             this.comboBox1 = new System.Windows.Forms.ComboBox();
  95.             this.textBox2 = new System.Windows.Forms.TextBox();
  96.             this.textBox3 = new System.Windows.Forms.TextBox();
  97.             this.label1 = new System.Windows.Forms.Label();
  98.             this.label2 = new System.Windows.Forms.Label();
  99.             this.textBox4 = new System.Windows.Forms.TextBox();
  100.             this.label3 = new System.Windows.Forms.Label();
  101.             this.textBox5 = new System.Windows.Forms.TextBox();
  102.             this.checkBox1 = new System.Windows.Forms.CheckBox();
  103.             this.textBox6 = new System.Windows.Forms.TextBox();
  104.             this.button1 = new System.Windows.Forms.Button();
  105.             this.webBrowser2 = new System.Windows.Forms.WebBrowser();
  106.             this.button2 = new System.Windows.Forms.Button();
  107.             this.SuspendLayout();
  108.             //
  109.             // btnOk
  110.             //
  111.             this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  112.             this.btnOk.Location = new System.Drawing.Point(697, 526);
  113.             this.btnOk.Name = "btnOk";
  114.             this.btnOk.Size = new System.Drawing.Size(75, 23);
  115.             this.btnOk.TabIndex = 2;
  116.             this.btnOk.Text = "&START";
  117.             this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
  118.             //
  119.             // btnCancel
  120.             //
  121.             this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  122.             this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  123.             this.btnCancel.Location = new System.Drawing.Point(12, 526);
  124.             this.btnCancel.Name = "btnCancel";
  125.             this.btnCancel.Size = new System.Drawing.Size(75, 23);
  126.             this.btnCancel.TabIndex = 1;
  127.             this.btnCancel.Text = "&STOP";
  128.             this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
  129.             //
  130.             // textBox1
  131.             //
  132.             this.textBox1.Location = new System.Drawing.Point(69, 242);
  133.             this.textBox1.Name = "textBox1";
  134.             this.textBox1.Size = new System.Drawing.Size(437, 20);
  135.             this.textBox1.TabIndex = 3;
  136.             //
  137.             // webBrowser1
  138.             //
  139.             this.webBrowser1.Location = new System.Drawing.Point(12, -1);
  140.             this.webBrowser1.Margin = new System.Windows.Forms.Padding(0);
  141.             this.webBrowser1.Name = "webBrowser1";
  142.             this.webBrowser1.ScriptErrorsSuppressed = true;
  143.             this.webBrowser1.ScrollBarsEnabled = false;
  144.             this.webBrowser1.Size = new System.Drawing.Size(747, 108);
  145.             this.webBrowser1.TabIndex = 1;
  146.             this.webBrowser1.Url = new System.Uri("http://mox5500.github.io/tools/ads/728x90.html", System.UriKind.Absolute);
  147.             //
  148.             // comboBox1
  149.             //
  150.             this.comboBox1.FormattingEnabled = true;
  151.             this.comboBox1.Location = new System.Drawing.Point(592, 241);
  152.             this.comboBox1.Name = "comboBox1";
  153.             this.comboBox1.Size = new System.Drawing.Size(69, 21);
  154.             this.comboBox1.TabIndex = 4;
  155.             this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  156.             //
  157.             // textBox2
  158.             //
  159.             this.textBox2.Location = new System.Drawing.Point(629, 42);
  160.             this.textBox2.Name = "textBox2";
  161.             this.textBox2.Size = new System.Drawing.Size(100, 20);
  162.             this.textBox2.TabIndex = 5;
  163.             this.textBox2.Visible = false;
  164.             //
  165.             // textBox3
  166.             //
  167.             this.textBox3.BackColor = System.Drawing.SystemColors.InfoText;
  168.             this.textBox3.ForeColor = System.Drawing.Color.Lime;
  169.             this.textBox3.Location = new System.Drawing.Point(12, 268);
  170.             this.textBox3.Multiline = true;
  171.             this.textBox3.Name = "textBox3";
  172.             this.textBox3.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
  173.             this.textBox3.Size = new System.Drawing.Size(760, 247);
  174.             this.textBox3.TabIndex = 6;
  175.             this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged);
  176.             //
  177.             // label1
  178.             //
  179.             this.label1.AutoSize = true;
  180.             this.label1.Location = new System.Drawing.Point(10, 245);
  181.             this.label1.Name = "label1";
  182.             this.label1.Size = new System.Drawing.Size(53, 13);
  183.             this.label1.TabIndex = 7;
  184.             this.label1.Text = "TARGET :";
  185.             //
  186.             // label2
  187.             //
  188.             this.label2.AutoSize = true;
  189.             this.label2.Location = new System.Drawing.Point(512, 245);
  190.             this.label2.Name = "label2";
  191.             this.label2.Size = new System.Drawing.Size(74, 13);
  192.             this.label2.TabIndex = 8;
  193.             this.label2.Text = "ENUMERATE :";
  194.             //
  195.             // textBox4
  196.             //
  197.             this.textBox4.Location = new System.Drawing.Point(69, 216);
  198.             this.textBox4.Name = "textBox4";
  199.             this.textBox4.Size = new System.Drawing.Size(100, 20);
  200.             this.textBox4.TabIndex = 9;
  201.             this.textBox4.TextChanged += new System.EventHandler(this.textBox4_TextChanged);
  202.             //
  203.             // label3
  204.             //
  205.             this.label3.AutoSize = true;
  206.             this.label3.Location = new System.Drawing.Point(9, 219);
  207.             this.label3.Name = "label3";
  208.             this.label3.Size = new System.Drawing.Size(53, 13);
  209.             this.label3.TabIndex = 10;
  210.             this.label3.Text = "PROXY   :";
  211.             //
  212.             // textBox5
  213.             //
  214.             this.textBox5.Location = new System.Drawing.Point(510, 61);
  215.             this.textBox5.Name = "textBox5";
  216.             this.textBox5.Size = new System.Drawing.Size(91, 20);
  217.             this.textBox5.TabIndex = 11;
  218.             this.textBox5.Visible = false;
  219.             //
  220.             // checkBox1
  221.             //
  222.             this.checkBox1.AutoSize = true;
  223.             this.checkBox1.Location = new System.Drawing.Point(667, 244);
  224.             this.checkBox1.Name = "checkBox1";
  225.             this.checkBox1.Size = new System.Drawing.Size(106, 17);
  226.             this.checkBox1.TabIndex = 12;
  227.             this.checkBox1.Text = "RANDOM AGENT";
  228.             this.checkBox1.UseVisualStyleBackColor = true;
  229.             this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
  230.             //
  231.             // textBox6
  232.             //
  233.             this.textBox6.Location = new System.Drawing.Point(514, 32);
  234.             this.textBox6.Name = "textBox6";
  235.             this.textBox6.Size = new System.Drawing.Size(72, 20);
  236.             this.textBox6.TabIndex = 13;
  237.             this.textBox6.Visible = false;
  238.             //
  239.             // button1
  240.             //
  241.             this.button1.Location = new System.Drawing.Point(346, 526);
  242.             this.button1.Name = "button1";
  243.             this.button1.Size = new System.Drawing.Size(75, 23);
  244.             this.button1.TabIndex = 14;
  245.             this.button1.Text = "CLEAR";
  246.             this.button1.UseVisualStyleBackColor = true;
  247.             this.button1.Click += new System.EventHandler(this.button1_Click);
  248.             //
  249.             // webBrowser2
  250.             //
  251.             this.webBrowser2.Location = new System.Drawing.Point(575, 115);
  252.             this.webBrowser2.MinimumSize = new System.Drawing.Size(20, 20);
  253.             this.webBrowser2.Name = "webBrowser2";
  254.             this.webBrowser2.ScrollBarsEnabled = false;
  255.             this.webBrowser2.Size = new System.Drawing.Size(183, 75);
  256.             this.webBrowser2.TabIndex = 15;
  257.             this.webBrowser2.Url = new System.Uri("http://mox5500.github.io/tools/ads/donate.html", System.UriKind.Absolute);
  258.             //
  259.             // button2
  260.             //
  261.             this.button2.Location = new System.Drawing.Point(17, 125);
  262.             this.button2.Name = "button2";
  263.             this.button2.Size = new System.Drawing.Size(81, 24);
  264.             this.button2.TabIndex = 16;
  265.             this.button2.Text = "UPDATE";
  266.             this.button2.UseVisualStyleBackColor = true;
  267.             this.button2.Click += new System.EventHandler(this.button2_Click);
  268.             //
  269.             // ProgressForm
  270.             //
  271.             this.AcceptButton = this.btnOk;
  272.             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  273.             this.BackColor = System.Drawing.SystemColors.ButtonFace;
  274.             this.CancelButton = this.btnCancel;
  275.             this.ClientSize = new System.Drawing.Size(784, 561);
  276.             this.Controls.Add(this.button2);
  277.             this.Controls.Add(this.webBrowser2);
  278.             this.Controls.Add(this.button1);
  279.             this.Controls.Add(this.textBox6);
  280.             this.Controls.Add(this.checkBox1);
  281.             this.Controls.Add(this.textBox5);
  282.             this.Controls.Add(this.label3);
  283.             this.Controls.Add(this.textBox4);
  284.             this.Controls.Add(this.label2);
  285.             this.Controls.Add(this.label1);
  286.             this.Controls.Add(this.textBox3);
  287.             this.Controls.Add(this.textBox2);
  288.             this.Controls.Add(this.comboBox1);
  289.             this.Controls.Add(this.webBrowser1);
  290.             this.Controls.Add(this.textBox1);
  291.             this.Controls.Add(this.btnCancel);
  292.             this.Controls.Add(this.btnOk);
  293.             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
  294.             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  295.             this.MaximizeBox = false;
  296.             this.Name = "ProgressForm";
  297.             this.Text = "Wpscan For Windows";
  298.             this.Load += new System.EventHandler(this.ProgressForm_Load);
  299.             this.ResumeLayout(false);
  300.             this.PerformLayout();
  301.  
  302.         }
  303.  
  304.         #endregion
  305.  
  306.        
  307.         private ProcessCaller processCaller;
  308.      
  309.         private void btnOk_Click(object sender, System.EventArgs e)
  310.         {
  311.             this.Cursor = Cursors.AppStarting;
  312.             this.btnOk.Enabled = false;
  313.            
  314.             processCaller = new ProcessCaller(this);
  315.             processCaller.FileName = @"cmd.exe";
  316.             //processCaller.FileName = @"..\env\bin\ruby.exe";
  317.             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);
  318.             processCaller.StdErrReceived += new DataReceivedHandler(writeStreamInfo);
  319.             processCaller.StdOutReceived += new DataReceivedHandler(writeStreamInfo);
  320.             processCaller.Completed += new EventHandler(processCompletedOrCanceled);
  321.             processCaller.Cancelled += new EventHandler(processCompletedOrCanceled);
  322.              //processCaller.Failed += no event handler for this one, yet;
  323.  
  324.             this.textBox3.Text = "Started function.  Please stand by.." + Environment.NewLine;
  325.  
  326.             // the following function starts a process and returns immediately,
  327.             // thus allowing the form to stay responsive.
  328.             processCaller.Start();  
  329.                      
  330.         }
  331.  
  332.         private void btnCancel_Click(object sender, System.EventArgs e)
  333.         {
  334.             if (processCaller != null)
  335.             {
  336.                 processCaller.Cancel();
  337.             }
  338.         }
  339.  
  340.         /// <summary>
  341.         /// Handles the events of StdErrReceived and StdOutReceived.
  342.         /// </summary>
  343.         /// <remarks>
  344.         /// If stderr were handled in a separate function, it could possibly
  345.         /// be displayed in red in the richText box, but that is beyond
  346.         /// the scope of this demo.
  347.         /// </remarks>
  348.        
  349.         private void writeStreamInfo(object sender, DataReceivedEventArgs e)
  350.         {
  351.             this.textBox3.AppendText(e.Text + Environment.NewLine);
  352.         }
  353.         /// <summary>
  354.         /// Handles the events of processCompleted & processCanceled
  355.         /// </summary>
  356.  
  357.         private void processCompletedOrCanceled(object sender, EventArgs e)
  358.         {
  359.             this.Cursor = Cursors.Default;
  360.             this.btnOk.Enabled = true;
  361.             this.textBox3.AppendText(Environment.NewLine + "completed");
  362.         }
  363.  
  364.  
  365.         [STAThread]
  366.         static void Main(string[] args)        
  367.         {
  368.             Application.Run(new ProgressForm());
  369.         }
  370.  
  371.         private void textBox3_TextChanged(object sender, EventArgs e)
  372.         {
  373.  
  374.         }
  375.  
  376.         private void ProgressForm_Load(object sender, EventArgs e)
  377.         {
  378.             comboBox1.Items.Add("Users");
  379.             comboBox1.Items.Add("Themes");
  380.             comboBox1.Items.Add("Plugins");
  381.             comboBox1.Items.Add("Timthumbs");
  382.         }
  383.  
  384.         private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  385.         {
  386.             if (comboBox1.SelectedItem.ToString() == "Users")
  387.             {
  388.                 textBox2.Text = " --enumerate u";
  389.             }
  390.             else
  391.                 if (comboBox1.SelectedItem.ToString() == "Themes")
  392.                 {
  393.                     textBox2.Text = " --enumerate t";
  394.                 }
  395.                 else
  396.                     if (comboBox1.SelectedItem.ToString() == "Plugins")
  397.                     {
  398.                         textBox2.Text = " --enumerate p";
  399.                     }
  400.                     else
  401.                         if (comboBox1.SelectedItem.ToString() == "Timthumbs")
  402.                         {
  403.                             textBox2.Text = " --enumerate tt";
  404.                         }
  405.         }
  406.  
  407.         private void textBox4_TextChanged(object sender, EventArgs e)
  408.         {
  409.             if (textBox4.Text.ToString() == "")
  410.             {
  411.                 textBox5.Text = (textBox4.Text);
  412.             }
  413.             else
  414.                 textBox5.Text = (" --proxy " +textBox4.Text);
  415.         }
  416.  
  417.         private void checkBox1_CheckedChanged(object sender, EventArgs e)
  418.         {
  419.             if (checkBox1.Checked == true)
  420.             {
  421.                 textBox6.Text = (" --random-agent");
  422.             }
  423.             else if (checkBox1.Checked == false)
  424.             {
  425.                 textBox6.Text = ("");
  426.             }
  427.         }
  428.  
  429.         private void button1_Click(object sender, EventArgs e)
  430.         {
  431.             textBox3.Text = String.Empty;
  432.         }
  433.  
  434.         private void button2_Click(object sender, EventArgs e)
  435.         {
  436.          
  437.             this.button2.Enabled = false;
  438.  
  439.             processCaller = new ProcessCaller(this);
  440.             processCaller.FileName = @"cmd.exe";
  441.             processCaller.Arguments = (@"/k chcp 1252 & %cd%\env\bin\ruby.exe %cd%\files\wpscan.rb --no-color --update");
  442.             processCaller.StdErrReceived += new DataReceivedHandler(writeStreamInfo);
  443.             processCaller.StdOutReceived += new DataReceivedHandler(writeStreamInfo);
  444.             processCaller.Completed += new EventHandler(processCompletedOrCanceled);
  445.             processCaller.Cancelled += new EventHandler(processCompletedOrCanceled);
  446.             //processCaller.Failed += no event handler for this one, yet;
  447.  
  448.             this.textBox3.Text = "Started function.  Please stand by.." + Environment.NewLine;
  449.  
  450.             // the following function starts a process and returns immediately,
  451.             // thus allowing the form to stay responsive.
  452.             processCaller.Start();
  453.            
  454.            
  455.            
  456.            
  457.         }
  458.  
  459.        
  460.  
  461.     }
  462. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement