Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.IO;
- namespace ChatBlocker
- {
- class Program
- {
- static void Main(string[] args)
- {
- Menu();
- }
- static void Menu()
- {
- int id = 0;
- 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" };
- while (true)
- {
- switch (id)
- {
- case 1:
- {
- Console.Clear();
- try
- {
- FileStream file = new FileStream(System.Environment.SystemDirectory+ @"\drivers\etc\hosts", FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
- foreach (string line in lines)
- {
- byte[] message = Encoding.ASCII.GetBytes("\n"+line+"\n");
- file.Write(message, 0, message.Length);
- }
- file.Close();
- }
- catch (Exception e)
- {
- Console.WriteLine(e.Message);
- Console.WriteLine("Unable to open file, is it open by any other program?");
- Console.WriteLine("Press any button to go back to the menu");
- Console.Read();
- id = 0;
- break;
- }
- Console.WriteLine("Succesfully wrote to hosts file!");
- Console.WriteLine("Press any button to go back to the menu");
- Console.Read();
- id = 0;
- break;
- }
- case 2:
- {
- Console.Clear();
- try
- {
- string[] alllines = File.ReadAllLines(System.Environment.SystemDirectory + @"\drivers\etc\hosts");
- List<string> list = new List<string>(alllines);
- foreach (string line in lines)
- {
- list.Remove(line);
- }
- list.RemoveAll(delegate(string line) { return line == ""; });
- FileStream file = new FileStream(System.Environment.SystemDirectory + @"\drivers\etc\hosts", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
- foreach (string str in list)
- {
- byte[] message = Encoding.ASCII.GetBytes(str+"\n");
- file.Write(message, 0, message.Length);
- }
- file.Close();
- }
- catch (Exception)
- {
- Console.WriteLine("Unable to open file, is it open by any other program?");
- Console.WriteLine("Press any button to go back to the menu");
- Console.Read();
- id = 0;
- break;
- }
- Console.WriteLine("Succesfully wrote to hosts file!");
- Console.WriteLine("Press any button to go back to the menu");
- Console.Read();
- id = 0;
- break;
- }
- case 3:
- {
- return;
- }
- default:
- {
- Console.Write("\n\n");
- Console.WriteLine("Invisible Mode for League of Legends!");
- Console.Write("\n\n");
- Console.WriteLine("1. Enable Invisible Mode");
- Console.WriteLine("2. Disable Invisible Mode");
- Console.WriteLine("3. Exit\n");
- try
- {
- id = Int32.Parse(Console.ReadLine());
- }
- catch (Exception)
- {
- Console.WriteLine("\n Please write a valid number!");
- }
- break;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement