Advertisement
Guest User

Untitled

a guest
Nov 28th, 2011
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.IO;
  5.  
  6. namespace ChatBlocker
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Menu();
  13.         }
  14.         static void Menu()
  15.         {
  16.             int id = 0;
  17.             string[] lines = { "127.0.0.1 chat.na1.lol.riotgames.com", "127.0.0.1 chat.eu.lol.riotgames.com", "127.0.0.1 chat.eun1.lol.riotgames.com" };
  18.             while (true)
  19.             {
  20.                 switch (id)
  21.                 {
  22.                     case 1:
  23.                         {
  24.                             Console.Clear();
  25.                             try
  26.                             {
  27.  
  28.                                 FileStream file = new FileStream(System.Environment.SystemDirectory+ @"\drivers\etc\hosts", FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
  29.                                 foreach (string line in lines)
  30.                                 {
  31.                                     byte[] message = Encoding.ASCII.GetBytes("\n"+line+"\n");
  32.                                     file.Write(message, 0, message.Length);
  33.                                 }
  34.                                 file.Close();
  35.                             }
  36.                             catch (Exception e)
  37.                             {
  38.                                 Console.WriteLine(e.Message);
  39.                                 Console.WriteLine("Unable to open file, is it open by any other program?");
  40.                                 Console.WriteLine("Press any button to go back to the menu");
  41.                                 Console.Read();
  42.                                 id = 0;
  43.                                 break;
  44.                             }
  45.                             Console.WriteLine("Succesfully wrote to hosts file!");
  46.                             Console.WriteLine("Press any button to go back to the menu");
  47.                             Console.Read();
  48.                             id = 0;
  49.                             break;
  50.                         }
  51.                     case 2:
  52.                         {
  53.                             Console.Clear();
  54.                             try
  55.                             {
  56.                                 string[] alllines = File.ReadAllLines(System.Environment.SystemDirectory + @"\drivers\etc\hosts");
  57.                                 List<string> list = new List<string>(alllines);
  58.                                 foreach (string line in lines)
  59.                                 {
  60.                                     list.Remove(line);
  61.                                 }
  62.                                 list.RemoveAll(delegate(string line) { return line == ""; });
  63.                                 FileStream file = new FileStream(System.Environment.SystemDirectory + @"\drivers\etc\hosts", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
  64.                                 foreach (string str in list)
  65.                                 {
  66.                                     byte[] message = Encoding.ASCII.GetBytes(str+"\n");
  67.                                     file.Write(message, 0, message.Length);
  68.                                 }
  69.                                 file.Close();
  70.                             }
  71.                             catch (Exception)
  72.                             {
  73.                                 Console.WriteLine("Unable to open file, is it open by any other program?");
  74.                                 Console.WriteLine("Press any button to go back to the menu");
  75.                                 Console.Read();
  76.                                 id = 0;
  77.                                 break;
  78.                             }
  79.                             Console.WriteLine("Succesfully wrote to hosts file!");
  80.                             Console.WriteLine("Press any button to go back to the menu");
  81.                             Console.Read();
  82.                             id = 0;
  83.                             break;
  84.                         }
  85.                     case 3:
  86.                         {
  87.                             return;
  88.                         }
  89.                     default:
  90.                         {
  91.                             Console.Write("\n\n");
  92.                             Console.WriteLine("Invisible Mode for League of Legends!");
  93.                             Console.Write("\n\n");
  94.                             Console.WriteLine("1. Enable Invisible Mode");
  95.                             Console.WriteLine("2. Disable Invisible Mode");
  96.                             Console.WriteLine("3. Exit\n");
  97.                             try
  98.                             {
  99.                                 id = Int32.Parse(Console.ReadLine());
  100.                             }
  101.                             catch (Exception)
  102.                             {
  103.                                 Console.WriteLine("\n Please write a valid number!");
  104.                             }
  105.                             break;
  106.                         }
  107.                 }
  108.             }
  109.         }
  110.     }
  111. }
  112.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement