H4T3D

Mass SMS Sender and GET Contact List From Android C#

Oct 5th, 2016
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Net;
  9. using System.Net.Sockets;
  10. using System.Text;
  11. using System.Text.RegularExpressions;
  12. using System.Threading;
  13. using System.Threading.Tasks;
  14. using System.Windows.Forms;
  15.  
  16. namespace SMS_4_PK_BY_HAT
  17. {
  18.     public partial class Form1 : Form
  19.     {
  20.             string[] a;
  21.             string messages = "";
  22.             string sig="";
  23.             string namer = "";
  24.             static int counter = 0;
  25.  
  26.             public List<string> arr_of_contacts()
  27.             {
  28.                 List<string> contacts= new List<string>();
  29.                 string url = "http://" + ipAdd.Text + ":" + port_in.Text;
  30.                 WebRequest request = WebRequest.Create(url);
  31.                 WebResponse response = request.GetResponse();
  32.                 Stream data = response.GetResponseStream();
  33.                 string html = String.Empty;
  34.                 using (StreamReader sr = new StreamReader(data))
  35.                 {
  36.                     html += sr.ReadToEnd();
  37.                       //contacts.Add(sr.ReadToEnd());
  38.                 }
  39.               //  MessageBox.Show(html);
  40.                 MatchCollection mc = Regex.Matches(html, @"\d+");
  41.                 foreach (Match m in mc)
  42.                 {
  43.                     //MessageBox.Show(m.Value.Trim(' '));
  44.                     if (m.Value.Length == 11)
  45.                     {
  46.                         contacts.Add(m.Value.Trim(' '));
  47.                     }
  48.                 }
  49.  
  50.                 //contacts.Add(m.Value.Split('\n')[0]);
  51.                 return contacts;
  52.             }
  53.  
  54.         public Form1()
  55.         {
  56.             InitializeComponent();
  57.             backgroundWorker1.DoWork += backgroundWorker1_DoWork;
  58.             backgroundWorker1.ProgressChanged += backgroundWorker1_ProgressChanged;
  59.             backgroundWorker1.WorkerReportsProgress = true;
  60.             toolTip1.SetToolTip(button9, "Test Your Connection with Your Device");
  61.             button1.Enabled = false;
  62.             button10.Enabled = false;
  63.             comboBox1.SelectedItem = "Ufone";
  64.             label19.Hide();
  65.             label20.Hide();
  66.         }
  67.  
  68.         private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
  69.         {
  70.            
  71.             progressBar1.Value = e.ProgressPercentage;
  72.             //char[] splitter = { '\n', ':' };
  73.             //string[] datashow = result_textbox.Text.Split(splitter);
  74.             string[] phone_no = richTextBox1.Text.Split('\n');
  75.            // for (int i = 0; i < a.Length;i++ )
  76.             {
  77.                // dataGridView1.Rows.Add(a[i], a[i+5], messagebox.Text, a[i+2], DateTime.Now.ToString("mm:ss tt"));
  78.  
  79.              //   dataGridView1.Rows.Add(a[i], a[i + 5], messagebox.Text, a[i + 2], DateTime.Now.ToString("mm:ss tt"));
  80.             }
  81.  
  82.             dataGridView1.Rows.Add(counter, phone_no[counter], messagebox.Text, DateTime.Now.ToString("mm:ss tt"));
  83.             counter++;
  84.             label19.Text = DateTime.Now.ToString("h:mm:ss tt");
  85.               }
  86.  
  87.         private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
  88.         {
  89.  
  90.             Invoke(new Action(() => a = richTextBox1.Text.Split('\n')));
  91.             Invoke(new Action(() => messages = messagebox.Text));
  92.             Invoke(new Action(() => namer = textBox3.Text));
  93.             Invoke(new Action(() => sig = signature.Text));
  94.             int  counter = 0 ;
  95.             foreach(var no in a ){
  96.  
  97.                   Thread.Sleep(Convert.ToInt32(Math.Round(numericUpDown1.Value, 0)));
  98.               //  Thread.Sleep(8000);
  99.                   string url = "http://" + ipAdd.Text + ":" + port_in.Text + "/send/?pass=" + textBox2.Text + "&number=" + System.Net.WebUtility.UrlEncode(no) + "&data=" + namer + " :\n" + messages + "\n" + sig;
  100.                 WebRequest request = WebRequest.Create(url);
  101.                 WebResponse response = request.GetResponse();
  102.                 Stream data = response.GetResponseStream();
  103.                 string html = String.Empty;
  104.                 using (StreamReader sr = new StreamReader(data))
  105.                 {
  106.                     html += sr.ReadToEnd();
  107.                 }
  108.  
  109.                 Invoke(new Action(() => result_textbox.AppendText(counter+"\n"+html.ToString())));
  110.               //  richTextBox1.Text = html.ToString();
  111.  
  112.                 backgroundWorker1.ReportProgress(counter++);
  113.             }
  114.  
  115.         }
  116.  
  117.         private void button1_Click(object sender, EventArgs e)
  118.         {
  119.             label16.Text = DateTime.Now.ToString("h:mm:ss tt");
  120.             progressBar1.Maximum = richTextBox1.Text.Split('\n').Length;
  121.             button10.Enabled = true;
  122.             backgroundWorker1.RunWorkerAsync();
  123.             label19.Show();
  124.             label20.Show();
  125.         }
  126.  
  127.         private void messagebox_TextChanged(object sender, EventArgs e)
  128.         {
  129.             int left_char = 122 - messagebox.TextLength;
  130.             char_left.Text = left_char.ToString();
  131.         }
  132.  
  133.         private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
  134.         {
  135.  
  136.         }
  137.  
  138.         private void richTextBox1_TextChanged(object sender, EventArgs e)
  139.         {
  140.             groupBox1.Text = "Contacts Uploads : " + richTextBox1.Text.Split('\n').Length.ToString();
  141.         }
  142.  
  143.         private void label1_Click(object sender, EventArgs e)
  144.         {
  145.  
  146.         }
  147.  
  148.         private void textBox1_TextChanged(object sender, EventArgs e)
  149.         {
  150.            
  151.  
  152.         }
  153.  
  154.         private void button2_Click(object sender, EventArgs e)
  155.         {
  156.             string[] a = richTextBox1.Text.Split('\n');
  157.             richTextBox1.Text = "";
  158.             for (int i = 0; i < a.Length; i++)
  159.             {
  160.                 richTextBox1.Text += preffixer.Text + a[i].ToString() + "\n";
  161.             }
  162.         }
  163.  
  164.         private void button3_Click(object sender, EventArgs e)
  165.         {
  166.             //textBox1.Text.ToCharArray()[0]
  167.             char[] trimer = { textBox1.Text.ToCharArray()[0]};
  168.             string[] a = richTextBox1.Text.Split('\n');
  169.             richTextBox1.Text = "";
  170.             for (int i = 0; i < a.Length; i++)
  171.             {
  172.                 richTextBox1.Text += a[i].ToString().Trim(trimer) + "\n";
  173.             }
  174.  
  175.         }
  176.  
  177.         private void Form1_Load(object sender, EventArgs e)
  178.         {
  179.  
  180.         }
  181.  
  182.         private void load_contacts_Click(object sender, EventArgs e)
  183.         {
  184.  
  185.             for (int t = 0; t < arr_of_contacts().ToArray().Length; t++)
  186.                     {
  187.                         checkedListBox1.Items.Add(arr_of_contacts().ToArray()[t]);
  188.                     }
  189.                    
  190.         }
  191.  
  192.         private void button4_Click(object sender, EventArgs e)
  193.         {
  194.             foreach (object itemChecked in checkedListBox1.CheckedItems)
  195.             {
  196.                 richTextBox1.Text += "\n"+itemChecked.ToString();
  197.             }
  198.  
  199.         }
  200.  
  201.         private void button5_Click(object sender, EventArgs e)
  202.         {
  203.             for (int i = 0; i < checkedListBox1.Items.Count; i++)
  204.             {
  205.                 checkedListBox1.SetItemChecked(i, true);
  206.             }
  207.         }
  208.  
  209.         private void button6_Click(object sender, EventArgs e)
  210.         {
  211.             for (int i = 0; i < checkedListBox1.Items.Count; i++)
  212.             {
  213.                 checkedListBox1.SetItemChecked(i, false);
  214.             }
  215.         }
  216.  
  217.         private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  218.         {
  219.             if (comboBox1.SelectedItem == "Mobilink")
  220.             {
  221.                 comboBox2.BackColor = Color.Red;
  222.                 comboBox2.Items.Clear();
  223.                 //0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, 0308, 0309
  224.                 for (int i = 0; i <= 9;i++ )
  225.                 {
  226.                     comboBox2.Items.Add("30" + i);
  227.                 }
  228.                
  229.             }
  230.             else if (comboBox1.SelectedItem == "Telenor")
  231.             {
  232.                 comboBox2.BackColor = Color.BlueViolet;
  233.  
  234.                 comboBox2.Items.Clear();
  235.                 for (int i = 1; i <= 7; i++)
  236.                 {
  237.                     comboBox2.Items.Add("34" + i);
  238.                 }
  239.             }
  240.             else if (comboBox1.SelectedItem == "Ufone")
  241.             {
  242.                 comboBox2.BackColor = Color.Orange;
  243.  
  244.                 comboBox2.Items.Clear();
  245.                 for (int i = 1; i <= 6; i++)
  246.                 {
  247.                     comboBox2.Items.Add("33" + i);
  248.                 }
  249.             }
  250.  
  251.             else if (comboBox1.SelectedItem == "Warid")
  252.             {
  253.                 comboBox2.BackColor = Color.Green;
  254.  
  255.                 comboBox2.Items.Clear();
  256.                 for (int i = 1; i <= 5; i++)
  257.                 {
  258.                     comboBox2.Items.Add("32" + i);
  259.                 }
  260.             }
  261.  
  262.             else if (comboBox1.SelectedItem == "Zong")
  263.             {
  264.                 comboBox2.BackColor = Color.Purple;
  265.                 comboBox2.Items.Clear();
  266.  
  267.                 for (int i = 1; i <= 5; i++)
  268.                 {
  269.                     comboBox2.Items.Add("31" + i);
  270.                 }
  271.             }
  272.  
  273.             else if (comboBox1.SelectedItem == "Instaphone")
  274.             {
  275.                 comboBox2.BackColor = Color.Pink;
  276.                 comboBox2.Items.Clear();
  277.                 comboBox2.Items.Add("346");
  278.             }
  279.  
  280.             else if (comboBox1.SelectedItem == "SCOM (AJK & Northern Areas)")
  281.             {
  282.                 comboBox2.BackColor = Color.PeachPuff;
  283.                 comboBox2.Items.Clear();
  284.                 comboBox2.Items.Add("3555");
  285.             }
  286.  
  287.             else if (comboBox1.SelectedItem == "Local (Northern Areas)")
  288.             {
  289.                 comboBox2.BackColor = Color.MintCream;
  290.                 comboBox2.Items.Clear();
  291.                 comboBox2.Items.Add("581");
  292.             }
  293.  
  294.         }
  295.  
  296.         private void button7_Click(object sender, EventArgs e)
  297.         {
  298.             //rnd.Next(0, 9)
  299.             Random rnd = new Random();
  300.             List<string> random_contacts = new List<string>();
  301.             for (int i = 0; i <= Convert.ToInt32(ranger.Text);i++)
  302.             {
  303.                 random_contacts.Add(country_code.Text + comboBox2.SelectedItem + rnd.Next(0, 9) + rnd.Next(0, 9) + rnd.Next(0, 9) + rnd.Next(0, 9) + rnd.Next(0, 9) + rnd.Next(0, 9) + rnd.Next(0, 9));
  304.             }
  305.  
  306.             listBox1.DataSource = random_contacts;
  307.         }
  308.  
  309.         private void button8_Click(object sender, EventArgs e)
  310.         {
  311.             foreach (var item in listBox1.Items)
  312.             {
  313.                 richTextBox1.Text += "\n" + item;
  314.             }
  315.         }
  316.  
  317.         private void button9_Click(object sender, EventArgs e)
  318.         {
  319.            
  320.             Socket s = new Socket(AddressFamily.InterNetwork,
  321.        SocketType.Stream,
  322.        ProtocolType.Tcp);
  323.             try
  324.             {
  325.                 s.Connect(ipAdd.Text, Convert.ToInt32(port_in.Text));
  326.                 MessageBox.Show("Connection Established");
  327.                 button1.Enabled = true;
  328.             }
  329.             catch(Exception ex){
  330.                 MessageBox.Show("Error ! \n Connection Could Not Be Established ! \n"+ex.ToString());
  331.             }
  332.         }
  333.  
  334.         private void toolTip1_Popup(object sender, PopupEventArgs e)
  335.         {
  336.            
  337.         }
  338.  
  339.         private void button10_Click(object sender, EventArgs e)
  340.         {
  341.             backgroundWorker1.CancelAsync();
  342.         }
  343.     }
  344. }
  345.  
  346. // By Hat Programmers : www.hatinco.com
  347.  
  348. // Facebook @ https://www.facebook.com/HAT.programmers
Add Comment
Please, Sign In to add comment