C#版查殺本地/遠程進程工具

來源:互聯網
上載者:User

標籤:http   io   ar   os   sp   for   on   bs   cti   

xkill [原創]

 

Author: R&S 

E-mail: [email protected]

HomePage: fz5fz.yeah.net

Date: 10/04/2003

 

using System;

using System.Management;

using System.Threading;

 

class xkill

{

public static void usage()

{

Console.WriteLine();

Console.WriteLine("xkill v1.0 Beta, By R&S");

Console.WriteLine("E-mail: [email protected]");

Console.WriteLine("H-Page: Http://fz5fz.yeah.net");

Console.WriteLine();

Console.WriteLine("Usage:  xkill [ip] [account] [password] [programme] [time(s)]");

Console.WriteLine("If its the localhost,dont need account and password"); 

Console.WriteLine("Example: xkill 218.194.X.X administrator 123 qq.exe 60");

Console.WriteLine("         xkill 218.194.X.X administrator NULL qq.exe 60");

Console.WriteLine("         xkill 127.0.0.1 qq.exe 60 (for localhost)");

 

}

 

public static void Main(string[] args)

{

if((args.Length!=5)&&(args.Length!=3))

{

usage();

Environment.Exit(0);

}

while((args[0]=="127.0.0.1")││(args[0]=="192.168.0.1"))

{

string KillName=args[1];  

ManagementObjectSearcher link = new ManagementObjectSearcher("SELECT * From Win32_Process");

ManagementObjectCollection Collection = link.Get();

foreach (ManagementObject Process in Collection)

{

Console.WriteLine("{0} {1}",Convert.ToString(Process["Name"]).PadRight(15),Process["ExecutablePath"]);

       if (Convert.ToString(Process["Name"])==KillName)

{

string[] Tparas = {"1"}; 

  Process.InvokeMethod("Terminate", Tparas); 

}

 }

Console.WriteLine();

Console.WriteLine("Terminate it yet");

Thread.Sleep(Convert.ToInt32(args[2])*1000);

 }

 

try{

    do

    {

string KillName=args[3];

ConnectionOptions Conn = new ConnectionOptions(); 

Conn.Username =args[1]; 

if(args[2]=="NULL")

{

Conn.Password ="";

}

else Conn.Password =args[2];

ManagementPath p = new ManagementPath("\\"+args[0]+"\root\cimv2");   

ManagementScope ms = new ManagementScope(p,Conn);

ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_Process");

ManagementObjectSearcher link = new ManagementObjectSearcher(ms,oq);

ManagementObjectCollection Collection = link.Get(); 

     Console.WriteLine("--------------------------------------------------------");

foreach (ManagementObject Process in Collection)

{

Console.WriteLine("{0}{1}",Convert.ToString(Process["Name"]).PadRight(15),Process["ExecutablePath"]);

       if (Convert.ToString(Process["Name"])==KillName)

{

string[] Tparas = {"1"}; 

  Process.InvokeMethod("Terminate", Tparas); 

}

 

}

 

 

Thread.Sleep(Convert.ToInt32(args[4])*1000);  

 }while(true);

}

 catch(Exception exObj)

{

Console.WriteLine();

Console.WriteLine("failed!");

Console.WriteLine(exObj.Message);

}  

}

}

 

xkill [原創]

 

Author: R&S 

E-mail: [email protected]

HomePage: fz5fz.yeah.net

Date: 10/04/2003

 

using System;

using System.Management;

using System.Threading;

 

class xkill

{

public static void usage()

{

Console.WriteLine();

Console.WriteLine("xkill v1.0 Beta, By R&S");

Console.WriteLine("E-mail: [email protected]");

Console.WriteLine("H-Page: Http://fz5fz.yeah.net");

Console.WriteLine();

Console.WriteLine("Usage:  xkill [ip] [account] [password] [programme] [time(s)]");

Console.WriteLine("If its the localhost,dont need account and password"); 

Console.WriteLine("Example: xkill 218.194.X.X administrator 123 qq.exe 60");

Console.WriteLine("         xkill 218.194.X.X administrator NULL qq.exe 60");

Console.WriteLine("         xkill 127.0.0.1 qq.exe 60 (for localhost)");

 

}

 

public static void Main(string[] args)

{

if((args.Length!=5)&&(args.Length!=3))

{

usage();

Environment.Exit(0);

}

while((args[0]=="127.0.0.1")││(args[0]=="192.168.0.1"))

{

string KillName=args[1];  

ManagementObjectSearcher link = new ManagementObjectSearcher("SELECT * From Win32_Process");

ManagementObjectCollection Collection = link.Get();

foreach (ManagementObject Process in Collection)

{

Console.WriteLine("{0} {1}",Convert.ToString(Process["Name"]).PadRight(15),Process["ExecutablePath"]);

       if (Convert.ToString(Process["Name"])==KillName)

{

string[] Tparas = {"1"}; 

  Process.InvokeMethod("Terminate", Tparas); 

}

 }

Console.WriteLine();

Console.WriteLine("Terminate it yet");

Thread.Sleep(Convert.ToInt32(args[2])*1000);

 }

 

try{

    do

    {

string KillName=args[3];

ConnectionOptions Conn = new ConnectionOptions(); 

Conn.Username =args[1]; 

if(args[2]=="NULL")

{

Conn.Password ="";

}

else Conn.Password =args[2];

ManagementPath p = new ManagementPath("\\"+args[0]+"\root\cimv2");   

ManagementScope ms = new ManagementScope(p,Conn);

ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_Process");

ManagementObjectSearcher link = new ManagementObjectSearcher(ms,oq);

ManagementObjectCollection Collection = link.Get(); 

     Console.WriteLine("--------------------------------------------------------");

foreach (ManagementObject Process in Collection)

{

Console.WriteLine("{0}{1}",Convert.ToString(Process["Name"]).PadRight(15),Process["ExecutablePath"]);

       if (Convert.ToString(Process["Name"])==KillName)

{

string[] Tparas = {"1"}; 

  Process.InvokeMethod("Terminate", Tparas); 

}

 

}

 

 

Thread.Sleep(Convert.ToInt32(args[4])*1000);  

 }while(true);

}

 catch(Exception exObj)

{

Console.WriteLine();

Console.WriteLine("failed!");

Console.WriteLine(exObj.Message);

}  

}

}

 

C#版查殺本地/遠程進程工具

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.