[watermark]木马和蠕虫的横行一直困扰着我们,本程序试图查找特定木马或蠕虫,以便查杀。
本程序适用查找的木马如:http://www.thysea.com/lb/cgi-bin/topic.cgi?forum=1&topic=21947&show=0
首先这个是主程序。- /**
- * Created by IntelliJ IDEA.
- * User: fengzhizi
- * Date: 2006-10-14
- * Time: 11:26:00
- * To change this template use File | Settings | File Templates.
- */
- import java.net.*;
- import java.util.*;
- import java.io.*;
- public class Worm&TrojanCatcher{
- public static void main(String[] args)
- {
- ServerSocket serv = null;
- ThreadPool tpool = null;
- Socket clnt = null;
- String tmp = null;
- int port = 0;
- if (args.length != 1)
- {
- System.err.println("usage:java Worm&TrojanCatcher"+" <local_port>");
- System.err.println("Example:java Worm&TrojanCatcher"+" 80");
- System.exit(1);
- }
- tmp = args[0];
- try
- {
- port = Integer.parseInt(tmp);
- tpool = new ThreadPool(5);
- try
- {
- serv = new ServerSocket(port);
- }
- catch (IOException e)
- {
- System.out.println(e);
- }
- while (true)
- {
- try
- {
- clnt = serv.accept();
- }
- catch (IOException e)
- {
- System.out.println(e);
- }
- tpool.add(clnt);
- }
- }
- catch (NumberFormatException nfe)
- {
- System.err.println("NumberFormatException:"+nfe.getMessage());
- }
- }
- }
复制代码 以下是线程池- class ThreadPool
- {
- private Vector m_queue = new Vector();
- public ThreadPool(int thread_count)
- {
- WorkerThread wt = null;
- int x = 0;
- for (x=0;x<thread_count;x++)
- {
- wt = new WorkerThread(m_queue);
- wt.start();
- }
- }
- public void add(Object object)
- {
- synchronized(m_queue)
- {
- m_queue.add(object);
- }
- }
- }
复制代码 以下是工作线程
通过配置端口和木马或蠕虫访问的网页查找特定的木马或蠕虫,也可以把这些信息也入XML文件,让XML来配置这些信息,这样就不止查找某一个特定的木马或蠕虫了,这就成了一个通用的程序。本程序亦可修改成局域网内查找木马的程序,那样的意义就更大了,因此只在这里抛砖引玉。[/watermark] |