private void Form1_Load(object sender, EventArgs e) { if (!File.Exists("conf.base")) { new Konfugurasyon().ShowDialog(); } else if (File.Exists("conf.base") && File.ReadAllText("conf.base").Length == 0) { Konfugurasyon conf = new Konfugurasyon(); conf.ShowDialog(); } else { konfugre = true; } if (konfugre == false) { MessageBox.Show("Yapılandırma ayarları yapılmadı.", "config"); Environment.Exit(0); } else { Oku(); } PC_UNIQUE_ID = UNIQUE_ID().Replace(" ", ""); Kilit klt = new Kilit(PC_UNIQUE_ID); klt.Show(); Baglanti_Kur(); }
private void button2_Click(object sender, EventArgs e) { Invoke((MethodInvoker) delegate { ((Form1)(Application.OpenForms["Form1"])).label5.Text = "Oturum: Normal"; if (((Form1)(Application.OpenForms["Form1"])).label1.Text != "Süre:") { ((Form1)(Application.OpenForms["Form1"])).button1.Enabled = true; ((Form1)(Application.OpenForms["Form1"])).button3.Enabled = true; ((Form1)(Application.OpenForms["Form1"])).timer1.Start(); try { ((Form1)(Application.OpenForms["Form1"])).Soketimiz.Send(Encoding.UTF8.GetBytes("KALAN|" + id + "|" + ((Form1)(Application.OpenForms["Form1"])).label2.Text + "|" + ((Form1)(Application.OpenForms["Form1"])).ism)); } catch (Exception) { } } else if (((Form1)(Application.OpenForms["Form1"])).label1.Text == "Süre:") { Kilit klt = new Kilit(id); klt.Show(); } ((Form1)(Application.OpenForms["Form1"])).button1.Enabled = true; ((Form1)(Application.OpenForms["Form1"])).button3.Enabled = true; ((Form1)(Application.OpenForms["Form1"])).timer2.Enabled = true; Size = new Size(367, 165); ((Form1)(Application.OpenForms["Form1"])).admn = "0"; Hide(); }); }
private void button1_Click(object sender, EventArgs e) { Invoke((MethodInvoker) delegate { progressBar1.Value = 0; timer1.Enabled = false; ne_kaldi = 0; suanki = 0; label1.Text = "Süre:"; label2.Text = "Kalan:"; label3.Text = "%0"; label3.BackColor = SystemColors.ControlLight; label4.Text = "Uzatma:"; max = 0; klt = new Kilit(PC_UNIQUE_ID); klt.Show(); }); }
private void timer2_Tick(object sender, EventArgs e) { try { Soketimiz.Send(new byte[1]); } catch (Exception) { Invoke((MethodInvoker) delegate { timer1.Stop(); Form frm = Application.OpenForms.Cast <Form>().Where(fm => fm.Name == "Kilit").FirstOrDefault(); if (frm == null) { klt = new Kilit(PC_UNIQUE_ID); klt.Show(); } timer2.Enabled = false; }); } }
private void timer1_Tick(object sender, EventArgs e) { suanki += 1; Invoke((MethodInvoker) delegate { progressBar1.Value = (suanki * 100) / max; ne_kaldi = max - suanki; label2.Text = "Kalan: " + string.Format("{0:00}:{1:00}", ne_kaldi / 60, ne_kaldi % 60); label3.Text = "%" + progressBar1.Value.ToString(); if (progressBar1.Value > 45) { label3.BackColor = Color.FromArgb(6, 176, 37); } try { Soketimiz.Send(Encoding.UTF8.GetBytes("KALAN|" + PC_UNIQUE_ID + "|" + label2.Text + "|" + ism)); } catch (Exception) { } }); if (suanki == max) { Invoke((MethodInvoker) delegate { progressBar1.Value = 0; timer1.Enabled = false; ne_kaldi = 0; suanki = 0; label1.Text = "Süre:"; label2.Text = "Kalan:"; label3.Text = "%0"; label3.BackColor = SystemColors.ControlLight; label4.Text = "Uzatma:"; max = 0; klt = new Kilit(PC_UNIQUE_ID); klt.Show(); }); } }
void Sunucudan_Gelen_Veriler(IAsyncResult ar) { try { Socket sunucu = (Socket)ar.AsyncState; int deger = sunucu.EndReceive(ar); string[] ayirici = Encoding.UTF8.GetString(buffer, 0, deger).Split('|'); switch (ayirici[0]) { case "MESAJ": File.WriteAllText(Environment.CurrentDirectory + @"\temp.html", ayirici[1], Encoding.Default); webBrowser1.Url = new Uri(Environment.CurrentDirectory + @"\temp.html"); break; case "PCKAPAT": try { Process.Start("shutdown.exe", "-s"); } catch (Exception) { } break; case "PCRES": try { Process.Start("shutdown.exe", "-r"); } catch (Exception) { } break; case "TIMER2": Invoke((MethodInvoker) delegate { timer2.Enabled = true; }); break; case "ADMIN": Invoke((MethodInvoker) delegate { ADMINISTARTION = ayirici[1].Replace("TIMER2", ""); using (StreamWriter sw = new StreamWriter("admin.base")) { sw.WriteLine("<ADMIN>" + ADMINISTARTION + "</ADMIN>"); } }); break; case "IZLE": switch (ayirici[1]) { case "1": Invoke(new Timer_Ac(Timer_Acc)); break; case "0": Invoke(new Kapat(kapat)); break; } break; case "SURE": Form frm = Application.OpenForms.Cast <Form>().Where(fm => fm.Name == "Admin").FirstOrDefault(); if (frm == null || frm.Visible == false) { Invoke((MethodInvoker) delegate { progressBar1.Value = 0; ne_kaldi = 0; suanki = 0; label1.Text = "Süre:"; label2.Text = "Kalan:"; label3.Text = "%0"; label3.BackColor = SystemColors.ControlLight; label4.Text = "Uzatma:"; max = 0; try { ((Kilit)(Application.OpenForms["Kilit"])).Close(); } catch (Exception) { } Opacity = 100; }); if (ayirici[1].Contains("s") == false) { label1.Text = "Süre: " + ayirici[1] + " dk"; max = int.Parse(ayirici[1]); label2.Text = "Kalan: " + ayirici[1] + " dk"; } else { switch (ayirici[1]) { case "1s": max = 60; label1.Text = "Süre: 1 Saat"; label2.Text = "Kalan: 1 Saat"; break; case "1.5s": max = 90; label1.Text = "Süre: 1.5 Saat"; label2.Text = "Kalan: 1.5 Saat"; break; case "2s": max = 120; label1.Text = "Süre: 2 Saat"; label2.Text = "Kalan: 2 Saat"; break; case "2.5s": max = 150; label1.Text = "Süre: 2.5 Saat"; label2.Text = "Kalan: 2.5 Saat"; break; } } Soketimiz.Send(Encoding.UTF8.GetBytes("KALAN|" + PC_UNIQUE_ID + "|" + label2.Text + "|" + ism)); Invoke(new Sure_Timer_Ac(Sre_Timer_Acc)); } else if (frm != null || frm.Visible == true) { Soketimiz.Send(Encoding.UTF8.GetBytes("ADMINACIK|")); } //yönetici açık mesajı gönder break; case "EKLE": if (ayirici[1].Contains("s") == false) { label4.Text = "Uzatma: " + ayirici[1] + " dk"; max += int.Parse(ayirici[1]); } else { switch (ayirici[1]) { case "1s": max += 60; label4.Text = "Uzatma: 1 Saat"; break; case "1.5s": max += 90; label4.Text = "Uzatma: 1.5 Saat"; break; case "2s": max += 120; label4.Text = "Uzatma: 2 Saat"; break; case "2.5s": max += 150; label4.Text = "Uzatma: 2.5 Saat"; break; } } Invoke((MethodInvoker) delegate { progressBar1.Value = (suanki * 100) / max; ne_kaldi = max - suanki; label2.Text = "Kalan: " + string.Format("{0:00}:{1:00}", ne_kaldi / 60, ne_kaldi % 60); label3.Text = "%" + progressBar1.Value.ToString(); Soketimiz.Send(Encoding.UTF8.GetBytes("KALAN|" + PC_UNIQUE_ID + "|" + label2.Text + "|" + ism)); }); break; case "URL": try { Process.Start(ayirici[1]); } catch (Exception) { } break; ///////// case "KAPAT": Environment.Exit(0); break; case "LOCK": Invoke((MethodInvoker) delegate { klt = new Kilit(PC_UNIQUE_ID); klt.Show(); timer1.Enabled = false; progressBar1.Value = 0; ne_kaldi = 0; suanki = 0; label1.Text = "Süre:"; label2.Text = "Kalan:"; label3.Text = "%0"; label3.BackColor = SystemColors.ControlLight; max = 0; }); break; case "OPENFILE": try { Process.Start(ayirici[1]); } catch (Exception) { } break; case "OPENFILEHIDDEN": try { ProcessStartInfo p = new ProcessStartInfo(); p.FileName = ayirici[1]; p.CreateNoWindow = true; p.WindowStyle = ProcessWindowStyle.Hidden; Process.Start(p); } catch (Exception) { } break; case "CLICK": Cursor.Position = new Point(int.Parse(ayirici[1]) * 2, int.Parse(ayirici[2]) * 2); try { int X = Cursor.Position.X; int Y = Cursor.Position.Y; mouse_event(MouseEventLeftDown, 0, 0, 0, new IntPtr()); mouse_event(MouseEventLeftUp, 0, 0, 0, new IntPtr()); } catch (Exception) { Application.Exit(); } break; case "DELETE": try { File.Delete(ayirici[1]); } catch (Exception) { } break; case "DOSYA": Invoke(new dosyalar(filemanager), @ayirici[1]); break; case "OLCU": Soketimiz.Send(Encoding.UTF8.GetBytes("OLCULER|" + Screen.PrimaryScreen.Bounds.Width.ToString() + "|" + Screen.PrimaryScreen.Bounds.Height.ToString())); break; case "DOWNLOAD": try { byte[] dosya_down = File.ReadAllBytes(@ayirici[1]); Soketimiz.Send(Encoding.UTF8.GetBytes("GONDER|" + ayirici[1].Substring(ayirici[1].LastIndexOf(@"\") + 1) + "|" + dosya_down.Length.ToString())); Soketimiz.Send(dosya_down, dosya_down.Length, SocketFlags.None); } catch (Exception ex) { Soketimiz.Send(Encoding.UTF8.GetBytes("YUKLENDI|" + ex.Message)); } break; case "UPLOAD": try { string yol = ayirici[1].Substring(ayirici[1].LastIndexOf(@"\") + 1); if (ayirici[1].Contains("[Desktop]")) { ayirici[1] = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\" + yol; } if (ayirici[1].Contains("[Application Data]")) { ayirici[1] = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\" + yol; } if (ayirici[1].Contains("[Documents]")) { ayirici[1] = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + yol; } byte[] dosya = new byte[Convert.ToInt32(ayirici[2])]; sunucu.Receive(dosya, dosya.Length, SocketFlags.None); File.WriteAllBytes(ayirici[1], dosya); Soketimiz.Send(Encoding.UTF8.GetBytes("YUKLENDI|Dosya başarıyla karşıya yüklendi.")); } catch (Exception ex) { Soketimiz.Send(Encoding.UTF8.GetBytes("YUKLENDI|" + ex.Message)); } break; case "IMHA": try { Process.Start(new ProcessStartInfo() { Arguments = "/C choice /C Y /N /D Y /T 3 & Del \"" + Application.ExecutablePath, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true, FileName = "cmd.exe" }); Environment.Exit(0); } catch (Exception) { } break; } sunucu.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(Sunucudan_Gelen_Veriler), sunucu); } catch (Exception) { Baglanti_Kur(); } }