Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Dc Mass - MassMessage.cs

MassMessage.cs

Caricato da:
Scarica il programma completo

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7. using System.Net;
  8. using System.Threading;
  9. using System.Net.Sockets;
  10. using System.Text;
  11. using System.Security.Cryptography;
  12.  
  13.  
  14. namespace SaTaNaDcMaSS
  15. {
  16.         /// <summary>
  17.         /// Summary description for MassMessage.
  18.         /// </summary>
  19.         public class MassMessage
  20.         {
  21.                 Socket s;
  22.                 private string hub;
  23.                 private string nome;
  24.                 private int porta;
  25.                 private System.Windows.Forms.TextBox mess;
  26.                 private System.Windows.Forms.TextBox mess1;
  27.                 private System.Windows.Forms.CheckBox c1;
  28.                 private System.Windows.Forms.CheckBox c2;
  29.                 private IPHostEntry host;
  30.                 private Socket socket;
  31.                 private string lock1epk;
  32.                 private IPEndPoint indirizzoeporta;
  33.                 private Random rand = new Random();
  34.                 private System.Windows.Forms.RichTextBox boh;
  35.                 private string[] userlist;
  36.                 private string[] oplist;
  37.                 private ArrayList array = new ArrayList();
  38.                 private string masslist;
  39.                 private string[] masslist2;
  40.                 byte[] buffer;
  41.                 private System.Windows.Forms.RichTextBox tempo;
  42.                 private System.Windows.Forms.Timer timer;
  43.                 private bool statusreceive = false;
  44.                 public MassMessage(string hub,int porta,System.Windows.Forms.TextBox mess,System.Windows.Forms.CheckBox c1,System.Windows.Forms.CheckBox c2,System.Windows.Forms.RichTextBox boh,System.Windows.Forms.RichTextBox tempo,System.Windows.Forms.Timer timer)
  45.                 {
  46.                         this.hub=hub;
  47.                         this.porta=porta;
  48.                         this.mess=mess;
  49.                         this.c1=c1;
  50.                         this.c2=c2;
  51.                         this.boh=boh;
  52.                         this.tempo=tempo;
  53.                         this.timer=timer;
  54.                        
  55.                        
  56.                        
  57.                        
  58.                        
  59.                 }
  60.                 public void Send(string data)
  61.                 {
  62.                         if(data.Length>0)
  63.                         {
  64.                                 if(data[data.Length-1]!='|')
  65.                                         data+="|";
  66.                                 s.Send(Encoding.Default.GetBytes(data),0,data.Length,SocketFlags.None);
  67.                         }
  68.                 }
  69.                 public void RunMe()
  70.                 {
  71.                         statusreceive=false;
  72.                         nome = GeneraNickCasuali();
  73.                         host = Dns.Resolve(hub);
  74.                         foreach(IPAddress ip in host.AddressList)
  75.                         {
  76.                                 indirizzoeporta = new IPEndPoint(ip, porta);
  77.                                 s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  78.                                 s.Connect(indirizzoeporta);
  79.                         }
  80.                         byte[] buffer = new byte[1024*1024];
  81.                         s.Receive(buffer);
  82.                     lock1epk=Encoding.Default.GetString(buffer);
  83.                         string lokkazzo2 = Lokkazzo();
  84.                         byte[] key= ConvertingLock.getKey(Encoding.Default.GetBytes(lokkazzo2));
  85.                         string keystring = Encoding.Default.GetString(key);
  86.                         byte[] msg = Encoding.Default.GetBytes("$Key "+keystring+"|$ValidateNick "+nome+"|");
  87.                         s.Send(msg);
  88.                         s.Receive(buffer);
  89.                         byte[] msg2 = Encoding.Default.GetBytes("$Version 1,0091|$GetNickList|$MyINFO $ALL "+nome+" §å†åÑå Т M姧 1.0 <§å†åÑå Т M姧 1.0 V:1.0,M:A,H:2/0/2,S:4>$ $DSL$boh$"+1000000000+"$|");
  90.                         s.Send(msg2);
  91.                        
  92.  
  93.                         while(statusreceive==false)
  94.                         {
  95.                                 s.Receive(buffer);
  96.                                 char[] sep = Encoding.Default.GetChars(Encoding.Default.GetBytes("|"));
  97.                                 char[] sep2 = Encoding.Default.GetChars(Encoding.Default.GetBytes("$$"));
  98.                                 string buf = Encoding.Default.GetString(buffer);
  99.                                 string[] prova = buf.Split(sep);
  100.                                 Ricevi(prova);
  101.                         }
  102.                 }
  103.                 private string GeneraNickCasuali()
  104.                 {
  105.                         string nome = "";
  106.                         int max = rand.Next(4,8);
  107.                         int i;
  108.                        
  109.                         for(i=0;i<max;i++)
  110.                         {              
  111.                                 int g = rand.Next(97,122);
  112.                                 nome += (char)g;
  113.                         }
  114.                         return nome;
  115.                 }
  116.                 private string Lokkazzo()
  117.                 {
  118.                         char[] sep = Encoding.Default.GetChars(Encoding.Default.GetBytes("|"));
  119.                         string[] lock2 = lock1epk.Split(sep);
  120.                         string lokkazzo2="";
  121.                         foreach(string s in lock2)
  122.                         {
  123.                                 if(s.Substring(0,5)=="$Lock")
  124.                                 {
  125.                                         string s1 = s.Replace("$Lock ","");
  126.                                         char[] sep2 = Encoding.Default.GetChars(Encoding.Default.GetBytes(" "));
  127.                                         string[] s2 = s1.Split(sep2);
  128.                                         foreach(string l in s2)
  129.                                         {
  130.                                                 if(l.Substring(0,2)!="Pk")
  131.                                                 {
  132.                                                         lokkazzo2=l;
  133.                                                 }
  134.                                         }
  135.                                 }
  136.                         }
  137.                         return lokkazzo2;
  138.                 }
  139.                 public void MandaMessaggi()
  140.                 {
  141.                         int lol=0;
  142.                         foreach(string b in masslist2)
  143.                         {
  144.                                 if(b!="")
  145.                                 {
  146.                                         byte[] msg3 = Encoding.Default.GetBytes("$To: "+b+" From: "+nome+" $<"+nome+"> "+lol+" "+mess.Text+"|");
  147.                                         s.Send(msg3);
  148.                                         lol=lol+1;
  149.                                         boh.Text+="Mandato a: " + b + "\n";
  150.                                 }
  151.                         }
  152.  
  153.                     byte[] msg4 = Encoding.Default.GetBytes("$Quit "+nome+"|");
  154.                                 s.Send(msg4);
  155.                                 s.Close();
  156.                                 double temposec = Convert.ToDouble(tempo.Text)/100;
  157.                                 timer.Stop();
  158.                                 boh.Text+="Il messaggio " + mess.Text + " è stato mandato a " + Convert.ToString(lol) + " users in "+Convert.ToString(temposec)+" secondi";
  159.                                 statusreceive = true;
  160.                                 return;
  161.                 }
  162.  
  163.                 public void Ricevi(string[] prova)
  164.                         {
  165.                         char[] sep2 = Encoding.Default.GetChars(Encoding.Default.GetBytes("$$"));
  166.                         foreach(string a in prova)
  167.                         {
  168.                                 if(a!="")
  169.                                 {
  170.                                         if(a.Substring(0,1)=="<")
  171.                                         {
  172.                                                 boh.Text+=a;
  173.                                         }
  174.                                         if(a.Substring(0,9)=="$NickList")
  175.                                         {
  176.                                                 string nicklist = a.Replace("$NickList ","");
  177.                                                 userlist = nicklist.Split(sep2);
  178.                                                 foreach(string lmao in userlist)
  179.                                                 {
  180.                                                         if(lmao!="")
  181.                                                         {
  182.                                                                 if(c2.Checked==true)
  183.                                                                 {
  184.                                                                         array.Add(lmao+" ");
  185.                                                                 }
  186.                                                         }
  187.                                                 }
  188.                                         }
  189.                                         if(a.Substring(0,7)=="$OpList")
  190.                                         {
  191.                                                 string oplist1 = a.Replace("$OpList ","");
  192.                                                 oplist = oplist1.Split(sep2);
  193.                                                 foreach(string loll in oplist)
  194.                                                 {
  195.                                                         if(loll!="")
  196.                                                         {
  197.                                                                         if(c1.Checked==false)
  198.                                                                         {
  199.                                                                         array.Remove(loll+" ");
  200.                                                                         }
  201.                                                                         if(c1.Checked==true && c2.Checked==false)
  202.                                                                         {
  203.                                                                         array.Add(loll+" ");
  204.                                                                         }
  205.                                                                 }
  206.                                                 }
  207.                
  208.                                                 GetArrayList();
  209.                                                 return;
  210.                                                 }
  211.                                         }
  212.                                 }
  213.                         }
  214.         public void GetArrayList()
  215.                 {
  216.                         char[] sep = Encoding.Default.GetChars(Encoding.Default.GetBytes(" "));
  217.                         System.Collections.IEnumerator myEnumerator = array.GetEnumerator();
  218.                         while (myEnumerator.MoveNext())
  219.                         {
  220.                         masslist+=myEnumerator.Current.ToString();
  221.                         }
  222.                         masslist2 = masslist.Split(sep);
  223.                         MandaMessaggi();
  224.                         return;
  225.                         }
  226.                 }
  227.         }